override ExitMainLoop() to exit the MFC main loop instead of wxWidgets one, otherwise the application hangs on exit

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42924 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-11-01 21:53:30 +00:00
parent abe2128564
commit bb2775b9e8

View 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))