Page 1 of 1

Changing the icon file in a wxStaticBitmap

Posted: Tue Nov 21, 2017 1:29 am
by ColleenKobe
I would like to place a small colored-in circle in the lower-left corner of my wxFrame. Its color would change between green, yellow, and gray, based on what's happening in the rest of the program.

I have created 32x32 pixel icon files for each color (DataFlowOn.ico (green), DataFlowWaiting.ico (yellow), and DataFlowOff.ico (gray)) and placed them in the resources folder of my project.

In wxCrafter, I have created a wxStaticBitmap called m_Data_Flow_Icon in a boxSizer in my wxFrame. I initialized it to the gray disk in wxCrafter by setting the Bitmap File field to "../Resources/DataFlowOff.ico". The icon appears on my wxCrafter image just fine.

Now, in my code, I want to change the file in m_Data_Flow_Icon to yellow. I assumed the file name would be a field in the wxStaticBitmap class, and I could just change it and that would be it. But I can't seem to find a field for that.

I thought maybe there would be an example in the C:\wxWidgets\samples folder, so I looked at the Control wxWidgets App and experimented with wxBitmapXXX. I looked at the code, but the code appears to be making the icons on the spot; it wasn't using existing icon files. In the event I have more complicated images to display that would be difficult to create in wxWidgets, I'd rather use the files I have now.

Since wxCrafter successfully loaded a bitmap image into my wxStaticBitmap, it seems like I should be able to load a new bitmap (or icon) file again. I'm looking for a command something like--

Code: Select all

m_Data_Flow_Icon->SetImage ("../Resources/DataFlowOn.ico");
How can I change the icon file that I'm loading into a wxStaticBitmap class variable? Or is there a more appropriate class I should be using?

Thanks!

Colleen

Re: Changing the icon file in a wxStaticBitmap

Posted: Tue Nov 21, 2017 1:42 am
by eranif
What you are looking for is wxStatusBar
Look at the samples of wxWidgets

Re: Changing the icon file in a wxStaticBitmap

Posted: Wed Nov 29, 2017 12:43 am
by ColleenKobe
Great! Thank you!!!