]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/app.cpp
All char, char *, and char arrays changed to use wxChar or wxString. 99% backward...
[wxWidgets.git] / src / msw / app.cpp
index d994f7b343acf060a6ac0e35d68ad2be553ff07c..399e734e84ed96bc1b1a7b982d2fd430af7ee2a9 100644 (file)
@@ -724,15 +724,33 @@ int wxEntry(WXHINSTANCE hInstance,
 
         int retValue = 0;
 
-        if ( wxTheApp->OnInit() )
+        // it is common to create a modal dialog in OnInit() (to ask/notify the
+        // user about something) but it wouldn't work if we don't change the
+        // "exit on delete last frame" flag here as when this dialog is
+        // deleted, the app would terminate (it was the last top level window
+        // as the main frame wasn't created yet!), so disable this behaviour
+        // temproarily
+        bool exitOnLastFrameDelete = wxTheApp->GetExitOnFrameDelete();
+        wxTheApp->SetExitOnFrameDelete(FALSE);
+
+        // init the app
+        retValue = wxTheApp->OnInit() ? 0 : -1;
+
+        // restore the old flag value
+        wxTheApp->SetExitOnFrameDelete(exitOnLastFrameDelete);
+
+        if ( retValue == 0 )
         {
             if ( enterLoop )
             {
+                // run the main loop
                 retValue = wxTheApp->OnRun();
             }
             else
-                // We want to initialize, but not run or exit immediately.
+            {
+                // we want to initialize, but not run or exit immediately.
                 return 1;
+            }
         }
         //else: app initialization failed, so we skipped OnRun()
 
@@ -1035,6 +1053,7 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg)
     // Try translations first; find the youngest window with
     // a translation table.
     wxWindow *wnd;
+
     for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
     {
         if ( wnd->MSWTranslateMessage(wxmsg) )