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