Hi!
I have created a wxListBox called Icon. It contains the following Choices: Question Mark; Asterisk; Exclamation Point; Superman; Batman; and Homer.
In the same sizer, I have created a wxStaticBitmap called Pichow (ie "Picture").
And I have a directory containing images of each of those Choices, in either *.png or *.jpg format.
My goal is to change the image in Pichow based upon the current value of Choice.
Is there an example file, or tutorial, that can tell me how to do that? Conceptually, I know what to do, but I don't know the syntax.
---
Per viewtopic.php?f=11&t=804:
1. Your codelite version: 9.1.5
2. Is it a self compiled version of codelite: I don't understand this question. I did not compile it; I'm using it as-is. Does that answer the question?
3. Your OS: Windows 7. Target is Windows.
4. Compiler version: g++ TDM-GCC, version 5.1.0.3
Thank you!
Colleen
How to Change a Bitmap Based on a ListBox Value
- ColleenKobe
- CodeLite Expert
- Posts: 130
- Joined: Wed Mar 30, 2016 4:31 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
How to Change a Bitmap Based on a ListBox Value
You do not have the required permissions to view the files attached to this post.
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to Change a Bitmap Based on a ListBox Value
Add event handler to the wxListBox event type: wxEVT_COMMAND_LISTBOX_SELECTED
In the handler:
NOTE: these kind of questions are more related to wxWidgets than CodeLite, and should be asked on the wxForum (https://forums.wxwidgets.org)
Eran
In the handler:
Code: Select all
void MyClass::OnItemSelected(wxCommandEvent& event)
{
int selectedIndex = listBox->GetSelection();
if(selectedIndex == wxNOT_FOUND) return;
wxString label = listBox->GetString(selectedIndex);
// Replace the image
if(label == " .... ") {
staticBitmap->SetBitmap(my_bitmap);
} else if ( label == " ..." ) {
...
} else {
...
}
staticBitmap->Refresh();
}
Eran
Make sure you have read the HOW TO POST thread
- ColleenKobe
- CodeLite Expert
- Posts: 130
- Joined: Wed Mar 30, 2016 4:31 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: How to Change a Bitmap Based on a ListBox Value
Eran, thank you for the code!
It doesn't quite run yet. I get an error message saying "Can't load bitmap 'exclamationpoint01.png' from resources! Check .rc file." So I will try to figure out what is wrong. If I can't, I'll post on the wxWidgets forum.
I apologize for posting this message in the wrong forum. I am still new and I am not always clear on whether the issue is wxWidgets, CodeLite, or TPM-GCC.
Thank you again.
Colleen
It doesn't quite run yet. I get an error message saying "Can't load bitmap 'exclamationpoint01.png' from resources! Check .rc file." So I will try to figure out what is wrong. If I can't, I'll post on the wxWidgets forum.
I apologize for posting this message in the wrong forum. I am still new and I am not always clear on whether the issue is wxWidgets, CodeLite, or TPM-GCC.
Thank you again.
Colleen