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:
@@ -75,6 +75,10 @@ class MyApp: public wxApp
|
|||||||
public:
|
public:
|
||||||
virtual bool OnInit();
|
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -229,14 +233,20 @@ BOOL CTheApp::OnIdle(LONG WXUNUSED(lCount))
|
|||||||
bool MyApp::OnInit()
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
#if !START_WITH_MFC_WINDOW
|
#if !START_WITH_MFC_WINDOW
|
||||||
|
// as we're not inside wxWidgets main loop, the default logic doesn't work
|
||||||
// Exit app when the top level frame is deleted
|
// in our case and we need to do this explicitly
|
||||||
SetExitOnFrameDelete(TRUE);
|
SetExitOnFrameDelete(true);
|
||||||
|
|
||||||
(void) CreateFrame();
|
(void) CreateFrame();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyApp::ExitMainLoop()
|
||||||
|
{
|
||||||
|
// instead of existing wxWidgets main loop, terminate the MFC one
|
||||||
|
::PostQuitMessage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFrame *MyApp::CreateFrame()
|
wxFrame *MyApp::CreateFrame()
|
||||||
@@ -268,7 +278,7 @@ wxFrame *MyApp::CreateFrame()
|
|||||||
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
|
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
|
||||||
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
|
||||||
subframe->canvas = canvas;
|
subframe->canvas = canvas;
|
||||||
subframe->Show(TRUE);
|
subframe->Show(true);
|
||||||
|
|
||||||
// Return the main frame window
|
// Return the main frame window
|
||||||
return subframe;
|
return subframe;
|
||||||
@@ -344,7 +354,7 @@ MyChild::~MyChild()
|
|||||||
|
|
||||||
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
|
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
Close(TRUE);
|
Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))
|
void MyChild::OnNew(wxCommandEvent& WXUNUSED(event))
|
||||||
|
Reference in New Issue
Block a user