-//----------------------------------------------------------------------
-// Entry point helpers, used by wxPython
-//----------------------------------------------------------------------
-
-int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char** WXUNUSED(argv) )
-{
- return wxApp::Initialize();
-}
-
-int WXDLLEXPORT wxEntryInitGui()
-{
- return wxTheApp->OnInitGui();
-}
-
-void WXDLLEXPORT wxEntryCleanup()
-{
- wxApp::CleanUp();
-}
-
-
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
-
-// temporarily disable this warning which would be generated in release builds
-// because of __try
-#ifdef __VISUALC__
- #pragma warning(disable: 4715) // not all control paths return a value
-#endif // Visual C++
-
-//----------------------------------------------------------------------
-// Main wxWindows entry point
-//----------------------------------------------------------------------
-int wxEntry(WXHINSTANCE hInstance,
- WXHINSTANCE WXUNUSED(hPrevInstance),
- char *lpCmdLine,
- int nCmdShow,
- bool enterLoop)
-{
- // do check for memory leaks on program exit
- // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
- // deallocated memory which may be used to simulate low-memory condition)
-#ifndef __WXMICROWIN__
- wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
-#endif
-
-#ifdef __MWERKS__
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // This seems to be necessary since there are 'rogue'
- // objects present at this point (perhaps global objects?)
- // Setting a checkpoint will ignore them as far as the
- // memory checking facility is concerned.
- // Of course you may argue that memory allocated in globals should be
- // checked, but this is a reasonable compromise.
- wxDebugContext::SetCheckpoint();
-#endif
-#endif
-
- // take everything into a try-except block to be able to call
- // OnFatalException() if necessary
-#if wxUSE_ON_FATAL_EXCEPTION
- __try {
-#endif
- wxhInstance = (HINSTANCE) hInstance;
-
- if (!wxEntryStart(0,0))
- return 0;
-
- // create the application object or ensure that one already exists
- if (!wxTheApp)
- {
- // The app may have declared a global application object, but we recommend
- // the IMPLEMENT_APP macro is used instead, which sets an initializer
- // function for delayed, dynamic app object construction.
- wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
- wxT("No initializer - use IMPLEMENT_APP macro.") );
-
- wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
-
- // save the WinMain() parameters
- if (lpCmdLine) // MicroWindows passes NULL
- wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
- wxTheApp->m_nCmdShow = nCmdShow;
-
- // We really don't want timestamps by default, because it means
- // we can't simply double-click on the error message and get to that
- // line in the source. So VC++ at least, let's have a sensible default.
-#ifdef __VISUALC__
- wxLog::SetTimestamp(NULL);
-#endif
-
- int retValue = 0;
-
- // 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 = wxEntryInitGui() && 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.
- return 1;
- }
- }
- //else: app initialization failed, so we skipped OnRun()
-
- wxWindow *topWindow = wxTheApp->GetTopWindow();
- if ( topWindow )
- {
- // Forcibly delete the window.
- if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
- topWindow->IsKindOf(CLASSINFO(wxDialog)) )
- {
- topWindow->Close(TRUE);
- wxTheApp->DeletePendingObjects();
- }
- else
- {
- delete topWindow;
- wxTheApp->SetTopWindow(NULL);
- }
- }
-
- wxTheApp->OnExit();
-
- wxEntryCleanup();
-
- return retValue;
-
-#if wxUSE_ON_FATAL_EXCEPTION
- }
- __except ( gs_handleExceptions ? EXCEPTION_EXECUTE_HANDLER
- : EXCEPTION_CONTINUE_SEARCH ) {
- if ( wxTheApp )
- {
- // give the user a chance to do something special about this
- wxTheApp->OnFatalException();
- }
-
- ::ExitProcess(3); // the same exit code as abort()
-
- // NOTREACHED
- }
-#endif // wxUSE_ON_FATAL_EXCEPTION
-}
-
-// restore warning state
-#ifdef __VISUALC__
- #pragma warning(default: 4715) // not all control paths return a value
-#endif // Visual C++
-
-#else /* _WINDLL */
-
-//----------------------------------------------------------------------
-// Entry point for wxWindows + the App in a DLL
-//----------------------------------------------------------------------
-
-int wxEntry(WXHINSTANCE hInstance)
-{
- wxhInstance = (HINSTANCE) hInstance;
- wxEntryStart(0, 0);
-
- // The app may have declared a global application object, but we recommend
- // the IMPLEMENT_APP macro is used instead, which sets an initializer function
- // for delayed, dynamic app object construction.
- if (!wxTheApp)
- {
- wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
- "No initializer - use IMPLEMENT_APP macro." );
-
- wxTheApp = (* wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, "You have to define an instance of wxApp!" );
-
- wxTheApp->argc = 0;
- wxTheApp->argv = NULL;
-
- wxEntryInitGui();
-
- wxTheApp->OnInit();
-
- wxWindow *topWindow = wxTheApp->GetTopWindow();
- if ( topWindow && topWindow->GetHWND())
- {
- topWindow->Show(TRUE);
- }
-
- return 1;
-}
-#endif // _WINDLL
-
-//// Static member initialization
-
-wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;