don't wait for Windows messages in WaitForThread() if we don't dispatch events (shoul...
[wxWidgets.git] / src / msw / basemsw.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/basemsw.cpp
3 // Purpose: misc stuff only used in console applications under MSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 22.06.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #endif //WX_PRECOMP
29
30 #include "wx/apptrait.h"
31 // MBN: this is a workaround for MSVC 5: if it is not #included in
32 // some wxBase file, wxRecursionGuard methods won't be exported from
33 // wxBase.dll, and MSVC 5 will give linker errors
34 #include "wx/recguard.h"
35
36 #include "wx/msw/private.h"
37
38 // ============================================================================
39 // wxAppTraits implementation
40 // ============================================================================
41
42 WXDWORD wxAppTraits::DoSimpleWaitForThread(WXHANDLE hThread)
43 {
44 return ::WaitForSingleObject((HANDLE)hThread, INFINITE);
45 }
46
47 // ============================================================================
48 // wxConsoleAppTraits implementation
49 // ============================================================================
50
51 void wxConsoleAppTraits::AlwaysYield()
52 {
53 // we need to use special logic to deal with WM_PAINT: as this pseudo
54 // message is generated automatically as long as there are invalidated
55 // windows belonging to this thread, we'd never return if we waited here
56 // until we have no more of them left. OTOH, this message is always the
57 // last one in the queue, so we can safely return as soon as we detect it
58 MSG msg;
59 while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
60 {
61 if ( msg.message == WM_PAINT )
62 break;
63 }
64 }
65
66 void *wxConsoleAppTraits::BeforeChildWaitLoop()
67 {
68 // nothing to do here
69 return NULL;
70 }
71
72 void wxConsoleAppTraits::AfterChildWaitLoop(void * WXUNUSED(data))
73 {
74 // nothing to do here
75 }
76
77 bool wxConsoleAppTraits::DoMessageFromThreadWait()
78 {
79 // nothing to process here
80 return true;
81 }
82
83 WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread)
84 {
85 return DoSimpleWaitForThread(hThread);
86 }
87