]>
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 #error "This sample is MSW-only"
39 #error "This sample doesn't work with DLL build of wxWidgets"
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 static const int ID_RUN_DLL
= wxNewId();
48 class MainFrame
: public wxFrame
53 void OnRunDLL(wxCommandEvent
& event
);
59 class MainApp
: public wxApp
62 virtual bool OnInit();
67 // ============================================================================
69 // ============================================================================
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 BEGIN_EVENT_TABLE(MainFrame
, wxFrame
)
76 EVT_BUTTON(ID_RUN_DLL
, MainFrame::OnRunDLL
)
79 MainFrame::MainFrame()
80 : wxFrame(NULL
, wxID_ANY
, "Main wx app",
81 wxDefaultPosition
, wxSize(400, 300))
83 wxPanel
*p
= new wxPanel(this, wxID_ANY
);
84 wxSizer
*sizer
= new wxBoxSizer(wxVERTICAL
);
93 "Main wxApp instance is %p (%s),\n"
97 wxThread::GetCurrentId()
100 wxSizerFlags(1).Expand().Border(wxALL
, 10)
105 new wxButton(p
, ID_RUN_DLL
, "Run GUI from DLL"),
106 wxSizerFlags(0).Right().Border(wxALL
, 10)
109 p
->SetSizerAndFit(sizer
);
111 wxSizer
*fsizer
= new wxBoxSizer(wxVERTICAL
);
112 fsizer
->Add(p
, wxSizerFlags(1).Expand());
113 SetSizerAndFit(fsizer
);
116 void MainFrame::OnRunDLL(wxCommandEvent
& WXUNUSED(event
))
118 run_wx_gui_from_dll("child instance");
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
126 bool MainApp::OnInit()
128 if ( !wxApp::OnInit() )
131 wxFrame
*f
= new MainFrame();
137 int MainApp::OnExit()
140 return wxApp::OnExit();
144 IMPLEMENT_APP(MainApp
)