Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: JoeH on May 27, 2025, 11:57:52 pm

Title: Sharing Dialog and Control Resources Among Projects
Post by: JoeH on May 27, 2025, 11:57:52 pm
In my efforts to learn how to use CodeBlocks I have developed a number of projects which focus on a specific set of conditions.  Some of the dialog and control configurations I would like to use in other projects.  Is it possible to extract a dialog I have built in one project and "paste" it into another project, or must the dialog be rebuilt from scratch?

Joe
Title: Re: Sharing Dialog and Control Resources Among Projects
Post by: Miguel Gimenez on May 28, 2025, 11:38:01 am
AFAIK there is no automatic way, but you can do it easily. Suppose you have created MyDialog with sources MyDialog.cpp/MyDialog.h:
  - copy MyDialog.cpp/MyDialog.h to the new project folder
  - copy wxsmith/MyDialog.wxs file to the wxsmith folder in the new project folder
  - edit the project with a text editor and add the source files and the wxs

Code
<Unit filename="MyDialog.cpp" />
<Unit filename="MyDialog.h" />
<Unit filename="wxsmith/MyDialog.wxs" />
  - add in the wxsmith section the line associated to the resource, in this case:

Code
<resources>
    ...
    <wxDialog wxs="wxsmith/MyDialog.wxs" src="MyDialog.cpp" hdr="MyDialog.h" fwddecl="0" i18n="1" name="MyDialog" language="CPP" />
    ...
</resources>
You can use the original project as a guide.
Title: Re: Sharing Dialog and Control Resources Among Projects
Post by: JoeH on May 29, 2025, 05:54:50 pm
Thanks,

      It took me a little bit of poking around in the project files and testing but I got the process you described to work.  This will save me a fair amount of effort.  Thanks again.

Joe