If you step into the ShowModal, then there' line 50 in msgdlg.cpp
Code: Select all
if ( !wxTheApp->GetTopWindow() ) {
...
}
wxTheApp being an uninitialized pointer? My first idea (I thought it was NULL),
Code: Select all
if ( wxTheApp && !wxTheApp->GetTopWindow() ) {
is not a solution, because (1) I found out there's a wxDummyConsoleApp in play to supplement an app object. But it's not a descendant of wxApp, so it doesn't have GetTopWindow in its vtable! That's the crash. (2) Even if you repaired this, later on FindSuitableParent is called, which requires some hashtable mapping hwnd's to wxWindows, which also doesn't exist if there is no wxApp. And even if you made that call safe somehow, then there it is accessed again in the dialog's destructor.
So why do you want a WinMain at all? I think it's much more comfortable to have a MyApp which has initialization and cleanup separated. You can always override OnRun if you need some special kind of operation.