{"id":3782,"date":"2021-12-13T04:26:40","date_gmt":"2021-12-13T04:26:40","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=3782"},"modified":"2024-04-28T07:25:29","modified_gmt":"2024-04-28T07:25:29","slug":"3a-wxwidgets-simple-window","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2021\/12\/13\/3a-wxwidgets-simple-window\/","title":{"rendered":"3a. wxWidgets &#8211; Simple Window"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>We create two windows in the sample program below.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">window1.h<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n\n\nclass Window1: public wxFrame {\n\tpublic:\n\t\tWindow1(const wxString&amp; title);\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">window1.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;window1.h&quot;\n\nWindow1::Window1(const wxString&amp; title):\n\twxFrame(NULL, -1, title, wxDefaultPosition, wxSize(400,200)) {\n\n\tCenter();\n}\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">window2.h<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n\n\nclass Window2: public wxFrame {\n\tpublic:\n\t\tWindow2(const wxString&amp; title);\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">window2.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;window2.h&quot;\n\nWindow2::Window2(const wxString&amp; title):\n\twxFrame(NULL, -1, title, wxPoint(100,10), wxSize(400,200)) {\n\n}\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">main.h<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;wx\/wxprec.h&gt;\n#ifndef WX_PRECOMP\n\t#include &lt;wx\/wx.h&gt;\n#endif\n\nclass Main: public wxApp {\n\n\tpublic:\n\t\tvirtual bool OnInit();\n};\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">main.cpp<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &quot;main.h&quot;\n#include &quot;window1.h&quot;\n#include &quot;window2.h&quot;\n\nIMPLEMENT_APP(Main)\n\nbool Main::OnInit() {\n\tWindow1 *win = new Window1(wxT(&quot;First Window&quot;));\n\twin-&gt;Show(true);\n\n\tWindow2 *win2 = new Window2(wxT(&quot;Second Window&quot;));\n\twin2-&gt;Show(true);\n   return TRUE;\n}\n\n<\/pre><\/div>\n\n\n<p>The output is shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"518\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-09-53-33.png\" alt=\"\" class=\"wp-image-3786\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-09-53-33.png 843w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-09-53-33-620x381.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-09-53-33-300x184.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2021\/12\/Screenshot-from-2021-12-13-09-53-33-768x472.png 768w\" sizes=\"auto, (max-width: 843px) 100vw, 843px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW We create two windows in the sample program below. SAMPLE CODE window1.h window1.cpp window2.h window2.cpp main.h main.cpp The output is shown below:<\/p>\n<\/div>","protected":false},"author":1,"featured_media":3595,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,365],"tags":[],"class_list":["post-3782","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cc","category-wxwidgets"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=3782"}],"version-history":[{"count":5,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3782\/revisions"}],"predecessor-version":[{"id":4563,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/3782\/revisions\/4563"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/3595"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=3782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=3782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=3782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}