]> git.saurik.com Git - wxWidgets.git/blob - src/msw/main.cpp
fix DMars compilation to use precompiled headers
[wxWidgets.git] / src / msw / main.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #include "wx/event.h"
32 #include "wx/app.h"
33
34 #include "wx/msw/private.h"
35
36 // Don't implement WinMain if we're building an MFC/wxWindows
37 // hybrid app.
38 #if wxUSE_MFC && !defined(NOMAIN)
39 #define NOMAIN 1
40 #endif
41
42 // from src/msw/app.cpp
43 extern void WXDLLEXPORT wxEntryCleanup();
44
45 // ----------------------------------------------------------------------------
46 // globals
47 // ----------------------------------------------------------------------------
48
49 HINSTANCE wxhInstance = 0;
50
51 // ============================================================================
52 // implementation
53 // ============================================================================
54
55 // ----------------------------------------------------------------------------
56 // various entry points
57 // ----------------------------------------------------------------------------
58
59 // May wish not to have a DllMain or WinMain, e.g. if we're programming
60 // a Netscape plugin or if we're writing a console application
61 #if wxUSE_GUI && !defined(NOMAIN)
62
63 // NT defines APIENTRY, 3.x not
64 #if !defined(APIENTRY)
65 #define APIENTRY FAR PASCAL
66 #endif
67
68 /////////////////////////////////////////////////////////////////////////////////
69 // WinMain
70 // Note that WinMain is also defined in dummy.obj, which is linked to
71 // an application that is using the DLL version of wxWindows.
72
73 #if !defined(_WINDLL)
74
75 #if defined(__WXMICROWIN__)
76 #define HINSTANCE HANDLE
77
78 extern "C"
79 #endif
80
81 int PASCAL WinMain(HINSTANCE hInstance,
82 HINSTANCE hPrevInstance,
83 LPSTR lpCmdLine,
84 int nCmdShow)
85 {
86 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,
87 lpCmdLine, nCmdShow);
88 }
89
90 #endif // !defined(_WINDLL)
91
92 /////////////////////////////////////////////////////////////////////////////////
93 // DllMain
94
95 #if defined(_WINDLL)
96
97 // DLL entry point
98
99 extern "C"
100 #ifdef __BORLANDC__
101 // SCD: I don't know why, but also OWL uses this function
102 BOOL WINAPI DllEntryPoint (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
103 #else
104 BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
105 #endif
106 {
107 #ifndef WXMAKINGDLL
108 switch (fdwReason)
109 {
110 case DLL_PROCESS_ATTACH:
111 // Only call wxEntry if the application itself is part of the DLL.
112 // If only the wxWindows library is in the DLL, then the
113 // initialisation will be called when the application implicitly
114 // calls WinMain.
115 return wxEntry((WXHINSTANCE) hModule);
116
117 case DLL_PROCESS_DETACH:
118 if ( wxTheApp )
119 wxTheApp->OnExit();
120 wxEntryCleanup();
121 break;
122 }
123 #else
124 (void)hModule;
125 (void)fdwReason;
126 #endif // !WXMAKINGDLL
127 (void)lpReserved;
128 return TRUE;
129 }
130
131 #endif // _WINDLL
132
133 #endif // !NOMAIN
134
135 // ----------------------------------------------------------------------------
136 // global functions
137 // ----------------------------------------------------------------------------
138
139 HINSTANCE wxGetInstance()
140 {
141 return wxhInstance;
142 }
143
144 void wxSetInstance(HINSTANCE hInst)
145 {
146 wxhInstance = hInst;
147 }
148