added some wxMSW stuff
[wxWidgets.git] / src / msw / main.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: main.cpp
3 // Purpose: Main/DllMain
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #include "wx/app.h"
20 #include <windows.h>
21
22 // May wish not to have a DllMain or WinMain, e.g. if we're programming
23 // a Netscape plugin.
24 #ifndef NOMAIN
25
26 // NT defines APIENTRY, 3.x not
27 #if !defined(APIENTRY)
28 #define APIENTRY FAR PASCAL
29 #endif
30
31 /////////////////////////////////////////////////////////////////////////////////
32 // WinMain
33 // Note that WinMain is also defined in dummy.obj, which is linked to
34 // an application that is using the DLL version of wxWindows.
35
36 #if !defined(_WINDLL)
37
38 #ifdef __WATCOMC__
39 int PASCAL
40 #else
41 int APIENTRY
42 #endif
43
44 WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR m_lpCmdLine, int nCmdShow )
45 {
46 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance, m_lpCmdLine, nCmdShow);
47 }
48 #endif
49
50 /////////////////////////////////////////////////////////////////////////////////
51 // DllMain
52
53 #if defined(_WINDLL)
54
55 // DLL entry point
56
57 extern "C"
58 #ifdef __BORLANDC__
59 // SCD: I don't know why, but also OWL uses this function
60 BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
61 #else
62 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
63 #endif
64 {
65 switch (fdwReason)
66 {
67 case DLL_PROCESS_ATTACH:
68 // Only call wxEntry if the application itself is part of the DLL.
69 // If only the wxWindows library is in the DLL, then the initialisation
70 // will be called when the application implicitly calls WinMain.
71
72 #if !defined(WXMAKINGDLL)
73 return wxEntry((WXHINSTANCE) hModule);
74 #endif
75 break;
76
77 case DLL_PROCESS_DETACH:
78 default:
79 break;
80 }
81 return TRUE;
82 }
83
84 #endif
85
86 #endif
87