]> git.saurik.com Git - wxWidgets.git/commitdiff
override ExitMainLoop() to exit the MFC main loop instead of wxWidgets one, otherwise...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 1 Nov 2006 21:53:30 +0000 (21:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 1 Nov 2006 21:53:30 +0000 (21:53 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42924 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/mfc/mfctest.cpp

index 2712c716c1d78052eebdf6c00352421351a3eb35..7a3f3d34e48a10ba66e7b84250625b7094c1b9ff 100644 (file)
@@ -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();
 };
 
@@ -229,14 +233,20 @@ BOOL CTheApp::OnIdle(LONG WXUNUSED(lCount))
 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
 
-    return TRUE;
+    return true;
+}
+
+void MyApp::ExitMainLoop()
+{
+    // instead of existing wxWidgets main loop, terminate the MFC one
+    ::PostQuitMessage(0);
 }
 
 wxFrame *MyApp::CreateFrame()
@@ -268,7 +278,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 +354,7 @@ MyChild::~MyChild()
 
 void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
-    Close(TRUE);
+    Close(true);
 }
 
 void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))