]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: app.cpp | |
3 | // Purpose: wxApp | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
a5e0e655 | 9 | // Licence: wxWindows license |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
a3b46648 | 13 | #pragma implementation "app.h" |
2bda0e17 KB |
14 | #endif |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
2bda0e17 KB |
17 | #include "wx/wxprec.h" |
18 | ||
19 | #if defined(__BORLANDC__) | |
a3b46648 | 20 | #pragma hdrstop |
2bda0e17 KB |
21 | #endif |
22 | ||
23 | #ifndef WX_PRECOMP | |
a5e0e655 VZ |
24 | #include "wx/frame.h" |
25 | #include "wx/app.h" | |
26 | #include "wx/utils.h" | |
27 | #include "wx/gdicmn.h" | |
28 | #include "wx/pen.h" | |
29 | #include "wx/brush.h" | |
30 | #include "wx/cursor.h" | |
31 | #include "wx/icon.h" | |
32 | #include "wx/palette.h" | |
33 | #include "wx/dc.h" | |
34 | #include "wx/dialog.h" | |
35 | #include "wx/msgdlg.h" | |
2bda0e17 KB |
36 | #endif |
37 | ||
38 | #include "wx/msw/private.h" | |
2bda0e17 KB |
39 | #include "wx/log.h" |
40 | #include "wx/module.h" | |
41 | ||
47d67540 | 42 | #if wxUSE_WX_RESOURCES |
a5e0e655 | 43 | #include "wx/resource.h" |
2bda0e17 KB |
44 | #endif |
45 | ||
2bda0e17 | 46 | #include <string.h> |
a5e0e655 | 47 | #include <ctype.h> |
2bda0e17 KB |
48 | |
49 | #if defined(__WIN95__) && !defined(__GNUWIN32__) | |
a5e0e655 | 50 | #include <commctrl.h> |
2bda0e17 KB |
51 | #endif |
52 | ||
fd3f686c VZ |
53 | // use debug CRT functions for memory leak detections in VC++ if we're not |
54 | // using wxWindows own methods | |
8a111b29 | 55 | #if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__) |
fd3f686c VZ |
56 | #define wxUSE_VC_CRTDBG |
57 | #else | |
58 | #undef wxUSE_VC_CRTDBG | |
59 | #endif | |
60 | ||
61 | #ifdef wxUSE_VC_CRTDBG | |
a5e0e655 VZ |
62 | // VC++ uses this macro as debug/release mode indicator |
63 | #ifndef _DEBUG | |
64 | #define _DEBUG | |
65 | #endif | |
66 | ||
c030b70f JS |
67 | /* Need to undef new if including crtdbg.h */ |
68 | #ifdef new | |
69 | #undef new | |
70 | #endif | |
71 | ||
370382c7 | 72 | #include <crtdbg.h> |
c030b70f JS |
73 | |
74 | #if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS | |
75 | #define new new(__FILE__,__LINE__) | |
76 | #endif | |
77 | ||
370382c7 VZ |
78 | #endif |
79 | ||
2bda0e17 KB |
80 | extern char *wxBuffer; |
81 | extern char *wxOsVersion; | |
82 | extern wxList *wxWinHandleList; | |
83 | extern wxList wxPendingDelete; | |
84 | extern void wxSetKeyboardHook(bool doIt); | |
85 | extern wxCursor *g_globalCursor; | |
86 | ||
c4e7c2aa | 87 | HINSTANCE wxhInstance = 0; |
2bda0e17 KB |
88 | static MSG s_currentMsg; |
89 | wxApp *wxTheApp = NULL; | |
90 | ||
a5e0e655 | 91 | // @@ why not const? and not static? |
2bda0e17 KB |
92 | char wxFrameClassName[] = "wxFrameClass"; |
93 | char wxMDIFrameClassName[] = "wxMDIFrameClass"; | |
94 | char wxMDIChildFrameClassName[] = "wxMDIChildFrameClass"; | |
95 | char wxPanelClassName[] = "wxPanelClass"; | |
96 | char wxCanvasClassName[] = "wxCanvasClass"; | |
97 | ||
98 | HICON wxSTD_FRAME_ICON = NULL; | |
99 | HICON wxSTD_MDICHILDFRAME_ICON = NULL; | |
100 | HICON wxSTD_MDIPARENTFRAME_ICON = NULL; | |
101 | ||
102 | HICON wxDEFAULT_FRAME_ICON = NULL; | |
103 | HICON wxDEFAULT_MDICHILDFRAME_ICON = NULL; | |
104 | HICON wxDEFAULT_MDIPARENTFRAME_ICON = NULL; | |
105 | ||
106 | HBRUSH wxDisableButtonBrush = 0; | |
107 | ||
108 | LRESULT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM); | |
109 | ||
110 | #if !USE_SHARED_LIBRARY | |
a5e0e655 VZ |
111 | IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) |
112 | ||
113 | BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) | |
114 | EVT_IDLE(wxApp::OnIdle) | |
387a3b02 JS |
115 | EVT_END_SESSION(wxApp::OnEndSession) |
116 | EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) | |
a5e0e655 | 117 | END_EVENT_TABLE() |
2bda0e17 KB |
118 | #endif |
119 | ||
120 | long wxApp::sm_lastMessageTime = 0; | |
121 | ||
122 | #ifdef __WIN95__ | |
a5e0e655 | 123 | static HINSTANCE gs_hRichEdit = NULL; |
2bda0e17 KB |
124 | #endif |
125 | ||
589f0e3e JS |
126 | //// Initialize |
127 | ||
128 | bool wxApp::Initialize() | |
2bda0e17 | 129 | { |
c030b70f JS |
130 | // Some people may wish to use this, but |
131 | // probably it shouldn't be here by default. | |
132 | #ifdef __WXDEBUG__ | |
133 | // wxRedirectIOToConsole(); | |
134 | #endif | |
135 | ||
aa0b7e1e | 136 | wxBuffer = new char[1500]; |
589f0e3e | 137 | |
aa0b7e1e | 138 | #ifdef wxUSE_VC_CRTDBG |
589f0e3e JS |
139 | // do check for memory leaks on program exit |
140 | // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free | |
141 | // deallocated memory which may be used to simulate low-memory condition) | |
142 | _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); | |
aa0b7e1e | 143 | #endif // debug build under MS VC++ |
589f0e3e | 144 | |
aa0b7e1e | 145 | wxClassInfo::InitializeClasses(); |
589f0e3e | 146 | |
aa0b7e1e | 147 | #if wxUSE_RESOURCES |
a5e0e655 | 148 | wxGetResource("wxWindows", "OsVersion", &wxOsVersion); |
aa0b7e1e | 149 | #endif |
589f0e3e | 150 | |
aa0b7e1e JS |
151 | wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); |
152 | wxTheColourDatabase->Initialize(); | |
589f0e3e | 153 | |
aa0b7e1e JS |
154 | wxInitializeStockLists(); |
155 | wxInitializeStockObjects(); | |
589f0e3e | 156 | |
aa0b7e1e | 157 | #if wxUSE_WX_RESOURCES |
a5e0e655 | 158 | wxInitializeResourceSystem(); |
aa0b7e1e | 159 | #endif |
2bda0e17 | 160 | |
aa0b7e1e | 161 | wxBitmap::InitStandardHandlers(); |
2bda0e17 | 162 | |
aa0b7e1e | 163 | #if defined(__WIN95__) |
a5e0e655 VZ |
164 | InitCommonControls(); |
165 | gs_hRichEdit = LoadLibrary("RICHED32.DLL"); | |
2bda0e17 | 166 | |
a5e0e655 VZ |
167 | if (gs_hRichEdit == NULL) |
168 | { | |
169 | wxMessageBox("Could not initialise Rich Edit DLL"); | |
170 | } | |
aa0b7e1e | 171 | #endif |
2bda0e17 | 172 | |
aa0b7e1e JS |
173 | int iMsg = 96; |
174 | ||
175 | // for OLE, enlarge message queue to be as large as possible | |
176 | while (!SetMessageQueue(iMsg) && (iMsg -= 8)); | |
177 | ||
178 | /* | |
179 | DWORD dwOleVer; | |
180 | dwOleVer = CoBuildVersion(); | |
181 | ||
182 | // check the OLE library version | |
183 | if (rmm != HIWORD(dwOleVer)) | |
184 | { | |
185 | wxMessageBox("Incorrect version of OLE libraries."); | |
186 | return FALSE; | |
187 | } | |
188 | */ | |
5de5db0e JS |
189 | |
190 | #ifndef __GNUWIN32__ | |
a5e0e655 VZ |
191 | // we need to initialize OLE library |
192 | if ( FAILED(::OleInitialize(NULL)) ) | |
193 | wxFatalError(_("Cannot initialize OLE")); | |
5de5db0e | 194 | #endif |
2bda0e17 | 195 | |
aa0b7e1e | 196 | #if CTL3D |
a5e0e655 VZ |
197 | if (!Ctl3dRegister(wxhInstance)) |
198 | wxFatalError("Cannot register CTL3D"); | |
2bda0e17 | 199 | |
a5e0e655 | 200 | Ctl3dAutoSubclass(wxhInstance); |
aa0b7e1e | 201 | #endif |
2bda0e17 | 202 | |
aa0b7e1e | 203 | g_globalCursor = new wxCursor; |
589f0e3e | 204 | |
aa0b7e1e JS |
205 | wxSTD_FRAME_ICON = LoadIcon(wxhInstance, "wxSTD_FRAME"); |
206 | wxSTD_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, "wxSTD_MDIPARENTFRAME"); | |
207 | wxSTD_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, "wxSTD_MDICHILDFRAME"); | |
2bda0e17 | 208 | |
aa0b7e1e JS |
209 | wxDEFAULT_FRAME_ICON = LoadIcon(wxhInstance, "wxDEFAULT_FRAME"); |
210 | wxDEFAULT_MDIPARENTFRAME_ICON = LoadIcon(wxhInstance, "wxDEFAULT_MDIPARENTFRAME"); | |
211 | wxDEFAULT_MDICHILDFRAME_ICON = LoadIcon(wxhInstance, "wxDEFAULT_MDICHILDFRAME"); | |
2bda0e17 | 212 | |
aa0b7e1e | 213 | RegisterWindowClasses(); |
2bda0e17 | 214 | |
aa0b7e1e | 215 | // Create the brush for disabling bitmap buttons |
2bda0e17 | 216 | |
aa0b7e1e JS |
217 | LOGBRUSH lb ; |
218 | lb.lbStyle = BS_PATTERN; | |
219 | lb.lbHatch = (int)LoadBitmap( wxhInstance, "wxDISABLE_BUTTON_BITMAP" ) ; | |
220 | wxDisableButtonBrush = ::CreateBrushIndirect( & lb ) ; | |
221 | ::DeleteObject( (HGDIOBJ)lb.lbHatch ) ; | |
2bda0e17 | 222 | |
aa0b7e1e | 223 | #if wxUSE_PENWINDOWS |
a5e0e655 | 224 | wxRegisterPenWin(); |
aa0b7e1e | 225 | #endif |
2bda0e17 | 226 | |
aa0b7e1e | 227 | wxWinHandleList = new wxList(wxKEY_INTEGER); |
2bda0e17 | 228 | |
aa0b7e1e JS |
229 | // This is to foil optimizations in Visual C++ that |
230 | // throw out dummy.obj. | |
231 | #if (_MSC_VER >= 800) && !defined(WXMAKINGDLL) | |
a5e0e655 VZ |
232 | extern char wxDummyChar; |
233 | if (wxDummyChar) wxDummyChar++; | |
aa0b7e1e | 234 | #endif |
a5e0e655 | 235 | |
aa0b7e1e | 236 | wxSetKeyboardHook(TRUE); |
2bda0e17 | 237 | |
aa0b7e1e JS |
238 | wxModule::RegisterModules(); |
239 | if (!wxModule::InitializeModules()) | |
240 | return FALSE; | |
241 | return TRUE; | |
2bda0e17 KB |
242 | } |
243 | ||
589f0e3e JS |
244 | //// RegisterWindowClasses |
245 | ||
bb6290e3 | 246 | bool wxApp::RegisterWindowClasses() |
2bda0e17 KB |
247 | { |
248 | /////////////////////////////////////////////////////////////////////// | |
249 | // Register the frame window class. | |
250 | WNDCLASS wndclass; // Structure used to register Windows class. | |
251 | ||
252 | wndclass.style = CS_HREDRAW | CS_VREDRAW; | |
253 | wndclass.lpfnWndProc = (WNDPROC)wxWndProc; | |
254 | wndclass.cbClsExtra = 0; | |
255 | wndclass.cbWndExtra = sizeof( DWORD ); // was 4 | |
256 | wndclass.hInstance = wxhInstance; | |
257 | wndclass.hIcon = NULL; // wxSTD_FRAME_ICON; | |
258 | wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); | |
259 | wndclass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1) ; | |
260 | // wndclass.hbrBackground = GetStockObject( WHITE_BRUSH ); | |
261 | wndclass.lpszMenuName = NULL; | |
262 | #ifdef _MULTIPLE_INSTANCES | |
589f0e3e | 263 | sprintf( wxFrameClassName,"wxFrameClass%d", wxhInstance ); |
2bda0e17 KB |
264 | #endif |
265 | wndclass.lpszClassName = wxFrameClassName; | |
266 | ||
267 | if (!RegisterClass( &wndclass )) | |
268 | { | |
269 | // wxFatalError("Can't register Frame Window class"); | |
270 | } | |
271 | ||
272 | /////////////////////////////////////////////////////////////////////// | |
273 | // Register the MDI frame window class. | |
274 | WNDCLASS wndclass1; // Structure used to register Windows class. | |
275 | ||
276 | wndclass1.style = CS_HREDRAW | CS_VREDRAW; | |
277 | wndclass1.lpfnWndProc = (WNDPROC)wxWndProc; | |
278 | wndclass1.cbClsExtra = 0; | |
279 | wndclass1.cbWndExtra = sizeof( DWORD ); // was 4 | |
280 | wndclass1.hInstance = wxhInstance; | |
281 | wndclass1.hIcon = NULL; // wxSTD_MDIPARENTFRAME_ICON; | |
282 | wndclass1.hCursor = LoadCursor( NULL, IDC_ARROW ); | |
283 | // wndclass1.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1) ; | |
284 | wndclass1.hbrBackground = NULL; | |
285 | wndclass1.lpszMenuName = NULL; | |
286 | ||
287 | wndclass1.lpszClassName = wxMDIFrameClassName; | |
288 | if (!RegisterClass( &wndclass1 )) | |
289 | { | |
290 | // wxFatalError("Can't register MDI Frame window class"); | |
a5e0e655 | 291 | // return FALSE; |
2bda0e17 KB |
292 | } |
293 | ||
294 | /////////////////////////////////////////////////////////////////////// | |
295 | // Register the MDI child frame window class. | |
296 | WNDCLASS wndclass4; // Structure used to register Windows class. | |
297 | ||
298 | wndclass4.style = CS_HREDRAW | CS_VREDRAW; | |
299 | wndclass4.lpfnWndProc = (WNDPROC)wxWndProc; | |
300 | wndclass4.cbClsExtra = 0; | |
301 | wndclass4.cbWndExtra = sizeof( DWORD ); // was 4 | |
302 | wndclass4.hInstance = wxhInstance; | |
303 | wndclass4.hIcon = NULL; // wxSTD_MDICHILDFRAME_ICON; | |
304 | wndclass4.hCursor = LoadCursor( NULL, IDC_ARROW ); | |
305 | // TODO: perhaps this should be NULL so that Windows doesn't | |
306 | // paint the background itself (would OnEraseBackground duplicate | |
307 | // this?) | |
308 | wndclass4.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ; | |
309 | // wndclass4.hbrBackground = NULL; | |
310 | wndclass4.lpszMenuName = NULL; | |
311 | wndclass4.lpszClassName = wxMDIChildFrameClassName; | |
312 | ||
313 | if (!RegisterClass( &wndclass4 )) | |
314 | { | |
315 | // wxFatalError("Can't register MDI child frame window class"); | |
316 | // return FALSE; | |
317 | } | |
318 | ||
319 | /////////////////////////////////////////////////////////////////////// | |
320 | // Register the panel window class. | |
321 | WNDCLASS wndclass2; // Structure used to register Windows class. | |
322 | memset(&wndclass2, 0, sizeof(WNDCLASS)); // start with NULL defaults | |
323 | // Use CS_OWNDC to avoid messing about restoring the context | |
324 | // for every graphic operation. | |
325 | wndclass2.style = CS_HREDRAW | CS_VREDRAW; | |
326 | wndclass2.lpfnWndProc = (WNDPROC)wxWndProc; | |
327 | wndclass2.cbClsExtra = 0; | |
328 | wndclass2.cbWndExtra = sizeof( DWORD ); // was 4 | |
329 | wndclass2.hInstance = wxhInstance; | |
330 | wndclass2.hIcon = NULL; | |
331 | wndclass2.hCursor = NULL; | |
332 | // wndclass2.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1) ; | |
c4e7c2aa | 333 | wndclass2.hbrBackground = (HBRUSH) GetStockObject( LTGRAY_BRUSH ); |
2bda0e17 KB |
334 | wndclass2.lpszMenuName = NULL; |
335 | wndclass2.lpszClassName = wxPanelClassName; | |
336 | if (!RegisterClass( &wndclass2 )) | |
337 | { | |
338 | // wxFatalError("Can't register Panel Window class"); | |
339 | // return FALSE; | |
340 | } | |
341 | ||
342 | /////////////////////////////////////////////////////////////////////// | |
343 | // Register the canvas and textsubwindow class name | |
344 | WNDCLASS wndclass3; // Structure used to register Windows class. | |
345 | memset(&wndclass3, 0, sizeof(WNDCLASS)); // start with NULL defaults | |
346 | // Use CS_OWNDC to avoid messing about restoring the context | |
347 | // for every graphic operation. | |
d50b2a58 | 348 | // wndclass3.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS ; |
2bda0e17 | 349 | // wxWin 2.0 |
d50b2a58 | 350 | wndclass3.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ; |
2bda0e17 KB |
351 | wndclass3.lpfnWndProc = (WNDPROC)wxWndProc; |
352 | wndclass3.cbClsExtra = 0; | |
353 | wndclass3.cbWndExtra = sizeof( DWORD ); // was 4 | |
354 | wndclass3.hInstance = wxhInstance; | |
355 | wndclass3.hIcon = NULL; | |
356 | wndclass3.hCursor = NULL; | |
357 | // wndclass3.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ; | |
358 | wndclass3.hbrBackground = NULL; | |
359 | wndclass3.lpszMenuName = NULL; | |
360 | wndclass3.lpszClassName = wxCanvasClassName; | |
361 | if (!RegisterClass( &wndclass3)) | |
362 | { | |
363 | // wxFatalError("Can't register Canvas class"); | |
364 | // return FALSE; | |
365 | } | |
366 | ||
367 | return TRUE; | |
368 | } | |
369 | ||
589f0e3e JS |
370 | //// Convert Windows to argc, argv style |
371 | ||
372 | void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine) | |
373 | { | |
da36f544 | 374 | wxStringList args; |
589f0e3e | 375 | |
da36f544 JS |
376 | wxString cmdLine(lpCmdLine); |
377 | int count = 0; | |
589f0e3e | 378 | |
da36f544 | 379 | // Get application name |
c085e333 | 380 | char name[260]; // 260 is MAX_PATH value from windef.h |
da36f544 JS |
381 | ::GetModuleFileName(wxhInstance, name, WXSIZEOF(name)); |
382 | ||
383 | // GNUWIN32 already fills in the first arg with the application name. | |
589f0e3e | 384 | #if !defined(__GNUWIN32__) |
da36f544 JS |
385 | args.Add(name); |
386 | count ++; | |
589f0e3e JS |
387 | #endif |
388 | ||
da36f544 JS |
389 | strcpy(name, wxFileNameFromPath(name)); |
390 | wxStripExtension(name); | |
391 | wxTheApp->SetAppName(name); | |
589f0e3e | 392 | |
da36f544 JS |
393 | // Break up string |
394 | // Treat strings enclosed in double-quotes as single arguments | |
395 | int i = 0; | |
396 | int len = cmdLine.Length(); | |
397 | while (i < len) | |
a5e0e655 | 398 | { |
da36f544 JS |
399 | // Skip whitespace |
400 | while ((i < len) && isspace(cmdLine.GetChar(i))) | |
401 | i ++; | |
402 | ||
403 | if (i < len) | |
404 | { | |
405 | if (cmdLine.GetChar(i) == '"') // We found the start of a string | |
406 | { | |
407 | i ++; | |
408 | int first = i; | |
409 | while ((i < len) && (cmdLine.GetChar(i) != '"')) | |
410 | i ++; | |
411 | ||
412 | wxString arg(cmdLine.Mid(first, (i - first))); | |
413 | ||
414 | args.Add(arg); | |
415 | count ++; | |
416 | ||
417 | if (i < len) | |
418 | i ++; // Skip past 2nd quote | |
419 | } | |
420 | else // Unquoted argument | |
421 | { | |
422 | int first = i; | |
423 | while ((i < len) && !isspace(cmdLine.GetChar(i))) | |
424 | i ++; | |
425 | ||
426 | wxString arg(cmdLine.Mid(first, (i - first))); | |
427 | ||
428 | args.Add(arg); | |
429 | count ++; | |
430 | } | |
431 | } | |
a5e0e655 | 432 | } |
a5e0e655 | 433 | |
da36f544 JS |
434 | wxTheApp->argv = new char*[count + 1]; |
435 | for (i = 0; i < count; i++) | |
a5e0e655 | 436 | { |
da36f544 JS |
437 | wxString arg(args[i]); |
438 | wxTheApp->argv[i] = copystring((const char*)arg); | |
a5e0e655 | 439 | } |
da36f544 JS |
440 | wxTheApp->argv[count] = NULL; // argv[] is a NULL-terminated list |
441 | wxTheApp->argc = count; | |
589f0e3e JS |
442 | } |
443 | ||
444 | //// Cleans up any wxWindows internal structures left lying around | |
445 | ||
bb6290e3 | 446 | void wxApp::CleanUp() |
2bda0e17 | 447 | { |
589f0e3e | 448 | //// COMMON CLEANUP |
2bda0e17 KB |
449 | wxModule::CleanUpModules(); |
450 | ||
47d67540 | 451 | #if wxUSE_WX_RESOURCES |
589f0e3e JS |
452 | wxCleanUpResourceSystem(); |
453 | ||
454 | // wxDefaultResourceTable->ClearTable(); | |
455 | #endif | |
456 | ||
457 | // Indicate that the cursor can be freed, | |
458 | // so that cursor won't be deleted by deleting | |
459 | // the bitmap list before g_globalCursor goes out | |
460 | // of scope (double deletion of the cursor). | |
461 | wxSetCursor(wxNullCursor); | |
462 | delete g_globalCursor; | |
463 | ||
464 | wxDeleteStockObjects() ; | |
465 | ||
466 | // Destroy all GDI lists, etc. | |
467 | wxDeleteStockLists(); | |
468 | ||
469 | delete wxTheColourDatabase; | |
470 | wxTheColourDatabase = NULL; | |
471 | ||
589f0e3e JS |
472 | wxBitmap::CleanUpHandlers(); |
473 | ||
474 | delete[] wxBuffer; | |
475 | wxBuffer = NULL; | |
476 | ||
477 | //// WINDOWS-SPECIFIC CLEANUP | |
2bda0e17 KB |
478 | |
479 | wxSetKeyboardHook(FALSE); | |
480 | ||
481 | #ifdef __WIN95__ | |
482 | if (gs_hRichEdit != NULL) | |
483 | FreeLibrary(gs_hRichEdit); | |
484 | #endif | |
485 | ||
47d67540 | 486 | #if wxUSE_PENWINDOWS |
2bda0e17 KB |
487 | wxCleanUpPenWin(); |
488 | #endif | |
489 | ||
490 | if (wxSTD_FRAME_ICON) | |
491 | DestroyIcon(wxSTD_FRAME_ICON); | |
492 | if (wxSTD_MDICHILDFRAME_ICON) | |
493 | DestroyIcon(wxSTD_MDICHILDFRAME_ICON); | |
494 | if (wxSTD_MDIPARENTFRAME_ICON) | |
495 | DestroyIcon(wxSTD_MDIPARENTFRAME_ICON); | |
496 | ||
497 | if (wxDEFAULT_FRAME_ICON) | |
498 | DestroyIcon(wxDEFAULT_FRAME_ICON); | |
499 | if (wxDEFAULT_MDICHILDFRAME_ICON) | |
500 | DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON); | |
501 | if (wxDEFAULT_MDIPARENTFRAME_ICON) | |
502 | DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON); | |
503 | ||
504 | if ( wxDisableButtonBrush ) | |
505 | ::DeleteObject( wxDisableButtonBrush ) ; | |
506 | ||
5de5db0e | 507 | #ifndef __GNUWIN32__ |
2bda0e17 | 508 | ::OleUninitialize(); |
5de5db0e | 509 | #endif |
2bda0e17 KB |
510 | |
511 | #if CTL3D | |
512 | Ctl3dUnregister(wxhInstance); | |
513 | #endif | |
514 | ||
515 | if (wxWinHandleList) | |
516 | delete wxWinHandleList ; | |
d50b2a58 | 517 | |
0c32066b JS |
518 | wxClassInfo::CleanUpClasses(); |
519 | ||
184b5d99 JS |
520 | delete wxTheApp; |
521 | wxTheApp = NULL; | |
522 | ||
523 | #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT | |
524 | // At this point we want to check if there are any memory | |
525 | // blocks that aren't part of the wxDebugContext itself, | |
526 | // as a special case. Then when dumping we need to ignore | |
527 | // wxDebugContext, too. | |
528 | if (wxDebugContext::CountObjectsLeft() > 0) | |
529 | { | |
530 | wxLogDebug("There were memory leaks."); | |
531 | wxDebugContext::Dump(); | |
532 | wxDebugContext::PrintStatistics(); | |
533 | } | |
534 | // wxDebugContext::SetStream(NULL, NULL); | |
535 | #endif | |
536 | ||
c54f78a2 | 537 | // do it as the very last thing because everything else can log messages |
370382c7 | 538 | wxLog::DontCreateOnDemand(); |
c54f78a2 | 539 | delete wxLog::SetActiveTarget(NULL); |
2bda0e17 KB |
540 | } |
541 | ||
2bda0e17 KB |
542 | #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) |
543 | ||
589f0e3e | 544 | //// Main wxWindows entry point |
a5e0e655 VZ |
545 | int wxEntry(WXHINSTANCE hInstance, |
546 | WXHINSTANCE WXUNUSED(hPrevInstance), | |
547 | char *lpCmdLine, | |
548 | int nCmdShow, | |
549 | bool enterLoop) | |
2bda0e17 | 550 | { |
a5e0e655 | 551 | #ifndef __WXDEBUG__ // take everything into a try-except block in release build |
dfad0599 | 552 | try { |
a5e0e655 VZ |
553 | #endif |
554 | ||
2bda0e17 KB |
555 | wxhInstance = (HINSTANCE) hInstance; |
556 | ||
589f0e3e | 557 | if (!wxApp::Initialize()) |
2bda0e17 KB |
558 | return 0; |
559 | ||
a5e0e655 | 560 | // create the application object or ensure that one already exists |
2bda0e17 KB |
561 | if (!wxTheApp) |
562 | { | |
a5e0e655 VZ |
563 | // The app may have declared a global application object, but we recommend |
564 | // the IMPLEMENT_APP macro is used instead, which sets an initializer | |
565 | // function for delayed, dynamic app object construction. | |
566 | wxCHECK_MSG( wxApp::GetInitializerFunction(), 0, | |
567 | "No initializer - use IMPLEMENT_APP macro." ); | |
2bda0e17 | 568 | |
a5e0e655 | 569 | wxTheApp = (*wxApp::GetInitializerFunction()) (); |
2bda0e17 KB |
570 | } |
571 | ||
a5e0e655 | 572 | wxCHECK_MSG( wxTheApp, 0, "You have to define an instance of wxApp!" ); |
2bda0e17 | 573 | |
a5e0e655 | 574 | // save the WinMain() parameters |
589f0e3e | 575 | wxTheApp->ConvertToStandardCommandArgs(lpCmdLine); |
2bda0e17 KB |
576 | wxTheApp->m_nCmdShow = nCmdShow; |
577 | ||
578 | // GUI-specific initialisation. In fact on Windows we don't have any, | |
579 | // but this call is provided for compatibility across platforms. | |
580 | wxTheApp->OnInitGui() ; | |
581 | ||
a5e0e655 | 582 | int retValue = 0; |
2bda0e17 | 583 | |
a5e0e655 VZ |
584 | if ( wxTheApp->OnInit() ) |
585 | { | |
586 | if ( enterLoop ) | |
587 | { | |
588 | retValue = wxTheApp->OnRun(); | |
589 | } | |
2bda0e17 | 590 | } |
a5e0e655 | 591 | //else: app initialization failed, so we skipped OnRun() |
2bda0e17 | 592 | |
a5e0e655 VZ |
593 | wxWindow *topWindow = wxTheApp->GetTopWindow(); |
594 | if ( topWindow ) | |
2bda0e17 | 595 | { |
a5e0e655 VZ |
596 | // Forcibly delete the window. |
597 | if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) || | |
598 | topWindow->IsKindOf(CLASSINFO(wxDialog)) ) | |
599 | { | |
600 | topWindow->Close(TRUE); | |
601 | wxTheApp->DeletePendingObjects(); | |
602 | } | |
603 | else | |
604 | { | |
605 | delete topWindow; | |
606 | wxTheApp->SetTopWindow(NULL); | |
607 | } | |
2bda0e17 | 608 | } |
d50b2a58 | 609 | |
2bda0e17 | 610 | wxTheApp->OnExit(); |
f57fe24c JS |
611 | |
612 | // flush the logged messages if any | |
613 | wxLog *pLog = wxLog::GetActiveTarget(); | |
614 | if ( pLog != NULL && pLog->HasPendingMessages() ) | |
615 | pLog->Flush(); | |
616 | ||
617 | ||
2bda0e17 KB |
618 | wxApp::CleanUp(); |
619 | ||
2bda0e17 | 620 | return retValue; |
a5e0e655 VZ |
621 | #ifndef __WXDEBUG__ // catch exceptions only in release build |
622 | } | |
dfad0599 | 623 | except ( EXCEPTION_EXECUTE_HANDLER ) { |
a5e0e655 VZ |
624 | /* |
625 | if ( wxTheApp ) | |
626 | wxTheApp->OnFatalException(); | |
627 | */ | |
628 | ||
629 | ::ExitProcess(3); // the same exit code as abort() | |
630 | } | |
631 | #endif //debug | |
2bda0e17 KB |
632 | } |
633 | ||
634 | #else /* _WINDLL */ | |
635 | ||
589f0e3e JS |
636 | //// Entry point for DLLs |
637 | ||
2bda0e17 KB |
638 | int wxEntry(WXHINSTANCE hInstance) |
639 | { | |
640 | wxhInstance = (HINSTANCE) hInstance; | |
589f0e3e | 641 | wxApp::Initialize(); |
2bda0e17 KB |
642 | |
643 | // The app may have declared a global application object, but we recommend | |
644 | // the IMPLEMENT_APP macro is used instead, which sets an initializer function | |
645 | // for delayed, dynamic app object construction. | |
646 | ||
647 | if (!wxTheApp) | |
648 | { | |
a5e0e655 VZ |
649 | if (!wxApp::GetInitializerFunction()) |
650 | { | |
651 | MessageBox(NULL, "No initializer - use IMPLEMENT_APP macro.", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK); | |
652 | return 0; | |
653 | } | |
2bda0e17 | 654 | |
a5e0e655 | 655 | wxTheApp = (* wxApp::GetInitializerFunction()) (); |
2bda0e17 KB |
656 | } |
657 | ||
658 | if (!wxTheApp) { | |
659 | MessageBox(NULL, "You have to define an instance of wxApp!", "wxWindows Error", MB_APPLMODAL | MB_ICONSTOP | MB_OK); | |
660 | return 0; | |
661 | } | |
662 | ||
663 | wxTheApp->argc = 0; | |
664 | wxTheApp->argv = NULL; | |
665 | ||
666 | wxTheApp->OnInitGui(); | |
667 | ||
668 | wxTheApp->OnInit(); | |
669 | ||
670 | if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->GetHWND()) { | |
671 | wxTheApp->GetTopWindow()->Show(TRUE); | |
672 | } | |
673 | ||
674 | return 1; | |
675 | } | |
676 | #endif // _WINDLL | |
677 | ||
589f0e3e JS |
678 | //// Static member initialization |
679 | ||
2bda0e17 KB |
680 | wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL; |
681 | ||
bb6290e3 | 682 | wxApp::wxApp() |
2bda0e17 KB |
683 | { |
684 | m_topWindow = NULL; | |
685 | wxTheApp = this; | |
2bda0e17 | 686 | m_className = ""; |
2bda0e17 KB |
687 | m_wantDebugOutput = TRUE ; |
688 | m_appName = ""; | |
689 | argc = 0; | |
690 | argv = NULL; | |
2049ba38 | 691 | #ifdef __WXMSW__ |
2bda0e17 KB |
692 | m_printMode = wxPRINT_WINDOWS; |
693 | #else | |
694 | m_printMode = wxPRINT_POSTSCRIPT; | |
695 | #endif | |
2bda0e17 | 696 | m_exitOnFrameDelete = TRUE; |
2bda0e17 KB |
697 | m_auto3D = TRUE; |
698 | } | |
699 | ||
589f0e3e JS |
700 | wxApp::~wxApp() |
701 | { | |
702 | // Delete command-line args | |
703 | int i; | |
704 | for (i = 0; i < argc; i++) | |
705 | { | |
706 | delete[] argv[i]; | |
707 | } | |
da36f544 | 708 | delete[] argv; |
589f0e3e JS |
709 | } |
710 | ||
bb6290e3 | 711 | bool wxApp::Initialized() |
2bda0e17 KB |
712 | { |
713 | #ifndef _WINDLL | |
714 | if (GetTopWindow()) | |
715 | return TRUE; | |
716 | else | |
717 | return FALSE; | |
718 | #endif | |
719 | #ifdef _WINDLL // Assume initialized if DLL (no way of telling) | |
720 | return TRUE; | |
721 | #endif | |
722 | } | |
723 | ||
724 | /* | |
725 | * Get and process a message, returning FALSE if WM_QUIT | |
726 | * received. | |
727 | * | |
728 | */ | |
bb6290e3 | 729 | bool wxApp::DoMessage() |
2bda0e17 KB |
730 | { |
731 | if (!::GetMessage(&s_currentMsg, (HWND) NULL, 0, 0)) | |
732 | { | |
733 | return FALSE; | |
734 | } | |
d50b2a58 | 735 | |
2bda0e17 KB |
736 | // Process the message |
737 | if (!ProcessMessage((WXMSG *)&s_currentMsg)) | |
738 | { | |
739 | ::TranslateMessage(&s_currentMsg); | |
740 | wxApp::sm_lastMessageTime = s_currentMsg.time; /* MATTHEW: timeStamp impl. */ | |
741 | ::DispatchMessage(&s_currentMsg); | |
742 | } | |
743 | return TRUE; | |
744 | } | |
745 | ||
746 | /* | |
747 | * Keep trying to process messages until WM_QUIT | |
748 | * received. | |
749 | * | |
750 | * If there are messages to be processed, they will all be | |
751 | * processed and OnIdle will not be called. | |
752 | * When there are no more messages, OnIdle is called. | |
753 | * If OnIdle requests more time, | |
754 | * it will be repeatedly called so long as there are no pending messages. | |
755 | * A 'feature' of this is that once OnIdle has decided that no more processing | |
756 | * is required, then it won't get processing time until further messages | |
757 | * are processed (it'll sit in DoMessage). | |
758 | */ | |
759 | ||
bb6290e3 | 760 | int wxApp::MainLoop() |
2bda0e17 KB |
761 | { |
762 | m_keepGoing = TRUE; | |
763 | while (m_keepGoing) | |
764 | { | |
765 | while (!::PeekMessage(&s_currentMsg, 0, 0, 0, PM_NOREMOVE) && | |
766 | ProcessIdle()) {} | |
767 | if (!DoMessage()) | |
768 | m_keepGoing = FALSE; | |
769 | } | |
770 | ||
771 | return s_currentMsg.wParam; | |
772 | } | |
773 | ||
774 | // Returns TRUE if more time is needed. | |
bb6290e3 | 775 | bool wxApp::ProcessIdle() |
2bda0e17 KB |
776 | { |
777 | wxIdleEvent event; | |
778 | event.SetEventObject(this); | |
779 | ProcessEvent(event); | |
780 | ||
781 | return event.MoreRequested(); | |
782 | } | |
783 | ||
bb6290e3 | 784 | void wxApp::ExitMainLoop() |
2bda0e17 KB |
785 | { |
786 | m_keepGoing = FALSE; | |
787 | } | |
788 | ||
bb6290e3 | 789 | bool wxApp::Pending() |
2bda0e17 KB |
790 | { |
791 | return (::PeekMessage(&s_currentMsg, 0, 0, 0, PM_NOREMOVE) != 0) ; | |
792 | } | |
793 | ||
bb6290e3 | 794 | void wxApp::Dispatch() |
2bda0e17 KB |
795 | { |
796 | if (!DoMessage()) | |
797 | m_keepGoing = FALSE; | |
798 | } | |
799 | ||
800 | /* | |
801 | * Give all windows a chance to preprocess | |
802 | * the message. Some may have accelerator tables, or have | |
803 | * MDI complications. | |
804 | */ | |
805 | bool wxApp::ProcessMessage(WXMSG *Msg) | |
806 | { | |
807 | MSG *msg = (MSG *)Msg; | |
808 | ||
809 | HWND hWnd; | |
810 | ||
57a7b7c1 JS |
811 | // Try translations first; find the youngest window with |
812 | // a translation table. | |
2bda0e17 KB |
813 | for (hWnd = msg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd)) |
814 | { | |
815 | wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); | |
816 | if (wnd) | |
817 | { | |
57a7b7c1 | 818 | if (wnd->MSWTranslateMessage(Msg)) |
2bda0e17 | 819 | return TRUE; |
2bda0e17 KB |
820 | } |
821 | } | |
822 | ||
57a7b7c1 JS |
823 | // Anyone for a non-translation message? Try youngest descendants first. |
824 | for (hWnd = msg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd)) | |
825 | { | |
826 | wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); | |
827 | if (wnd) | |
828 | { | |
829 | if (wnd->MSWProcessMessage(Msg)) | |
830 | return TRUE; | |
831 | } | |
832 | } | |
833 | return FALSE; | |
2bda0e17 KB |
834 | } |
835 | ||
836 | void wxApp::OnIdle(wxIdleEvent& event) | |
837 | { | |
838 | static bool inOnIdle = FALSE; | |
839 | ||
840 | // Avoid recursion (via ProcessEvent default case) | |
841 | if (inOnIdle) | |
842 | return; | |
843 | ||
844 | inOnIdle = TRUE; | |
845 | ||
846 | // 'Garbage' collection of windows deleted with Close(). | |
847 | DeletePendingObjects(); | |
848 | ||
c54f78a2 VZ |
849 | // flush the logged messages if any |
850 | wxLog *pLog = wxLog::GetActiveTarget(); | |
851 | if ( pLog != NULL && pLog->HasPendingMessages() ) | |
852 | pLog->Flush(); | |
853 | ||
2bda0e17 KB |
854 | // Send OnIdle events to all windows |
855 | bool needMore = SendIdleEvents(); | |
1c089c47 | 856 | // bool needMore = FALSE; |
2bda0e17 KB |
857 | |
858 | if (needMore) | |
859 | event.RequestMore(TRUE); | |
860 | ||
861 | inOnIdle = FALSE; | |
862 | } | |
863 | ||
864 | // Send idle event to all top-level windows | |
bb6290e3 | 865 | bool wxApp::SendIdleEvents() |
2bda0e17 KB |
866 | { |
867 | bool needMore = FALSE; | |
a5e0e655 VZ |
868 | wxNode* node = wxTopLevelWindows.First(); |
869 | while (node) | |
870 | { | |
871 | wxWindow* win = (wxWindow*) node->Data(); | |
872 | if (SendIdleEvents(win)) | |
2bda0e17 KB |
873 | needMore = TRUE; |
874 | ||
a5e0e655 VZ |
875 | node = node->Next(); |
876 | } | |
2bda0e17 KB |
877 | return needMore; |
878 | } | |
879 | ||
880 | // Send idle event to window and all subwindows | |
881 | bool wxApp::SendIdleEvents(wxWindow* win) | |
882 | { | |
a5e0e655 | 883 | bool needMore = FALSE; |
2bda0e17 | 884 | |
a5e0e655 VZ |
885 | wxIdleEvent event; |
886 | event.SetEventObject(win); | |
02800301 | 887 | win->GetEventHandler()->ProcessEvent(event); |
2bda0e17 | 888 | |
a5e0e655 VZ |
889 | if (event.MoreRequested()) |
890 | needMore = TRUE; | |
2bda0e17 | 891 | |
c0ed460c | 892 | wxNode* node = win->GetChildren().First(); |
a5e0e655 VZ |
893 | while (node) |
894 | { | |
895 | wxWindow* win = (wxWindow*) node->Data(); | |
896 | if (SendIdleEvents(win)) | |
897 | needMore = TRUE; | |
2bda0e17 | 898 | |
a5e0e655 VZ |
899 | node = node->Next(); |
900 | } | |
901 | return needMore ; | |
2bda0e17 KB |
902 | } |
903 | ||
bb6290e3 | 904 | void wxApp::DeletePendingObjects() |
2bda0e17 KB |
905 | { |
906 | wxNode *node = wxPendingDelete.First(); | |
907 | while (node) | |
908 | { | |
909 | wxObject *obj = (wxObject *)node->Data(); | |
d50b2a58 | 910 | |
2bda0e17 KB |
911 | delete obj; |
912 | ||
913 | if (wxPendingDelete.Member(obj)) | |
914 | delete node; | |
915 | ||
916 | // Deleting one object may have deleted other pending | |
917 | // objects, so start from beginning of list again. | |
918 | node = wxPendingDelete.First(); | |
919 | } | |
920 | } | |
921 | ||
387a3b02 JS |
922 | void wxApp::OnEndSession(wxCloseEvent& event) |
923 | { | |
924 | if (GetTopWindow()) | |
925 | GetTopWindow()->Close(TRUE); | |
926 | } | |
927 | ||
928 | // Default behaviour: close the application with prompts. The | |
929 | // user can veto the close, and therefore the end session. | |
930 | void wxApp::OnQueryEndSession(wxCloseEvent& event) | |
931 | { | |
932 | if (GetTopWindow()) | |
933 | { | |
934 | if (!GetTopWindow()->Close(!event.CanVeto())) | |
935 | event.Veto(TRUE); | |
936 | } | |
937 | } | |
938 | ||
bb6290e3 | 939 | wxLog* wxApp::CreateLogTarget() |
2bda0e17 KB |
940 | { |
941 | return new wxLogGui; | |
942 | } | |
943 | ||
bb6290e3 | 944 | wxWindow* wxApp::GetTopWindow() const |
2bda0e17 KB |
945 | { |
946 | if (m_topWindow) | |
947 | return m_topWindow; | |
948 | else if (wxTopLevelWindows.Number() > 0) | |
949 | return (wxWindow*) wxTopLevelWindows.First()->Data(); | |
950 | else | |
951 | return NULL; | |
952 | } | |
953 | ||
bb6290e3 JS |
954 | int wxApp::GetComCtl32Version() const |
955 | { | |
956 | // have we loaded COMCTL32 yet? | |
957 | HMODULE theModule = ::GetModuleHandle("COMCTL32"); | |
958 | int version = 0; | |
d50b2a58 | 959 | |
bb6290e3 JS |
960 | // if so, then we can check for the version |
961 | if (theModule) | |
962 | { | |
963 | // InitCommonControlsEx is unique to 4.7 and later | |
964 | FARPROC theProc = ::GetProcAddress(theModule, "InitCommonControlsEx"); | |
d50b2a58 | 965 | |
bb6290e3 JS |
966 | if (! theProc) |
967 | { // not found, must be 4.00 | |
a5e0e655 | 968 | version = 400; |
bb6290e3 JS |
969 | } |
970 | else | |
971 | { | |
a5e0e655 VZ |
972 | // The following symbol are unique to 4.71 |
973 | // DllInstall | |
974 | // FlatSB_EnableScrollBar FlatSB_GetScrollInfo FlatSB_GetScrollPos | |
975 | // FlatSB_GetScrollProp FlatSB_GetScrollRange FlatSB_SetScrollInfo | |
976 | // FlatSB_SetScrollPos FlatSB_SetScrollProp FlatSB_SetScrollRange | |
977 | // FlatSB_ShowScrollBar | |
978 | // _DrawIndirectImageList _DuplicateImageList | |
979 | // InitializeFlatSB | |
980 | // UninitializeFlatSB | |
981 | // we could check for any of these - I chose DllInstall | |
982 | FARPROC theProc = ::GetProcAddress(theModule, "DllInstall"); | |
983 | if (! theProc) | |
984 | { | |
985 | // not found, must be 4.70 | |
986 | version = 470; | |
987 | } | |
988 | else | |
989 | { // found, must be 4.71 | |
990 | version = 471; | |
991 | } | |
bb6290e3 JS |
992 | } |
993 | } | |
994 | return version; | |
995 | } | |
996 | ||
997 | void wxExit() | |
2bda0e17 KB |
998 | { |
999 | wxApp::CleanUp(); | |
1000 | FatalAppExit(0, "Fatal error: exiting"); | |
1001 | } | |
1002 | ||
1003 | // Yield to incoming messages | |
bb6290e3 | 1004 | bool wxYield() |
2bda0e17 KB |
1005 | { |
1006 | MSG msg; | |
1007 | // We want to go back to the main message loop | |
1008 | // if we see a WM_QUIT. (?) | |
1009 | while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT) | |
1010 | { | |
1011 | if (!wxTheApp->DoMessage()) | |
1012 | break; | |
1013 | } | |
1014 | ||
1015 | return TRUE; | |
1016 | } | |
1017 | ||
1018 | HINSTANCE wxGetInstance() | |
1019 | { | |
a5e0e655 | 1020 | return wxhInstance; |
2bda0e17 KB |
1021 | } |
1022 | ||
1023 | // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly | |
1024 | // if in a separate file. So include it here to ensure it's linked. | |
1025 | #if (defined(_MSC_VER) && !defined(__WIN32__)) || defined(__GNUWIN32__) | |
a5e0e655 | 1026 | #include "main.cpp" |
2bda0e17 | 1027 | #endif |