1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
21 #pragma implementation "app.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
27 #if defined(__BORLANDC__)
35 #include "wx/gdicmn.h"
38 #include "wx/cursor.h"
40 #include "wx/palette.h"
42 #include "wx/dialog.h"
43 #include "wx/msgdlg.h"
45 #include "wx/dynarray.h"
46 #include "wx/wxchar.h"
51 #include "wx/apptrait.h"
52 #include "wx/filename.h"
53 #include "wx/module.h"
55 #include "wx/msw/private.h"
58 #include "wx/thread.h"
60 // define the array of MSG strutures
61 WX_DECLARE_OBJARRAY(MSG
, wxMsgArray
);
63 #include "wx/arrimpl.cpp"
65 WX_DEFINE_OBJARRAY(wxMsgArray
);
66 #endif // wxUSE_THREADS
69 #include "wx/tooltip.h"
70 #endif // wxUSE_TOOLTIPS
72 // OLE is used for drag-and-drop, clipboard, OLE Automation..., but some
73 // compilers don't support it (missing headers, libs, ...)
74 #if defined(__GNUWIN32_OLD__) || defined(__SYMANTEC__) || defined(__SALFORDC__)
78 #endif // broken compilers
87 #if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__WXMICROWIN__)) && !defined(__CYGWIN10__))
91 // ----------------------------------------------------------------------------
92 // conditional compilation
93 // ----------------------------------------------------------------------------
95 // The macro _WIN32_IE is defined by commctrl.h (unless it had already been
96 // defined before) and shows us what common control features are available
97 // during the compile time (it doesn't mean that they will be available during
98 // the run-time, use GetComCtl32Version() to test for them!). The possible
101 // 0x0200 for comctl32.dll 4.00 shipped with Win95/NT 4.0
102 // 0x0300 4.70 IE 3.x
103 // 0x0400 4.71 IE 4.0
104 // 0x0401 4.72 IE 4.01 and Win98
105 // 0x0500 5.00 IE 5.x and NT 5.0 (Win2000)
108 // minimal set of features by default
109 #define _WIN32_IE 0x0200
112 #if _WIN32_IE >= 0x0300 && \
113 (!defined(__MINGW32__) || wxCHECK_W32API_VERSION( 2, 0 )) && \
114 !defined(__CYGWIN__) && !defined(__WXWINCE__)
118 // ---------------------------------------------------------------------------
120 // ---------------------------------------------------------------------------
122 extern wxList WXDLLEXPORT wxPendingDelete
;
124 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
125 extern void wxSetKeyboardHook(bool doIt
);
130 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
131 // with NR suffix - wxWindow::MSWCreate() supposes this
132 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
133 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
134 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
135 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
136 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
137 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
139 HBRUSH wxDisableButtonBrush
= (HBRUSH
) 0;
141 // ----------------------------------------------------------------------------
143 // ----------------------------------------------------------------------------
145 LRESULT WXDLLEXPORT APIENTRY
wxWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
147 // ===========================================================================
148 // wxGUIAppTraits implementation
149 // ===========================================================================
151 // private class which we use to pass parameters from BeforeChildWaitLoop() to
152 // AfterChildWaitLoop()
153 struct ChildWaitLoopData
155 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
158 winActive
= winActive_
;
161 wxWindowDisabler
*wd
;
165 void *wxGUIAppTraits::BeforeChildWaitLoop()
168 We use a dirty hack here to disable all application windows (which we
169 must do because otherwise the calls to wxYield() could lead to some very
170 unexpected reentrancies in the users code) but to avoid losing
171 focus/activation entirely when the child process terminates which would
172 happen if we simply disabled everything using wxWindowDisabler. Indeed,
173 remember that Windows will never activate a disabled window and when the
174 last childs window is closed and Windows looks for a window to activate
175 all our windows are still disabled. There is no way to enable them in
176 time because we don't know when the childs windows are going to be
177 closed, so the solution we use here is to keep one special tiny frame
178 enabled all the time. Then when the child terminates it will get
179 activated and when we close it below -- after reenabling all the other
180 windows! -- the previously active window becomes activated again and
185 // first disable all existing windows
186 wxWindowDisabler
*wd
= new wxWindowDisabler
;
188 // then create an "invisible" frame: it has minimal size, is positioned
189 // (hopefully) outside the screen and doesn't appear on the taskbar
190 wxWindow
*winActive
= new wxFrame
192 wxTheApp
->GetTopWindow(),
195 wxPoint(32600, 32600),
197 wxDEFAULT_FRAME_STYLE
| wxFRAME_NO_TASKBAR
201 return new ChildWaitLoopData(wd
, winActive
);
204 void wxGUIAppTraits::AlwaysYield()
209 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
213 const ChildWaitLoopData
* const data
= (ChildWaitLoopData
*)dataOrig
;
217 // finally delete the dummy frame and, as wd has been already destroyed and
218 // the other windows reenabled, the activation is going to return to the
219 // window which had had it before
220 data
->winActive
->Destroy();
223 bool wxGUIAppTraits::DoMessageFromThreadWait()
225 return !wxTheApp
|| wxTheApp
->DoMessage();
228 // ===========================================================================
229 // wxApp implementation
230 // ===========================================================================
232 int wxApp::m_nCmdShow
= SW_SHOWNORMAL
;
234 // ---------------------------------------------------------------------------
236 // ---------------------------------------------------------------------------
238 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
240 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
241 EVT_IDLE(wxApp::OnIdle
)
242 EVT_END_SESSION(wxApp::OnEndSession
)
243 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
246 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
248 class wxCallBaseCleanup
251 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
252 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
254 void Dismiss() { m_app
= NULL
; }
261 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
263 if ( !wxAppBase::Initialize(argc
, argv
) )
266 // ensure that base cleanup is done if we return too early
267 wxCallBaseCleanup
callBaseCleanup(this);
269 // the first thing to do is to check if we're trying to run an Unicode
270 // program under Win9x w/o MSLU emulation layer - if so, abort right now
271 // as it has no chance to work
272 #if wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
273 if ( wxGetOsVersion() != wxWINDOWS_NT
)
275 // note that we can use MessageBoxW() as it's implemented even under
276 // Win9x - OTOH, we can't use wxGetTranslation() because the file APIs
277 // used by wxLocale are not
281 _T("This program uses Unicode and requires Windows NT/2000/XP.\nProgram aborted."),
282 _T("wxWindows Fatal Error"),
288 #endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
290 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
291 InitCommonControls();
294 #if wxUSE_OLE || wxUSE_DRAG_AND_DROP
297 // for OLE, enlarge message queue to be as large as possible
299 while (!SetMessageQueue(iMsg
) && (iMsg
-= 8))
304 // we need to initialize OLE library
305 if ( FAILED(::OleInitialize(NULL
)) )
306 wxLogError(_("Cannot initialize OLE"));
312 if (!Ctl3dRegister(wxhInstance
))
313 wxLogError(wxT("Cannot register CTL3D"));
315 Ctl3dAutoSubclass(wxhInstance
);
316 #endif // wxUSE_CTL3D
318 RegisterWindowClasses();
320 #if defined(__WXMICROWIN__) && !defined(__WXWINCE__)
321 // Create the brush for disabling bitmap buttons
324 lb
.lbStyle
= BS_PATTERN
;
326 lb
.lbHatch
= (int)LoadBitmap( wxhInstance
, wxT("wxDISABLE_BUTTON_BITMAP") );
329 wxDisableButtonBrush
= ::CreateBrushIndirect( & lb
);
330 ::DeleteObject( (HGDIOBJ
)lb
.lbHatch
);
332 //else: wxWindows resources are probably not linked in
339 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
341 // This is to foil optimizations in Visual C++ that throw out dummy.obj.
342 // PLEASE DO NOT ALTER THIS.
343 #if defined(__VISUALC__) && defined(__WIN16__) && !defined(WXMAKINGDLL)
344 extern char wxDummyChar
;
345 if (wxDummyChar
) wxDummyChar
++;
348 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
349 wxSetKeyboardHook(TRUE
);
352 callBaseCleanup
.Dismiss();
357 // ---------------------------------------------------------------------------
358 // RegisterWindowClasses
359 // ---------------------------------------------------------------------------
361 // TODO we should only register classes really used by the app. For this it
362 // would be enough to just delay the class registration until an attempt
363 // to create a window of this class is made.
364 bool wxApp::RegisterWindowClasses()
367 wxZeroMemory(wndclass
);
369 // for each class we register one with CS_(V|H)REDRAW style and one
370 // without for windows created with wxNO_FULL_REDRAW_ON_REPAINT flag
371 static const long styleNormal
= CS_HREDRAW
| CS_VREDRAW
| CS_DBLCLKS
;
372 static const long styleNoRedraw
= CS_DBLCLKS
;
374 // the fields which are common to all classes
375 wndclass
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
376 wndclass
.hInstance
= wxhInstance
;
377 wndclass
.hCursor
= ::LoadCursor((HINSTANCE
)NULL
, IDC_ARROW
);
379 // Register the frame window class.
380 wndclass
.hbrBackground
= (HBRUSH
)(COLOR_APPWORKSPACE
+ 1);
381 wndclass
.lpszClassName
= wxCanvasClassName
;
382 wndclass
.style
= styleNormal
;
384 if ( !RegisterClass(&wndclass
) )
386 wxLogLastError(wxT("RegisterClass(frame)"));
390 wndclass
.lpszClassName
= wxCanvasClassNameNR
;
391 wndclass
.style
= styleNoRedraw
;
393 if ( !RegisterClass(&wndclass
) )
395 wxLogLastError(wxT("RegisterClass(no redraw frame)"));
398 // Register the MDI frame window class.
399 wndclass
.hbrBackground
= (HBRUSH
)NULL
; // paint MDI frame ourselves
400 wndclass
.lpszClassName
= wxMDIFrameClassName
;
401 wndclass
.style
= styleNormal
;
403 if ( !RegisterClass(&wndclass
) )
405 wxLogLastError(wxT("RegisterClass(MDI parent)"));
408 // "no redraw" MDI frame
409 wndclass
.lpszClassName
= wxMDIFrameClassNameNoRedraw
;
410 wndclass
.style
= styleNoRedraw
;
412 if ( !RegisterClass(&wndclass
) )
414 wxLogLastError(wxT("RegisterClass(no redraw MDI parent frame)"));
417 // Register the MDI child frame window class.
418 wndclass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
419 wndclass
.lpszClassName
= wxMDIChildFrameClassName
;
420 wndclass
.style
= styleNormal
;
422 if ( !RegisterClass(&wndclass
) )
424 wxLogLastError(wxT("RegisterClass(MDI child)"));
427 // "no redraw" MDI child frame
428 wndclass
.lpszClassName
= wxMDIChildFrameClassNameNoRedraw
;
429 wndclass
.style
= styleNoRedraw
;
431 if ( !RegisterClass(&wndclass
) )
433 wxLogLastError(wxT("RegisterClass(no redraw MDI child)"));
439 // ---------------------------------------------------------------------------
440 // UnregisterWindowClasses
441 // ---------------------------------------------------------------------------
443 bool wxApp::UnregisterWindowClasses()
447 #ifndef __WXMICROWIN__
448 // MDI frame window class.
449 if ( !::UnregisterClass(wxMDIFrameClassName
, wxhInstance
) )
451 wxLogLastError(wxT("UnregisterClass(MDI parent)"));
456 // "no redraw" MDI frame
457 if ( !::UnregisterClass(wxMDIFrameClassNameNoRedraw
, wxhInstance
) )
459 wxLogLastError(wxT("UnregisterClass(no redraw MDI parent frame)"));
464 // MDI child frame window class.
465 if ( !::UnregisterClass(wxMDIChildFrameClassName
, wxhInstance
) )
467 wxLogLastError(wxT("UnregisterClass(MDI child)"));
472 // "no redraw" MDI child frame
473 if ( !::UnregisterClass(wxMDIChildFrameClassNameNoRedraw
, wxhInstance
) )
475 wxLogLastError(wxT("UnregisterClass(no redraw MDI child)"));
481 if ( !::UnregisterClass(wxCanvasClassName
, wxhInstance
) )
483 wxLogLastError(wxT("UnregisterClass(canvas)"));
488 if ( !::UnregisterClass(wxCanvasClassNameNR
, wxhInstance
) )
490 wxLogLastError(wxT("UnregisterClass(no redraw canvas)"));
494 #endif // __WXMICROWIN__
499 void wxApp::CleanUp()
501 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
502 wxSetKeyboardHook(FALSE
);
509 if ( wxDisableButtonBrush
)
510 ::DeleteObject( wxDisableButtonBrush
);
516 // for an EXE the classes are unregistered when it terminates but DLL may
517 // be loaded several times (load/unload/load) into the same process in
518 // which case the registration will fail after the first time if we don't
519 // unregister the classes now
520 UnregisterWindowClasses();
523 Ctl3dUnregister(wxhInstance
);
526 delete wxWinHandleHash
;
527 wxWinHandleHash
= NULL
;
529 wxAppBase::CleanUp();
532 // ----------------------------------------------------------------------------
534 // ----------------------------------------------------------------------------
538 m_printMode
= wxPRINT_WINDOWS
;
543 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
544 // don't come from main(), so we have to free them
548 // m_argv elements were allocated by wxStrdup()
552 // but m_argv itself -- using new[]
556 bool wxApp::Initialized()
563 #else // Assume initialized if DLL (no way of telling)
569 * Get and process a message, returning FALSE if WM_QUIT
570 * received (and also set the flag telling the app to exit the main loop)
573 bool wxApp::DoMessage()
575 BOOL rc
= ::GetMessage(&s_currentMsg
, (HWND
) NULL
, 0, 0);
585 // should never happen, but let's test for it nevertheless
586 wxLogLastError(wxT("GetMessage"));
591 wxASSERT_MSG( wxThread::IsMain(),
592 wxT("only the main thread can process Windows messages") );
594 static bool s_hadGuiLock
= TRUE
;
595 static wxMsgArray s_aSavedMessages
;
597 // if a secondary thread owns is doing GUI calls, save all messages for
598 // later processing - we can't process them right now because it will
599 // lead to recursive library calls (and we're not reentrant)
600 if ( !wxGuiOwnedByMainThread() )
602 s_hadGuiLock
= FALSE
;
604 // leave out WM_COMMAND messages: too dangerous, sometimes
605 // the message will be processed twice
606 if ( !wxIsWaitingForThread() ||
607 s_currentMsg
.message
!= WM_COMMAND
)
609 s_aSavedMessages
.Add(s_currentMsg
);
616 // have we just regained the GUI lock? if so, post all of the saved
619 // FIXME of course, it's not _exactly_ the same as processing the
620 // messages normally - expect some things to break...
625 size_t count
= s_aSavedMessages
.GetCount();
626 for ( size_t n
= 0; n
< count
; n
++ )
628 MSG
& msg
= s_aSavedMessages
[n
];
630 DoMessage((WXMSG
*)&msg
);
633 s_aSavedMessages
.Empty();
636 #endif // wxUSE_THREADS
638 // Process the message
639 DoMessage((WXMSG
*)&s_currentMsg
);
645 void wxApp::DoMessage(WXMSG
*pMsg
)
647 if ( !ProcessMessage(pMsg
) )
649 ::TranslateMessage((MSG
*)pMsg
);
650 ::DispatchMessage((MSG
*)pMsg
);
655 * Keep trying to process messages until WM_QUIT
658 * If there are messages to be processed, they will all be
659 * processed and OnIdle will not be called.
660 * When there are no more messages, OnIdle is called.
661 * If OnIdle requests more time,
662 * it will be repeatedly called so long as there are no pending messages.
663 * A 'feature' of this is that once OnIdle has decided that no more processing
664 * is required, then it won't get processing time until further messages
665 * are processed (it'll sit in DoMessage).
668 int wxApp::MainLoop()
672 while ( m_keepGoing
)
675 wxMutexGuiLeaveOrEnter();
676 #endif // wxUSE_THREADS
678 while ( !Pending() && ProcessIdle() )
681 // a message came or no more idle processing to do
685 return s_currentMsg
.wParam
;
688 void wxApp::ExitMainLoop()
690 // this will set m_keepGoing to FALSE a bit later
691 ::PostQuitMessage(0);
694 bool wxApp::Pending()
696 return ::PeekMessage(&s_currentMsg
, 0, 0, 0, PM_NOREMOVE
) != 0;
699 void wxApp::Dispatch()
705 * Give all windows a chance to preprocess
706 * the message. Some may have accelerator tables, or have
710 bool wxApp::ProcessMessage(WXMSG
*wxmsg
)
712 MSG
*msg
= (MSG
*)wxmsg
;
713 HWND hwnd
= msg
->hwnd
;
714 wxWindow
*wndThis
= wxGetWindowFromHWND((WXHWND
)hwnd
);
716 // this may happen if the event occured in a standard modeless dialog (the
717 // only example of which I know of is the find/replace dialog) - then call
718 // IsDialogMessage() to make TAB navigation in it work
721 // we need to find the dialog containing this control as
722 // IsDialogMessage() just eats all the messages (i.e. returns TRUE for
723 // them) if we call it for the control itself
724 while ( hwnd
&& ::GetWindowLong(hwnd
, GWL_STYLE
) & WS_CHILD
)
726 hwnd
= ::GetParent(hwnd
);
729 return hwnd
&& ::IsDialogMessage(hwnd
, msg
) != 0;
733 // we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
734 // popup the tooltip bubbles
735 if ( (msg
->message
== WM_MOUSEMOVE
) )
737 wxToolTip
*tt
= wndThis
->GetToolTip();
740 tt
->RelayEvent(wxmsg
);
743 #endif // wxUSE_TOOLTIPS
745 // allow the window to prevent certain messages from being
746 // translated/processed (this is currently used by wxTextCtrl to always
747 // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
748 if ( !wndThis
->MSWShouldPreProcessMessage(wxmsg
) )
753 // try translations first: the accelerators override everything
756 for ( wnd
= wndThis
; wnd
; wnd
= wnd
->GetParent() )
758 if ( wnd
->MSWTranslateMessage(wxmsg
))
761 // stop at first top level window, i.e. don't try to process the key
762 // strokes originating in a dialog using the accelerators of the parent
763 // frame - this doesn't make much sense
764 if ( wnd
->IsTopLevel() )
768 // now try the other hooks (kbd navigation is handled here): we start from
769 // wndThis->GetParent() because wndThis->MSWProcessMessage() was already
771 for ( wnd
= wndThis
->GetParent(); wnd
; wnd
= wnd
->GetParent() )
773 if ( wnd
->MSWProcessMessage(wxmsg
) )
777 // no special preprocessing for this message, dispatch it normally
781 // this is a temporary hack and will be replaced by using wxEventLoop in the
784 // it is needed to allow other event loops (currently only one: the modal
785 // dialog one) to reset the OnIdle() semaphore because otherwise OnIdle()
786 // wouldn't do anything while a modal dialog shown from OnIdle() call is shown.
787 bool wxIsInOnIdleFlag
= FALSE
;
789 void wxApp::OnIdle(wxIdleEvent
& event
)
791 // Avoid recursion (via ProcessEvent default case)
792 if ( wxIsInOnIdleFlag
)
795 wxIsInOnIdleFlag
= TRUE
;
797 // If there are pending events, we must process them: pending events
798 // are either events to the threads other than main or events posted
799 // with wxPostEvent() functions
800 // GRG: I have moved this here so that all pending events are processed
801 // before starting to delete any objects. This behaves better (in
802 // particular, wrt wxPostEvent) and is coherent with wxGTK's current
803 // behaviour. Changed Feb/2000 before 2.1.14
804 ProcessPendingEvents();
806 // 'Garbage' collection of windows deleted with Close().
807 DeletePendingObjects();
810 // flush the logged messages if any
811 wxLog::FlushActive();
814 #if wxUSE_DC_CACHEING
815 // automated DC cache management: clear the cached DCs and bitmap
816 // if it's likely that the app has finished with them, that is, we
817 // get an idle event and we're not dragging anything.
818 if (!::GetKeyState(MK_LBUTTON
) && !::GetKeyState(MK_MBUTTON
) && !::GetKeyState(MK_RBUTTON
))
820 #endif // wxUSE_DC_CACHEING
822 // Send OnIdle events to all windows
823 if ( SendIdleEvents() )
825 // SendIdleEvents() returns TRUE if at least one window requested more
827 event
.RequestMore(TRUE
);
830 wxIsInOnIdleFlag
= FALSE
;
833 void wxApp::WakeUpIdle()
835 // Send the top window a dummy message so idle handler processing will
836 // start up again. Doing it this way ensures that the idle handler
837 // wakes up in the right thread (see also wxWakeUpMainThread() which does
838 // the same for the main app thread only)
839 wxWindow
*topWindow
= wxTheApp
->GetTopWindow();
842 if ( !::PostMessage(GetHwndOf(topWindow
), WM_NULL
, 0, 0) )
844 // should never happen
845 wxLogLastError(wxT("PostMessage(WM_NULL)"));
850 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
853 GetTopWindow()->Close(TRUE
);
856 // Default behaviour: close the application with prompts. The
857 // user can veto the close, and therefore the end session.
858 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
862 if (!GetTopWindow()->Close(!event
.CanVeto()))
867 typedef struct _WXADllVersionInfo
870 DWORD dwMajorVersion
; // Major version
871 DWORD dwMinorVersion
; // Minor version
872 DWORD dwBuildNumber
; // Build number
873 DWORD dwPlatformID
; // DLLVER_PLATFORM_*
876 typedef HRESULT (CALLBACK
* WXADLLGETVERSIONPROC
)(WXADLLVERSIONINFO
*);
879 int wxApp::GetComCtl32Version()
881 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
885 static int s_verComCtl32
= -1;
887 wxCRIT_SECT_DECLARE(csComCtl32
);
888 wxCRIT_SECT_LOCKER(lock
, csComCtl32
);
890 if ( s_verComCtl32
== -1 )
892 // initally assume no comctl32.dll at all
896 HMODULE hModuleComCtl32
= ::GetModuleHandle(wxT("COMCTL32"));
897 BOOL bFreeComCtl32
= FALSE
;
900 hModuleComCtl32
= ::LoadLibrary(wxT("COMCTL32.DLL")) ;
903 bFreeComCtl32
= TRUE
;
907 // if so, then we can check for the version
908 if ( hModuleComCtl32
)
910 // try to use DllGetVersion() if available in _headers_
911 WXADLLGETVERSIONPROC pfnDllGetVersion
= (WXADLLGETVERSIONPROC
)
912 ::GetProcAddress(hModuleComCtl32
, "DllGetVersion");
913 if ( pfnDllGetVersion
)
915 WXADLLVERSIONINFO dvi
;
916 dvi
.cbSize
= sizeof(dvi
);
918 HRESULT hr
= (*pfnDllGetVersion
)(&dvi
);
921 wxLogApiError(_T("DllGetVersion"), hr
);
925 // this is incompatible with _WIN32_IE values, but
926 // compatible with the other values returned by
927 // GetComCtl32Version()
928 s_verComCtl32
= 100*dvi
.dwMajorVersion
+
932 // DllGetVersion() unavailable either during compile or
933 // run-time, try to guess the version otherwise
934 if ( !s_verComCtl32
)
936 // InitCommonControlsEx is unique to 4.70 and later
937 FARPROC theProc
= ::GetProcAddress
940 "InitCommonControlsEx"
945 // not found, must be 4.00
950 // many symbols appeared in comctl32 4.71, could use
951 // any of them except may be DllInstall
952 theProc
= ::GetProcAddress
959 // not found, must be 4.70
964 // found, must be 4.71
973 ::FreeLibrary(hModuleComCtl32
) ;
977 return s_verComCtl32
;
981 // Yield to incoming messages
983 bool wxApp::Yield(bool onlyIfNeeded
)
986 static bool s_inYield
= FALSE
;
989 // disable log flushing from here because a call to wxYield() shouldn't
990 // normally result in message boxes popping up &c
998 wxFAIL_MSG( wxT("wxYield called recursively" ) );
1006 // we don't want to process WM_QUIT from here - it should be processed in
1007 // the main event loop in order to stop it
1009 while ( PeekMessage(&msg
, (HWND
)0, 0, 0, PM_NOREMOVE
) &&
1010 msg
.message
!= WM_QUIT
)
1013 wxMutexGuiLeaveOrEnter();
1014 #endif // wxUSE_THREADS
1016 if ( !wxTheApp
->DoMessage() )
1020 // if there are pending events, we must process them.
1021 ProcessPendingEvents();
1024 // let the logs be flashed again