<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bentcode</id>
	<title>Code::Blocks - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.codeblocks.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bentcode"/>
	<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php/Special:Contributions/Bentcode"/>
	<updated>2026-05-05T23:23:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7235</id>
		<title>WxSmith tutorial: Using wxPanel resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7235"/>
		<updated>2012-04-07T22:33:45Z</updated>

		<summary type="html">&lt;p&gt;Bentcode: /* Adding the wxPanel using a &amp;quot;Custom&amp;quot; item */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Using wxPanel resources =&lt;br /&gt;
&lt;br /&gt;
[Subsequent tutorials do not depend upon this one. If you find it confusing or not relevant to your needs, you can skip to the next without loss of continuity.]&lt;br /&gt;
&lt;br /&gt;
In some cases, one resource must be split into a few smaller parts. Such a split gives a few advantages: it helps with multiple people working on the same project, it may give you a cleaner view over really complex resources and it may help to divide source code for logical parts in case of several functionalities in one window. In this tutorial I'll show you how to create such resources.&lt;br /&gt;
&lt;br /&gt;
== Creating our playground ==&lt;br /&gt;
&lt;br /&gt;
wxPanel resources can not live as independent items - they must be placed inside a frame or dialog. We can use the main resource created inside the wizard. Assuming that you've read the previous tutorials, creating a simple window shouldn't be a big problem for you :).&lt;br /&gt;
&lt;br /&gt;
Let's start with something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_001.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding the wxPanel using a &amp;quot;Custom&amp;quot; item ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial I'll show you two methods of embedding an external wxPanel inside another resource.&lt;br /&gt;
The first one uses a &amp;quot;Custom&amp;quot; item which can be used to add any kind of resource not known to wxSmith.&lt;br /&gt;
&lt;br /&gt;
So let's create the wxPanel resource by using the wxSmith item on the Code::Blocks main menu. Note that using this embedding method will affect the initial configuration of the resource.&lt;br /&gt;
We want the id, size and position of our panel to be controlled by the parent resource so make sure that we add them into the panel's constructor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_002.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add some content into the panel:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_003.png]]&lt;br /&gt;
&lt;br /&gt;
The final step is to add a &amp;quot;Custom&amp;quot; item into the main window and configure it properly. The custom icon is the last one in the &amp;quot;Standard palette&amp;quot; identified by this icon:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_004.png]]&lt;br /&gt;
&lt;br /&gt;
A new item will be shown as a black square with three question marks on the top. Let's resize it a little bit:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_005.png]]&lt;br /&gt;
&lt;br /&gt;
Now we need to adjust the custom item's properties. &lt;br /&gt;
&lt;br /&gt;
The first thing we will adjust is the &amp;quot;Creating code&amp;quot; property. As the name says, here we will be able to adjust the way wxSmith adds the code responsible for creating this item. The default value is:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE),$(STYLE),wxDefaultValidator,$(NAME));&lt;br /&gt;
&lt;br /&gt;
You may find that there are some macros used. They are here to help you map other properties of this item into the creating code:&lt;br /&gt;
* $(THIS)  is replaced by the name of the variable for this item&lt;br /&gt;
* $(CLASS) is replaced by the name of the item's class&lt;br /&gt;
* $(PARENT) is replaced by the name of the parent item (it's granted that it will be a pointer to a class derived from wxWindow)&lt;br /&gt;
* $(ID) is replaced by the value of the ID property&lt;br /&gt;
* $(POS) is replaced by the value of the position property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(SIZE) is replaced by the value of the size property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(STYLE) is replaced by the style property - since custom items doesn't have a predefined set of styles, it's treated as a normal string&lt;br /&gt;
* $(NAME) is replaced by the generated name (which is equivalent to the string representation of the item's identifier)&lt;br /&gt;
&lt;br /&gt;
The default code template creates a standard item which uses the default set of properties. Let's replace it by a value corresponding to our panel's constructor:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE));&lt;br /&gt;
&lt;br /&gt;
Now we have to give the name of the header file with our external resource in the &amp;quot;Include file&amp;quot; property. I've created the wxPanel with the name &amp;quot;InternalPanel&amp;quot; so the header will be &amp;quot;InternalPanel.h&amp;quot;. Also let's check the &amp;quot;Use &amp;quot;&amp;quot; for include...&amp;quot; since we're including a local file.&lt;br /&gt;
&lt;br /&gt;
The last property to adjust is the &amp;quot;Class name&amp;quot; - we need to put the name of our panel here; in my case it's &amp;quot;InternalPanel&amp;quot;. When we do this, our embedded resource is ready.  While the resource view and the show preview continue to show the black square with three question marks, if you rebuild/run the project you will see the embedded resource; &lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_006.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding custom panel through standard wxPanel ==&lt;br /&gt;
&lt;br /&gt;
The second way in which an external resource may be used is through a normal wxPanel.&lt;br /&gt;
If you look closer, you'll find that most of the items have a property called &amp;quot;Class name&amp;quot; - this is the name of the class which will be used as the item's type. By default it contains the name of the original class in wxWidgets. Changing it will notify wxSmith that a different class will be used instead.&lt;br /&gt;
&lt;br /&gt;
So to put our own panel here we can add a &amp;quot;normal&amp;quot; panel into the main resource and change the class name to the name of our internal resource. So far it's easy but there's one requirement to this technique - our internal resource must have exactly the same constructor arguments as in the case of the &amp;quot;original&amp;quot; class.&lt;br /&gt;
&lt;br /&gt;
So let's take a look at the wxWidgets documentation. Here's the declaration of wxPanel's constructor:&lt;br /&gt;
&lt;br /&gt;
 wxPanel( wxWindow* parent, wxWindowID id = wxID_ANY, &lt;br /&gt;
          const wxPoint&amp;amp; pos = wxDefaultPosition, const wxSize&amp;amp; size = wxDefaultSize, &lt;br /&gt;
          long style = wxTAB_TRAVERSAL, const wxString&amp;amp; name = &amp;quot;panel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now let's create our own internal resource. We will have to adjust constructor arguments as in the case of the previous method:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_007.png]]&lt;br /&gt;
&lt;br /&gt;
Note that I've added custom arguments and turned off all default values (it's required since we cannot easily add default values of our custom args).&lt;br /&gt;
&lt;br /&gt;
Now that our panel is ready we can add it to the main resource - let's add a &amp;quot;normal&amp;quot; panel first:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_008.png]]&lt;br /&gt;
&lt;br /&gt;
and change &amp;quot;Class name&amp;quot; property to the name of our resource (in my case it's InternalResource2).&lt;br /&gt;
&lt;br /&gt;
We still need to add #include &amp;quot;InternalResource2.h&amp;quot; into the sources to make our project compile. In the previous solution it was done automatically through properties. Now we don't have such a system so let's add it manually (remember to put our include outside wxSmith's code section, otherwise any change in the resource will remove our change). Note that we need to add it to the header file of the main resource:&lt;br /&gt;
&lt;br /&gt;
 //(*Headers(Tutorial5Dialog)&lt;br /&gt;
 #include &amp;lt;wx/sizer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;wx/panel.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;InternalPanel.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;wx/dialog.h&amp;gt;&lt;br /&gt;
 //*)&lt;br /&gt;
 '''#include &amp;quot;InternalResource2.h&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
Now we can run our application:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I've presented two easy methods of creating complex windows from smaller resources. Perhaps you could find other ways to do it (if you do so, you can extend this tutorial :) ). On wxSmith's wishlist there's also a nice feature request to allow adding external panels in a more natural way (just by a few clicks) which will probably make other methods obsolete. But I hope that I gave you enough information to build nice compound resources so far :)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Working with multiple resources|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Accessing items in resource|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bentcode</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7234</id>
		<title>WxSmith tutorial: Using wxPanel resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7234"/>
		<updated>2012-04-07T22:32:41Z</updated>

		<summary type="html">&lt;p&gt;Bentcode: /* Adding the wxPanel using a &amp;quot;Custom&amp;quot; item */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Using wxPanel resources =&lt;br /&gt;
&lt;br /&gt;
[Subsequent tutorials do not depend upon this one. If you find it confusing or not relevant to your needs, you can skip to the next without loss of continuity.]&lt;br /&gt;
&lt;br /&gt;
In some cases, one resource must be split into a few smaller parts. Such a split gives a few advantages: it helps with multiple people working on the same project, it may give you a cleaner view over really complex resources and it may help to divide source code for logical parts in case of several functionalities in one window. In this tutorial I'll show you how to create such resources.&lt;br /&gt;
&lt;br /&gt;
== Creating our playground ==&lt;br /&gt;
&lt;br /&gt;
wxPanel resources can not live as independent items - they must be placed inside a frame or dialog. We can use the main resource created inside the wizard. Assuming that you've read the previous tutorials, creating a simple window shouldn't be a big problem for you :).&lt;br /&gt;
&lt;br /&gt;
Let's start with something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_001.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding the wxPanel using a &amp;quot;Custom&amp;quot; item ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial I'll show you two methods of embedding an external wxPanel inside another resource.&lt;br /&gt;
The first one uses a &amp;quot;Custom&amp;quot; item which can be used to add any kind of resource not known to wxSmith.&lt;br /&gt;
&lt;br /&gt;
So let's create the wxPanel resource by using the wxSmith item on the Code::Blocks main menu. Note that using this embedding method will affect the initial configuration of the resource.&lt;br /&gt;
We want the id, size and position of our panel to be controlled by the parent resource so make sure that we add them into the panel's constructor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_002.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add some content into the panel:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_003.png]]&lt;br /&gt;
&lt;br /&gt;
The final step is to add a &amp;quot;Custom&amp;quot; item into the main window and configure it properly. The custom icon is the last one in the &amp;quot;Standard palette&amp;quot; identified by this icon:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_004.png]]&lt;br /&gt;
&lt;br /&gt;
A new item will be shown as a black square with three question marks on the top. Let's resize it a little bit:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_005.png]]&lt;br /&gt;
&lt;br /&gt;
Now we need to adjust the custom item's properties. &lt;br /&gt;
&lt;br /&gt;
The first thing we will adjust is the &amp;quot;Creating code&amp;quot; property. As the name says, here we will be able to adjust the way wxSmith adds the code responsible for creating this item. The default value is:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE),$(STYLE),wxDefaultValidator,$(NAME));&lt;br /&gt;
&lt;br /&gt;
You may find that there are some macros used. They are here to help you map other properties of this item into the creating code:&lt;br /&gt;
* $(THIS)  is replaced by the name of the variable for this item&lt;br /&gt;
* $(CLASS) is replaced by the name of the item's class&lt;br /&gt;
* $(PARENT) is replaced by the name of the parent item (it's granted that it will be a pointer to a class derived from wxWindow)&lt;br /&gt;
* $(ID) is replaced by the value of the ID property&lt;br /&gt;
* $(POS) is replaced by the value of the position property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(SIZE) is replaced by the value of the size property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(STYLE) is replaced by the style property - since custom items doesn't have a predefined set of styles, it's treated as a normal string&lt;br /&gt;
* $(NAME) is replaced by the generated name (which is equivalent to the string representation of the item's identifier)&lt;br /&gt;
&lt;br /&gt;
The default code template creates a standard item which uses the default set of properties. Let's replace it by a value corresponding to our panel's constructor:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE));&lt;br /&gt;
&lt;br /&gt;
Now we have to give the name of the header file with our external resource in the &amp;quot;Include file&amp;quot; property. I've created the wxPanel with the name &amp;quot;InternalPanel&amp;quot; so the header will be &amp;quot;InternalPanel.h&amp;quot;. Also let's check the &amp;quot;Use &amp;quot;&amp;quot; for include...&amp;quot; since we're including a local file.&lt;br /&gt;
&lt;br /&gt;
The last property to adjust is the &amp;quot;Class name&amp;quot; - we need to put the name of our panel here; in my case it's &amp;quot;InternalPanel&amp;quot;. When we do this, our embedded resource is ready.  While the resource view and the show preview continue to show the black square with three question marks, if you rebuild/run the project you will see; &lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_006.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding custom panel through standard wxPanel ==&lt;br /&gt;
&lt;br /&gt;
The second way in which an external resource may be used is through a normal wxPanel.&lt;br /&gt;
If you look closer, you'll find that most of the items have a property called &amp;quot;Class name&amp;quot; - this is the name of the class which will be used as the item's type. By default it contains the name of the original class in wxWidgets. Changing it will notify wxSmith that a different class will be used instead.&lt;br /&gt;
&lt;br /&gt;
So to put our own panel here we can add a &amp;quot;normal&amp;quot; panel into the main resource and change the class name to the name of our internal resource. So far it's easy but there's one requirement to this technique - our internal resource must have exactly the same constructor arguments as in the case of the &amp;quot;original&amp;quot; class.&lt;br /&gt;
&lt;br /&gt;
So let's take a look at the wxWidgets documentation. Here's the declaration of wxPanel's constructor:&lt;br /&gt;
&lt;br /&gt;
 wxPanel( wxWindow* parent, wxWindowID id = wxID_ANY, &lt;br /&gt;
          const wxPoint&amp;amp; pos = wxDefaultPosition, const wxSize&amp;amp; size = wxDefaultSize, &lt;br /&gt;
          long style = wxTAB_TRAVERSAL, const wxString&amp;amp; name = &amp;quot;panel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now let's create our own internal resource. We will have to adjust constructor arguments as in the case of the previous method:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_007.png]]&lt;br /&gt;
&lt;br /&gt;
Note that I've added custom arguments and turned off all default values (it's required since we cannot easily add default values of our custom args).&lt;br /&gt;
&lt;br /&gt;
Now that our panel is ready we can add it to the main resource - let's add a &amp;quot;normal&amp;quot; panel first:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_008.png]]&lt;br /&gt;
&lt;br /&gt;
and change &amp;quot;Class name&amp;quot; property to the name of our resource (in my case it's InternalResource2).&lt;br /&gt;
&lt;br /&gt;
We still need to add #include &amp;quot;InternalResource2.h&amp;quot; into the sources to make our project compile. In the previous solution it was done automatically through properties. Now we don't have such a system so let's add it manually (remember to put our include outside wxSmith's code section, otherwise any change in the resource will remove our change). Note that we need to add it to the header file of the main resource:&lt;br /&gt;
&lt;br /&gt;
 //(*Headers(Tutorial5Dialog)&lt;br /&gt;
 #include &amp;lt;wx/sizer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;wx/panel.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;InternalPanel.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;wx/dialog.h&amp;gt;&lt;br /&gt;
 //*)&lt;br /&gt;
 '''#include &amp;quot;InternalResource2.h&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
Now we can run our application:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I've presented two easy methods of creating complex windows from smaller resources. Perhaps you could find other ways to do it (if you do so, you can extend this tutorial :) ). On wxSmith's wishlist there's also a nice feature request to allow adding external panels in a more natural way (just by a few clicks) which will probably make other methods obsolete. But I hope that I gave you enough information to build nice compound resources so far :)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Working with multiple resources|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Accessing items in resource|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bentcode</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7233</id>
		<title>WxSmith tutorial: Using wxPanel resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Using_wxPanel_resources&amp;diff=7233"/>
		<updated>2012-04-07T21:58:10Z</updated>

		<summary type="html">&lt;p&gt;Bentcode: /* Adding the wxPanel using a &amp;quot;Custom&amp;quot; item */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Using wxPanel resources =&lt;br /&gt;
&lt;br /&gt;
[Subsequent tutorials do not depend upon this one. If you find it confusing or not relevant to your needs, you can skip to the next without loss of continuity.]&lt;br /&gt;
&lt;br /&gt;
In some cases, one resource must be split into a few smaller parts. Such a split gives a few advantages: it helps with multiple people working on the same project, it may give you a cleaner view over really complex resources and it may help to divide source code for logical parts in case of several functionalities in one window. In this tutorial I'll show you how to create such resources.&lt;br /&gt;
&lt;br /&gt;
== Creating our playground ==&lt;br /&gt;
&lt;br /&gt;
wxPanel resources can not live as independent items - they must be placed inside a frame or dialog. We can use the main resource created inside the wizard. Assuming that you've read the previous tutorials, creating a simple window shouldn't be a big problem for you :).&lt;br /&gt;
&lt;br /&gt;
Let's start with something like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_001.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding the wxPanel using a &amp;quot;Custom&amp;quot; item ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial I'll show you two methods of embedding an external wxPanel inside another resource.&lt;br /&gt;
The first one uses a &amp;quot;Custom&amp;quot; item which can be used to add any kind of resource not known to wxSmith.&lt;br /&gt;
&lt;br /&gt;
So let's create the wxPanel resource by using the wxSmith item on the Code::Blocks main menu. Note that using this embedding method will affect the initial configuration of the resource.&lt;br /&gt;
We want the id, size and position of our panel to be controlled by the parent resource so make sure that we add them into the panel's constructor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_002.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add some content into the panel:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_003.png]]&lt;br /&gt;
&lt;br /&gt;
The final step is to add a &amp;quot;Custom&amp;quot; item into the main window and configure it properly. The custom icon is the last one in the &amp;quot;Standard palette&amp;quot; identified by this icon:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_004.png]]&lt;br /&gt;
&lt;br /&gt;
A new item will be shown as a black square with three question marks on the top. Let's resize it a little bit:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_005.png]]&lt;br /&gt;
&lt;br /&gt;
Now we need to adjust the custom item's properties. &lt;br /&gt;
&lt;br /&gt;
The first thing we will adjust is the &amp;quot;Creating code&amp;quot; property. As the name says, here we will be able to adjust the way wxSmith adds the code responsible for creating this item. The default value is:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE),$(STYLE),wxDefaultValidator,$(NAME));&lt;br /&gt;
&lt;br /&gt;
You may find that there are some macros used. They are here to help you map other properties of this item into the creating code:&lt;br /&gt;
* $(THIS)  is replaced by the name of the variable for this item&lt;br /&gt;
* $(CLASS) is replaced by the name of the item's class&lt;br /&gt;
* $(PARENT) is replaced by the name of the parent item (it's granted that it will be a pointer to a class derived from wxWindow)&lt;br /&gt;
* $(ID) is replaced by the value of the ID property&lt;br /&gt;
* $(POS) is replaced by the value of the position property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(SIZE) is replaced by the value of the size property (it may be adjusted by using drag boxes)&lt;br /&gt;
* $(STYLE) is replaced by the style property - since custom items doesn't have a predefined set of styles, it's treated as a normal string&lt;br /&gt;
* $(NAME) is replaced by the generated name (which is equivalent to the string representation of the item's identifier)&lt;br /&gt;
&lt;br /&gt;
The default code template creates a standard item which uses the default set of properties. Let's replace it by a value corresponding to our panel's constructor:&lt;br /&gt;
&lt;br /&gt;
 $(THIS) = new $(CLASS)($(PARENT),$(ID),$(POS),$(SIZE));&lt;br /&gt;
&lt;br /&gt;
Now we have to give the name of the header file with our external resource in the &amp;quot;Include file&amp;quot; property. I've created the wxPanel with the name &amp;quot;InternalPanel&amp;quot; so the header will be &amp;quot;InternalPanel.h&amp;quot;. Also let's check the &amp;quot;Use &amp;quot;&amp;quot; for include...&amp;quot; since we're including a local file.&lt;br /&gt;
&lt;br /&gt;
The last property to adjust is the &amp;quot;Class name&amp;quot; - we need to put the name of our panel here; in my case it's &amp;quot;InternalPanel&amp;quot;. When we do this, our embedded resource is ready:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_006.png]]&lt;br /&gt;
&lt;br /&gt;
== Adding custom panel through standard wxPanel ==&lt;br /&gt;
&lt;br /&gt;
The second way in which an external resource may be used is through a normal wxPanel.&lt;br /&gt;
If you look closer, you'll find that most of the items have a property called &amp;quot;Class name&amp;quot; - this is the name of the class which will be used as the item's type. By default it contains the name of the original class in wxWidgets. Changing it will notify wxSmith that a different class will be used instead.&lt;br /&gt;
&lt;br /&gt;
So to put our own panel here we can add a &amp;quot;normal&amp;quot; panel into the main resource and change the class name to the name of our internal resource. So far it's easy but there's one requirement to this technique - our internal resource must have exactly the same constructor arguments as in the case of the &amp;quot;original&amp;quot; class.&lt;br /&gt;
&lt;br /&gt;
So let's take a look at the wxWidgets documentation. Here's the declaration of wxPanel's constructor:&lt;br /&gt;
&lt;br /&gt;
 wxPanel( wxWindow* parent, wxWindowID id = wxID_ANY, &lt;br /&gt;
          const wxPoint&amp;amp; pos = wxDefaultPosition, const wxSize&amp;amp; size = wxDefaultSize, &lt;br /&gt;
          long style = wxTAB_TRAVERSAL, const wxString&amp;amp; name = &amp;quot;panel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Now let's create our own internal resource. We will have to adjust constructor arguments as in the case of the previous method:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_007.png]]&lt;br /&gt;
&lt;br /&gt;
Note that I've added custom arguments and turned off all default values (it's required since we cannot easily add default values of our custom args).&lt;br /&gt;
&lt;br /&gt;
Now that our panel is ready we can add it to the main resource - let's add a &amp;quot;normal&amp;quot; panel first:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_008.png]]&lt;br /&gt;
&lt;br /&gt;
and change &amp;quot;Class name&amp;quot; property to the name of our resource (in my case it's InternalResource2).&lt;br /&gt;
&lt;br /&gt;
We still need to add #include &amp;quot;InternalResource2.h&amp;quot; into the sources to make our project compile. In the previous solution it was done automatically through properties. Now we don't have such a system so let's add it manually (remember to put our include outside wxSmith's code section, otherwise any change in the resource will remove our change). Note that we need to add it to the header file of the main resource:&lt;br /&gt;
&lt;br /&gt;
 //(*Headers(Tutorial5Dialog)&lt;br /&gt;
 #include &amp;lt;wx/sizer.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;wx/panel.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;InternalPanel.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;wx/dialog.h&amp;gt;&lt;br /&gt;
 //*)&lt;br /&gt;
 '''#include &amp;quot;InternalResource2.h&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
Now we can run our application:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut05_009.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I've presented two easy methods of creating complex windows from smaller resources. Perhaps you could find other ways to do it (if you do so, you can extend this tutorial :) ). On wxSmith's wishlist there's also a nice feature request to allow adding external panels in a more natural way (just by a few clicks) which will probably make other methods obsolete. But I hope that I gave you enough information to build nice compound resources so far :)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Working with multiple resources|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Accessing items in resource|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bentcode</name></author>
	</entry>
	<entry>
		<id>https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Working_with_multiple_resources&amp;diff=7232</id>
		<title>WxSmith tutorial: Working with multiple resources</title>
		<link rel="alternate" type="text/html" href="https://wiki.codeblocks.org/index.php?title=WxSmith_tutorial:_Working_with_multiple_resources&amp;diff=7232"/>
		<updated>2012-04-07T21:17:29Z</updated>

		<summary type="html">&lt;p&gt;Bentcode: /* Working with Multiple Windows */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:wxSmith Documentation]]&lt;br /&gt;
= Working with Multiple Windows =&lt;br /&gt;
&lt;br /&gt;
In this tutorial, I'll show you how to create an application with more than one window. We will have, as usual, a main window; and in it we will create and show at the click of one button a wxFrame window and at the click of another button, a wxDialog window. One important difference between these two windows is that a wxDialog has the possibility of stopping the application until it is closed. It is generally used for asking the user a question or questions which demand answers before computation can proceed. Otherwise, the wxFrame generally has greater capabilities. &lt;br /&gt;
 &lt;br /&gt;
As usual, we will start with an empty project. Let's name the project &amp;quot;Tutorial_4&amp;quot;. As always, remember to add the Close() statement. Check that the empty application compiles, runs and closes fine.&lt;br /&gt;
 &lt;br /&gt;
New windows can be added from the '''wxSmith''' menu item from the main menu of Code::Blocks. You can find there the following possibilities: &lt;br /&gt;
&lt;br /&gt;
*'''Add wxPanel''' - this will add a new panel into the window &lt;br /&gt;
*'''Add wxFloatingFrame''' –  this will add Floating frame window&lt;br /&gt;
*'''Add wxDialog''' - this adds a new dialog window &lt;br /&gt;
*'''Add wxFrame''' - this adds a new frame window. &lt;br /&gt;
&lt;br /&gt;
Let's first add a new wxDialog. When you choose this option you will see the following window: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_001.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here we can set the following parameters: &lt;br /&gt;
*Class name -  the name of the class which will be generated for the resource. It will also be the name of a resource &lt;br /&gt;
*Header file – the name of the header file with the class declaration &lt;br /&gt;
*Source file – the name of the source file with the class definition &lt;br /&gt;
*XRC file - if you check this option you can enter the name of an XRC file which will contain the XRC's structure (XRC files will be covered in a tutorial not yet written.) &lt;br /&gt;
*Add XRC file to autoload list - this option is available only with XRC files and notifies wxSmith that it should automatically load the XRC file when the application starts. &lt;br /&gt;
&lt;br /&gt;
Now let's change the name of the window to something more distinctive like &amp;quot;FirstDialog&amp;quot;. Note that if you change the class name, the names of the files are also updated. (More correctly, they are updated as long as you don't change them manually). &lt;br /&gt;
&lt;br /&gt;
After clicking OK, you will be prompted for a list of build targets into which the new window will be added. Select both ''debug'' and ''release'', and we can continue.&lt;br /&gt;
 &lt;br /&gt;
A new dialog is automatically opened in the editor. In the top bar of the frame of the editor, note that there are two .wxs files available to the editor, Tutorial_4Frame.wks and the newly created FirstDialog1.wxs.  Both are completely blank. Into FirstDialog.wxs let's add some simple content so that it looks like this in the editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_002.png]]&lt;br /&gt;
&lt;br /&gt;
It is a good review exercise to figure out from this figure what has been done. It is very similar to what we did at the beginning of the previous tutorial. Before reading further, try your hand at making it.  (To tell the truth, it doesn't matter much what you put in because all we are going to do with it is show it, But if you need a review, here is what I did: 1. Put a wxBoxSizer on the editor. 2. Put a wxPanel in the sizer  (and remembered to turn on its Expand property). 3. Put on the panel a wxStaticBoxSizer, changed its orientation to Vertical,  and set its label to “This is the first dialog.” 4. Into the StaticBoxSizer put first a wxTextCtrl and then a wxStaticText item.)  At this point, the Show Preview button on the extreme right of the editor will show us what we have, while running the program will show nothing, because the application has no programming to show our dialog. &lt;br /&gt;
&lt;br /&gt;
Now let's go back to the wxSmith item on the Code::Blocks menu and add a wxFrame window (FirstFrame) and add some content into it:&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_003.png]]&lt;br /&gt;
&lt;br /&gt;
Again, it is good review to make the window look like this, but the content is not critical for what follows.&lt;br /&gt;
&lt;br /&gt;
== Using a Dialog Window Modally ==&lt;br /&gt;
&lt;br /&gt;
Dialogs (but not frames) can be shown modally. When  a dialog is shown modally, all other windows in the application are frozen until the dialog finishes its job. Modal dialogs are useful when the user must provide some information before computation can continue. For example, the window used to configure a new resource was shown modally.&lt;br /&gt;
 &lt;br /&gt;
Now let's try to invoke our dialog. Generally such dialogs will pop-up in reaction to some user action like choosing a menu option or clicking on a button. We will use a button since this approach is really easy. Let's switch into the main frame - the one that was opened right after creating the new project - and add a box sizer and button: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_004.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we have to create an action for the button-click event. The easiest way is to double-click the button in the editor. wxSmith will automatically add a new event handler function:&lt;br /&gt;
&lt;br /&gt;
 void Tutorial_4Frame::OnButton1Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
 {&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
If you don't see this code, scroll down to the end of the .cpp file.&lt;br /&gt;
&lt;br /&gt;
In this frame, let's put the code to invoke our dialog: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton1Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstDialog dialog(this);&lt;br /&gt;
    dialog.ShowModal();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the first added line, we create the dialog's object and declare that ''this'' window (the main frame) is the parent of dialog. In the second line, we show the dialog modally. The call to ShowModal(), which is a function (or method) of the dialog, blocks everything else until the dialog is closed. &lt;br /&gt;
&lt;br /&gt;
There's one more thing we need to add before our application will compile. Jump to the beginning of the file and add the following code after the first group of  other includes:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Note that you should '''not''' add it inside code which looks like this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a block of code that is automatically generated by wxSmith. Every block starts with a //(*BlockName comment and ends with a //*). You may find other similar blocks in both header and source files. If you change their content, all changes will be lost next time you change something in the editor. These comments and everything inside them belong to wxSmith, so don't mess with them.&lt;br /&gt;
&lt;br /&gt;
To sum up, the headers section should look like this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;wx_pch.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Tutorial_4Main.h&amp;quot;&lt;br /&gt;
#include &amp;lt;wx/msgdlg.h&amp;gt;&lt;br /&gt;
#include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can compile and run our application. If you click the button on the main window, this dialog will pop-up:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_005.png]]&lt;br /&gt;
&lt;br /&gt;
== Using Modeless Dialogs and Frame Windows ==&lt;br /&gt;
&lt;br /&gt;
Another way to show a window is as a modeless window. In such cases, the new window does not block other windows in the application and two (or more) windows can cooperate in one application. &lt;br /&gt;
Before we add new code into our application there's one more thing you should know. Each window may exist only as long as its object (the instance of the resource's c++ class) exists. So we cannot use the same approach as in the case of a modal dialog. In modal mode, an object was created as a local variable of the event handler by the simple declaration statement&lt;br /&gt;
&lt;br /&gt;
 FirstDialog dialog(this);&lt;br /&gt;
&lt;br /&gt;
We could do this only because the ShowModal method was blocking as long as the dialog was shown. Now with a wxFrame, which does not have the ShowModal possibility, we will have to create objects using the '''new''' operator of C++ because the objects must exist after leaving the handler function and also because windows not using modal mode will delete such objects automatically when the window is closed.&lt;br /&gt;
 &lt;br /&gt;
To allow creating the FirstFrame class we should add #include &amp;quot;FirstFrame.h&amp;quot; into the list of includes just as in the case of FirstDialog: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;wx_pch.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Tutorial_4Main.h&amp;quot;&lt;br /&gt;
#include &amp;lt;wx/msgdlg.h&amp;gt;&lt;br /&gt;
#include &amp;quot;FirstDialog.h&amp;quot;&lt;br /&gt;
#include &amp;quot;FirstFrame.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
//(*InternalHeaders(Tutorial_4Frame)&lt;br /&gt;
#include &amp;lt;wx/intl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;wx/string.h&amp;gt;&lt;br /&gt;
//*)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now let's add two more buttons to the main frame: &lt;br /&gt;
*Add new dialog &lt;br /&gt;
*Add new frame &lt;br /&gt;
&lt;br /&gt;
We can also name the first button to show what it does:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wxs_tut04_006.png]]&lt;br /&gt;
&lt;br /&gt;
Now let's add a handler to the ''Add new dialog'' button:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton2Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstDialog* dlg = new FirstDialog(this);&lt;br /&gt;
    dlg-&amp;gt;Show();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Analogously, we can write the code for FirstFrame:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void Tutorial_4Frame::OnButton3Click(wxCommandEvent&amp;amp; event)&lt;br /&gt;
{&lt;br /&gt;
    FirstFrame* frm = new FirstFrame(this);&lt;br /&gt;
    frm-&amp;gt;Show();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now each time we click the ''Add new dialog'' or ''Add new frame'' button, a new window shows up.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is the end of this tutorial. I hope that you learned some new and useful things. We have covered the use of two of the four things you can add to your project by using the wxSmith item on the Code::Blocks main menu. In the next tutorial, I'll show how to use another of the four, namely the wxPanel.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''[[WxSmith tutorial: Building more complex window|Previous]] | [[WxSmith tutorials|Index]] | [[WxSmith tutorial: Using wxPanel resources|Next]]'''&amp;lt;/center&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bentcode</name></author>
	</entry>
</feed>