SetIcon draws icon offset vertically from desired location

Post here wxCrafter related issues / features / bugs
User avatar
ColleenKobe
CodeLite Expert
Posts: 130
Joined: Wed Mar 30, 2016 4:31 pm
Genuine User: Yes
IDE Question: C++
Contact:

SetIcon draws icon offset vertically from desired location

Post by ColleenKobe »

I am trying to draw a wxStaticBitmap on my wxFrame. My wxStaticBitmap is a circle that can be colored either red, yellow, or green, so I have three xpm files, each a circle the same size but a different color. The wxStaticBitmap gets drawn in the correct location on the wxFrame the first time. However, every time I call SetIcon to change the color of the circle, instead of simply replacing the current xpm image with the new xpm image, a new little circle is drawn directly above the previous circle, so I have n + 1 circles. The more times I click to change the color, the more circles appear on the screen, all moving up from the previous icon. I don't want new circles. I only want one, and I want it in the lower left corner of the screen. Here is a screen shot of this:
DuplicatingCircles.png
What I did to make the circle: I created a wxBoxSizer. I set the wxALL, wxLEFT, wxRIGHT, wxTOP, wxBOTTOM, wxALIGN_BOTTOM wxBoxSizer Sizer Flags true. All the other wxBoxSizer Flags are false. Proportion = 0.

Inside the wxBoxSizer, I created a wxStaticBitmap. I set the wxALIGN_LEFT and wxALIGN_BOTTOM wxStaticBitmap Sizer Flags to true. All the other wxStaticBitmap Sizer Flags are false. Proportion = 1.

I change the value of the wxStaticBitmap during the course of execution, but it only gets updated in two lines of the code: once in the constructor, and once in a procedure called Display_Text_in_Status_Field. See MainFrame.cpp below. If you need anything else, please ask.
MainFrame.cpp
How do I make the circle get drawn in the correct location?

I looked at http://docs.wxwidgets.org/3.0/classwx_s ... itmap.html, but I didn't see a "SetPosition" or "MoveTo" or similar command. I thought setting the Sizer Flags would do the job. They work for everything else.


I am using Windows 10, Codelite version 11.0.1, and wxCrafter.

Thanks!

Colleen
You do not have the required permissions to view the files attached to this post.
User avatar
ColleenKobe
CodeLite Expert
Posts: 130
Joined: Wed Mar 30, 2016 4:31 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: SetIcon draws icon offset vertically from desired locati

Post by ColleenKobe »

Here is another clue:

I changed the wxStaticBitmap's wxFULL_REPAINT_ON_RESIZE flag to True. Alas, the circles still "climb up the screen."

Then I saw that if I click buttons to make the circle "climb up the screen," and then I resize the window, the extra circles vanish and only one circle remains, and it is located where it is supposed to be.

Colleen
Post Reply