git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42924
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
public:
virtual bool OnInit();
public:
virtual bool OnInit();
+ // we need to override this as the default behaviour only works when we're
+ // running wxWidgets main loop, not MFC one
+ virtual void ExitMainLoop();
+
wxFrame *CreateFrame();
};
wxFrame *CreateFrame();
};
bool MyApp::OnInit()
{
#if !START_WITH_MFC_WINDOW
bool MyApp::OnInit()
{
#if !START_WITH_MFC_WINDOW
-
- // Exit app when the top level frame is deleted
- SetExitOnFrameDelete(TRUE);
+ // as we're not inside wxWidgets main loop, the default logic doesn't work
+ // in our case and we need to do this explicitly
+ SetExitOnFrameDelete(true);
(void) CreateFrame();
#endif
(void) CreateFrame();
#endif
+ return true;
+}
+
+void MyApp::ExitMainLoop()
+{
+ // instead of existing wxWidgets main loop, terminate the MFC one
+ ::PostQuitMessage(0);
}
wxFrame *MyApp::CreateFrame()
}
wxFrame *MyApp::CreateFrame()
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
subframe->canvas = canvas;
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
subframe->canvas = canvas;
// Return the main frame window
return subframe;
// Return the main frame window
return subframe;
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
}
void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))
}
void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))