]> git.saurik.com Git - wxWidgets.git/blob - src/msw/basemsw.cpp
Do not propagate key events from child controls unless they have modifiers
[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 #include "wx/evtloop.h"
32 #include "wx/msw/private/timer.h"
33 // MBN: this is a workaround for MSVC 5: if it is not #included in
34 // some wxBase file, wxRecursionGuard methods won't be exported from
35 // wxBase.dll, and MSVC 5 will give linker errors
36 #include "wx/recguard.h"
37
38 #include "wx/crt.h"
39 #include "wx/msw/private.h"
40
41 // ============================================================================
42 // wxAppTraits implementation
43 // ============================================================================
44
45 WXDWORD wxAppTraits::DoSimpleWaitForThread(WXHANDLE hThread)
46 {
47 return ::WaitForSingleObject((HANDLE)hThread, INFINITE);
48 }
49
50 // ============================================================================
51 // wxConsoleAppTraits implementation
52 // ============================================================================
53
54 void wxConsoleAppTraits::AlwaysYield()
55 {
56 // we need to use special logic to deal with WM_PAINT: as this pseudo
57 // message is generated automatically as long as there are invalidated
58 // windows belonging to this thread, we'd never return if we waited here
59 // until we have no more of them left. OTOH, this message is always the
60 // last one in the queue, so we can safely return as soon as we detect it
61 MSG msg;
62 while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
63 {
64 if ( msg.message == WM_PAINT )
65 break;
66 }
67 }
68
69 void *wxConsoleAppTraits::BeforeChildWaitLoop()
70 {
71 // nothing to do here
72 return NULL;
73 }
74
75 void wxConsoleAppTraits::AfterChildWaitLoop(void * WXUNUSED(data))
76 {
77 // nothing to do here
78 }
79
80 bool wxConsoleAppTraits::DoMessageFromThreadWait()
81 {
82 // nothing to process here
83 return true;
84 }
85
86 #if wxUSE_TIMER
87
88 wxTimerImpl *wxConsoleAppTraits::CreateTimerImpl(wxTimer *timer)
89 {
90 return new wxMSWTimerImpl(timer);
91 }
92
93 #endif // wxUSE_TIMER
94
95 wxEventLoopBase *wxConsoleAppTraits::CreateEventLoop()
96 {
97 #if wxUSE_CONSOLE_EVENTLOOP
98 return new wxEventLoop();
99 #else // !wxUSE_CONSOLE_EVENTLOOP
100 return NULL;
101 #endif // wxUSE_CONSOLE_EVENTLOOP/!wxUSE_CONSOLE_EVENTLOOP
102 }
103
104
105 WXDWORD wxConsoleAppTraits::WaitForThread(WXHANDLE hThread)
106 {
107 return DoSimpleWaitForThread(hThread);
108 }
109
110 bool wxConsoleAppTraits::WriteToStderr(const wxString& text)
111 {
112 return wxFprintf(stderr, "%s", text) != -1;
113 }