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