- if (wxSTD_FRAME_ICON)
- DestroyIcon(wxSTD_FRAME_ICON);
- if (wxSTD_MDICHILDFRAME_ICON)
- DestroyIcon(wxSTD_MDICHILDFRAME_ICON);
- if (wxSTD_MDIPARENTFRAME_ICON)
- DestroyIcon(wxSTD_MDIPARENTFRAME_ICON);
-
- if (wxDEFAULT_FRAME_ICON)
- DestroyIcon(wxDEFAULT_FRAME_ICON);
- if (wxDEFAULT_MDICHILDFRAME_ICON)
- DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON);
- if (wxDEFAULT_MDIPARENTFRAME_ICON)
- DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON);
-
- if ( wxDisableButtonBrush )
- ::DeleteObject( wxDisableButtonBrush ) ;
-
-#if !defined(__GNUWIN32__) && !defined(__SC__) && !defined(__SALFORDC__)
- ::OleUninitialize();
-#endif
-
-#if CTL3D
- Ctl3dUnregister(wxhInstance);
-#endif
-
- if (wxWinHandleList)
- delete wxWinHandleList ;
-
- wxClassInfo::CleanUpClasses();
-
- delete wxTheApp;
- wxTheApp = NULL;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- // At this point we want to check if there are any memory
- // blocks that aren't part of the wxDebugContext itself,
- // as a special case. Then when dumping we need to ignore
- // wxDebugContext, too.
- if (wxDebugContext::CountObjectsLeft() > 0)
- {
- wxLogDebug("There were memory leaks.");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-// wxDebugContext::SetStream(NULL, NULL);
-#endif
-
- // do it as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
- delete wxLog::SetActiveTarget(NULL);
-}
-
-#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
-
-// temporarily disable this warning
-#ifdef _MSC_VER
- #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)
- wxCrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);
-
- // take everything into a try-except block in release build
- // FIXME other compilers must support Win32 SEH (structured exception
- // handling) too, just find the appropriate keyword in their docs!
- // Please note that it's _not_ the same as C++ exceptions!
-#if !defined(__WXDEBUG__) && defined(_MSC_VER) && !defined(__MWERKS__)
- #define CATCH_PROGRAM_EXCEPTIONS
-
- __try {
-#else
- #undef CATCH_PROGRAM_EXCEPTIONS
-#endif
-
- wxhInstance = (HINSTANCE) hInstance;
-
- if (!wxApp::Initialize())
- 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,
- "No initializer - use IMPLEMENT_APP macro." );
-
- wxTheApp = (*wxApp::GetInitializerFunction()) ();
- }
-
- wxCHECK_MSG( wxTheApp, 0, "You have to define an instance of wxApp!" );
-
- // save the WinMain() parameters
- wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
- wxTheApp->m_nCmdShow = nCmdShow;
-
- // GUI-specific initialisation. In fact on Windows we don't have any,
- // but this call is provided for compatibility across platforms.
- wxTheApp->OnInitGui() ;
-
- int retValue = 0;
-
- if ( wxTheApp->OnInit() )
- {
- if ( enterLoop )
- {
- retValue = wxTheApp->OnRun();
- }
- }
- //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();
-
- // flush the logged messages if any
- wxLog *pLog = wxLog::GetActiveTarget();
- if ( pLog != NULL && pLog->HasPendingMessages() )
- pLog->Flush();
-
-
- wxApp::CleanUp();
-
- return retValue;
-
-#ifdef CATCH_PROGRAM_EXCEPTIONS
- }
- __except ( EXCEPTION_EXECUTE_HANDLER ) {
- /*
- if ( wxTheApp )
- wxTheApp->OnFatalException();
- */
-
- ::ExitProcess(3); // the same exit code as abort()
-
- // NOTREACHED
- }
-#endif // CATCH_PROGRAM_EXCEPTIONS
-}
-
-// restore warning state
-#ifdef _MSC_VER
- #pragma warning(default: 4715) // not all control paths return a value
-#endif // Visual C++
-
-#else /* _WINDLL */
-
-//// Entry point for DLLs
-
-int wxEntry(WXHINSTANCE hInstance)
-{
- wxhInstance = (HINSTANCE) hInstance;
- wxApp::Initialize();
-
- // 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)
- {
- if (!wxApp::GetInitializerFunction())