Repository navigation
Expand file tree
/
Copy pathapp.cpp
More file actions
775 lines (634 loc) · 22.6 KB
/
Copy pathapp.cpp
File metadata and controls
775 lines (634 loc) · 22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/////////////////////////////////////////////////////////////////////////////
// Name: src/msw/app.cpp
// Purpose: wxApp
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ===========================================================================
// declarations
// ===========================================================================
// ---------------------------------------------------------------------------
// headers
// ---------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/dynarray.h"
#include "wx/frame.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/gdicmn.h"
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/cursor.h"
#include "wx/icon.h"
#include "wx/palette.h"
#include "wx/dc.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/intl.h"
#include "wx/wxchar.h"
#include "wx/log.h"
#endif
#include "wx/apptrait.h"
#include "wx/filename.h"
#include "wx/module.h"
#include "wx/dynlib.h"
#include "wx/evtloop.h"
#include "wx/msw/private.h"
#include "wx/msw/ole/oleutils.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#endif // wxUSE_TOOLTIPS
// OLE is used for drag-and-drop, clipboard, OLE Automation..., but some
// compilers don't support it (missing headers, libs, ...)
#if defined(__GNUWIN32_OLD__) || defined(__SYMANTEC__) || defined(__SALFORDC__)
#undef wxUSE_OLE
#define wxUSE_OLE 0
#endif // broken compilers
#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
#include <ole2.h>
#include <aygshell.h>
#endif
#if wxUSE_OLE
#include <ole2.h>
#endif
#include <string.h>
#include <ctype.h>
#include "wx/msw/wrapcctl.h"
// For MB_TASKMODAL
#ifdef __WXWINCE__
#include "wx/msw/wince/missing.h"
#endif
// instead of including <shlwapi.h> which is not part of the core SDK and not
// shipped at all with other compilers, we always define the parts of it we
// need here ourselves
//
// NB: DLLVER_PLATFORM_WINDOWS will be defined if shlwapi.h had been somehow
// included already
#ifndef DLLVER_PLATFORM_WINDOWS
// hopefully we don't need to change packing as DWORDs should be already
// correctly aligned
struct DLLVERSIONINFO
{
DWORD cbSize;
DWORD dwMajorVersion; // Major version
DWORD dwMinorVersion; // Minor version
DWORD dwBuildNumber; // Build number
DWORD dwPlatformID; // DLLVER_PLATFORM_*
};
typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
#endif // defined(DLLVERSIONINFO)
// ---------------------------------------------------------------------------
// global variables
// ---------------------------------------------------------------------------
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
extern void wxSetKeyboardHook(bool doIt);
#endif
// NB: all "NoRedraw" classes must have the same names as the "normal" classes
// with NR suffix - wxWindow::MSWCreate() supposes this
#ifdef __WXWINCE__
WXDLLIMPEXP_CORE wxChar *wxCanvasClassName;
WXDLLIMPEXP_CORE wxChar *wxCanvasClassNameNR;
#else
WXDLLIMPEXP_CORE const wxChar *wxCanvasClassName = wxT("wxWindowClass");
WXDLLIMPEXP_CORE const wxChar *wxCanvasClassNameNR = wxT("wxWindowClassNR");
#endif
WXDLLIMPEXP_CORE const wxChar *wxMDIFrameClassName = wxT("wxMDIFrameClass");
WXDLLIMPEXP_CORE const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR");
WXDLLIMPEXP_CORE const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass");
WXDLLIMPEXP_CORE const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR");
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
// ===========================================================================
// wxGUIAppTraits implementation
// ===========================================================================
// private class which we use to pass parameters from BeforeChildWaitLoop() to
// AfterChildWaitLoop()
struct ChildWaitLoopData
{
ChildWaitLoopData(wxWindowDisabler *wd_, wxWindow *winActive_)
{
wd = wd_;
winActive = winActive_;
}
wxWindowDisabler *wd;
wxWindow *winActive;
};
void *wxGUIAppTraits::BeforeChildWaitLoop()
{
/*
We use a dirty hack here to disable all application windows (which we
must do because otherwise the calls to wxYield() could lead to some very
unexpected reentrancies in the users code) but to avoid losing
focus/activation entirely when the child process terminates which would
happen if we simply disabled everything using wxWindowDisabler. Indeed,
remember that Windows will never activate a disabled window and when the
last childs window is closed and Windows looks for a window to activate
all our windows are still disabled. There is no way to enable them in
time because we don't know when the childs windows are going to be
closed, so the solution we use here is to keep one special tiny frame
enabled all the time. Then when the child terminates it will get
activated and when we close it below -- after reenabling all the other
windows! -- the previously active window becomes activated again and
everything is ok.
*/
wxBeginBusyCursor();
// first disable all existing windows
wxWindowDisabler *wd = new wxWindowDisabler;
// then create an "invisible" frame: it has minimal size, is positioned
// (hopefully) outside the screen and doesn't appear on the taskbar
wxWindow *winActive = new wxFrame
(
wxTheApp->GetTopWindow(),
wxID_ANY,
wxEmptyString,
wxPoint(32600, 32600),
wxSize(1, 1),
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
);
winActive->Show();
return new ChildWaitLoopData(wd, winActive);
}
void wxGUIAppTraits::AlwaysYield()
{
wxYield();
}
void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig)
{
wxEndBusyCursor();
ChildWaitLoopData * const data = (ChildWaitLoopData *)dataOrig;
delete data->wd;
// finally delete the dummy frame and, as wd has been already destroyed and
// the other windows reenabled, the activation is going to return to the
// window which had had it before
data->winActive->Destroy();
// also delete the temporary data object itself
delete data;
}
bool wxGUIAppTraits::DoMessageFromThreadWait()
{
// we should return false only if the app should exit, i.e. only if
// Dispatch() determines that the main event loop should terminate
wxEventLoop *evtLoop = wxEventLoop::GetActive();
if ( !evtLoop || !evtLoop->Pending() )
{
// no events means no quit event
return true;
}
return evtLoop->Dispatch();
}
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
{
static wxToolkitInfo info;
wxToolkitInfo& baseInfo = wxAppTraits::GetToolkitInfo();
info.versionMajor = baseInfo.versionMajor;
info.versionMinor = baseInfo.versionMinor;
info.os = baseInfo.os;
info.shortName = _T("msw");
info.name = _T("wxMSW");
#ifdef __WXUNIVERSAL__
info.shortName << _T("univ");
info.name << _T("/wxUniversal");
#endif
return info;
}
// ===========================================================================
// wxApp implementation
// ===========================================================================
int wxApp::m_nCmdShow = SW_SHOWNORMAL;
// ---------------------------------------------------------------------------
// wxWin macros
// ---------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle)
EVT_END_SESSION(wxApp::OnEndSession)
EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
END_EVENT_TABLE()
// class to ensure that wxAppBase::CleanUp() is called if our Initialize()
// fails
class wxCallBaseCleanup
{
public:
wxCallBaseCleanup(wxApp *app) : m_app(app) { }
~wxCallBaseCleanup() { if ( m_app ) m_app->wxAppBase::CleanUp(); }
void Dismiss() { m_app = NULL; }
private:
wxApp *m_app;
};
//// Initialize
bool wxApp::Initialize(int& argc, wxChar **argv)
{
if ( !wxAppBase::Initialize(argc, argv) )
return false;
// ensure that base cleanup is done if we return too early
wxCallBaseCleanup callBaseCleanup(this);
#ifdef __WXWINCE__
wxString tmp = GetAppName();
tmp += wxT("ClassName");
wxCanvasClassName = wxStrdup( tmp.c_str() );
tmp += wxT("NR");
wxCanvasClassNameNR = wxStrdup( tmp.c_str() );
HWND hWnd = FindWindow( wxCanvasClassNameNR, NULL );
if (hWnd)
{
SetForegroundWindow( (HWND)(((DWORD)hWnd)|0x01) );
return false;
}
#endif
#if !defined(__WXMICROWIN__)
InitCommonControls();
#endif // !defined(__WXMICROWIN__)
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
SHInitExtraControls();
#endif
#ifndef __WXWINCE__
// Don't show a message box if a function such as SHGetFileInfo
// fails to find a device.
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
wxOleInitialize();
RegisterWindowClasses();
wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
wxSetKeyboardHook(true);
#endif
callBaseCleanup.Dismiss();
return true;
}
// ---------------------------------------------------------------------------
// RegisterWindowClasses
// ---------------------------------------------------------------------------
// TODO we should only register classes really used by the app. For this it
// would be enough to just delay the class registration until an attempt
// to create a window of this class is made.
bool wxApp::RegisterWindowClasses()
{
WNDCLASS wndclass;
wxZeroMemory(wndclass);
// for each class we register one with CS_(V|H)REDRAW style and one
// without for windows created with wxNO_FULL_REDRAW_ON_REPAINT flag
static const long styleNormal = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
static const long styleNoRedraw = CS_DBLCLKS;
// the fields which are common to all classes
wndclass.lpfnWndProc = (WNDPROC)wxWndProc;
wndclass.hInstance = wxhInstance;
wndclass.hCursor = ::LoadCursor((HINSTANCE)NULL, IDC_ARROW);
// register the class for all normal windows
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszClassName = wxCanvasClassName;
wndclass.style = styleNormal;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(frame)"));
}
// "no redraw" frame
wndclass.lpszClassName = wxCanvasClassNameNR;
wndclass.style = styleNoRedraw;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(no redraw frame)"));
}
// Register the MDI frame window class.
wndclass.hbrBackground = (HBRUSH)NULL; // paint MDI frame ourselves
wndclass.lpszClassName = wxMDIFrameClassName;
wndclass.style = styleNormal;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(MDI parent)"));
}
// "no redraw" MDI frame
wndclass.lpszClassName = wxMDIFrameClassNameNoRedraw;
wndclass.style = styleNoRedraw;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(no redraw MDI parent frame)"));
}
// Register the MDI child frame window class.
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszClassName = wxMDIChildFrameClassName;
wndclass.style = styleNormal;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(MDI child)"));
}
// "no redraw" MDI child frame
wndclass.lpszClassName = wxMDIChildFrameClassNameNoRedraw;
wndclass.style = styleNoRedraw;
if ( !RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(no redraw MDI child)"));
}
return true;
}
// ---------------------------------------------------------------------------
// UnregisterWindowClasses
// ---------------------------------------------------------------------------
bool wxApp::UnregisterWindowClasses()
{
bool retval = true;
#ifndef __WXMICROWIN__
// MDI frame window class.
if ( !::UnregisterClass(wxMDIFrameClassName, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(MDI parent)"));
retval = false;
}
// "no redraw" MDI frame
if ( !::UnregisterClass(wxMDIFrameClassNameNoRedraw, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(no redraw MDI parent frame)"));
retval = false;
}
// MDI child frame window class.
if ( !::UnregisterClass(wxMDIChildFrameClassName, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(MDI child)"));
retval = false;
}
// "no redraw" MDI child frame
if ( !::UnregisterClass(wxMDIChildFrameClassNameNoRedraw, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(no redraw MDI child)"));
retval = false;
}
// canvas class name
if ( !::UnregisterClass(wxCanvasClassName, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(canvas)"));
retval = false;
}
if ( !::UnregisterClass(wxCanvasClassNameNR, wxhInstance) )
{
wxLogLastError(wxT("UnregisterClass(no redraw canvas)"));
retval = false;
}
#endif // __WXMICROWIN__
return retval;
}
void wxApp::CleanUp()
{
// all objects pending for deletion must be deleted first, otherwise we
// would crash when they use wxWinHandleHash (and UnregisterWindowClasses()
// call wouldn't succeed as long as any windows still exist), so call the
// base class method first and only then do our clean up
wxAppBase::CleanUp();
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
wxSetKeyboardHook(false);
#endif
wxOleUninitialize();
// for an EXE the classes are unregistered when it terminates but DLL may
// be loaded several times (load/unload/load) into the same process in
// which case the registration will fail after the first time if we don't
// unregister the classes now
UnregisterWindowClasses();
delete wxWinHandleHash;
wxWinHandleHash = NULL;
#ifdef __WXWINCE__
free( wxCanvasClassName );
free( wxCanvasClassNameNR );
#endif
}
// ----------------------------------------------------------------------------
// wxApp ctor/dtor
// ----------------------------------------------------------------------------
wxApp::wxApp()
{
m_printMode = wxPRINT_WINDOWS;
}
wxApp::~wxApp()
{
}
// ----------------------------------------------------------------------------
// wxApp idle handling
// ----------------------------------------------------------------------------
void wxApp::OnIdle(wxIdleEvent& event)
{
wxAppBase::OnIdle(event);
#if wxUSE_DC_CACHEING
// automated DC cache management: clear the cached DCs and bitmap
// if it's likely that the app has finished with them, that is, we
// get an idle event and we're not dragging anything.
if (!::GetKeyState(MK_LBUTTON) && !::GetKeyState(MK_MBUTTON) && !::GetKeyState(MK_RBUTTON))
wxDC::ClearCache();
#endif // wxUSE_DC_CACHEING
}
void wxApp::WakeUpIdle()
{
// Send the top window a dummy message so idle handler processing will
// start up again. Doing it this way ensures that the idle handler
// wakes up in the right thread (see also wxWakeUpMainThread() which does
// the same for the main app thread only)
wxWindow *topWindow = wxTheApp->GetTopWindow();
if ( topWindow )
{
if ( !::PostMessage(GetHwndOf(topWindow), WM_NULL, 0, 0) )
{
// should never happen
wxLogLastError(wxT("PostMessage(WM_NULL)"));
}
}
}
// ----------------------------------------------------------------------------
// other wxApp event hanlders
// ----------------------------------------------------------------------------
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
if (GetTopWindow())
GetTopWindow()->Close(true);
}
// Default behaviour: close the application with prompts. The
// user can veto the close, and therefore the end session.
void wxApp::OnQueryEndSession(wxCloseEvent& event)
{
if (GetTopWindow())
{
if (!GetTopWindow()->Close(!event.CanVeto()))
event.Veto(true);
}
}
// ----------------------------------------------------------------------------
// miscellaneous
// ----------------------------------------------------------------------------
/* static */
int wxApp::GetComCtl32Version()
{
#if defined(__WXMICROWIN__) || defined(__WXWINCE__)
return 0;
#else
// cache the result
//
// NB: this is MT-ok as in the worst case we'd compute s_verComCtl32 twice,
// but as its value should be the same both times it doesn't matter
static int s_verComCtl32 = -1;
if ( s_verComCtl32 == -1 )
{
// initally assume no comctl32.dll at all
s_verComCtl32 = 0;
// we're prepared to handle the errors
wxLogNull noLog;
#if wxUSE_DYNLIB_CLASS
// do we have it?
wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
// if so, then we can check for the version
if ( dllComCtl32.IsLoaded() )
{
// now check if the function is available during run-time
wxDYNLIB_FUNCTION( DLLGETVERSIONPROC, DllGetVersion, dllComCtl32 );
if ( pfnDllGetVersion )
{
DLLVERSIONINFO dvi;
dvi.cbSize = sizeof(dvi);
HRESULT hr = (*pfnDllGetVersion)(&dvi);
if ( FAILED(hr) )
{
wxLogApiError(_T("DllGetVersion"), hr);
}
else
{
// this is incompatible with _WIN32_IE values, but
// compatible with the other values returned by
// GetComCtl32Version()
s_verComCtl32 = 100*dvi.dwMajorVersion +
dvi.dwMinorVersion;
}
}
// if DllGetVersion() is unavailable either during compile or
// run-time, try to guess the version otherwise
if ( !s_verComCtl32 )
{
// InitCommonControlsEx is unique to 4.70 and later
void *pfn = dllComCtl32.GetSymbol(_T("InitCommonControlsEx"));
if ( !pfn )
{
// not found, must be 4.00
s_verComCtl32 = 400;
}
else // 4.70+
{
// many symbols appeared in comctl32 4.71, could use any of
// them except may be DllInstall()
pfn = dllComCtl32.GetSymbol(_T("InitializeFlatSB"));
if ( !pfn )
{
// not found, must be 4.70
s_verComCtl32 = 470;
}
else
{
// found, must be 4.71 or later
s_verComCtl32 = 471;
}
}
}
}
#endif
}
return s_verComCtl32;
#endif // Microwin/!Microwin
}
// Yield to incoming messages
bool wxApp::Yield(bool onlyIfNeeded)
{
// MT-FIXME
static bool s_inYield = false;
#if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
#endif // wxUSE_LOG
if ( s_inYield )
{
if ( !onlyIfNeeded )
{
wxFAIL_MSG( wxT("wxYield called recursively" ) );
}
return false;
}
s_inYield = true;
// we don't want to process WM_QUIT from here - it should be processed in
// the main event loop in order to stop it
MSG msg;
while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
msg.message != WM_QUIT )
{
#if wxUSE_THREADS
wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS
if ( !wxTheApp->Dispatch() )
break;
}
// if there are pending events, we must process them.
ProcessPendingEvents();
#if wxUSE_LOG
// let the logs be flashed again
wxLog::Resume();
#endif // wxUSE_LOG
s_inYield = false;
return true;
}
#if wxUSE_EXCEPTIONS
// ----------------------------------------------------------------------------
// exception handling
// ----------------------------------------------------------------------------
bool wxApp::OnExceptionInMainLoop()
{
// ask the user about what to do: use the Win32 API function here as it
// could be dangerous to use any wxWidgets code in this state
switch (
::MessageBox
(
NULL,
_T("An unhandled exception occurred. Press \"Abort\" to \
terminate the program,\r\n\
\"Retry\" to exit the program normally and \"Ignore\" to try to continue."),
_T("Unhandled exception"),
MB_ABORTRETRYIGNORE |
MB_ICONERROR|
MB_TASKMODAL
)
)
{
case IDABORT:
throw;
default:
wxFAIL_MSG( _T("unexpected MessageBox() return code") );
// fall through
case IDRETRY:
return false;
case IDIGNORE:
return true;
}
}
#endif // wxUSE_EXCEPTIONS
// ----------------------------------------------------------------------------
// deprecated event loop functions
// ----------------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_2_4
void wxApp::DoMessage(WXMSG *pMsg)
{
wxEventLoop *evtLoop = wxEventLoop::GetActive();
if ( evtLoop )
evtLoop->ProcessMessage(pMsg);
}
bool wxApp::DoMessage()
{
wxEventLoop *evtLoop = wxEventLoop::GetActive();
return evtLoop ? evtLoop->Dispatch() : false;
}
bool wxApp::ProcessMessage(WXMSG* pMsg)
{
wxEventLoop *evtLoop = wxEventLoop::GetActive();
return evtLoop && evtLoop->PreProcessMessage(pMsg);
}
#endif // WXWIN_COMPATIBILITY_2_4