X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8f177c8e7309c8cf3ece1563870d135cc8f0e6a1..76985f52b2b8f88e5ee8632e10ca3bbed7dae2cf:/src/msw/main.cpp?ds=sidebyside diff --git a/src/msw/main.cpp b/src/msw/main.cpp index 3f8833f408..00736a1394 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -33,6 +33,15 @@ #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,7 +72,11 @@ HINSTANCE wxhInstance = 0; #if !defined(_WINDLL) -#if defined(__TWIN32__) || defined(__WXWINE__) +#if defined(__WXWINE__) + #define HINSTANCE HINSTANCE__* + + extern "C" +#elif defined(__TWIN32__) || defined(__WXMICROWIN__) #define HINSTANCE HANDLE extern "C" @@ -95,22 +108,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; }