]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/main.cpp
Modified vc.t according to last changes to makefile.vc, and regenerated
[wxWidgets.git] / src / msw / main.cpp
index cfa9a598c97e602a55a5864e8999ade95e54fbec..9c99ed611c3fab14d38f113b503b84c0c0dcc14c 100644 (file)
 
 #include "wx/msw/private.h"
 
+// Don't implement WinMain if we're building an MFC/wxWindows
+// hybrid app.
+#if wxUSE_MFC && !defined(NOMAIN)
+#define NOMAIN 1
+#endif
+
+// from src/msw/app.cpp
+extern void WXDLLEXPORT wxEntryCleanup();
+
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
@@ -63,27 +72,22 @@ HINSTANCE wxhInstance = 0;
 
 #if !defined(_WINDLL)
 
-#if defined(__TWIN32__) || defined(__WXWINE__)
-
-extern "C"
-BOOL PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
-
-#else
+#if defined(__TWIN32__) || defined(__WXMICROWIN__)
+    #define HINSTANCE HANDLE
 
-#ifdef __WATCOMC__
-int PASCAL
-#else
-int APIENTRY
+    extern "C"
 #endif
 
- WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
-#endif
-// __TWIN32__
-
+int PASCAL WinMain(HINSTANCE hInstance,
+                   HINSTANCE hPrevInstance,
+                   LPSTR lpCmdLine,
+                   int nCmdShow)
 {
-  return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, lpCmdLine, nCmdShow);
+    return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
+                   lpCmdLine, nCmdShow);
 }
-#endif
+
+#endif // !defined(_WINDLL)
 
 /////////////////////////////////////////////////////////////////////////////////
 // DllMain
@@ -100,22 +104,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;
 }