- Main_L2.7z
- Contains most of the files needed for Colleen Kobe's "Level_2_Test" workspace and project.
- (54 KiB) Downloaded 112 times
"Can't load bitmap from resources" Error Topic is solved
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
doublemax, here you go!
If there is something missing--like the definition of the SetBitmap() method, which I couldn't find but maybe I just missed it--let me know and I'll look elsewhere. Or if the file doesn't unzip properly, perhaps I can attach a flurry of files, instead of just one.Re: "Can't load bitmap from resources" Error
Just WOW!
I really couldn't believe it, but the compiler actually created code to implicitly convert a wxString to wxBitmap using one of the wxBitmap constructors. But as this constructor has wxBITMAP_TYPE_BMP_RESOURCE as default for "type", loading of the bitmap fails.
To circumvent that, you have to rewrite the code a bit:
Now switching the bitmap works, but there will be some redraw errors because the bitmaps have different sizes. I'll leave fixing that for another thread
I really couldn't believe it, but the compiler actually created code to implicitly convert a wxString to wxBitmap using one of the wxBitmap constructors. But as this constructor has wxBITMAP_TYPE_BMP_RESOURCE as default for "type", loading of the bitmap fails.
To circumvent that, you have to rewrite the code a bit:
Code: Select all
wxString bmp_name;
if (label == lbl_A)
bmp_name = bmp_A;
else if (label == lbl_B)
bmp_name = bmp_B;
else if (label == lbl_E)
bmp_name = bmp_E;
else if (label == lbl_H)
bmp_name = bmp_H;
else if (label == lbl_Q)
bmp_name = bmp_Q;
else if (label == lbl_S)
bmp_name = bmp_S;
if ( !bmp_name.IsEmpty() )
{
wxBitmap bmp( bmp_name, wxBITMAP_TYPE_ANY);
if ( bmp.IsOk() )
Desired_Picture->SetBitmap(bmp);
Layout();
}
Use the source, Luke!
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
Thank you, doublemax! You're brilliant! You got rid of that error message for me. Thank you!
I will tackle the new errors, and if I can't fix them myself, I'll post again.
Best of wishes to you!
Colleen
I will tackle the new errors, and if I can't fix them myself, I'll post again.
Best of wishes to you!
Colleen
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
Just for the record...I fixed the last two problems by just copying the graphics files into the same directory as the executable.
doublemax was right about the pictures drawing a little funky because the images are different sizes, but that's easily fixed, and anyway this was just a test program to create wxWidgets controls. All is well. Thank you all!
doublemax was right about the pictures drawing a little funky because the images are different sizes, but that's easily fixed, and anyway this was just a test program to create wxWidgets controls. All is well. Thank you all!