I have created a wxListBox called Icon. It contains the following Choices: Question Mark; Asterisk; Exclamation Point; Superman; Batman; and Homer.
In Windows, I have copied *.png and *.jpgs of those choices into the same folder that the *.cpp files reside in.
Back in CodeLite, in the same sizer, I have created a wxStaticBitmap called Desired_Picture.
My goal is to change the image in Desired_Picture based upon the current value of Choice. Since this is just a practice program, I just want to load the external file into the picture (not embed the images into the executable).
What actually happens is that the program correctly identifies the selected choice, but when it goes to display the corresponding image, it gives me the error message "Can't load bitmap 'superman01.png' from resources! Check .rc file."
How can I fix this problem?
Here is some additional information.
1. My OS: Windows 7. Target is Windows.
2. My CodeLite version: 9.1.5
3. My wxWidgets version: 3.0.2
4. My compiler version: g++ TDM-GCC, version 5.1.0.3
See the screen shot. My code (MainFrame.cpp):
Code: Select all
#include "MainFrame.h"
#include <wx/msgdlg.h>
#include <wx/aboutdlg.h>
#include <wx/gdicmn.h>
MainFrame::MainFrame(wxWindow* parent)
: MainFrameBaseClass(parent)
{
}
MainFrame::~MainFrame()
{
}
void MainFrame::OnExit(wxCommandEvent& event)
{
wxUnusedVar(event);
Close();
}
// Unrelated code omitted...
void MainFrame::OnIcon_listboxDoubleclicked(wxCommandEvent& event)
{
// Do these statements go here or somewhere else? What are they for?
#define wxBITMAP (bmp_Asterisk);
#define wxBITMAP (bmp_Batman);
#define wxBITMAP (bmp_Exclamation_Point);
#define wxBITMAP (bmp_Homer);
#define wxBITMAP (bmp_QuestionMark);
#define wxBITMAP (bmp_Superman);
int selectedIndex = 0;
int i = 7;
// The choices: Question Mark;Asterisk;Exclamation Point;Superman;Batman;Homer
const wxString lbl_A = "Asterisk";
const wxString lbl_B = "Batman";
const wxString lbl_E = "Exclamation Point";
const wxString lbl_H = "Homer";
const wxString lbl_Q = "Question Mark";
const wxString lbl_S = "Superman";
wxString label = "";
wxString bmp_A = "asterisk01.png";
wxString bmp_B = "batman01.jpg";
wxString bmp_E = "exclamationpoint01.png";
wxString bmp_H = "homer01.png";
wxString bmp_Q = "questionmark01.png";
wxString bmp_S = "superman01.png";
wxString Foobar;
// -------------------------------------------------------------------------
// Begin. Get the current index. Make sure it's valid.
// -------------------------------------------------------------------------
// Get the current index.
selectedIndex = Icon->GetSelection();
// If the index was not found, then
// return silently.
if(selectedIndex == wxNOT_FOUND) return;
// -------------------------------------------------------------------------
// Get the label for this list box item.
// -------------------------------------------------------------------------
label = Icon->GetString(selectedIndex);
Foobar.Printf(wxT("The selected Label is <%s>."), label);
wxMessageBox( Foobar, wxT("Replace Image with Selected Image Description"), wxICON_INFORMATION);
// -------------------------------------------------------------------------
// Replace the image with the image corresponding to the text in the list
// box.
// -------------------------------------------------------------------------
if (label == lbl_A)
Desired_Picture->SetBitmap (bmp_A);
else if (label == lbl_B)
Desired_Picture->SetBitmap (bmp_B);
else if (label == lbl_E)
Desired_Picture->SetBitmap (bmp_E);
else if (label == lbl_H)
Desired_Picture->SetBitmap (bmp_H);
else if (label == lbl_Q)
Desired_Picture->SetBitmap (bmp_Q);
else if (label == lbl_S)
Desired_Picture->SetBitmap (bmp_S);
Desired_Picture->Refresh();
}
// More unrelated code omitted...
Code: Select all
#include "wx/msw/wx.rc"
#ifdef WIN64
1 24 "wx/msw/amd64.manifest"
#else
1 24 "wx/msw/wx.manifest"
#endif