Changing the icon file in a wxStaticBitmap

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

Changing the icon file in a wxStaticBitmap

Post by ColleenKobe » Tue Nov 21, 2017 1:29 am

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

User avatar
eranif
CodeLite Plugin
Posts: 5927
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Changing the icon file in a wxStaticBitmap

Post by eranif » Tue Nov 21, 2017 1:42 am

What you are looking for is wxStatusBar
Look at the samples of wxWidgets
Make sure you have read the HOW TO POST thread

ColleenKobe
CodeLite Expert
Posts: 104
Joined: Wed Mar 30, 2016 4:31 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Changing the icon file in a wxStaticBitmap

Post by ColleenKobe » Wed Nov 29, 2017 12:43 am

Great! Thank you!!!

Post Reply