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
How to add Resources in Code Blocks?
-
- Ultimate wxWidgets Guru
- Posts: 670
- Joined: Tue Jul 26, 2016 2:00 pm
Re: How to add Resources in Code Blocks?
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.
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.
Re: How to add Resources in Code Blocks?
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.
Re: How to add Resources in Code Blocks?
Hi,
For such oddity you might ask the C::B forum/ML.
Thank you.
For such oddity you might ask the C::B forum/ML.
Thank you.
- eranon
- 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?
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.0CJS 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.
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"]