]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/main.cpp
Moved the cleanup code to an EVT_WINDOW_DESTROY handler.
[wxWidgets.git] / src / msw / main.cpp
index 3f8833f408bdeeab61e244fd68147afed85cff20..f9a4ae5e657d41f7098004aef612d4f44b757485 100644 (file)
@@ -33,6 +33,9 @@
 
 #include "wx/msw/private.h"
 
+// from src/msw/app.cpp
+extern void WXDLLEXPORT wxEntryCleanup();
+
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
@@ -63,7 +66,7 @@ HINSTANCE wxhInstance = 0;
 
 #if !defined(_WINDLL)
 
-#if defined(__TWIN32__) || defined(__WXWINE__)
+#if defined(__TWIN32__) || defined(__WXWINE__) || defined(__WXMICROWIN__)
     #define HINSTANCE HANDLE
 
     extern "C"
@@ -95,22 +98,27 @@ BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
 #endif
 {
+#ifndef WXMAKINGDLL
     switch (fdwReason)
     {
         case DLL_PROCESS_ATTACH:
             // Only call wxEntry if the application itself is part of the DLL.
-            // If only the wxWindows library is in the DLL, then the initialisation
-            // will be called when the application implicitly calls WinMain.
-
-#if !defined(WXMAKINGDLL)
+            // If only the wxWindows library is in the DLL, then the
+            // initialisation will be called when the application implicitly
+            // calls WinMain.
             return wxEntry((WXHINSTANCE) hModule);
-#endif
-            break;
 
         case DLL_PROCESS_DETACH:
-        default:
-            break;
+           if ( wxTheApp )
+              wxTheApp->OnExit();
+           wxEntryCleanup();
+           break;
     }
+#else
+       (void)hModule;
+       (void)fdwReason;
+#endif // !WXMAKINGDLL
+       (void)lpReserved;
     return TRUE;
 }