How to add Resources in Code Blocks?

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Wanderer82
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 670
Joined: Tue Jul 26, 2016 2:00 pm

How to add Resources in Code Blocks?

Post by Wanderer82 »

Hello

It happens to me sometimes that Code Blocks crashes. Someties I froget to save the project.

So I added a new wxFrame to the project and when Code Block crashes it won't appear in the project although the files are still available. Also opening the .h or .cpp-file doesn't work.

Can anyone help me how I can add a resource to my project?

Thanks,
Thomas
CJS
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Jan 28, 2016 8:21 am

Re: How to add Resources in Code Blocks?

Post by CJS »

To restore a missing wxSmith resource, or port one in from another project:

Make sure you have a copy of the wanted wxSmith file, and the associated source code files, outside of your project, so that Code::Blocks won't affect them, for example you might have:
/wxsmith/MyFrame.wxs
MyFrame.cpp
MyFrame.h
If you are missing your new wxFrame in Resources-->wxsmith in your project you will need to move your wanted files to a completely different directory or another drive. If you are porting the frame or dialog in from another project presumably that is already in a completely different directory.
Now create a new frame in Code::Blocks with the exact same name as your wanted one, e.g. MyFrame. This should create a frame and source code files, and be listed in the project under Resources-->wxsmith. Now close Code::Blocks and if that proceeds normally, replace these newly created wxSmith files with your wanted ones. Check in Code::Blocks that the wanted frame shows up as expected and builds.

Note: When you modify a wxSmith frame or dialog in the editor, Code::Blocks does not save it automatically on a build - make sure you save your changes manually or if there is a crash they will be lost.
CJS
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Jan 28, 2016 8:21 am

Re: How to add Resources in Code Blocks?

Post by CJS »

There is a right-click "Add files" that can be used to add wxSmith files to the Projects/Resources/wxsmith branch, and the last time I tried it (in Code::Blocks 16.01) it worked, but I have also found that sometimes the resulting .wxs file in the projects tree only opens up as a text file, showing all the XML stuff instead of opening the dialog visually in wxSmith. I haven't found a systematic explanation for this odd behaviour, which results in having to use the workaround described in my previous post.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to add Resources in Code Blocks?

Post by ONEEYEMAN »

Hi,
For such oddity you might ask the C::B forum/ML.

Thank you.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: How to add Resources in Code Blocks?

Post by eranon »

CJS wrote:There is a right-click "Add files" that can be used to add wxSmith files to the Projects/Resources/wxsmith branch, and the last time I tried it (in Code::Blocks 16.01) it worked, but I have also found that sometimes the resulting .wxs file in the projects tree only opens up as a text file, showing all the XML stuff instead of opening the dialog visually in wxSmith. I haven't found a systematic explanation for this odd behaviour, which results in having to use the workaround described in my previous post.
Already faced this situation in the past... So, I searched and here is the thread in which I finally found a solution (there's maybe better since 2013, but I don't use wxSmith in my current projects in progress): http://forums.codeblocks.org/index.php?topic=9306.0

Where I said:
Solved, but there's maybe a smarter way (so, I'm still interested to know). Here is how I did it :

1) I've created a new dialog from wxSmith ("Add wxDialog" menu item), giving the same class name as the one I want to re-integrate (say "BambiDialog" class).
2) Closed Code::Blocks.
3) Overwritten BambiDialog.wxs, BambiDialog.h and BambiDialog.cpp with my old real files (the ones I want to re-integrate).
4) Re-opened Code::Blocks and all sounds right.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Post Reply