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__) && \
115 (!defined(_MSC_VER) || (_MSC_VER > 1100))
119 // ---------------------------------------------------------------------------
121 // ---------------------------------------------------------------------------
123 extern wxList WXDLLEXPORT wxPendingDelete
;
125 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
126 extern void wxSetKeyboardHook(bool doIt
);
131 // NB: all "NoRedraw" classes must have the same names as the "normal" classes
132 // with NR suffix - wxWindow::MSWCreate() supposes this
133 const wxChar
*wxCanvasClassName
= wxT("wxWindowClass");
134 const wxChar
*wxCanvasClassNameNR
= wxT("wxWindowClassNR");
135 const wxChar
*wxMDIFrameClassName
= wxT("wxMDIFrameClass");
136 const wxChar
*wxMDIFrameClassNameNoRedraw
= wxT("wxMDIFrameClassNR");
137 const wxChar
*wxMDIChildFrameClassName
= wxT("wxMDIChildFrameClass");
138 const wxChar
*wxMDIChildFrameClassNameNoRedraw
= wxT("wxMDIChildFrameClassNR");
140 HBRUSH wxDisableButtonBrush
= (HBRUSH
) 0;
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 LRESULT WXDLLEXPORT APIENTRY
wxWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
148 // ===========================================================================
149 // wxGUIAppTraits implementation
150 // ===========================================================================
152 // private class which we use to pass parameters from BeforeChildWaitLoop() to
153 // AfterChildWaitLoop()
154 struct ChildWaitLoopData
156 ChildWaitLoopData(wxWindowDisabler
*wd_
, wxWindow
*winActive_
)
159 winActive
= winActive_
;
162 wxWindowDisabler
*wd
;
166 void *wxGUIAppTraits::BeforeChildWaitLoop()
169 We use a dirty hack here to disable all application windows (which we
170 must do because otherwise the calls to wxYield() could lead to some very
171 unexpected reentrancies in the users code) but to avoid losing
172 focus/activation entirely when the child process terminates which would
173 happen if we simply disabled everything using wxWindowDisabler. Indeed,
174 remember that Windows will never activate a disabled window and when the
175 last childs window is closed and Windows looks for a window to activate
176 all our windows are still disabled. There is no way to enable them in
177 time because we don't know when the childs windows are going to be
178 closed, so the solution we use here is to keep one special tiny frame
179 enabled all the time. Then when the child terminates it will get
180 activated and when we close it below -- after reenabling all the other
181 windows! -- the previously active window becomes activated again and
186 // first disable all existing windows
187 wxWindowDisabler
*wd
= new wxWindowDisabler
;
189 // then create an "invisible" frame: it has minimal size, is positioned
190 // (hopefully) outside the screen and doesn't appear on the taskbar
191 wxWindow
*winActive
= new wxFrame
193 wxTheApp
->GetTopWindow(),
196 wxPoint(32600, 32600),
198 wxDEFAULT_FRAME_STYLE
| wxFRAME_NO_TASKBAR
202 return new ChildWaitLoopData(wd
, winActive
);
205 void wxGUIAppTraits::AlwaysYield()
210 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig
)
214 const ChildWaitLoopData
* const data
= (ChildWaitLoopData
*)dataOrig
;
218 // finally delete the dummy frame and, as wd has been already destroyed and
219 // the other windows reenabled, the activation is going to return to the
220 // window which had had it before
221 data
->winActive
->Destroy();
224 bool wxGUIAppTraits::DoMessageFromThreadWait()
226 return !wxTheApp
|| wxTheApp
->DoMessage();
229 // ===========================================================================
230 // wxApp implementation
231 // ===========================================================================
233 int wxApp::m_nCmdShow
= SW_SHOWNORMAL
;
235 // ---------------------------------------------------------------------------
237 // ---------------------------------------------------------------------------
239 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
241 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
242 EVT_IDLE(wxApp::OnIdle
)
243 EVT_END_SESSION(wxApp::OnEndSession
)
244 EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession
)
247 // class to ensure that wxAppBase::CleanUp() is called if our Initialize()
249 class wxCallBaseCleanup
252 wxCallBaseCleanup(wxApp
*app
) : m_app(app
) { }
253 ~wxCallBaseCleanup() { if ( m_app
) m_app
->wxAppBase::CleanUp(); }
255 void Dismiss() { m_app
= NULL
; }
262 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
264 if ( !wxAppBase::Initialize(argc
, argv
) )
267 // ensure that base cleanup is done if we return too early
268 wxCallBaseCleanup
callBaseCleanup(this);
270 // the first thing to do is to check if we're trying to run an Unicode
271 // program under Win9x w/o MSLU emulation layer - if so, abort right now
272 // as it has no chance to work
273 #if wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
274 if ( wxGetOsVersion() != wxWINDOWS_NT
&& wxGetOsVersion() != wxWINDOWS_CE
)
276 // note that we can use MessageBoxW() as it's implemented even under
277 // Win9x - OTOH, we can't use wxGetTranslation() because the file APIs
278 // used by wxLocale are not
282 _T("This program uses Unicode and requires Windows NT/2000/XP/CE.\nProgram aborted."),
283 _T("wxWindows Fatal Error"),
289 #endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
291 #if defined(__WIN95__) && !defined(__WXMICROWIN__)
292 InitCommonControls();
295 #if wxUSE_OLE || wxUSE_DRAG_AND_DROP
298 // for OLE, enlarge message queue to be as large as possible
300 while (!SetMessageQueue(iMsg
) && (iMsg
-= 8))
305 // we need to initialize OLE library
307 if ( FAILED(::CoInitializeEx(NULL
, COINIT_MULTITHREADED
)) )
308 wxLogError(_("Cannot initialize OLE"));
310 if ( FAILED(::OleInitialize(NULL
)) )
311 wxLogError(_("Cannot initialize OLE"));
318 if (!Ctl3dRegister(wxhInstance
))
319 wxLogError(wxT("Cannot register CTL3D"));
321 Ctl3dAutoSubclass(wxhInstance
);
322 #endif // wxUSE_CTL3D
324 RegisterWindowClasses();
326 #if defined(__WXMICROWIN__) && !defined(__WXWINCE__)
327 // Create the brush for disabling bitmap buttons
330 lb
.lbStyle
= BS_PATTERN
;
332 lb
.lbHatch
= (int)LoadBitmap( wxhInstance
, wxT("wxDISABLE_BUTTON_BITMAP") );
335 wxDisableButtonBrush
= ::CreateBrushIndirect( & lb
);
336 ::DeleteObject( (HGDIOBJ
)lb
.lbHatch
);
338 //else: wxWindows resources are probably not linked in
345 wxWinHandleHash
= new wxWinHashTable(wxKEY_INTEGER
, 100);
347 // This is to foil optimizations in Visual C++ that throw out dummy.obj.
348 // PLEASE DO NOT ALTER THIS.
349 #if defined(__VISUALC__) && defined(__WIN16__) && !defined(WXMAKINGDLL)
350 extern char wxDummyChar
;
351 if (wxDummyChar
) wxDummyChar
++;
354 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
355 wxSetKeyboardHook(TRUE
);
358 callBaseCleanup
.Dismiss();
363 // ---------------------------------------------------------------------------
364 // RegisterWindowClasses
365 // ---------------------------------------------------------------------------
367 // TODO we should only register classes really used by the app. For this it
368 // would be enough to just delay the class registration until an attempt
369 // to create a window of this class is made.
370 bool wxApp::RegisterWindowClasses()
373 wxZeroMemory(wndclass
);
375 // for each class we register one with CS_(V|H)REDRAW style and one
376 // without for windows created with wxNO_FULL_REDRAW_ON_REPAINT flag
377 static const long styleNormal
= CS_HREDRAW
| CS_VREDRAW
| CS_DBLCLKS
;
378 static const long styleNoRedraw
= CS_DBLCLKS
;
380 // the fields which are common to all classes
381 wndclass
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
382 wndclass
.hInstance
= wxhInstance
;
383 wndclass
.hCursor
= ::LoadCursor((HINSTANCE
)NULL
, IDC_ARROW
);
385 // Register the frame window class.
386 wndclass
.hbrBackground
= (HBRUSH
)(COLOR_APPWORKSPACE
+ 1);
387 wndclass
.lpszClassName
= wxCanvasClassName
;
388 wndclass
.style
= styleNormal
;
390 if ( !RegisterClass(&wndclass
) )
392 wxLogLastError(wxT("RegisterClass(frame)"));
396 wndclass
.lpszClassName
= wxCanvasClassNameNR
;
397 wndclass
.style
= styleNoRedraw
;
399 if ( !RegisterClass(&wndclass
) )
401 wxLogLastError(wxT("RegisterClass(no redraw frame)"));
404 // Register the MDI frame window class.
405 wndclass
.hbrBackground
= (HBRUSH
)NULL
; // paint MDI frame ourselves
406 wndclass
.lpszClassName
= wxMDIFrameClassName
;
407 wndclass
.style
= styleNormal
;
409 if ( !RegisterClass(&wndclass
) )
411 wxLogLastError(wxT("RegisterClass(MDI parent)"));
414 // "no redraw" MDI frame
415 wndclass
.lpszClassName
= wxMDIFrameClassNameNoRedraw
;
416 wndclass
.style
= styleNoRedraw
;
418 if ( !RegisterClass(&wndclass
) )
420 wxLogLastError(wxT("RegisterClass(no redraw MDI parent frame)"));
423 // Register the MDI child frame window class.
424 wndclass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
425 wndclass
.lpszClassName
= wxMDIChildFrameClassName
;
426 wndclass
.style
= styleNormal
;
428 if ( !RegisterClass(&wndclass
) )
430 wxLogLastError(wxT("RegisterClass(MDI child)"));
433 // "no redraw" MDI child frame
434 wndclass
.lpszClassName
= wxMDIChildFrameClassNameNoRedraw
;
435 wndclass
.style
= styleNoRedraw
;
437 if ( !RegisterClass(&wndclass
) )
439 wxLogLastError(wxT("RegisterClass(no redraw MDI child)"));
445 // ---------------------------------------------------------------------------
446 // UnregisterWindowClasses
447 // ---------------------------------------------------------------------------
449 bool wxApp::UnregisterWindowClasses()
453 #ifndef __WXMICROWIN__
454 // MDI frame window class.
455 if ( !::UnregisterClass(wxMDIFrameClassName
, wxhInstance
) )
457 wxLogLastError(wxT("UnregisterClass(MDI parent)"));
462 // "no redraw" MDI frame
463 if ( !::UnregisterClass(wxMDIFrameClassNameNoRedraw
, wxhInstance
) )
465 wxLogLastError(wxT("UnregisterClass(no redraw MDI parent frame)"));
470 // MDI child frame window class.
471 if ( !::UnregisterClass(wxMDIChildFrameClassName
, wxhInstance
) )
473 wxLogLastError(wxT("UnregisterClass(MDI child)"));
478 // "no redraw" MDI child frame
479 if ( !::UnregisterClass(wxMDIChildFrameClassNameNoRedraw
, wxhInstance
) )
481 wxLogLastError(wxT("UnregisterClass(no redraw MDI child)"));
487 if ( !::UnregisterClass(wxCanvasClassName
, wxhInstance
) )
489 wxLogLastError(wxT("UnregisterClass(canvas)"));
494 if ( !::UnregisterClass(wxCanvasClassNameNR
, wxhInstance
) )
496 wxLogLastError(wxT("UnregisterClass(no redraw canvas)"));
500 #endif // __WXMICROWIN__
505 void wxApp::CleanUp()
507 #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
508 wxSetKeyboardHook(FALSE
);
515 if ( wxDisableButtonBrush
)
516 ::DeleteObject( wxDisableButtonBrush
);
526 // for an EXE the classes are unregistered when it terminates but DLL may
527 // be loaded several times (load/unload/load) into the same process in
528 // which case the registration will fail after the first time if we don't
529 // unregister the classes now
530 UnregisterWindowClasses();
533 Ctl3dUnregister(wxhInstance
);
536 delete wxWinHandleHash
;
537 wxWinHandleHash
= NULL
;
539 wxAppBase::CleanUp();
542 // ----------------------------------------------------------------------------
544 // ----------------------------------------------------------------------------
548 m_printMode
= wxPRINT_WINDOWS
;
553 // our cmd line arguments are allocated inside wxEntry(HINSTANCE), they
554 // don't come from main(), so we have to free them
558 // m_argv elements were allocated by wxStrdup()
562 // but m_argv itself -- using new[]
566 bool wxApp::Initialized()
573 #else // Assume initialized if DLL (no way of telling)
579 * Get and process a message, returning FALSE if WM_QUIT
580 * received (and also set the flag telling the app to exit the main loop)
583 bool wxApp::DoMessage()
585 BOOL rc
= ::GetMessage(&s_currentMsg
, (HWND
) NULL
, 0, 0);
595 // should never happen, but let's test for it nevertheless
596 wxLogLastError(wxT("GetMessage"));
601 wxASSERT_MSG( wxThread::IsMain(),
602 wxT("only the main thread can process Windows messages") );
604 static bool s_hadGuiLock
= TRUE
;
605 static wxMsgArray s_aSavedMessages
;
607 // if a secondary thread owns is doing GUI calls, save all messages for
608 // later processing - we can't process them right now because it will
609 // lead to recursive library calls (and we're not reentrant)
610 if ( !wxGuiOwnedByMainThread() )
612 s_hadGuiLock
= FALSE
;
614 // leave out WM_COMMAND messages: too dangerous, sometimes
615 // the message will be processed twice
616 if ( !wxIsWaitingForThread() ||
617 s_currentMsg
.message
!= WM_COMMAND
)
619 s_aSavedMessages
.Add(s_currentMsg
);
626 // have we just regained the GUI lock? if so, post all of the saved
629 // FIXME of course, it's not _exactly_ the same as processing the
630 // messages normally - expect some things to break...
635 size_t count
= s_aSavedMessages
.GetCount();
636 for ( size_t n
= 0; n
< count
; n
++ )
638 MSG
& msg
= s_aSavedMessages
[n
];
640 DoMessage((WXMSG
*)&msg
);
643 s_aSavedMessages
.Empty();
646 #endif // wxUSE_THREADS
648 // Process the message
649 DoMessage((WXMSG
*)&s_currentMsg
);
655 void wxApp::DoMessage(WXMSG
*pMsg
)
657 if ( !ProcessMessage(pMsg
) )
659 ::TranslateMessage((MSG
*)pMsg
);
660 ::DispatchMessage((MSG
*)pMsg
);
665 * Keep trying to process messages until WM_QUIT
668 * If there are messages to be processed, they will all be
669 * processed and OnIdle will not be called.
670 * When there are no more messages, OnIdle is called.
671 * If OnIdle requests more time,
672 * it will be repeatedly called so long as there are no pending messages.
673 * A 'feature' of this is that once OnIdle has decided that no more processing
674 * is required, then it won't get processing time until further messages
675 * are processed (it'll sit in DoMessage).
678 int wxApp::MainLoop()
682 while ( m_keepGoing
)
685 wxMutexGuiLeaveOrEnter();
686 #endif // wxUSE_THREADS
688 while ( !Pending() && ProcessIdle() )
691 // a message came or no more idle processing to do
695 return s_currentMsg
.wParam
;
698 void wxApp::ExitMainLoop()
700 // this will set m_keepGoing to FALSE a bit later
701 ::PostQuitMessage(0);
704 bool wxApp::Pending()
706 return ::PeekMessage(&s_currentMsg
, 0, 0, 0, PM_NOREMOVE
) != 0;
709 void wxApp::Dispatch()
715 * Give all windows a chance to preprocess
716 * the message. Some may have accelerator tables, or have
720 bool wxApp::ProcessMessage(WXMSG
*wxmsg
)
722 MSG
*msg
= (MSG
*)wxmsg
;
723 HWND hwnd
= msg
->hwnd
;
724 wxWindow
*wndThis
= wxGetWindowFromHWND((WXHWND
)hwnd
);
726 // this may happen if the event occured in a standard modeless dialog (the
727 // only example of which I know of is the find/replace dialog) - then call
728 // IsDialogMessage() to make TAB navigation in it work
731 // we need to find the dialog containing this control as
732 // IsDialogMessage() just eats all the messages (i.e. returns TRUE for
733 // them) if we call it for the control itself
734 while ( hwnd
&& ::GetWindowLong(hwnd
, GWL_STYLE
) & WS_CHILD
)
736 hwnd
= ::GetParent(hwnd
);
739 return hwnd
&& ::IsDialogMessage(hwnd
, msg
) != 0;
743 // we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
744 // popup the tooltip bubbles
745 if ( (msg
->message
== WM_MOUSEMOVE
) )
747 wxToolTip
*tt
= wndThis
->GetToolTip();
750 tt
->RelayEvent(wxmsg
);
753 #endif // wxUSE_TOOLTIPS
755 // allow the window to prevent certain messages from being
756 // translated/processed (this is currently used by wxTextCtrl to always
757 // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
758 if ( !wndThis
->MSWShouldPreProcessMessage(wxmsg
) )
763 // try translations first: the accelerators override everything
766 for ( wnd
= wndThis
; wnd
; wnd
= wnd
->GetParent() )
768 if ( wnd
->MSWTranslateMessage(wxmsg
))
771 // stop at first top level window, i.e. don't try to process the key
772 // strokes originating in a dialog using the accelerators of the parent
773 // frame - this doesn't make much sense
774 if ( wnd
->IsTopLevel() )
778 // now try the other hooks (kbd navigation is handled here): we start from
779 // wndThis->GetParent() because wndThis->MSWProcessMessage() was already
781 for ( wnd
= wndThis
->GetParent(); wnd
; wnd
= wnd
->GetParent() )
783 if ( wnd
->MSWProcessMessage(wxmsg
) )
787 // no special preprocessing for this message, dispatch it normally
791 // this is a temporary hack and will be replaced by using wxEventLoop in the
794 // it is needed to allow other event loops (currently only one: the modal
795 // dialog one) to reset the OnIdle() semaphore because otherwise OnIdle()
796 // wouldn't do anything while a modal dialog shown from OnIdle() call is shown.
797 bool wxIsInOnIdleFlag
= FALSE
;
799 void wxApp::OnIdle(wxIdleEvent
& event
)
801 // Avoid recursion (via ProcessEvent default case)
802 if ( wxIsInOnIdleFlag
)
805 wxIsInOnIdleFlag
= TRUE
;
807 wxAppBase::OnIdle(event
);
809 #if wxUSE_DC_CACHEING
810 // automated DC cache management: clear the cached DCs and bitmap
811 // if it's likely that the app has finished with them, that is, we
812 // get an idle event and we're not dragging anything.
813 if (!::GetKeyState(MK_LBUTTON
) && !::GetKeyState(MK_MBUTTON
) && !::GetKeyState(MK_RBUTTON
))
815 #endif // wxUSE_DC_CACHEING
817 wxIsInOnIdleFlag
= FALSE
;
820 void wxApp::WakeUpIdle()
822 // Send the top window a dummy message so idle handler processing will
823 // start up again. Doing it this way ensures that the idle handler
824 // wakes up in the right thread (see also wxWakeUpMainThread() which does
825 // the same for the main app thread only)
826 wxWindow
*topWindow
= wxTheApp
->GetTopWindow();
829 if ( !::PostMessage(GetHwndOf(topWindow
), WM_NULL
, 0, 0) )
831 // should never happen
832 wxLogLastError(wxT("PostMessage(WM_NULL)"));
837 void wxApp::OnEndSession(wxCloseEvent
& WXUNUSED(event
))
840 GetTopWindow()->Close(TRUE
);
843 // Default behaviour: close the application with prompts. The
844 // user can veto the close, and therefore the end session.
845 void wxApp::OnQueryEndSession(wxCloseEvent
& event
)
849 if (!GetTopWindow()->Close(!event
.CanVeto()))
854 typedef struct _WXADllVersionInfo
857 DWORD dwMajorVersion
; // Major version
858 DWORD dwMinorVersion
; // Minor version
859 DWORD dwBuildNumber
; // Build number
860 DWORD dwPlatformID
; // DLLVER_PLATFORM_*
863 typedef HRESULT (CALLBACK
* WXADLLGETVERSIONPROC
)(WXADLLVERSIONINFO
*);
866 int wxApp::GetComCtl32Version()
868 #if defined(__WXMICROWIN__) || defined(__WXWINCE__)
872 static int s_verComCtl32
= -1;
874 wxCRIT_SECT_DECLARE(csComCtl32
);
875 wxCRIT_SECT_LOCKER(lock
, csComCtl32
);
877 if ( s_verComCtl32
== -1 )
879 // initally assume no comctl32.dll at all
883 HMODULE hModuleComCtl32
= ::GetModuleHandle(wxT("COMCTL32"));
884 BOOL bFreeComCtl32
= FALSE
;
887 hModuleComCtl32
= ::LoadLibrary(wxT("COMCTL32.DLL")) ;
890 bFreeComCtl32
= TRUE
;
894 // if so, then we can check for the version
895 if ( hModuleComCtl32
)
897 // try to use DllGetVersion() if available in _headers_
898 WXADLLGETVERSIONPROC pfnDllGetVersion
= (WXADLLGETVERSIONPROC
)
899 ::GetProcAddress(hModuleComCtl32
, "DllGetVersion");
900 if ( pfnDllGetVersion
)
902 WXADLLVERSIONINFO dvi
;
903 dvi
.cbSize
= sizeof(dvi
);
905 HRESULT hr
= (*pfnDllGetVersion
)(&dvi
);
908 wxLogApiError(_T("DllGetVersion"), hr
);
912 // this is incompatible with _WIN32_IE values, but
913 // compatible with the other values returned by
914 // GetComCtl32Version()
915 s_verComCtl32
= 100*dvi
.dwMajorVersion
+
919 // DllGetVersion() unavailable either during compile or
920 // run-time, try to guess the version otherwise
921 if ( !s_verComCtl32
)
923 // InitCommonControlsEx is unique to 4.70 and later
924 FARPROC theProc
= ::GetProcAddress
927 "InitCommonControlsEx"
932 // not found, must be 4.00
937 // many symbols appeared in comctl32 4.71, could use
938 // any of them except may be DllInstall
939 theProc
= ::GetProcAddress
946 // not found, must be 4.70
951 // found, must be 4.71
960 ::FreeLibrary(hModuleComCtl32
) ;
964 return s_verComCtl32
;
968 // Yield to incoming messages
970 bool wxApp::Yield(bool onlyIfNeeded
)
973 static bool s_inYield
= FALSE
;
976 // disable log flushing from here because a call to wxYield() shouldn't
977 // normally result in message boxes popping up &c
985 wxFAIL_MSG( wxT("wxYield called recursively" ) );
993 // we don't want to process WM_QUIT from here - it should be processed in
994 // the main event loop in order to stop it
996 while ( PeekMessage(&msg
, (HWND
)0, 0, 0, PM_NOREMOVE
) &&
997 msg
.message
!= WM_QUIT
)
1000 wxMutexGuiLeaveOrEnter();
1001 #endif // wxUSE_THREADS
1003 if ( !wxTheApp
->DoMessage() )
1007 // if there are pending events, we must process them.
1008 ProcessPendingEvents();
1011 // let the logs be flashed again