"Can't load bitmap from resources" Error Topic is solved
Re: "Can't load bitmap from resources" Error
Hi, Colleen,
Yes, it should.
Look at, e.g. image sample and check the documentation.
Also, word of advice - before posting that something does not work - check the appropriate sample and make sure you do the same thing.
Better yet - if you can reproduce the wrong behavior with the minimal changes to the sample and you have no idea how to debug it - post here. People here are amazing.
Thank you.
Yes, it should.
Look at, e.g. image sample and check the documentation.
Also, word of advice - before posting that something does not work - check the appropriate sample and make sure you do the same thing.
Better yet - if you can reproduce the wrong behavior with the minimal changes to the sample and you have no idea how to debug it - post here. People here are amazing.
Thank you.
Re: "Can't load bitmap from resources" Error
Colleen,
I am not doublemax, but can answer.
You are on Windows IIRC. Which means you downloaded the distribution or the installer and compiled it yourself.
Look inside the wxWidgets folder. Inside there is a folder called 'samples'. If you look inside that folder you will see a number of different samples which are the starting point of work with anything, including you own project.
Compile those samples and run them one by one. Then look at each one's code. Try to understand it.
If you have more questions - post here.
Thank you.
I am not doublemax, but can answer.
You are on Windows IIRC. Which means you downloaded the distribution or the installer and compiled it yourself.
Look inside the wxWidgets folder. Inside there is a folder called 'samples'. If you look inside that folder you will see a number of different samples which are the starting point of work with anything, including you own project.
Compile those samples and run them one by one. Then look at each one's code. Try to understand it.
If you have more questions - post here.
Thank you.
Re: "Can't load bitmap from resources" Error
That definitely shouldn't happen and i'm pretty sure that's not what's happening - there must be some other effect at work.I'm especially confused because the program compiles. Why doesn't it flag an error if I give a method parameter a variable that's the wrong type?
Can you post the whole code you have so far?
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
Certainly. This is the entire MainFrame.cpp file. There are a couple of other methods in there that do not apply to this problem; ignore them if you like. What other files do you want to see?doublemax wrote:That definitely shouldn't happen and i'm pretty sure that's not what's happening - there must be some other effect at work.I'm especially confused because the program compiles. Why doesn't it flag an error if I give a method parameter a variable that's the wrong type?
Can you post the whole code you have so far?
My goal for writing this program was just to test out wxWidgets and CodeLite. So I have radio buttons and checkboxes that I can play around with, in addition to the list boxes.
I should say right now that I didn't write very much of this code; "something else" (wxWidgets? CodeLite?) did. When I compile, I get a lot of "deprecated" warnings. Am I supposed to make the changes the "deprecated" warnings tell me about? Or will the changes appear in a future version of wxWidgets?
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();
}
void MainFrame::OnAbout(wxCommandEvent& event)
{
wxUnusedVar(event);
wxAboutDialogInfo info;
info.SetCopyright(_("My MainFrame"));
info.SetLicence(_("GPL v2 or later"));
info.SetDescription(_("Short description goes here"));
::wxAboutBox(info);
}
void MainFrame::OnHolidaysCheckAll_ButtonClicked(wxCommandEvent& event)
{
for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++)
{
CheckBoxes_ListBox->Check((unsigned int)i, true);
}
}
void MainFrame::OnHolidaysUncheckAll_ButtonClicked(wxCommandEvent& event)
{
for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++)
{
CheckBoxes_ListBox->Check((unsigned int)i, false);
}
}
void MainFrame::OnBlue_RadiobuttonSelected(wxCommandEvent& event)
{
Blue->SetValue (true);
Red->SetValue (false);
Green->SetValue (false);
Yellow->SetValue (false);
}
void MainFrame::OnGreen_RadiobuttonSelected(wxCommandEvent& event)
{
Blue->SetValue (false);
Red->SetValue (false);
Green->SetValue (true);
Yellow->SetValue (false);
}
void MainFrame::OnRed_RadiobuttonSelected(wxCommandEvent& event)
{
Blue->SetValue (false);
Red->SetValue (true);
Green->SetValue (false);
Yellow->SetValue (false);
}
void MainFrame::OnYellow_RadiobuttonSelected(wxCommandEvent& event)
{
Blue->SetValue (false);
Red->SetValue (false);
Green->SetValue (false);
Yellow->SetValue (true);
}
void MainFrame::OnIcon_listboxDoubleclicked(wxCommandEvent& event)
{
#define wxBITMAP (wxBITMAP_TYPE_ANY);
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;
// 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.
//wxBitmap bitmap(bmp_A, wxBITMAP_TYPE_ANY);
//you have bmp1 as valid bitmap, do with it whatever you want
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();
}
void MainFrame::OnIcon_listboxSelected(wxCommandEvent& event)
{
}
void MainFrame::OnHolidayscheckall_buttonButtonClicked(wxCommandEvent& event)
{
for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++)
{
CheckBoxes_ListBox->Check((unsigned int)i, true);
}
}
void MainFrame::OnHolidaysuncheckall_buttonButtonClicked(wxCommandEvent& event)
{
for(size_t i=0; i<CheckBoxes_ListBox->GetCount(); i++)
{
CheckBoxes_ListBox->Check((unsigned int)i, false);
}
}
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
Wonderful! Thank you, ONEEYEMAN. I will do this.ONEEYEMAN wrote: Look inside the wxWidgets folder. Inside there is a folder called 'samples'. If you look inside that folder you will see a number of different samples which are the starting point of work with anything, including you own project.
Re: "Can't load bitmap from resources" Error
Colleen,
Also keep in mind that the samples folder and the official documentation on the wxwidgets.org website are the only 2 sources of information you need to look at.
Also, make sure you understand the code in the different wxWidgets sample - where the different things are and how different controls are operated. Also check the drawing and image samples to see how the painting code works.
Check the code inside the sample against the documentation.
Play with the samples. They are for you to better understand stuff inside the library.
Come back if you have any questions.
P.S.: Try to drop the call to wxInitAllImageHandlers() to the application class as the very first line and re-run your code.
Thank you.
Also keep in mind that the samples folder and the official documentation on the wxwidgets.org website are the only 2 sources of information you need to look at.
Also, make sure you understand the code in the different wxWidgets sample - where the different things are and how different controls are operated. Also check the drawing and image samples to see how the painting code works.
Check the code inside the sample against the documentation.
Play with the samples. They are for you to better understand stuff inside the library.
Come back if you have any questions.
P.S.: Try to drop the call to wxInitAllImageHandlers() to the application class as the very first line and re-run your code.
Thank you.
Re: "Can't load bitmap from resources" Error
With "whole code" i mean everything needed to compile it. We still don't know what type "Desired_Picture" is and why the compiler doesn't complain about the SetBitmap() call.What other files do you want to see?
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
Check.ONEEYEMAN wrote:Colleen,
Also keep in mind that the samples folder and the official documentation on the wxwidgets.org website are the only 2 sources of information you need to look at.
Okay, I went to C:\wxWidgets\samples and picked the directory \artprov to try to compile. I looked in the directory, and I see one *.cpp and one *.h file, and a lot of files whose types I don't know what to do with.ONEEYEMAN wrote:Also, make sure you understand the code in the different wxWidgets sample - where the different things are and how different controls are operated. Also check the drawing and image samples to see how the painting code works.
I tried to load artprov as a project from inside a new CodeLite workspace, but there were no CodeLite projects (or workspaces) in C:\wxWidgets\samples\artprov. Then I thought maybe I could just create a new project inside a new workspace, but I didn't know how to fit it into the project.
So now I'm lost. How do I compile, build, and run artprov?
I do not believe I call wxInitAllImageHandlers anywhere as it is. Where do you see it?ONEEYEMAN wrote:P.S.: Try to drop the call to wxInitAllImageHandlers() to the application class as the very first line and re-run your code.
I apologize if I sound dumb. I am actually smart. Right now, I just don't understand how all the pieces fit together in wxWidgets/CodeLite. I have to understand the big picture before I understand how to put the pieces together.
Re: "Can't load bitmap from resources" Error
Colleen,
Yes, unfortunately the main wxWidgets library is not shipped with anything but MSVC solution, gcc Makefiles and Xcode projects. Those are the main compilers/IDE by platforms. There are just too many different IDEs and so the wxWidgets is trying to lock on most popular/used.
But you can just create a new project, bring the sources into it and set the include and lib folders.
Then compile and run the application.
Things would be much simpler if you had the MSVC or installed MinGW
Now for wxInitAllImageHandlers() call: try to open either drawing or image sample. Or even better - do a search for this text inside the whole sample folder. I believe you just need to drop this call as the first line of you application class.
Also check the documentation for this function - it should give you a hint on why this call is needed.
Thank you.
Yes, unfortunately the main wxWidgets library is not shipped with anything but MSVC solution, gcc Makefiles and Xcode projects. Those are the main compilers/IDE by platforms. There are just too many different IDEs and so the wxWidgets is trying to lock on most popular/used.
But you can just create a new project, bring the sources into it and set the include and lib folders.
Then compile and run the application.
Things would be much simpler if you had the MSVC or installed MinGW
Now for wxInitAllImageHandlers() call: try to open either drawing or image sample. Or even better - do a search for this text inside the whole sample folder. I believe you just need to drop this call as the first line of you application class.
Also check the documentation for this function - it should give you a hint on why this call is needed.
Thank you.
Re: "Can't load bitmap from resources" Error
You can try importing the MSVC project into Codelite.
It doesn't always work perfectly but it is worth a try!
It doesn't always work perfectly but it is worth a try!
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
Hi, iwbnwif,iwbnwif wrote:You can try importing the MSVC project into Codelite.
It doesn't always work perfectly but it is worth a try!
It *was* worth a try. But when I tried that, I got an error message that said, "Corrupted workspace file".
Oh, well. Thanks anyway!
Colleen
- ColleenKobe
- Earned some good credits
- Posts: 109
- Joined: Mon Aug 31, 2015 3:47 pm
Re: "Can't load bitmap from resources" Error
Okay, that's exactly what I don't know how to do. In C:\wxWidgets\samples\artprov, there are two *.cpp files, and one *.h file. How do I divide up the code in the *.cpp files to fit in the CodeLite files?ONEEYEMAN wrote:But you can just create a new project, bring the sources into it and set the include and lib folders.
I actually do have MinGW installed. It's in C:\MinGW. I use it with NetBeans, but I only write plain vanilla C DLLs in that environment. Nothing GUI.ONEEYEMAN wrote:Things would be much simpler if you had the MSVC or installed MinGW
Re: opening the images. Inside Windows Explorer, I display the folder with the images in it. I double-clicked on each filename. Each opened in Windows Photo Viewer successfully. Some of the files are jpgs, some are pngs. Does the file type matter, if the file is just being imported?ONEEYEMAN wrote:Now for wxInitAllImageHandlers() call: try to open either drawing or image sample. Or even better - do a search for this text inside the whole sample folder. I believe you just need to drop this call as the first line of you application class.
I did a search on the folder holding all my wxWidgets projects, using Agent Ransack, looking for "wxInitAllImageHandlers." That word only appears in file Level_2_Test.tags ("Level_2_Test" is the name of my workspace). That's all. The program still barfs on the line trying to replace the current image with a new image.
Thank you for your help, ONEEYEMAN!
Re: "Can't load bitmap from resources" Error
My offer still stands. If you could upload the complete code with headers, i'll take a look into it. Actually i'm really curious to know what's going on with that SetBitmap() methodThe program still barfs on the line trying to replace the current image with a new image.
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
Okay, doublemax. The following files appear in mydoublemax wrote:My offer still stands. If you could upload the complete code with headers, i'll take a look into it. Actually i'm really curious to know what's going on with that SetBitmap() methodThe program still barfs on the line trying to replace the current image with a new image.
CodeLite/wxWidgets environment. I'll be happy to send any or all
to you. Which ones do you want?
Include files:
------- ------
- MainFrame.h
wxcrafter.h
-------- ------
- win_resources.rc
wxcrafter.wxcp
--- --- -------- ------
- asterisk01.png
batman01.jpg
exclamationpoint01.png
homer01.png
main.cpp
Main_L2.mk
Main_L2.project
Main_L2.txt
MainFrame.cpp
MainFrame.h
questionmark01.png
superman01.png
win_resources.rc
wxcrafter.cpp
wxcrafter.h
wxcrafter.wxcp
wxcrafter_bitmaps.cpp
wxcrafter_bitmaps.xrc
with everything in it? Or would you rather have me post specific
files here on this forum?
Re: "Can't load bitmap from resources" Error
Pack everything. If the archive is bigger than 250k (which is the limit on this forum), leave out the images.
Use the source, Luke!