X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ff96483989dfd0649360c704e16d01601e3b070d..5ef723747cc680b3c237053bf0e3a78f0f179694:/samples/mfc/mfctest.cpp?ds=sidebyside diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index 2712c716c1..d0c92194ab 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -75,6 +75,10 @@ class MyApp: public wxApp 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(); }; @@ -228,15 +232,24 @@ BOOL CTheApp::OnIdle(LONG WXUNUSED(lCount)) bool MyApp::OnInit() { -#if !START_WITH_MFC_WINDOW + if ( !wxApp::OnInit() ) + return false; - // Exit app when the top level frame is deleted - SetExitOnFrameDelete(TRUE); +#if !START_WITH_MFC_WINDOW + // 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 - return TRUE; + return true; +} + +void MyApp::ExitMainLoop() +{ + // instead of existing wxWidgets main loop, terminate the MFC one + ::PostQuitMessage(0); } wxFrame *MyApp::CreateFrame() @@ -268,7 +281,7 @@ wxFrame *MyApp::CreateFrame() MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height)); canvas->SetCursor(wxCursor(wxCURSOR_PENCIL)); subframe->canvas = canvas; - subframe->Show(TRUE); + subframe->Show(true); // Return the main frame window return subframe; @@ -344,7 +357,7 @@ MyChild::~MyChild() void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event)) { - Close(TRUE); + Close(true); } void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))