]>
git.saurik.com Git - wxWidgets.git/blob - samples/dll/wx_exe.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Sample showing how to use wx from a DLL
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2009 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/wxprec.h"
31 #include "wx/stattext.h"
32 #include "wx/button.h"
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 static const int ID_RUN_DLL
= wxNewId();
41 class MainFrame
: public wxFrame
46 void OnRunDLL(wxCommandEvent
& event
);
52 class MainApp
: public wxApp
55 virtual bool OnInit();
60 // ============================================================================
62 // ============================================================================
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 BEGIN_EVENT_TABLE(MainFrame
, wxFrame
)
69 EVT_BUTTON(ID_RUN_DLL
, MainFrame::OnRunDLL
)
72 MainFrame::MainFrame()
73 : wxFrame(NULL
, wxID_ANY
, "Main wx app",
74 wxDefaultPosition
, wxSize(400, 300))
76 wxPanel
*p
= new wxPanel(this, wxID_ANY
);
77 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
86 "Main wxApp instance is %p (%s),\n"
90 wxThread::GetCurrentId()
93 wxSizerFlags(1).Expand().Border(wxALL
, 10)
98 new wxButton(p
, ID_RUN_DLL
, "Run GUI from DLL"),
99 wxSizerFlags(0).Right().Border(wxALL
, 10)
102 p
->SetSizerAndFit(sizer
);
104 wxSizer
*fsizer
= new wxBoxSizer(wxVERTICAL
);
105 fsizer
->Add(p
, wxSizerFlags(1).Expand());
106 SetSizerAndFit(fsizer
);
109 void MainFrame::OnRunDLL(wxCommandEvent
& WXUNUSED(event
))
111 run_wx_gui_from_dll("child instance");
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 bool MainApp::OnInit()
121 if ( !wxApp::OnInit() )
124 wxFrame
*f
= new MainFrame();
130 int MainApp::OnExit()
133 return wxApp::OnExit();
137 IMPLEMENT_APP(MainApp
)