]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
faa49bfd WS |
2 | // Name: src/msw/window.cpp |
3 | // Purpose: wxWindowMSW | |
2bda0e17 | 4 | // Author: Julian Smart |
a23fd0e1 | 5 | // Modified by: VZ on 13.05.99: no more Default(), MSWOnXXX() reorganisation |
2bda0e17 KB |
6 | // Created: 04/01/98 |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
a23fd0e1 VZ |
12 | // =========================================================================== |
13 | // declarations | |
14 | // =========================================================================== | |
15 | ||
16 | // --------------------------------------------------------------------------- | |
17 | // headers | |
18 | // --------------------------------------------------------------------------- | |
19 | ||
2bda0e17 KB |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
09914df7 | 24 | #pragma hdrstop |
2bda0e17 KB |
25 | #endif |
26 | ||
e4db172a WS |
27 | #include "wx/window.h" |
28 | ||
2bda0e17 | 29 | #ifndef WX_PRECOMP |
9ed0d735 | 30 | #include "wx/msw/wrapwin.h" |
57bd4c60 WS |
31 | #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly" |
32 | #include "wx/msw/missing.h" | |
0c589ad0 | 33 | #include "wx/accel.h" |
3a19e16d VZ |
34 | #include "wx/menu.h" |
35 | #include "wx/dc.h" | |
36 | #include "wx/dcclient.h" | |
8e92ccef | 37 | #include "wx/dcmemory.h" |
3a19e16d VZ |
38 | #include "wx/utils.h" |
39 | #include "wx/app.h" | |
3a19e16d VZ |
40 | #include "wx/layout.h" |
41 | #include "wx/dialog.h" | |
42 | #include "wx/frame.h" | |
43 | #include "wx/listbox.h" | |
44 | #include "wx/button.h" | |
3a19e16d | 45 | #include "wx/msgdlg.h" |
1f3943e0 | 46 | #include "wx/settings.h" |
8d753488 | 47 | #include "wx/statbox.h" |
1e2aa2f8 | 48 | #include "wx/sizer.h" |
88a7a4e1 | 49 | #include "wx/intl.h" |
e4db172a | 50 | #include "wx/log.h" |
fec9cc08 | 51 | #include "wx/textctrl.h" |
25466131 | 52 | #include "wx/menuitem.h" |
02761f6c | 53 | #include "wx/module.h" |
2bda0e17 KB |
54 | #endif |
55 | ||
61fef19b | 56 | #if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__) |
09914df7 | 57 | #include "wx/ownerdrw.h" |
2bda0e17 KB |
58 | #endif |
59 | ||
5acec112 | 60 | #include "wx/hashmap.h" |
a3dc1da9 | 61 | #include "wx/evtloop.h" |
355debca | 62 | #include "wx/power.h" |
c6430ed0 | 63 | #include "wx/sysopt.h" |
d79df32c | 64 | |
9e2896e5 VZ |
65 | #if wxUSE_DRAG_AND_DROP |
66 | #include "wx/dnd.h" | |
2bda0e17 KB |
67 | #endif |
68 | ||
ed5317e5 JS |
69 | #if wxUSE_ACCESSIBILITY |
70 | #include "wx/access.h" | |
bef8d481 | 71 | #include <ole2.h> |
ed5317e5 JS |
72 | #include <oleacc.h> |
73 | #ifndef WM_GETOBJECT | |
74 | #define WM_GETOBJECT 0x003D | |
75 | #endif | |
76 | #ifndef OBJID_CLIENT | |
77 | #define OBJID_CLIENT 0xFFFFFFFC | |
78 | #endif | |
79 | #endif | |
80 | ||
0c589ad0 BM |
81 | #include "wx/msw/private.h" |
82 | ||
750b78ba | 83 | #if wxUSE_TOOLTIPS |
42e69d6b | 84 | #include "wx/tooltip.h" |
750b78ba JS |
85 | #endif |
86 | ||
789295bf VZ |
87 | #if wxUSE_CARET |
88 | #include "wx/caret.h" | |
89 | #endif // wxUSE_CARET | |
90 | ||
6fe19057 VZ |
91 | #if wxUSE_SPINCTRL |
92 | #include "wx/spinctrl.h" | |
93 | #endif // wxUSE_SPINCTRL | |
94 | ||
d9317fd4 | 95 | #include "wx/notebook.h" |
5c6c3176 | 96 | #include "wx/listctrl.h" |
aafb9978 | 97 | #include "wx/dynlib.h" |
2a47d3c1 | 98 | |
2bda0e17 KB |
99 | #include <string.h> |
100 | ||
d61c1a6f | 101 | #if (!defined(__GNUWIN32_OLD__) && !defined(__WXMICROWIN__) /* && !defined(__WXWINCE__) */ ) || defined(__CYGWIN10__) |
3a19e16d VZ |
102 | #include <shellapi.h> |
103 | #include <mmsystem.h> | |
2bda0e17 KB |
104 | #endif |
105 | ||
106 | #ifdef __WIN32__ | |
3a19e16d | 107 | #include <windowsx.h> |
2bda0e17 KB |
108 | #endif |
109 | ||
dcfd4ac4 | 110 | #if !defined __WXWINCE__ && !defined NEED_PBT_H |
dbc74bcc WS |
111 | #include <pbt.h> |
112 | #endif | |
2bda0e17 | 113 | |
7f0586ef | 114 | #if defined(__WXWINCE__) |
4e5c6c33 | 115 | #include "wx/msw/wince/missing.h" |
7d4f65e3 JS |
116 | #ifdef __POCKETPC__ |
117 | #include <windows.h> | |
118 | #include <shellapi.h> | |
119 | #include <ole2.h> | |
120 | #include <aygshell.h> | |
121 | #endif | |
7f0586ef JS |
122 | #endif |
123 | ||
aafb9978 | 124 | #if defined(TME_LEAVE) && defined(WM_MOUSELEAVE) && wxUSE_DYNLIB_CLASS |
4e5c6c33 VZ |
125 | #define HAVE_TRACKMOUSEEVENT |
126 | #endif // everything needed for TrackMouseEvent() | |
127 | ||
7d86a2d4 VZ |
128 | // if this is set to 1, we use deferred window sizing to reduce flicker when |
129 | // resizing complicated window hierarchies, but this can in theory result in | |
130 | // different behaviour than the old code so we keep the possibility to use it | |
131 | // by setting this to 0 (in the future this should be removed completely) | |
f2197644 JS |
132 | #ifdef __WXWINCE__ |
133 | #define USE_DEFERRED_SIZING 0 | |
134 | #else | |
8e44f3ca | 135 | #define USE_DEFERRED_SIZING 1 |
f2197644 | 136 | #endif |
8e44f3ca | 137 | |
c358ea41 VZ |
138 | // set this to 1 to filter out duplicate mouse events, e.g. mouse move events |
139 | // when mouse position didnd't change | |
140 | #ifdef __WXWINCE__ | |
141 | #define wxUSE_MOUSEEVENT_HACK 0 | |
142 | #else | |
143 | #define wxUSE_MOUSEEVENT_HACK 1 | |
144 | #endif | |
145 | ||
a23fd0e1 | 146 | // --------------------------------------------------------------------------- |
42e69d6b | 147 | // global variables |
a23fd0e1 | 148 | // --------------------------------------------------------------------------- |
47cbd6da | 149 | |
1e6feb95 | 150 | #if wxUSE_MENUS_NATIVE |
2bda0e17 | 151 | wxMenu *wxCurrentPopupMenu = NULL; |
1e6feb95 VZ |
152 | #endif // wxUSE_MENUS_NATIVE |
153 | ||
46fa338b RR |
154 | #ifdef __WXWINCE__ |
155 | extern wxChar *wxCanvasClassName; | |
156 | #else | |
2ffa221c | 157 | extern const wxChar *wxCanvasClassName; |
46fa338b | 158 | #endif |
42e69d6b | 159 | |
90c1530a VZ |
160 | // true if we had already created the std colour map, used by |
161 | // wxGetStdColourMap() and wxWindow::OnSysColourChanged() (FIXME-MT) | |
08158721 | 162 | static bool gs_hasStdCmap = false; |
90c1530a | 163 | |
c358ea41 VZ |
164 | // last mouse event information we need to filter out the duplicates |
165 | #if wxUSE_MOUSEEVENT_HACK | |
2b053ae9 | 166 | static struct MouseEventInfoDummy |
c358ea41 VZ |
167 | { |
168 | // mouse position (in screen coordinates) | |
169 | wxPoint pos; | |
170 | ||
171 | // last mouse event type | |
172 | wxEventType type; | |
173 | } gs_lastMouseEvent; | |
174 | #endif // wxUSE_MOUSEEVENT_HACK | |
175 | ||
5acec112 VZ |
176 | // hash containing the registered handlers for the custom messages |
177 | WX_DECLARE_HASH_MAP(int, wxWindow::MSWMessageHandler, | |
178 | wxIntegerHash, wxIntegerEqual, | |
179 | MSWMessageHandlers); | |
180 | ||
181 | static MSWMessageHandlers gs_messageHandlers; | |
182 | ||
42e69d6b VZ |
183 | // --------------------------------------------------------------------------- |
184 | // private functions | |
185 | // --------------------------------------------------------------------------- | |
186 | ||
187 | // the window proc for all our windows | |
3135f4a7 | 188 | LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, |
42e69d6b | 189 | WPARAM wParam, LPARAM lParam); |
577baeef | 190 | |
42e69d6b VZ |
191 | |
192 | #ifdef __WXDEBUG__ | |
4a712ba3 | 193 | const wxChar *wxGetMessageName(int message); |
42e69d6b | 194 | #endif //__WXDEBUG__ |
2bda0e17 | 195 | |
1e6feb95 | 196 | void wxRemoveHandleAssociation(wxWindowMSW *win); |
cc972ac6 | 197 | extern void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win); |
2bda0e17 KB |
198 | wxWindow *wxFindWinFromHandle(WXHWND hWnd); |
199 | ||
f6bcfd97 | 200 | // get the text metrics for the current font |
1e6feb95 VZ |
201 | static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win); |
202 | ||
42b1fb63 | 203 | #ifdef __WXWINCE__ |
dfafa702 | 204 | // find the window for the mouse event at the specified position |
42b1fb63 VZ |
205 | static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y); |
206 | #endif // __WXWINCE__ | |
dfafa702 | 207 | |
c48926e1 | 208 | // wrapper around BringWindowToTop() API |
44d5b352 | 209 | static inline void wxBringWindowToTop(HWND hwnd) |
c48926e1 VZ |
210 | { |
211 | #ifdef __WXMICROWIN__ | |
212 | // It seems that MicroWindows brings the _parent_ of the window to the top, | |
213 | // which can be the wrong one. | |
214 | ||
215 | // activate (set focus to) specified window | |
216 | ::SetFocus(hwnd); | |
313901f3 | 217 | #endif |
c48926e1 VZ |
218 | |
219 | // raise top level parent to top of z order | |
313901f3 | 220 | if (!::SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)) |
c48926e1 | 221 | { |
313901f3 | 222 | wxLogLastError(_T("SetWindowPos")); |
c48926e1 | 223 | } |
c48926e1 | 224 | } |
f6bcfd97 | 225 | |
e0c5c96f VZ |
226 | #ifndef __WXWINCE__ |
227 | ||
ee471817 VZ |
228 | // ensure that all our parent windows have WS_EX_CONTROLPARENT style |
229 | static void EnsureParentHasControlParentStyle(wxWindow *parent) | |
230 | { | |
231 | /* | |
232 | If we have WS_EX_CONTROLPARENT flag we absolutely *must* set it for our | |
233 | parent as well as otherwise several Win32 functions using | |
234 | GetNextDlgTabItem() to iterate over all controls such as | |
235 | IsDialogMessage() or DefDlgProc() would enter an infinite loop: indeed, | |
236 | all of them iterate over all the controls starting from the currently | |
237 | focused one and stop iterating when they get back to the focus but | |
238 | unless all parents have WS_EX_CONTROLPARENT bit set, they would never | |
239 | get back to the initial (focused) window: as we do have this style, | |
240 | GetNextDlgTabItem() will leave this window and continue in its parent, | |
241 | but if the parent doesn't have it, it wouldn't recurse inside it later | |
90e572f1 | 242 | on and so wouldn't have a chance of getting back to this window either. |
ee471817 | 243 | */ |
ee471817 VZ |
244 | while ( parent && !parent->IsTopLevel() ) |
245 | { | |
246 | LONG exStyle = ::GetWindowLong(GetHwndOf(parent), GWL_EXSTYLE); | |
247 | if ( !(exStyle & WS_EX_CONTROLPARENT) ) | |
248 | { | |
249 | // force the parent to have this style | |
250 | ::SetWindowLong(GetHwndOf(parent), GWL_EXSTYLE, | |
251 | exStyle | WS_EX_CONTROLPARENT); | |
252 | } | |
253 | ||
254 | parent = parent->GetParent(); | |
255 | } | |
ee471817 VZ |
256 | } |
257 | ||
e0c5c96f VZ |
258 | #endif // !__WXWINCE__ |
259 | ||
f2325516 JS |
260 | #ifdef __WXWINCE__ |
261 | // On Windows CE, GetCursorPos can return an error, so use this function | |
262 | // instead | |
263 | bool GetCursorPosWinCE(POINT* pt) | |
264 | { | |
7d30268c JS |
265 | if (!GetCursorPos(pt)) |
266 | { | |
267 | DWORD pos = GetMessagePos(); | |
268 | pt->x = LOWORD(pos); | |
269 | pt->y = HIWORD(pos); | |
270 | } | |
f2325516 JS |
271 | return true; |
272 | } | |
273 | #endif | |
274 | ||
a23fd0e1 VZ |
275 | // --------------------------------------------------------------------------- |
276 | // event tables | |
277 | // --------------------------------------------------------------------------- | |
278 | ||
1e6feb95 VZ |
279 | // in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu() |
280 | // method | |
281 | #ifdef __WXUNIVERSAL__ | |
282 | IMPLEMENT_ABSTRACT_CLASS(wxWindowMSW, wxWindowBase) | |
283 | #else // __WXMSW__ | |
51596bcb | 284 | #if wxUSE_EXTENDED_RTTI |
6a89f9ee | 285 | |
f3291a82 SC |
286 | // windows that are created from a parent window during its Create method, eg. spin controls in a calendar controls |
287 | // must never been streamed out separately otherwise chaos occurs. Right now easiest is to test for negative ids, as | |
288 | // windows with negative ids never can be recreated anyway | |
289 | ||
290 | bool wxWindowStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & ) | |
291 | { | |
292 | const wxWindow * win = dynamic_cast<const wxWindow*>(object) ; | |
293 | if ( win && win->GetId() < 0 ) | |
294 | return false ; | |
295 | return true ; | |
296 | } | |
297 | ||
298 | IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxWindow, wxWindowBase,"wx/window.h", wxWindowStreamingCallback) | |
51596bcb | 299 | |
6a89f9ee SC |
300 | // make wxWindowList known before the property is used |
301 | ||
321239b6 | 302 | wxCOLLECTION_TYPE_INFO( wxWindow* , wxWindowList ) ; |
6a89f9ee SC |
303 | |
304 | template<> void wxCollectionToVariantArray( wxWindowList const &theList, wxxVariantArray &value) | |
305 | { | |
0c6b0084 | 306 | wxListCollectionToVariantArray<wxWindowList::compatibility_iterator>( theList , value ) ; |
6a89f9ee SC |
307 | } |
308 | ||
bc9fb572 JS |
309 | WX_DEFINE_FLAGS( wxWindowStyle ) |
310 | ||
321239b6 | 311 | wxBEGIN_FLAGS( wxWindowStyle ) |
bc9fb572 JS |
312 | // new style border flags, we put them first to |
313 | // use them for streaming out | |
5c6c3176 | 314 | |
321239b6 SC |
315 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
316 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
317 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
318 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
319 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
320 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
35bbb0c6 | 321 | |
bc9fb572 | 322 | // old style border flags |
321239b6 SC |
323 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
324 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
325 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
326 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
327 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 328 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
329 | |
330 | // standard window styles | |
321239b6 SC |
331 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
332 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
333 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
334 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 335 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
321239b6 SC |
336 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
337 | wxFLAGS_MEMBER(wxVSCROLL) | |
338 | wxFLAGS_MEMBER(wxHSCROLL) | |
339 | ||
340 | wxEND_FLAGS( wxWindowStyle ) | |
341 | ||
342 | wxBEGIN_PROPERTIES_TABLE(wxWindow) | |
3a3c8603 DS |
343 | wxEVENT_PROPERTY( Close , wxEVT_CLOSE_WINDOW , wxCloseEvent) |
344 | wxEVENT_PROPERTY( Create , wxEVT_CREATE , wxWindowCreateEvent ) | |
345 | wxEVENT_PROPERTY( Destroy , wxEVT_DESTROY , wxWindowDestroyEvent ) | |
51741307 SC |
346 | // Always constructor Properties first |
347 | ||
af498247 | 348 | wxREADONLY_PROPERTY( Parent,wxWindow*, GetParent, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
fb7e28db | 349 | wxPROPERTY( Id,wxWindowID, SetId, GetId, -1 /*wxID_ANY*/ , 0 /*flags*/ , wxT("Helpstring") , wxT("group") ) |
abb74e0f WS |
350 | wxPROPERTY( Position,wxPoint, SetPosition , GetPosition, wxDefaultPosition , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // pos |
351 | wxPROPERTY( Size,wxSize, SetSize, GetSize, wxDefaultSize , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // size | |
af498247 | 352 | wxPROPERTY( WindowStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
51741307 SC |
353 | |
354 | // Then all relations of the object graph | |
355 | ||
321239b6 | 356 | wxREADONLY_PROPERTY_COLLECTION( Children , wxWindowList , wxWindowBase* , GetWindowChildren , wxPROP_OBJECT_GRAPH /*flags*/ , wxT("Helpstring") , wxT("group")) |
51741307 SC |
357 | |
358 | // and finally all other properties | |
359 | ||
3a3c8603 DS |
360 | wxPROPERTY( ExtraStyle , long , SetExtraStyle , GetExtraStyle , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // extstyle |
361 | wxPROPERTY( BackgroundColour , wxColour , SetBackgroundColour , GetBackgroundColour , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // bg | |
362 | wxPROPERTY( ForegroundColour , wxColour , SetForegroundColour , GetForegroundColour , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // fg | |
363 | wxPROPERTY( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
364 | wxPROPERTY( Shown , bool , Show , IsShown , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
51741307 SC |
365 | #if 0 |
366 | // possible property candidates (not in xrc) or not valid in all subclasses | |
8b5d5223 | 367 | wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxEmptyString ) |
3a3c8603 | 368 | wxPROPERTY( Font , wxFont , SetFont , GetWindowFont , ) |
8b5d5223 | 369 | wxPROPERTY( Label,wxString, SetLabel, GetLabel, wxEmptyString ) |
3a3c8603 DS |
370 | // MaxHeight, Width , MinHeight , Width |
371 | // TODO switch label to control and title to toplevels | |
6a89f9ee | 372 | |
3a3c8603 DS |
373 | wxPROPERTY( ThemeEnabled , bool , SetThemeEnabled , GetThemeEnabled , ) |
374 | //wxPROPERTY( Cursor , wxCursor , SetCursor , GetCursor , ) | |
375 | // wxPROPERTY( ToolTip , wxString , SetToolTip , GetToolTipText , ) | |
376 | wxPROPERTY( AutoLayout , bool , SetAutoLayout , GetAutoLayout , ) | |
6a89f9ee SC |
377 | |
378 | ||
379 | ||
51741307 | 380 | #endif |
321239b6 | 381 | wxEND_PROPERTIES_TABLE() |
51596bcb | 382 | |
321239b6 SC |
383 | wxBEGIN_HANDLERS_TABLE(wxWindow) |
384 | wxEND_HANDLERS_TABLE() | |
51596bcb | 385 | |
321239b6 | 386 | wxCONSTRUCTOR_DUMMY(wxWindow) |
6a89f9ee | 387 | |
51596bcb | 388 | #else |
1e6feb95 | 389 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) |
51596bcb | 390 | #endif |
1e6feb95 VZ |
391 | #endif // __WXUNIVERSAL__/__WXMSW__ |
392 | ||
393 | BEGIN_EVENT_TABLE(wxWindowMSW, wxWindowBase) | |
1e6feb95 | 394 | EVT_SYS_COLOUR_CHANGED(wxWindowMSW::OnSysColourChanged) |
8681b094 | 395 | EVT_ERASE_BACKGROUND(wxWindowMSW::OnEraseBackground) |
79099b80 | 396 | #ifdef __WXWINCE__ |
1e6feb95 | 397 | EVT_INIT_DIALOG(wxWindowMSW::OnInitDialog) |
79099b80 | 398 | #endif |
2bda0e17 KB |
399 | END_EVENT_TABLE() |
400 | ||
a23fd0e1 VZ |
401 | // =========================================================================== |
402 | // implementation | |
403 | // =========================================================================== | |
404 | ||
42e69d6b VZ |
405 | // --------------------------------------------------------------------------- |
406 | // wxWindow utility functions | |
407 | // --------------------------------------------------------------------------- | |
408 | ||
2bda0e17 | 409 | // Find an item given the MS Windows id |
1e6feb95 | 410 | wxWindow *wxWindowMSW::FindItem(long id) const |
2bda0e17 | 411 | { |
1e6feb95 | 412 | #if wxUSE_CONTROLS |
f7637829 | 413 | wxControl *item = wxDynamicCastThis(wxControl); |
f048e32f VZ |
414 | if ( item ) |
415 | { | |
90e572f1 | 416 | // is it us or one of our "internal" children? |
1e6feb95 VZ |
417 | if ( item->GetId() == id |
418 | #ifndef __WXUNIVERSAL__ | |
419 | || (item->GetSubcontrols().Index(id) != wxNOT_FOUND) | |
420 | #endif // __WXUNIVERSAL__ | |
421 | ) | |
f048e32f VZ |
422 | { |
423 | return item; | |
424 | } | |
425 | } | |
1e6feb95 | 426 | #endif // wxUSE_CONTROLS |
f048e32f | 427 | |
222ed1d6 | 428 | wxWindowList::compatibility_iterator current = GetChildren().GetFirst(); |
2d0a075d JS |
429 | while (current) |
430 | { | |
42e69d6b | 431 | wxWindow *childWin = current->GetData(); |
2bda0e17 | 432 | |
42e69d6b | 433 | wxWindow *wnd = childWin->FindItem(id); |
cc2b7472 | 434 | if ( wnd ) |
42e69d6b | 435 | return wnd; |
2bda0e17 | 436 | |
42e69d6b | 437 | current = current->GetNext(); |
2bda0e17 | 438 | } |
42e69d6b | 439 | |
2d0a075d | 440 | return NULL; |
2bda0e17 KB |
441 | } |
442 | ||
443 | // Find an item given the MS Windows handle | |
1e6feb95 | 444 | wxWindow *wxWindowMSW::FindItemByHWND(WXHWND hWnd, bool controlOnly) const |
2bda0e17 | 445 | { |
222ed1d6 | 446 | wxWindowList::compatibility_iterator current = GetChildren().GetFirst(); |
2d0a075d | 447 | while (current) |
2bda0e17 | 448 | { |
42e69d6b VZ |
449 | wxWindow *parent = current->GetData(); |
450 | ||
2d0a075d | 451 | // Do a recursive search. |
42e69d6b | 452 | wxWindow *wnd = parent->FindItemByHWND(hWnd); |
cc2b7472 | 453 | if ( wnd ) |
42e69d6b | 454 | return wnd; |
2d0a075d | 455 | |
1e6feb95 VZ |
456 | if ( !controlOnly |
457 | #if wxUSE_CONTROLS | |
458 | || parent->IsKindOf(CLASSINFO(wxControl)) | |
459 | #endif // wxUSE_CONTROLS | |
460 | ) | |
2d0a075d | 461 | { |
42e69d6b VZ |
462 | wxWindow *item = current->GetData(); |
463 | if ( item->GetHWND() == hWnd ) | |
2d0a075d JS |
464 | return item; |
465 | else | |
466 | { | |
467 | if ( item->ContainsHWND(hWnd) ) | |
468 | return item; | |
469 | } | |
470 | } | |
42e69d6b VZ |
471 | |
472 | current = current->GetNext(); | |
2bda0e17 | 473 | } |
2d0a075d | 474 | return NULL; |
2bda0e17 KB |
475 | } |
476 | ||
477 | // Default command handler | |
1e6feb95 | 478 | bool wxWindowMSW::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) |
2bda0e17 | 479 | { |
08158721 | 480 | return false; |
2bda0e17 KB |
481 | } |
482 | ||
fd3f686c VZ |
483 | // ---------------------------------------------------------------------------- |
484 | // constructors and such | |
485 | // ---------------------------------------------------------------------------- | |
486 | ||
1e6feb95 | 487 | void wxWindowMSW::Init() |
2bda0e17 | 488 | { |
cc2b7472 | 489 | // MSW specific |
08158721 | 490 | m_isBeingDeleted = false; |
5a403e3f | 491 | m_oldWndProc = NULL; |
08158721 DS |
492 | m_mouseInWindow = false; |
493 | m_lastKeydownProcessed = false; | |
2bda0e17 | 494 | |
a1037371 | 495 | m_frozenness = 0; |
d7cbabe0 | 496 | |
319fefa9 | 497 | m_hWnd = 0; |
220f77b0 | 498 | m_hDWP = 0; |
319fefa9 | 499 | |
2d0a075d JS |
500 | m_xThumbSize = 0; |
501 | m_yThumbSize = 0; | |
2bda0e17 | 502 | |
67644c1d RD |
503 | m_pendingPosition = wxDefaultPosition; |
504 | m_pendingSize = wxDefaultSize; | |
7d4f65e3 JS |
505 | |
506 | #ifdef __POCKETPC__ | |
507 | m_contextMenuEnabled = false; | |
508 | #endif | |
fd3f686c VZ |
509 | } |
510 | ||
2bda0e17 | 511 | // Destructor |
1e6feb95 | 512 | wxWindowMSW::~wxWindowMSW() |
2bda0e17 | 513 | { |
08158721 | 514 | m_isBeingDeleted = true; |
2bda0e17 | 515 | |
2e9f62da | 516 | #ifndef __WXUNIVERSAL__ |
4a41c655 | 517 | // VS: make sure there's no wxFrame with last focus set to us: |
2e9f62da | 518 | for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) |
4a41c655 | 519 | { |
085ad686 | 520 | wxTopLevelWindow *frame = wxDynamicCast(win, wxTopLevelWindow); |
4a41c655 VS |
521 | if ( frame ) |
522 | { | |
c5053639 | 523 | if ( frame->GetLastFocus() == this ) |
2e9f62da | 524 | { |
085ad686 | 525 | frame->SetLastFocus(NULL); |
2e9f62da | 526 | } |
4552892f VZ |
527 | |
528 | // apparently sometimes we can end up with our grand parent | |
529 | // pointing to us as well: this is surely a bug in focus handling | |
530 | // code but it's not clear where it happens so for now just try to | |
531 | // fix it here by not breaking out of the loop | |
532 | //break; | |
4a41c655 VS |
533 | } |
534 | } | |
2e9f62da | 535 | #endif // __WXUNIVERSAL__ |
2bda0e17 | 536 | |
cc0c7cd8 | 537 | // VS: destroy children first and _then_ detach *this from its parent. |
90e572f1 | 538 | // If we did it the other way around, children wouldn't be able |
cc0c7cd8 VS |
539 | // find their parent frame (see above). |
540 | DestroyChildren(); | |
541 | ||
cc2b7472 | 542 | if ( m_hWnd ) |
42e69d6b | 543 | { |
98440bc3 VZ |
544 | // VZ: test temp removed to understand what really happens here |
545 | //if (::IsWindow(GetHwnd())) | |
df61c009 JS |
546 | { |
547 | if ( !::DestroyWindow(GetHwnd()) ) | |
f6bcfd97 | 548 | wxLogLastError(wxT("DestroyWindow")); |
df61c009 | 549 | } |
2bda0e17 | 550 | |
c50f1fb9 VZ |
551 | // remove hWnd <-> wxWindow association |
552 | wxRemoveHandleAssociation(this); | |
553 | } | |
d7cbabe0 | 554 | |
2bda0e17 KB |
555 | } |
556 | ||
fd3f686c | 557 | // real construction (Init() must have been called before!) |
1e6feb95 VZ |
558 | bool wxWindowMSW::Create(wxWindow *parent, |
559 | wxWindowID id, | |
560 | const wxPoint& pos, | |
561 | const wxSize& size, | |
562 | long style, | |
563 | const wxString& name) | |
2d0a075d | 564 | { |
08158721 | 565 | wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") ); |
2bda0e17 | 566 | |
8d99be5f | 567 | if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) |
08158721 | 568 | return false; |
42e69d6b | 569 | |
fd3f686c | 570 | parent->AddChild(this); |
2bda0e17 | 571 | |
b2d5a7ee | 572 | WXDWORD exstyle; |
e49d97e6 | 573 | DWORD msflags = MSWGetCreateWindowFlags(&exstyle); |
1e6feb95 VZ |
574 | |
575 | #ifdef __WXUNIVERSAL__ | |
d1fe917b | 576 | // no borders, we draw them ourselves |
76c79ff4 VZ |
577 | exstyle &= ~(WS_EX_DLGMODALFRAME | |
578 | WS_EX_STATICEDGE | | |
579 | WS_EX_CLIENTEDGE | | |
580 | WS_EX_WINDOWEDGE); | |
d1fe917b | 581 | msflags &= ~WS_BORDER; |
b2d5a7ee | 582 | #endif // wxUniversal |
1e6feb95 | 583 | |
ff792344 | 584 | if ( IsShown() ) |
e49d97e6 VZ |
585 | { |
586 | msflags |= WS_VISIBLE; | |
587 | } | |
1e6feb95 | 588 | |
45956e37 VZ |
589 | if ( !MSWCreate(wxCanvasClassName, NULL, pos, size, msflags, exstyle) ) |
590 | return false; | |
591 | ||
592 | InheritAttributes(); | |
593 | ||
594 | return true; | |
2bda0e17 KB |
595 | } |
596 | ||
42e69d6b VZ |
597 | // --------------------------------------------------------------------------- |
598 | // basic operations | |
599 | // --------------------------------------------------------------------------- | |
600 | ||
1e6feb95 | 601 | void wxWindowMSW::SetFocus() |
2bda0e17 | 602 | { |
a23fd0e1 | 603 | HWND hWnd = GetHwnd(); |
1e6feb95 VZ |
604 | wxCHECK_RET( hWnd, _T("can't set focus to invalid window") ); |
605 | ||
7f0586ef | 606 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
1e6feb95 | 607 | ::SetLastError(0); |
8cb172b4 | 608 | #endif |
d0a3d109 | 609 | |
1e6feb95 VZ |
610 | if ( !::SetFocus(hWnd) ) |
611 | { | |
5262eb0a | 612 | #if defined(__WXDEBUG__) && !defined(__WXMICROWIN__) |
1e6feb95 VZ |
613 | // was there really an error? |
614 | DWORD dwRes = ::GetLastError(); | |
615 | if ( dwRes ) | |
616 | { | |
5262eb0a VZ |
617 | HWND hwndFocus = ::GetFocus(); |
618 | if ( hwndFocus != hWnd ) | |
619 | { | |
620 | wxLogApiError(_T("SetFocus"), dwRes); | |
621 | } | |
1e6feb95 | 622 | } |
5262eb0a | 623 | #endif // Debug |
1e6feb95 | 624 | } |
2bda0e17 KB |
625 | } |
626 | ||
ddf9d04f VZ |
627 | void wxWindowMSW::SetFocusFromKbd() |
628 | { | |
ddf9d04f VZ |
629 | // when the focus is given to the control with DLGC_HASSETSEL style from |
630 | // keyboard its contents should be entirely selected: this is what | |
631 | // ::IsDialogMessage() does and so we should do it as well to provide the | |
632 | // same LNF as the native programs | |
633 | if ( ::SendMessage(GetHwnd(), WM_GETDLGCODE, 0, 0) & DLGC_HASSETSEL ) | |
634 | { | |
635 | ::SendMessage(GetHwnd(), EM_SETSEL, 0, -1); | |
636 | } | |
1b1ca07a VZ |
637 | |
638 | // do this after (maybe) setting the selection as like this when | |
639 | // wxEVT_SET_FOCUS handler is called, the selection would have been already | |
640 | // set correctly -- this may be important | |
641 | wxWindowBase::SetFocusFromKbd(); | |
ddf9d04f VZ |
642 | } |
643 | ||
42e69d6b | 644 | // Get the window with the focus |
0fe02759 | 645 | wxWindow *wxWindowBase::DoFindFocus() |
42e69d6b VZ |
646 | { |
647 | HWND hWnd = ::GetFocus(); | |
648 | if ( hWnd ) | |
649 | { | |
a2242341 | 650 | return wxGetWindowFromHWND((WXHWND)hWnd); |
42e69d6b VZ |
651 | } |
652 | ||
653 | return NULL; | |
654 | } | |
655 | ||
47a8a4d5 | 656 | void wxWindowMSW::DoEnable( bool enable ) |
2bda0e17 | 657 | { |
a23fd0e1 | 658 | HWND hWnd = GetHwnd(); |
cc2b7472 | 659 | if ( hWnd ) |
2d0a075d | 660 | ::EnableWindow(hWnd, (BOOL)enable); |
2bda0e17 KB |
661 | } |
662 | ||
1e6feb95 | 663 | bool wxWindowMSW::Show(bool show) |
42e69d6b VZ |
664 | { |
665 | if ( !wxWindowBase::Show(show) ) | |
08158721 | 666 | return false; |
42e69d6b VZ |
667 | |
668 | HWND hWnd = GetHwnd(); | |
42e69d6b | 669 | |
a068160f VZ |
670 | // we could be called before the underlying window is created (this is |
671 | // actually useful to prevent it from being initially shown), e.g. | |
672 | // | |
673 | // wxFoo *foo = new wxFoo; | |
674 | // foo->Hide(); | |
675 | // foo->Create(parent, ...); | |
676 | // | |
677 | // should work without errors | |
678 | if ( hWnd ) | |
42e69d6b | 679 | { |
a068160f | 680 | ::ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE); |
42e69d6b VZ |
681 | } |
682 | ||
08158721 | 683 | return true; |
42e69d6b VZ |
684 | } |
685 | ||
686 | // Raise the window to the top of the Z order | |
1e6feb95 | 687 | void wxWindowMSW::Raise() |
42e69d6b | 688 | { |
c48926e1 | 689 | wxBringWindowToTop(GetHwnd()); |
42e69d6b VZ |
690 | } |
691 | ||
692 | // Lower the window to the bottom of the Z order | |
1e6feb95 | 693 | void wxWindowMSW::Lower() |
42e69d6b VZ |
694 | { |
695 | ::SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, | |
696 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
697 | } | |
698 | ||
94633ad9 | 699 | void wxWindowMSW::DoCaptureMouse() |
2bda0e17 | 700 | { |
a23fd0e1 | 701 | HWND hWnd = GetHwnd(); |
1e6feb95 | 702 | if ( hWnd ) |
2d0a075d | 703 | { |
1e6feb95 | 704 | ::SetCapture(hWnd); |
2d0a075d | 705 | } |
2bda0e17 KB |
706 | } |
707 | ||
94633ad9 | 708 | void wxWindowMSW::DoReleaseMouse() |
2bda0e17 | 709 | { |
1e6feb95 | 710 | if ( !::ReleaseCapture() ) |
2d0a075d | 711 | { |
1e6feb95 | 712 | wxLogLastError(_T("ReleaseCapture")); |
2d0a075d | 713 | } |
2bda0e17 KB |
714 | } |
715 | ||
1e6feb95 VZ |
716 | /* static */ wxWindow *wxWindowBase::GetCapture() |
717 | { | |
718 | HWND hwnd = ::GetCapture(); | |
719 | return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL; | |
720 | } | |
721 | ||
722 | bool wxWindowMSW::SetFont(const wxFont& font) | |
2bda0e17 | 723 | { |
42e69d6b VZ |
724 | if ( !wxWindowBase::SetFont(font) ) |
725 | { | |
726 | // nothing to do | |
08158721 | 727 | return false; |
2d0a075d | 728 | } |
195896c7 | 729 | |
42e69d6b VZ |
730 | HWND hWnd = GetHwnd(); |
731 | if ( hWnd != 0 ) | |
732 | { | |
733 | WXHANDLE hFont = m_font.GetResourceHandle(); | |
2bda0e17 | 734 | |
223d09f6 | 735 | wxASSERT_MSG( hFont, wxT("should have valid font") ); |
3a19e16d | 736 | |
c50f1fb9 | 737 | ::SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); |
42e69d6b | 738 | } |
2bda0e17 | 739 | |
08158721 | 740 | return true; |
42e69d6b | 741 | } |
1e6feb95 | 742 | bool wxWindowMSW::SetCursor(const wxCursor& cursor) |
2bda0e17 | 743 | { |
42e69d6b VZ |
744 | if ( !wxWindowBase::SetCursor(cursor) ) |
745 | { | |
746 | // no change | |
08158721 | 747 | return false; |
42e69d6b VZ |
748 | } |
749 | ||
8e75dca8 VZ |
750 | // don't "overwrite" busy cursor |
751 | if ( m_cursor.Ok() && !wxIsBusy() ) | |
8a9c2246 | 752 | { |
a8b2285e VZ |
753 | // normally we should change the cursor only if it's over this window |
754 | // but we should do it always if we capture the mouse currently | |
755 | bool set = HasCapture(); | |
756 | if ( !set ) | |
757 | { | |
758 | HWND hWnd = GetHwnd(); | |
759 | ||
760 | POINT point; | |
761 | #ifdef __WXWINCE__ | |
762 | ::GetCursorPosWinCE(&point); | |
763 | #else | |
764 | ::GetCursorPos(&point); | |
765 | #endif | |
766 | ||
767 | RECT rect = wxGetWindowRect(hWnd); | |
768 | ||
769 | set = ::PtInRect(&rect, point) != 0; | |
770 | } | |
771 | ||
772 | if ( set ) | |
773 | { | |
774 | ::SetCursor(GetHcursorOf(m_cursor)); | |
775 | } | |
776 | //else: will be set later when the mouse enters this window | |
8a9c2246 | 777 | } |
3a19e16d | 778 | |
08158721 | 779 | return true; |
3a19e16d VZ |
780 | } |
781 | ||
d7e0024b | 782 | void wxWindowMSW::WarpPointer(int x, int y) |
2bda0e17 | 783 | { |
1e6feb95 | 784 | ClientToScreen(&x, &y); |
42e69d6b | 785 | |
1e6feb95 VZ |
786 | if ( !::SetCursorPos(x, y) ) |
787 | { | |
788 | wxLogLastError(_T("SetCursorPos")); | |
789 | } | |
2bda0e17 KB |
790 | } |
791 | ||
1ca78aa1 | 792 | void wxWindowMSW::MSWUpdateUIState(int action, int state) |
d7e0024b | 793 | { |
1ca78aa1 | 794 | // WM_CHANGEUISTATE only appeared in Windows 2000 so it can do us no good |
d7e0024b VZ |
795 | // to use it on older systems -- and could possibly do some harm |
796 | static int s_needToUpdate = -1; | |
797 | if ( s_needToUpdate == -1 ) | |
798 | { | |
799 | int verMaj, verMin; | |
406d283a | 800 | s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxOS_WINDOWS_NT && |
d7e0024b VZ |
801 | verMaj >= 5; |
802 | } | |
803 | ||
804 | if ( s_needToUpdate ) | |
805 | { | |
1ca78aa1 JS |
806 | // we send WM_CHANGEUISTATE so if nothing needs changing then the system |
807 | // won't send WM_UPDATEUISTATE | |
808 | ::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0); | |
d7e0024b VZ |
809 | } |
810 | } | |
811 | ||
42e69d6b VZ |
812 | // --------------------------------------------------------------------------- |
813 | // scrolling stuff | |
814 | // --------------------------------------------------------------------------- | |
2d0a075d | 815 | |
9cd6d737 VZ |
816 | inline int GetScrollPosition(HWND hWnd, int wOrient) |
817 | { | |
818 | #ifdef __WXMICROWIN__ | |
819 | return ::GetScrollPosWX(hWnd, wOrient); | |
820 | #else | |
f676b387 | 821 | WinStruct<SCROLLINFO> scrollInfo; |
4676948b | 822 | scrollInfo.cbSize = sizeof(SCROLLINFO); |
7f0586ef | 823 | scrollInfo.fMask = SIF_POS; |
e795e8b5 | 824 | ::GetScrollInfo(hWnd, wOrient, &scrollInfo ); |
a71d815b | 825 | |
7f0586ef | 826 | return scrollInfo.nPos; |
e795e8b5 | 827 | |
9cd6d737 VZ |
828 | #endif |
829 | } | |
830 | ||
1e6feb95 | 831 | int wxWindowMSW::GetScrollPos(int orient) const |
2bda0e17 | 832 | { |
42e69d6b | 833 | HWND hWnd = GetHwnd(); |
9cd6d737 VZ |
834 | wxCHECK_MSG( hWnd, 0, _T("no HWND in GetScrollPos") ); |
835 | ||
0cf5de11 | 836 | return GetScrollPosition(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT); |
42e69d6b | 837 | } |
2bda0e17 | 838 | |
42e69d6b VZ |
839 | // This now returns the whole range, not just the number |
840 | // of positions that we can scroll. | |
1e6feb95 | 841 | int wxWindowMSW::GetScrollRange(int orient) const |
42e69d6b | 842 | { |
7f0586ef | 843 | int maxPos; |
a23fd0e1 | 844 | HWND hWnd = GetHwnd(); |
0cf5de11 | 845 | if ( !hWnd ) |
42e69d6b | 846 | return 0; |
7f0586ef | 847 | #if 0 |
0cf5de11 VZ |
848 | ::GetScrollRange(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, |
849 | &minPos, &maxPos); | |
7f0586ef | 850 | #endif |
f676b387 | 851 | WinStruct<SCROLLINFO> scrollInfo; |
7f0586ef JS |
852 | scrollInfo.fMask = SIF_RANGE; |
853 | if ( !::GetScrollInfo(hWnd, | |
f676b387 RD |
854 | orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, |
855 | &scrollInfo) ) | |
7f0586ef | 856 | { |
f676b387 RD |
857 | // Most of the time this is not really an error, since the return |
858 | // value can also be zero when there is no scrollbar yet. | |
859 | // wxLogLastError(_T("GetScrollInfo")); | |
7f0586ef JS |
860 | } |
861 | maxPos = scrollInfo.nMax; | |
0cf5de11 VZ |
862 | |
863 | // undo "range - 1" done in SetScrollbar() | |
864 | return maxPos + 1; | |
cc2b7472 | 865 | } |
2bda0e17 | 866 | |
1e6feb95 | 867 | int wxWindowMSW::GetScrollThumb(int orient) const |
2bda0e17 | 868 | { |
0cf5de11 | 869 | return orient == wxHORIZONTAL ? m_xThumbSize : m_yThumbSize; |
2bda0e17 KB |
870 | } |
871 | ||
1e6feb95 | 872 | void wxWindowMSW::SetScrollPos(int orient, int pos, bool refresh) |
2bda0e17 | 873 | { |
5f3286d1 VZ |
874 | HWND hWnd = GetHwnd(); |
875 | wxCHECK_RET( hWnd, _T("SetScrollPos: no HWND") ); | |
72fd19a1 | 876 | |
0cf5de11 | 877 | WinStruct<SCROLLINFO> info; |
42e69d6b VZ |
878 | info.nPage = 0; |
879 | info.nMin = 0; | |
880 | info.nPos = pos; | |
881 | info.fMask = SIF_POS; | |
a647d42a VZ |
882 | if ( HasFlag(wxALWAYS_SHOW_SB) ) |
883 | { | |
884 | // disable scrollbar instead of removing it then | |
885 | info.fMask |= SIF_DISABLENOSCROLL; | |
886 | } | |
2d0a075d | 887 | |
0cf5de11 VZ |
888 | ::SetScrollInfo(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, |
889 | &info, refresh); | |
2bda0e17 KB |
890 | } |
891 | ||
42e69d6b | 892 | // New function that will replace some of the above. |
0cf5de11 VZ |
893 | void wxWindowMSW::SetScrollbar(int orient, |
894 | int pos, | |
895 | int pageSize, | |
896 | int range, | |
897 | bool refresh) | |
898 | { | |
899 | WinStruct<SCROLLINFO> info; | |
900 | info.nPage = pageSize; | |
901 | info.nMin = 0; // range is nMax - nMin + 1 | |
902 | info.nMax = range - 1; // as both nMax and nMax are inclusive | |
42e69d6b VZ |
903 | info.nPos = pos; |
904 | info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; | |
a647d42a VZ |
905 | if ( HasFlag(wxALWAYS_SHOW_SB) ) |
906 | { | |
907 | // disable scrollbar instead of removing it then | |
908 | info.fMask |= SIF_DISABLENOSCROLL; | |
909 | } | |
2bda0e17 | 910 | |
42e69d6b VZ |
911 | HWND hWnd = GetHwnd(); |
912 | if ( hWnd ) | |
81d66cf3 | 913 | { |
55a667b6 JS |
914 | // We have to set the variables here to make them valid in events |
915 | // triggered by ::SetScrollInfo() | |
916 | *(orient == wxHORIZONTAL ? &m_xThumbSize : &m_yThumbSize) = pageSize; | |
521bf4ff | 917 | |
0cf5de11 VZ |
918 | ::SetScrollInfo(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT, |
919 | &info, refresh); | |
81d66cf3 JS |
920 | } |
921 | } | |
922 | ||
1e6feb95 | 923 | void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) |
2bda0e17 | 924 | { |
574c939e KB |
925 | RECT rect; |
926 | RECT *pr; | |
1e6feb95 | 927 | if ( prect ) |
2d0a075d | 928 | { |
1e6feb95 VZ |
929 | rect.left = prect->x; |
930 | rect.top = prect->y; | |
931 | rect.right = prect->x + prect->width; | |
932 | rect.bottom = prect->y + prect->height; | |
f797e53d VZ |
933 | pr = ▭ |
934 | } | |
935 | else | |
936 | { | |
937 | pr = NULL; | |
304b8bc1 | 938 | |
2d0a075d | 939 | } |
2bda0e17 | 940 | |
7f0586ef JS |
941 | #ifdef __WXWINCE__ |
942 | // FIXME: is this the exact equivalent of the line below? | |
304b8bc1 | 943 | ::ScrollWindowEx(GetHwnd(), dx, dy, pr, pr, 0, 0, SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE); |
7f0586ef | 944 | #else |
f797e53d | 945 | ::ScrollWindow(GetHwnd(), dx, dy, pr, pr); |
7f0586ef | 946 | #endif |
2bda0e17 KB |
947 | } |
948 | ||
9cd6d737 | 949 | static bool ScrollVertically(HWND hwnd, int kind, int count) |
b9b3393e | 950 | { |
9cd6d737 VZ |
951 | int posStart = GetScrollPosition(hwnd, SB_VERT); |
952 | ||
953 | int pos = posStart; | |
c0cdd6cc VZ |
954 | for ( int n = 0; n < count; n++ ) |
955 | { | |
956 | ::SendMessage(hwnd, WM_VSCROLL, kind, 0); | |
9cd6d737 VZ |
957 | |
958 | int posNew = GetScrollPosition(hwnd, SB_VERT); | |
959 | if ( posNew == pos ) | |
960 | { | |
961 | // don't bother to continue, we're already at top/bottom | |
962 | break; | |
963 | } | |
964 | ||
965 | pos = posNew; | |
c0cdd6cc | 966 | } |
9cd6d737 VZ |
967 | |
968 | return pos != posStart; | |
b9b3393e VZ |
969 | } |
970 | ||
9cd6d737 | 971 | bool wxWindowMSW::ScrollLines(int lines) |
b9b3393e VZ |
972 | { |
973 | bool down = lines > 0; | |
974 | ||
9cd6d737 VZ |
975 | return ScrollVertically(GetHwnd(), |
976 | down ? SB_LINEDOWN : SB_LINEUP, | |
977 | down ? lines : -lines); | |
b9b3393e VZ |
978 | } |
979 | ||
9cd6d737 | 980 | bool wxWindowMSW::ScrollPages(int pages) |
b9b3393e VZ |
981 | { |
982 | bool down = pages > 0; | |
983 | ||
9cd6d737 VZ |
984 | return ScrollVertically(GetHwnd(), |
985 | down ? SB_PAGEDOWN : SB_PAGEUP, | |
986 | down ? pages : -pages); | |
b9b3393e VZ |
987 | } |
988 | ||
978af864 VZ |
989 | // ---------------------------------------------------------------------------- |
990 | // RTL support | |
991 | // ---------------------------------------------------------------------------- | |
992 | ||
993 | void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir) | |
994 | { | |
08a58133 WS |
995 | #ifdef __WXWINCE__ |
996 | wxUnusedVar(dir); | |
997 | #else | |
978af864 VZ |
998 | const HWND hwnd = GetHwnd(); |
999 | wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") ); | |
1000 | ||
1001 | LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE); | |
1002 | ||
1003 | LONG styleNew = styleOld; | |
1004 | switch ( dir ) | |
1005 | { | |
1006 | case wxLayout_LeftToRight: | |
1007 | styleNew &= ~WS_EX_LAYOUTRTL; | |
1008 | break; | |
1009 | ||
1010 | case wxLayout_RightToLeft: | |
1011 | styleNew |= WS_EX_LAYOUTRTL; | |
1012 | break; | |
1013 | ||
1014 | default: | |
1015 | wxFAIL_MSG(_T("unsupported layout direction")); | |
1016 | break; | |
1017 | } | |
1018 | ||
1019 | if ( styleNew != styleOld ) | |
1020 | { | |
1021 | ::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew); | |
1022 | } | |
08a58133 | 1023 | #endif |
978af864 VZ |
1024 | } |
1025 | ||
1026 | wxLayoutDirection wxWindowMSW::GetLayoutDirection() const | |
1027 | { | |
08a58133 WS |
1028 | #ifdef __WXWINCE__ |
1029 | return wxLayout_Default; | |
1030 | #else | |
978af864 VZ |
1031 | const HWND hwnd = GetHwnd(); |
1032 | wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") ); | |
1033 | ||
1034 | return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL | |
1035 | ? wxLayout_RightToLeft | |
1036 | : wxLayout_LeftToRight; | |
08a58133 | 1037 | #endif |
978af864 VZ |
1038 | } |
1039 | ||
1040 | wxCoord | |
1041 | wxWindowMSW::AdjustForLayoutDirection(wxCoord x, | |
1042 | wxCoord WXUNUSED(width), | |
1043 | wxCoord WXUNUSED(widthTotal)) const | |
1044 | { | |
1045 | // Win32 mirrors the coordinates of RTL windows automatically, so don't | |
1046 | // redo it ourselves | |
1047 | return x; | |
1048 | } | |
1049 | ||
42e69d6b VZ |
1050 | // --------------------------------------------------------------------------- |
1051 | // subclassing | |
1052 | // --------------------------------------------------------------------------- | |
1053 | ||
1e6feb95 | 1054 | void wxWindowMSW::SubclassWin(WXHWND hWnd) |
2bda0e17 | 1055 | { |
223d09f6 | 1056 | wxASSERT_MSG( !m_oldWndProc, wxT("subclassing window twice?") ); |
2bda0e17 | 1057 | |
c50f1fb9 | 1058 | HWND hwnd = (HWND)hWnd; |
223d09f6 | 1059 | wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in SubclassWin") ); |
c50f1fb9 VZ |
1060 | |
1061 | wxAssociateWinWithHandle(hwnd, this); | |
2bda0e17 | 1062 | |
975b6bcf | 1063 | m_oldWndProc = (WXFARPROC)wxGetWindowProc((HWND)hWnd); |
b2d5a7ee | 1064 | |
b225f659 VZ |
1065 | // we don't need to subclass the window of our own class (in the Windows |
1066 | // sense of the word) | |
3a3c8603 | 1067 | if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) ) |
b225f659 | 1068 | { |
975b6bcf | 1069 | wxSetWindowProc(hwnd, wxWndProc); |
b225f659 VZ |
1070 | } |
1071 | else | |
1072 | { | |
90e572f1 | 1073 | // don't bother restoring it either: this also makes it easy to |
08158721 | 1074 | // implement IsOfStandardClass() method which returns true for the |
77ffb593 | 1075 | // standard controls and false for the wxWidgets own windows as it can |
5a403e3f | 1076 | // simply check m_oldWndProc |
b225f659 VZ |
1077 | m_oldWndProc = NULL; |
1078 | } | |
e7c652bc VZ |
1079 | |
1080 | // we're officially created now, send the event | |
1081 | wxWindowCreateEvent event((wxWindow *)this); | |
1082 | (void)GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
1083 | } |
1084 | ||
1e6feb95 | 1085 | void wxWindowMSW::UnsubclassWin() |
2bda0e17 | 1086 | { |
42e69d6b | 1087 | wxRemoveHandleAssociation(this); |
2bda0e17 | 1088 | |
42e69d6b | 1089 | // Restore old Window proc |
c50f1fb9 VZ |
1090 | HWND hwnd = GetHwnd(); |
1091 | if ( hwnd ) | |
42e69d6b | 1092 | { |
ed4780ea | 1093 | SetHWND(0); |
c50f1fb9 | 1094 | |
223d09f6 | 1095 | wxCHECK_RET( ::IsWindow(hwnd), wxT("invalid HWND in UnsubclassWin") ); |
c50f1fb9 | 1096 | |
b225f659 | 1097 | if ( m_oldWndProc ) |
42e69d6b | 1098 | { |
eb5e4d9a | 1099 | if ( !wxCheckWindowWndProc((WXHWND)hwnd, m_oldWndProc) ) |
b225f659 | 1100 | { |
975b6bcf | 1101 | wxSetWindowProc(hwnd, (WNDPROC)m_oldWndProc); |
b225f659 VZ |
1102 | } |
1103 | ||
1104 | m_oldWndProc = NULL; | |
42e69d6b | 1105 | } |
42e69d6b | 1106 | } |
2bda0e17 KB |
1107 | } |
1108 | ||
a4d1972d | 1109 | void wxWindowMSW::AssociateHandle(WXWidget handle) |
ed4780ea VZ |
1110 | { |
1111 | if ( m_hWnd ) | |
1112 | { | |
1113 | if ( !::DestroyWindow(GetHwnd()) ) | |
1114 | wxLogLastError(wxT("DestroyWindow")); | |
1115 | } | |
a4d1972d | 1116 | |
ed4780ea VZ |
1117 | WXHWND wxhwnd = (WXHWND)handle; |
1118 | ||
1119 | SetHWND(wxhwnd); | |
1120 | SubclassWin(wxhwnd); | |
1121 | } | |
1122 | ||
1123 | void wxWindowMSW::DissociateHandle() | |
a4d1972d | 1124 | { |
ed4780ea | 1125 | // this also calls SetHWND(0) for us |
a4d1972d | 1126 | UnsubclassWin(); |
ed4780ea VZ |
1127 | } |
1128 | ||
1129 | ||
0c0d1521 | 1130 | bool wxCheckWindowWndProc(WXHWND hWnd, |
11f104e5 | 1131 | WXFARPROC WXUNUSED(wndProc)) |
eb5e4d9a | 1132 | { |
f57f984c RD |
1133 | // TODO: This list of window class names should be factored out so they can be |
1134 | // managed in one place and then accessed from here and other places, such as | |
1135 | // wxApp::RegisterWindowClasses() and wxApp::UnregisterWindowClasses() | |
521bf4ff WS |
1136 | |
1137 | #ifdef __WXWINCE__ | |
3a3c8603 DS |
1138 | extern wxChar *wxCanvasClassName; |
1139 | extern wxChar *wxCanvasClassNameNR; | |
f57f984c RD |
1140 | #else |
1141 | extern const wxChar *wxCanvasClassName; | |
1142 | extern const wxChar *wxCanvasClassNameNR; | |
1143 | #endif | |
3a3c8603 DS |
1144 | extern const wxChar *wxMDIFrameClassName; |
1145 | extern const wxChar *wxMDIFrameClassNameNoRedraw; | |
1146 | extern const wxChar *wxMDIChildFrameClassName; | |
1147 | extern const wxChar *wxMDIChildFrameClassNameNoRedraw; | |
1148 | wxString str(wxGetWindowClass(hWnd)); | |
1149 | if (str == wxCanvasClassName || | |
1150 | str == wxCanvasClassNameNR || | |
26c2a266 JG |
1151 | #if wxUSE_GLCANVAS |
1152 | str == _T("wxGLCanvasClass") || | |
1153 | str == _T("wxGLCanvasClassNR") || | |
1154 | #endif // wxUSE_GLCANVAS | |
3a3c8603 DS |
1155 | str == wxMDIFrameClassName || |
1156 | str == wxMDIFrameClassNameNoRedraw || | |
1157 | str == wxMDIChildFrameClassName || | |
1158 | str == wxMDIChildFrameClassNameNoRedraw || | |
1159 | str == _T("wxTLWHiddenParent")) | |
1160 | return true; // Effectively means don't subclass | |
f57f984c | 1161 | else |
08158721 | 1162 | return false; |
eb5e4d9a VS |
1163 | } |
1164 | ||
b2d5a7ee VZ |
1165 | // ---------------------------------------------------------------------------- |
1166 | // Style handling | |
1167 | // ---------------------------------------------------------------------------- | |
1168 | ||
1169 | void wxWindowMSW::SetWindowStyleFlag(long flags) | |
1170 | { | |
1171 | long flagsOld = GetWindowStyleFlag(); | |
1172 | if ( flags == flagsOld ) | |
1173 | return; | |
1174 | ||
1175 | // update the internal variable | |
1176 | wxWindowBase::SetWindowStyleFlag(flags); | |
1177 | ||
7bd6bf45 VZ |
1178 | // and the real window flags |
1179 | MSWUpdateStyle(flagsOld, GetExtraStyle()); | |
1180 | } | |
1181 | ||
1182 | void wxWindowMSW::SetExtraStyle(long exflags) | |
1183 | { | |
1184 | long exflagsOld = GetExtraStyle(); | |
1185 | if ( exflags == exflagsOld ) | |
1186 | return; | |
1187 | ||
1188 | // update the internal variable | |
1189 | wxWindowBase::SetExtraStyle(exflags); | |
1190 | ||
1191 | // and the real window flags | |
1192 | MSWUpdateStyle(GetWindowStyleFlag(), exflagsOld); | |
1193 | } | |
1194 | ||
1195 | void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld) | |
1196 | { | |
5b2f31eb VZ |
1197 | // now update the Windows style as well if needed - and if the window had |
1198 | // been already created | |
1199 | if ( !GetHwnd() ) | |
1200 | return; | |
1201 | ||
9ce75461 VZ |
1202 | // we may need to call SetWindowPos() when we change some styles |
1203 | bool callSWP = false; | |
1204 | ||
7bd6bf45 VZ |
1205 | WXDWORD exstyle; |
1206 | long style = MSWGetStyle(GetWindowStyleFlag(), &exstyle); | |
1207 | ||
1208 | // this is quite a horrible hack but we need it because MSWGetStyle() | |
1209 | // doesn't take exflags as parameter but uses GetExtraStyle() internally | |
1210 | // and so we have to modify the window exflags temporarily to get the | |
1211 | // correct exstyleOld | |
1212 | long exflagsNew = GetExtraStyle(); | |
1213 | wxWindowBase::SetExtraStyle(exflagsOld); | |
1214 | ||
1215 | WXDWORD exstyleOld; | |
1216 | long styleOld = MSWGetStyle(flagsOld, &exstyleOld); | |
1217 | ||
1218 | wxWindowBase::SetExtraStyle(exflagsNew); | |
1219 | ||
b2d5a7ee VZ |
1220 | |
1221 | if ( style != styleOld ) | |
1222 | { | |
1223 | // some flags (e.g. WS_VISIBLE or WS_DISABLED) should not be changed by | |
1224 | // this function so instead of simply setting the style to the new | |
1225 | // value we clear the bits which were set in styleOld but are set in | |
1226 | // the new one and set the ones which were not set before | |
1227 | long styleReal = ::GetWindowLong(GetHwnd(), GWL_STYLE); | |
1228 | styleReal &= ~styleOld; | |
1229 | styleReal |= style; | |
1230 | ||
1231 | ::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal); | |
9ce75461 | 1232 | |
7bd6bf45 VZ |
1233 | // we need to call SetWindowPos() if any of the styles affecting the |
1234 | // frame appearance have changed | |
9ce75461 VZ |
1235 | callSWP = ((styleOld ^ style ) & (WS_BORDER | |
1236 | WS_THICKFRAME | | |
1237 | WS_CAPTION | | |
1238 | WS_DLGFRAME | | |
1239 | WS_MAXIMIZEBOX | | |
1240 | WS_MINIMIZEBOX | | |
1241 | WS_SYSMENU) ) != 0; | |
b2d5a7ee VZ |
1242 | } |
1243 | ||
1244 | // and the extended style | |
9ce75461 VZ |
1245 | long exstyleReal = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE); |
1246 | ||
b2d5a7ee VZ |
1247 | if ( exstyle != exstyleOld ) |
1248 | { | |
b2d5a7ee VZ |
1249 | exstyleReal &= ~exstyleOld; |
1250 | exstyleReal |= exstyle; | |
1251 | ||
1252 | ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, exstyleReal); | |
1253 | ||
9ce75461 VZ |
1254 | // ex style changes don't take effect without calling SetWindowPos |
1255 | callSWP = true; | |
1256 | } | |
1257 | ||
1258 | if ( callSWP ) | |
1259 | { | |
85d8df29 | 1260 | // we must call SetWindowPos() to flush the cached extended style and |
b2d5a7ee VZ |
1261 | // also to make the change to wxSTAY_ON_TOP style take effect: just |
1262 | // setting the style simply doesn't work | |
1263 | if ( !::SetWindowPos(GetHwnd(), | |
1264 | exstyleReal & WS_EX_TOPMOST ? HWND_TOPMOST | |
1265 | : HWND_NOTOPMOST, | |
1266 | 0, 0, 0, 0, | |
9ce75461 | 1267 | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED) ) |
b2d5a7ee VZ |
1268 | { |
1269 | wxLogLastError(_T("SetWindowPos")); | |
1270 | } | |
1271 | } | |
1272 | } | |
1273 | ||
1274 | WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const | |
1275 | { | |
77ffb593 | 1276 | // translate common wxWidgets styles to Windows ones |
af495479 VZ |
1277 | |
1278 | // most of windows are child ones, those which are not (such as | |
1279 | // wxTopLevelWindow) should remove WS_CHILD in their MSWGetStyle() | |
1280 | WXDWORD style = WS_CHILD; | |
b2d5a7ee | 1281 | |
9b6ae450 VZ |
1282 | // using this flag results in very significant reduction in flicker, |
1283 | // especially with controls inside the static boxes (as the interior of the | |
90e572f1 | 1284 | // box is not redrawn twice), but sometimes results in redraw problems, so |
c7e1d004 VZ |
1285 | // optionally allow the old code to continue to use it provided a special |
1286 | // system option is turned on | |
1287 | if ( !wxSystemOptions::GetOptionInt(wxT("msw.window.no-clip-children")) | |
1288 | || (flags & wxCLIP_CHILDREN) ) | |
c6430ed0 | 1289 | style |= WS_CLIPCHILDREN; |
9b6ae450 VZ |
1290 | |
1291 | // it doesn't seem useful to use WS_CLIPSIBLINGS here as we officially | |
1292 | // don't support overlapping windows and it only makes sense for them and, | |
1293 | // presumably, gives the system some extra work (to manage more clipping | |
1294 | // regions), so avoid it alltogether | |
b2d5a7ee | 1295 | |
b2d5a7ee | 1296 | |
f9007c32 JS |
1297 | if ( flags & wxVSCROLL ) |
1298 | style |= WS_VSCROLL; | |
1299 | ||
1300 | if ( flags & wxHSCROLL ) | |
1301 | style |= WS_HSCROLL; | |
1302 | ||
65bc172c | 1303 | const wxBorder border = GetBorder(flags); |
577baeef | 1304 | |
65bc172c VZ |
1305 | // WS_BORDER is only required for wxBORDER_SIMPLE |
1306 | if ( border == wxBORDER_SIMPLE ) | |
b2d5a7ee | 1307 | style |= WS_BORDER; |
577baeef | 1308 | |
b2d5a7ee VZ |
1309 | // now deal with ext style if the caller wants it |
1310 | if ( exstyle ) | |
1311 | { | |
1312 | *exstyle = 0; | |
1313 | ||
7f0586ef | 1314 | #ifndef __WXWINCE__ |
b2d5a7ee VZ |
1315 | if ( flags & wxTRANSPARENT_WINDOW ) |
1316 | *exstyle |= WS_EX_TRANSPARENT; | |
7f0586ef | 1317 | #endif |
b2d5a7ee | 1318 | |
fe3d9123 | 1319 | switch ( border ) |
b2d5a7ee VZ |
1320 | { |
1321 | default: | |
65bc172c | 1322 | case wxBORDER_DEFAULT: |
b2d5a7ee VZ |
1323 | wxFAIL_MSG( _T("unknown border style") ); |
1324 | // fall through | |
1325 | ||
1326 | case wxBORDER_NONE: | |
1327 | case wxBORDER_SIMPLE: | |
1328 | break; | |
1329 | ||
1330 | case wxBORDER_STATIC: | |
1331 | *exstyle |= WS_EX_STATICEDGE; | |
1332 | break; | |
1333 | ||
1334 | case wxBORDER_RAISED: | |
7699361c | 1335 | *exstyle |= WS_EX_DLGMODALFRAME; |
b2d5a7ee VZ |
1336 | break; |
1337 | ||
b2d5a7ee VZ |
1338 | case wxBORDER_SUNKEN: |
1339 | *exstyle |= WS_EX_CLIENTEDGE; | |
fe3d9123 | 1340 | style &= ~WS_BORDER; |
b2d5a7ee VZ |
1341 | break; |
1342 | ||
1343 | case wxBORDER_DOUBLE: | |
1344 | *exstyle |= WS_EX_DLGMODALFRAME; | |
1345 | break; | |
1346 | } | |
d515c32d | 1347 | |
09168de7 | 1348 | // wxUniv doesn't use Windows dialog navigation functions at all |
7f0586ef | 1349 | #if !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__) |
5b9c12e1 | 1350 | // to make the dialog navigation work with the nested panels we must |
09168de7 VZ |
1351 | // use this style (top level windows such as dialogs don't need it) |
1352 | if ( (flags & wxTAB_TRAVERSAL) && !IsTopLevel() ) | |
d515c32d VZ |
1353 | { |
1354 | *exstyle |= WS_EX_CONTROLPARENT; | |
1355 | } | |
09168de7 | 1356 | #endif // __WXUNIVERSAL__ |
b2d5a7ee VZ |
1357 | } |
1358 | ||
1359 | return style; | |
1360 | } | |
eb5e4d9a | 1361 | |
42e69d6b | 1362 | // Setup background and foreground colours correctly |
1e6feb95 | 1363 | void wxWindowMSW::SetupColours() |
42e69d6b VZ |
1364 | { |
1365 | if ( GetParent() ) | |
1366 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
1367 | } | |
a23fd0e1 | 1368 | |
1e6feb95 VZ |
1369 | bool wxWindowMSW::IsMouseInWindow() const |
1370 | { | |
1371 | // get the mouse position | |
1372 | POINT pt; | |
f2325516 JS |
1373 | #ifdef __WXWINCE__ |
1374 | ::GetCursorPosWinCE(&pt); | |
1375 | #else | |
1e6feb95 | 1376 | ::GetCursorPos(&pt); |
f2325516 | 1377 | #endif |
1e6feb95 VZ |
1378 | |
1379 | // find the window which currently has the cursor and go up the window | |
1380 | // chain until we find this window - or exhaust it | |
1381 | HWND hwnd = ::WindowFromPoint(pt); | |
1382 | while ( hwnd && (hwnd != GetHwnd()) ) | |
1383 | hwnd = ::GetParent(hwnd); | |
1384 | ||
1385 | return hwnd != NULL; | |
1386 | } | |
1387 | ||
e39af974 | 1388 | void wxWindowMSW::OnInternalIdle() |
42e69d6b | 1389 | { |
4e5c6c33 | 1390 | #ifndef HAVE_TRACKMOUSEEVENT |
42e69d6b VZ |
1391 | // Check if we need to send a LEAVE event |
1392 | if ( m_mouseInWindow ) | |
2d0a075d | 1393 | { |
ee74faf9 VZ |
1394 | // note that we should generate the leave event whether the window has |
1395 | // or doesn't have mouse capture | |
1396 | if ( !IsMouseInWindow() ) | |
42e69d6b | 1397 | { |
51e4e266 | 1398 | GenerateMouseLeave(); |
42e69d6b VZ |
1399 | } |
1400 | } | |
4e5c6c33 | 1401 | #endif // !HAVE_TRACKMOUSEEVENT |
c085e333 | 1402 | |
e39af974 JS |
1403 | if (wxUpdateUIEvent::CanUpdate(this)) |
1404 | UpdateWindowUI(wxUPDATE_UI_FROMIDLE); | |
42e69d6b | 1405 | } |
568cb543 | 1406 | |
42e69d6b | 1407 | // Set this window to be the child of 'parent'. |
1e6feb95 | 1408 | bool wxWindowMSW::Reparent(wxWindowBase *parent) |
42e69d6b VZ |
1409 | { |
1410 | if ( !wxWindowBase::Reparent(parent) ) | |
08158721 | 1411 | return false; |
c085e333 | 1412 | |
42e69d6b VZ |
1413 | HWND hWndChild = GetHwnd(); |
1414 | HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0; | |
a23fd0e1 | 1415 | |
42e69d6b | 1416 | ::SetParent(hWndChild, hWndParent); |
a23fd0e1 | 1417 | |
ee471817 VZ |
1418 | #ifndef __WXWINCE__ |
1419 | if ( ::GetWindowLong(hWndChild, GWL_EXSTYLE) & WS_EX_CONTROLPARENT ) | |
1420 | { | |
1421 | EnsureParentHasControlParentStyle(GetParent()); | |
1422 | } | |
1423 | #endif // !__WXWINCE__ | |
1424 | ||
08158721 | 1425 | return true; |
42e69d6b | 1426 | } |
a23fd0e1 | 1427 | |
a0e449ff VZ |
1428 | static inline void SendSetRedraw(HWND hwnd, bool on) |
1429 | { | |
c67d6888 | 1430 | #ifndef __WXMICROWIN__ |
a0e449ff | 1431 | ::SendMessage(hwnd, WM_SETREDRAW, (WPARAM)on, 0); |
c67d6888 | 1432 | #endif |
a0e449ff VZ |
1433 | } |
1434 | ||
1435 | void wxWindowMSW::Freeze() | |
1436 | { | |
a1037371 VZ |
1437 | if ( !m_frozenness++ ) |
1438 | { | |
dc993cbf VZ |
1439 | if ( IsShown() ) |
1440 | SendSetRedraw(GetHwnd(), false); | |
a1037371 | 1441 | } |
a0e449ff VZ |
1442 | } |
1443 | ||
1444 | void wxWindowMSW::Thaw() | |
1445 | { | |
a1037371 | 1446 | wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); |
c0cdd6cc | 1447 | |
8d7eaf91 | 1448 | if ( --m_frozenness == 0 ) |
a1037371 | 1449 | { |
dc993cbf VZ |
1450 | if ( IsShown() ) |
1451 | { | |
1452 | SendSetRedraw(GetHwnd(), true); | |
a1037371 | 1453 | |
dc993cbf VZ |
1454 | // we need to refresh everything or otherwise the invalidated area |
1455 | // is not going to be repainted | |
1456 | Refresh(); | |
1457 | } | |
a1037371 | 1458 | } |
a0e449ff VZ |
1459 | } |
1460 | ||
1e6feb95 | 1461 | void wxWindowMSW::Refresh(bool eraseBack, const wxRect *rect) |
42e69d6b VZ |
1462 | { |
1463 | HWND hWnd = GetHwnd(); | |
1464 | if ( hWnd ) | |
1465 | { | |
d181e053 VZ |
1466 | RECT mswRect; |
1467 | const RECT *pRect; | |
42e69d6b VZ |
1468 | if ( rect ) |
1469 | { | |
42e69d6b VZ |
1470 | mswRect.left = rect->x; |
1471 | mswRect.top = rect->y; | |
1472 | mswRect.right = rect->x + rect->width; | |
1473 | mswRect.bottom = rect->y + rect->height; | |
a23fd0e1 | 1474 | |
d181e053 | 1475 | pRect = &mswRect; |
42e69d6b VZ |
1476 | } |
1477 | else | |
d181e053 VZ |
1478 | { |
1479 | pRect = NULL; | |
1480 | } | |
1481 | ||
82e3664e | 1482 | // RedrawWindow not available on SmartPhone or eVC++ 3 |
41527143 | 1483 | #if !defined(__SMARTPHONE__) && !(defined(_WIN32_WCE) && _WIN32_WCE < 400) |
d181e053 VZ |
1484 | UINT flags = RDW_INVALIDATE | RDW_ALLCHILDREN; |
1485 | if ( eraseBack ) | |
1486 | flags |= RDW_ERASE; | |
1487 | ||
1488 | ::RedrawWindow(hWnd, pRect, NULL, flags); | |
480e9098 | 1489 | #else |
16d652a5 | 1490 | ::InvalidateRect(hWnd, pRect, eraseBack); |
480e9098 | 1491 | #endif |
42e69d6b VZ |
1492 | } |
1493 | } | |
a23fd0e1 | 1494 | |
1e6feb95 VZ |
1495 | void wxWindowMSW::Update() |
1496 | { | |
1497 | if ( !::UpdateWindow(GetHwnd()) ) | |
1498 | { | |
1499 | wxLogLastError(_T("UpdateWindow")); | |
1500 | } | |
2b5f62a0 | 1501 | |
7f0586ef | 1502 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
1e6feb95 VZ |
1503 | // just calling UpdateWindow() is not enough, what we did in our WM_PAINT |
1504 | // handler needs to be really drawn right now | |
1505 | (void)::GdiFlush(); | |
1506 | #endif // __WIN32__ | |
1507 | } | |
1508 | ||
42e69d6b VZ |
1509 | // --------------------------------------------------------------------------- |
1510 | // drag and drop | |
1511 | // --------------------------------------------------------------------------- | |
a23fd0e1 | 1512 | |
3febc967 VZ |
1513 | #if wxUSE_DRAG_AND_DROP || !defined(__WXWINCE__) |
1514 | ||
1515 | #if wxUSE_STATBOX | |
1516 | ||
006b8dff JG |
1517 | // we need to lower the sibling static boxes so controls contained within can be |
1518 | // a drop target | |
3febc967 | 1519 | static void AdjustStaticBoxZOrder(wxWindow *parent) |
006b8dff | 1520 | { |
deb0d191 JG |
1521 | // no sibling static boxes if we have no parent (ie TLW) |
1522 | if ( !parent ) | |
1523 | return; | |
1524 | ||
006b8dff JG |
1525 | for ( wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); |
1526 | node; | |
1527 | node = node->GetNext() ) | |
1528 | { | |
1529 | wxStaticBox *statbox = wxDynamicCast(node->GetData(), wxStaticBox); | |
1530 | if ( statbox ) | |
1531 | { | |
1532 | ::SetWindowPos(GetHwndOf(statbox), HWND_BOTTOM, 0, 0, 0, 0, | |
1533 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
1534 | } | |
1535 | } | |
1536 | } | |
a23fd0e1 | 1537 | |
3febc967 VZ |
1538 | #else // !wxUSE_STATBOX |
1539 | ||
1540 | static inline void AdjustStaticBoxZOrder(wxWindow * WXUNUSED(parent)) | |
1541 | { | |
1542 | } | |
1543 | ||
1544 | #endif // wxUSE_STATBOX/!wxUSE_STATBOX | |
1545 | ||
1546 | #endif // drag and drop is used | |
1547 | ||
4ce1efe1 | 1548 | #if wxUSE_DRAG_AND_DROP |
1e6feb95 | 1549 | void wxWindowMSW::SetDropTarget(wxDropTarget *pDropTarget) |
42e69d6b VZ |
1550 | { |
1551 | if ( m_dropTarget != 0 ) { | |
1552 | m_dropTarget->Revoke(m_hWnd); | |
1553 | delete m_dropTarget; | |
1554 | } | |
a23fd0e1 | 1555 | |
42e69d6b VZ |
1556 | m_dropTarget = pDropTarget; |
1557 | if ( m_dropTarget != 0 ) | |
006b8dff JG |
1558 | { |
1559 | AdjustStaticBoxZOrder(GetParent()); | |
42e69d6b | 1560 | m_dropTarget->Register(m_hWnd); |
006b8dff | 1561 | } |
42e69d6b | 1562 | } |
42e69d6b | 1563 | #endif // wxUSE_DRAG_AND_DROP |
2a47d3c1 | 1564 | |
90e572f1 | 1565 | // old-style file manager drag&drop support: we retain the old-style |
42e69d6b | 1566 | // DragAcceptFiles in parallel with SetDropTarget. |
0c0d1521 | 1567 | void wxWindowMSW::DragAcceptFiles(bool WXUNUSED_IN_WINCE(accept)) |
42e69d6b | 1568 | { |
0c0d1521 | 1569 | #ifndef __WXWINCE__ |
42e69d6b VZ |
1570 | HWND hWnd = GetHwnd(); |
1571 | if ( hWnd ) | |
006b8dff JG |
1572 | { |
1573 | AdjustStaticBoxZOrder(GetParent()); | |
42e69d6b | 1574 | ::DragAcceptFiles(hWnd, (BOOL)accept); |
006b8dff | 1575 | } |
7f0586ef | 1576 | #endif |
42e69d6b | 1577 | } |
a23fd0e1 | 1578 | |
42e69d6b VZ |
1579 | // ---------------------------------------------------------------------------- |
1580 | // tooltips | |
1581 | // ---------------------------------------------------------------------------- | |
dbda9e86 | 1582 | |
42e69d6b | 1583 | #if wxUSE_TOOLTIPS |
2d0a075d | 1584 | |
1e6feb95 | 1585 | void wxWindowMSW::DoSetToolTip(wxToolTip *tooltip) |
42e69d6b VZ |
1586 | { |
1587 | wxWindowBase::DoSetToolTip(tooltip); | |
839b865d | 1588 | |
42e69d6b | 1589 | if ( m_tooltip ) |
d4e5272b | 1590 | m_tooltip->SetWindow((wxWindow *)this); |
42e69d6b | 1591 | } |
9a05fd8d | 1592 | |
42e69d6b | 1593 | #endif // wxUSE_TOOLTIPS |
9a05fd8d | 1594 | |
42e69d6b VZ |
1595 | // --------------------------------------------------------------------------- |
1596 | // moving and resizing | |
1597 | // --------------------------------------------------------------------------- | |
839b865d | 1598 | |
f7040b5f VZ |
1599 | bool wxWindowMSW::IsSizeDeferred() const |
1600 | { | |
1601 | #if USE_DEFERRED_SIZING | |
1602 | if ( m_pendingPosition != wxDefaultPosition || | |
1603 | m_pendingSize != wxDefaultSize ) | |
1604 | return true; | |
1605 | #endif // USE_DEFERRED_SIZING | |
1606 | ||
1607 | return false; | |
1608 | } | |
1609 | ||
42e69d6b | 1610 | // Get total size |
1e6feb95 | 1611 | void wxWindowMSW::DoGetSize(int *x, int *y) const |
42e69d6b | 1612 | { |
0d6fdb3c | 1613 | #if USE_DEFERRED_SIZING |
11cfa8ef VZ |
1614 | // if SetSize() had been called at wx level but not realized at Windows |
1615 | // level yet (i.e. EndDeferWindowPos() not called), we still should return | |
1616 | // the new and not the old position to the other wx code | |
1617 | if ( m_pendingSize != wxDefaultSize ) | |
1618 | { | |
1619 | if ( x ) | |
1620 | *x = m_pendingSize.x; | |
1621 | if ( y ) | |
1622 | *y = m_pendingSize.y; | |
1623 | } | |
1624 | else // use current size | |
0d6fdb3c | 1625 | #endif // USE_DEFERRED_SIZING |
11cfa8ef VZ |
1626 | { |
1627 | RECT rect = wxGetWindowRect(GetHwnd()); | |
82c9f85c | 1628 | |
11cfa8ef VZ |
1629 | if ( x ) |
1630 | *x = rect.right - rect.left; | |
1631 | if ( y ) | |
1632 | *y = rect.bottom - rect.top; | |
1633 | } | |
42e69d6b VZ |
1634 | } |
1635 | ||
82c9f85c VZ |
1636 | // Get size *available for subwindows* i.e. excluding menu bar etc. |
1637 | void wxWindowMSW::DoGetClientSize(int *x, int *y) const | |
42e69d6b | 1638 | { |
f2197644 | 1639 | #if USE_DEFERRED_SIZING |
0d6fdb3c | 1640 | if ( m_pendingSize != wxDefaultSize ) |
0d7f75df | 1641 | { |
0d6fdb3c | 1642 | // we need to calculate the client size corresponding to pending size |
dc497201 JG |
1643 | RECT rect; |
1644 | rect.left = m_pendingPosition.x; | |
1645 | rect.top = m_pendingPosition.y; | |
1646 | rect.right = rect.left + m_pendingSize.x; | |
1647 | rect.bottom = rect.top + m_pendingSize.y; | |
1648 | ||
1649 | ::SendMessage(GetHwnd(), WM_NCCALCSIZE, FALSE, (LPARAM)&rect); | |
1650 | ||
1651 | if ( x ) | |
1652 | *x = rect.right - rect.left; | |
1653 | if ( y ) | |
1654 | *y = rect.bottom - rect.top; | |
0d7f75df | 1655 | } |
0d6fdb3c VZ |
1656 | else |
1657 | #endif // USE_DEFERRED_SIZING | |
1658 | { | |
1659 | RECT rect = wxGetClientRect(GetHwnd()); | |
1660 | ||
1661 | if ( x ) | |
1662 | *x = rect.right; | |
1663 | if ( y ) | |
1664 | *y = rect.bottom; | |
1665 | } | |
82c9f85c VZ |
1666 | } |
1667 | ||
1668 | void wxWindowMSW::DoGetPosition(int *x, int *y) const | |
1669 | { | |
a7e0e432 VZ |
1670 | wxWindow * const parent = GetParent(); |
1671 | ||
1672 | wxPoint pos; | |
11cfa8ef VZ |
1673 | if ( m_pendingPosition != wxDefaultPosition ) |
1674 | { | |
a7e0e432 | 1675 | pos = m_pendingPosition; |
11cfa8ef VZ |
1676 | } |
1677 | else // use current position | |
1678 | { | |
1679 | RECT rect = wxGetWindowRect(GetHwnd()); | |
42e69d6b | 1680 | |
11cfa8ef VZ |
1681 | POINT point; |
1682 | point.x = rect.left; | |
1683 | point.y = rect.top; | |
42e69d6b | 1684 | |
11cfa8ef VZ |
1685 | // we do the adjustments with respect to the parent only for the "real" |
1686 | // children, not for the dialogs/frames | |
1687 | if ( !IsTopLevel() ) | |
92049cd4 | 1688 | { |
e5b5af91 VZ |
1689 | if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ) |
1690 | { | |
967acfb5 | 1691 | // In RTL mode, we want the logical left x-coordinate, |
e5b5af91 VZ |
1692 | // which would be the physical right x-coordinate. |
1693 | point.x = rect.right; | |
1694 | } | |
1695 | ||
11cfa8ef VZ |
1696 | // Since we now have the absolute screen coords, if there's a |
1697 | // parent we must subtract its top left corner | |
11cfa8ef VZ |
1698 | if ( parent ) |
1699 | { | |
a7e0e432 | 1700 | ::ScreenToClient(GetHwndOf(parent), &point); |
11cfa8ef | 1701 | } |
89e3037c | 1702 | } |
42e69d6b | 1703 | |
a7e0e432 VZ |
1704 | pos.x = point.x; |
1705 | pos.y = point.y; | |
1706 | } | |
1707 | ||
1708 | // we also must adjust by the client area offset: a control which is just | |
1709 | // under a toolbar could be at (0, 30) in Windows but at (0, 0) in wx | |
1710 | if ( parent && !IsTopLevel() ) | |
1711 | { | |
1712 | const wxPoint pt(parent->GetClientAreaOrigin()); | |
1713 | pos.x -= pt.x; | |
1714 | pos.y -= pt.y; | |
11cfa8ef | 1715 | } |
a7e0e432 VZ |
1716 | |
1717 | if ( x ) | |
1718 | *x = pos.x; | |
1719 | if ( y ) | |
1720 | *y = pos.y; | |
42e69d6b | 1721 | } |
54bdd8b0 | 1722 | |
1e6feb95 | 1723 | void wxWindowMSW::DoScreenToClient(int *x, int *y) const |
42e69d6b VZ |
1724 | { |
1725 | POINT pt; | |
1726 | if ( x ) | |
1727 | pt.x = *x; | |
1728 | if ( y ) | |
1729 | pt.y = *y; | |
54bdd8b0 | 1730 | |
82c9f85c | 1731 | ::ScreenToClient(GetHwnd(), &pt); |
a23fd0e1 | 1732 | |
42e69d6b VZ |
1733 | if ( x ) |
1734 | *x = pt.x; | |
1735 | if ( y ) | |
1736 | *y = pt.y; | |
1737 | } | |
a23fd0e1 | 1738 | |
1e6feb95 | 1739 | void wxWindowMSW::DoClientToScreen(int *x, int *y) const |
42e69d6b VZ |
1740 | { |
1741 | POINT pt; | |
1742 | if ( x ) | |
1743 | pt.x = *x; | |
1744 | if ( y ) | |
1745 | pt.y = *y; | |
54bdd8b0 | 1746 | |
82c9f85c | 1747 | ::ClientToScreen(GetHwnd(), &pt); |
a23fd0e1 | 1748 | |
42e69d6b VZ |
1749 | if ( x ) |
1750 | *x = pt.x; | |
1751 | if ( y ) | |
1752 | *y = pt.y; | |
1753 | } | |
a23fd0e1 | 1754 | |
86e30911 | 1755 | bool |
7d86a2d4 VZ |
1756 | wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height) |
1757 | { | |
1758 | #if USE_DEFERRED_SIZING | |
1759 | // if our parent had prepared a defer window handle for us, use it (unless | |
1760 | // we are a top level window) | |
1761 | wxWindowMSW * const parent = IsTopLevel() ? NULL : GetParent(); | |
1762 | ||
1763 | HDWP hdwp = parent ? (HDWP)parent->m_hDWP : NULL; | |
1764 | if ( hdwp ) | |
1765 | { | |
1766 | hdwp = ::DeferWindowPos(hdwp, (HWND)hwnd, NULL, x, y, width, height, | |
dd28827a | 1767 | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); |
7d86a2d4 VZ |
1768 | if ( !hdwp ) |
1769 | { | |
1770 | wxLogLastError(_T("DeferWindowPos")); | |
1771 | } | |
1772 | } | |
1773 | ||
1774 | if ( parent ) | |
1775 | { | |
1776 | // hdwp must be updated as it may have been changed | |
1777 | parent->m_hDWP = (WXHANDLE)hdwp; | |
1778 | } | |
1779 | ||
86e30911 VZ |
1780 | if ( hdwp ) |
1781 | { | |
1782 | // did deferred move, remember new coordinates of the window as they're | |
1783 | // different from what Windows would return for it | |
1784 | return true; | |
1785 | } | |
1786 | ||
7d86a2d4 | 1787 | // otherwise (or if deferring failed) move the window in place immediately |
7d86a2d4 | 1788 | #endif // USE_DEFERRED_SIZING |
86e30911 | 1789 | if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) ) |
7d86a2d4 | 1790 | { |
86e30911 | 1791 | wxLogLastError(wxT("MoveWindow")); |
7d86a2d4 | 1792 | } |
86e30911 VZ |
1793 | |
1794 | // if USE_DEFERRED_SIZING, indicates that we didn't use deferred move, | |
1795 | // ignored otherwise | |
1796 | return false; | |
7d86a2d4 VZ |
1797 | } |
1798 | ||
1e6feb95 | 1799 | void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height) |
b782f2e0 | 1800 | { |
62e1ba75 JS |
1801 | // TODO: is this consistent with other platforms? |
1802 | // Still, negative width or height shouldn't be allowed | |
1803 | if (width < 0) | |
1804 | width = 0; | |
1805 | if (height < 0) | |
1806 | height = 0; | |
9b6ae450 | 1807 | |
86e30911 VZ |
1808 | if ( DoMoveSibling(m_hWnd, x, y, width, height) ) |
1809 | { | |
1810 | #if USE_DEFERRED_SIZING | |
1811 | m_pendingPosition = wxPoint(x, y); | |
1812 | m_pendingSize = wxSize(width, height); | |
1813 | #endif // USE_DEFERRED_SIZING | |
1814 | } | |
b782f2e0 VZ |
1815 | } |
1816 | ||
4438caf4 VZ |
1817 | // set the size of the window: if the dimensions are positive, just use them, |
1818 | // but if any of them is equal to -1, it means that we must find the value for | |
1819 | // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in | |
1820 | // which case -1 is a valid value for x and y) | |
1821 | // | |
1822 | // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate | |
1823 | // the width/height to best suit our contents, otherwise we reuse the current | |
1824 | // width/height | |
1e6feb95 | 1825 | void wxWindowMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
42e69d6b | 1826 | { |
4438caf4 | 1827 | // get the current size and position... |
42e69d6b | 1828 | int currentX, currentY; |
da78f3b1 RD |
1829 | int currentW, currentH; |
1830 | ||
42e69d6b | 1831 | GetPosition(¤tX, ¤tY); |
42e69d6b | 1832 | GetSize(¤tW, ¤tH); |
a23fd0e1 | 1833 | |
952f2aaa VZ |
1834 | // ... and don't do anything (avoiding flicker) if it's already ok unless |
1835 | // we're forced to resize the window | |
4438caf4 | 1836 | if ( x == currentX && y == currentY && |
952f2aaa VZ |
1837 | width == currentW && height == currentH && |
1838 | !(sizeFlags & wxSIZE_FORCE) ) | |
4438caf4 | 1839 | { |
42e69d6b | 1840 | return; |
4438caf4 | 1841 | } |
a23fd0e1 | 1842 | |
422d0ff0 | 1843 | if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) |
4438caf4 | 1844 | x = currentX; |
422d0ff0 | 1845 | if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) |
4438caf4 | 1846 | y = currentY; |
a23fd0e1 | 1847 | |
4438caf4 | 1848 | AdjustForParentClientOrigin(x, y, sizeFlags); |
a23fd0e1 | 1849 | |
abb74e0f | 1850 | wxSize size = wxDefaultSize; |
422d0ff0 | 1851 | if ( width == wxDefaultCoord ) |
4438caf4 | 1852 | { |
9e2896e5 | 1853 | if ( sizeFlags & wxSIZE_AUTO_WIDTH ) |
4438caf4 VZ |
1854 | { |
1855 | size = DoGetBestSize(); | |
1856 | width = size.x; | |
1857 | } | |
1858 | else | |
1859 | { | |
1860 | // just take the current one | |
1861 | width = currentW; | |
1862 | } | |
1863 | } | |
1864 | ||
422d0ff0 | 1865 | if ( height == wxDefaultCoord ) |
4438caf4 | 1866 | { |
9e2896e5 | 1867 | if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) |
4438caf4 | 1868 | { |
422d0ff0 | 1869 | if ( size.x == wxDefaultCoord ) |
4438caf4 | 1870 | { |
b782f2e0 | 1871 | size = DoGetBestSize(); |
4438caf4 VZ |
1872 | } |
1873 | //else: already called DoGetBestSize() above | |
a23fd0e1 | 1874 | |
4438caf4 VZ |
1875 | height = size.y; |
1876 | } | |
1877 | else | |
1878 | { | |
1879 | // just take the current one | |
1880 | height = currentH; | |
1881 | } | |
1882 | } | |
1883 | ||
b782f2e0 | 1884 | DoMoveWindow(x, y, width, height); |
4438caf4 VZ |
1885 | } |
1886 | ||
1e6feb95 | 1887 | void wxWindowMSW::DoSetClientSize(int width, int height) |
42e69d6b | 1888 | { |
90e572f1 | 1889 | // setting the client size is less obvious than it could have been |
d4597e13 | 1890 | // because in the result of changing the total size the window scrollbar |
c72b1ad7 VZ |
1891 | // may [dis]appear and/or its menubar may [un]wrap (and AdjustWindowRect() |
1892 | // doesn't take neither into account) and so the client size will not be | |
1893 | // correct as the difference between the total and client size changes -- | |
1894 | // so we keep changing it until we get it right | |
d4597e13 | 1895 | // |
d6a97306 VZ |
1896 | // normally this loop shouldn't take more than 3 iterations (usually 1 but |
1897 | // if scrollbars [dis]appear as the result of the first call, then 2 and it | |
1898 | // may become 3 if the window had 0 size originally and so we didn't | |
1899 | // calculate the scrollbar correction correctly during the first iteration) | |
1900 | // but just to be on the safe side we check for it instead of making it an | |
d4597e13 | 1901 | // "infinite" loop (i.e. leaving break inside as the only way to get out) |
d6a97306 | 1902 | for ( int i = 0; i < 4; i++ ) |
d4597e13 VZ |
1903 | { |
1904 | RECT rectClient; | |
1905 | ::GetClientRect(GetHwnd(), &rectClient); | |
2bda0e17 | 1906 | |
b0268daf | 1907 | // if the size is already ok, stop here (NB: rectClient.left = top = 0) |
422d0ff0 WS |
1908 | if ( (rectClient.right == width || width == wxDefaultCoord) && |
1909 | (rectClient.bottom == height || height == wxDefaultCoord) ) | |
d4597e13 VZ |
1910 | { |
1911 | break; | |
1912 | } | |
a23fd0e1 | 1913 | |
d4597e13 VZ |
1914 | // Find the difference between the entire window (title bar and all) |
1915 | // and the client area; add this to the new client size to move the | |
1916 | // window | |
1917 | RECT rectWin; | |
1918 | ::GetWindowRect(GetHwnd(), &rectWin); | |
1919 | ||
b0268daf VZ |
1920 | const int widthWin = rectWin.right - rectWin.left, |
1921 | heightWin = rectWin.bottom - rectWin.top; | |
387a3b02 | 1922 | |
d4597e13 VZ |
1923 | // MoveWindow positions the child windows relative to the parent, so |
1924 | // adjust if necessary | |
1925 | if ( !IsTopLevel() ) | |
1926 | { | |
1927 | wxWindow *parent = GetParent(); | |
1928 | if ( parent ) | |
1929 | { | |
b0268daf | 1930 | ::ScreenToClient(GetHwndOf(parent), (POINT *)&rectWin); |
d4597e13 VZ |
1931 | } |
1932 | } | |
a23fd0e1 | 1933 | |
b0268daf | 1934 | // don't call DoMoveWindow() because we want to move window immediately |
c72b1ad7 VZ |
1935 | // and not defer it here as otherwise the value returned by |
1936 | // GetClient/WindowRect() wouldn't change as the window wouldn't be | |
1937 | // really resized | |
b0268daf VZ |
1938 | if ( !::MoveWindow(GetHwnd(), |
1939 | rectWin.left, | |
1940 | rectWin.top, | |
1941 | width + widthWin - rectClient.right, | |
1942 | height + heightWin - rectClient.bottom, | |
1943 | TRUE) ) | |
1944 | { | |
1945 | wxLogLastError(_T("MoveWindow")); | |
1946 | } | |
d4597e13 | 1947 | } |
42e69d6b | 1948 | } |
a23fd0e1 | 1949 | |
42e69d6b VZ |
1950 | // --------------------------------------------------------------------------- |
1951 | // text metrics | |
1952 | // --------------------------------------------------------------------------- | |
a23fd0e1 | 1953 | |
1e6feb95 | 1954 | int wxWindowMSW::GetCharHeight() const |
42e69d6b | 1955 | { |
f6bcfd97 | 1956 | return wxGetTextMetrics(this).tmHeight; |
42e69d6b | 1957 | } |
3eddf563 | 1958 | |
1e6feb95 | 1959 | int wxWindowMSW::GetCharWidth() const |
42e69d6b | 1960 | { |
f6bcfd97 BP |
1961 | // +1 is needed because Windows apparently adds it when calculating the |
1962 | // dialog units size in pixels | |
1963 | #if wxDIALOG_UNIT_COMPATIBILITY | |
1e6feb95 | 1964 | return wxGetTextMetrics(this).tmAveCharWidth; |
f6bcfd97 BP |
1965 | #else |
1966 | return wxGetTextMetrics(this).tmAveCharWidth + 1; | |
1967 | #endif | |
42e69d6b | 1968 | } |
f4621a09 | 1969 | |
1e6feb95 | 1970 | void wxWindowMSW::GetTextExtent(const wxString& string, |
34636400 | 1971 | int *x, int *y, |
42e69d6b VZ |
1972 | int *descent, int *externalLeading, |
1973 | const wxFont *theFont) const | |
1974 | { | |
64869ab7 VZ |
1975 | wxASSERT_MSG( !theFont || theFont->Ok(), |
1976 | _T("invalid font in GetTextExtent()") ); | |
634903fd | 1977 | |
2d17baae VS |
1978 | wxFont fontToUse; |
1979 | if (theFont) | |
1980 | fontToUse = *theFont; | |
1981 | else | |
1982 | fontToUse = GetFont(); | |
634903fd | 1983 | |
64869ab7 VZ |
1984 | WindowHDC hdc(GetHwnd()); |
1985 | SelectInHDC selectFont(hdc, GetHfontOf(fontToUse)); | |
341c92a8 | 1986 | |
42e69d6b VZ |
1987 | SIZE sizeRect; |
1988 | TEXTMETRIC tm; | |
767b35a5 | 1989 | ::GetTextExtentPoint32(hdc, string, string.length(), &sizeRect); |
64869ab7 | 1990 | GetTextMetrics(hdc, &tm); |
42e69d6b | 1991 | |
0655ad29 VZ |
1992 | if ( x ) |
1993 | *x = sizeRect.cx; | |
1994 | if ( y ) | |
1995 | *y = sizeRect.cy; | |
1996 | if ( descent ) | |
1997 | *descent = tm.tmDescent; | |
1998 | if ( externalLeading ) | |
1999 | *externalLeading = tm.tmExternalLeading; | |
2bda0e17 KB |
2000 | } |
2001 | ||
c50f1fb9 VZ |
2002 | // --------------------------------------------------------------------------- |
2003 | // popup menu | |
2004 | // --------------------------------------------------------------------------- | |
2005 | ||
2e9f62da VZ |
2006 | #if wxUSE_MENUS_NATIVE |
2007 | ||
ed45e263 VZ |
2008 | // yield for WM_COMMAND events only, i.e. process all WM_COMMANDs in the queue |
2009 | // immediately, without waiting for the next event loop iteration | |
2010 | // | |
2011 | // NB: this function should probably be made public later as it can almost | |
2012 | // surely replace wxYield() elsewhere as well | |
2013 | static void wxYieldForCommandsOnly() | |
2014 | { | |
2015 | // peek all WM_COMMANDs (it will always return WM_QUIT too but we don't | |
2016 | // want to process it here) | |
2017 | MSG msg; | |
1bf77ee5 | 2018 | while ( ::PeekMessage(&msg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE) ) |
ed45e263 | 2019 | { |
dd7ebf8b | 2020 | if ( msg.message == WM_QUIT ) |
1bf77ee5 VZ |
2021 | { |
2022 | // if we retrieved a WM_QUIT, insert back into the message queue. | |
2023 | ::PostQuitMessage(0); | |
2024 | break; | |
2025 | } | |
7de59551 | 2026 | |
1bf77ee5 VZ |
2027 | // luckily (as we don't have access to wxEventLoopImpl method from here |
2028 | // anyhow...) we don't need to pre process WM_COMMANDs so dispatch it | |
2029 | // immediately | |
2030 | ::TranslateMessage(&msg); | |
2031 | ::DispatchMessage(&msg); | |
2032 | } | |
ed45e263 VZ |
2033 | } |
2034 | ||
1e6feb95 | 2035 | bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y) |
c50f1fb9 VZ |
2036 | { |
2037 | menu->SetInvokingWindow(this); | |
2038 | menu->UpdateUI(); | |
2039 | ||
27d2dbbc | 2040 | if ( x == wxDefaultCoord && y == wxDefaultCoord ) |
971562cb VS |
2041 | { |
2042 | wxPoint mouse = ScreenToClient(wxGetMousePosition()); | |
2043 | x = mouse.x; y = mouse.y; | |
2044 | } | |
2045 | ||
c50f1fb9 VZ |
2046 | HWND hWnd = GetHwnd(); |
2047 | HMENU hMenu = GetHmenuOf(menu); | |
2048 | POINT point; | |
2049 | point.x = x; | |
2050 | point.y = y; | |
2051 | ::ClientToScreen(hWnd, &point); | |
2052 | wxCurrentPopupMenu = menu; | |
5cb598ae | 2053 | #if defined(__WXWINCE__) |
b40bf35c VZ |
2054 | static const UINT flags = 0; |
2055 | #else // !__WXWINCE__ | |
2056 | UINT flags = TPM_RIGHTBUTTON; | |
2057 | // NT4 doesn't support TPM_RECURSE and simply doesn't show the menu at all | |
2058 | // when it's use, I'm not sure about Win95/98 but prefer to err on the safe | |
2059 | // side and not to use it there neither -- modify the test if it does work | |
2060 | // on these systems | |
2061 | if ( wxGetWinVersion() >= wxWinVersion_5 ) | |
2062 | { | |
2063 | // using TPM_RECURSE allows us to show a popup menu while another menu | |
2064 | // is opened which can be useful and is supported by the other | |
2065 | // platforms, so allow it under Windows too | |
2066 | flags |= TPM_RECURSE; | |
2067 | } | |
2068 | #endif // __WXWINCE__/!__WXWINCE__ | |
2069 | ||
7f0586ef | 2070 | ::TrackPopupMenu(hMenu, flags, point.x, point.y, 0, hWnd, NULL); |
ed45e263 | 2071 | |
90e572f1 | 2072 | // we need to do it right now as otherwise the events are never going to be |
ed45e263 VZ |
2073 | // sent to wxCurrentPopupMenu from HandleCommand() |
2074 | // | |
2075 | // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't | |
2076 | // help and we'd still need wxYieldForCommandsOnly() as the menu may be | |
2077 | // destroyed as soon as we return (it can be a local variable in the caller | |
2078 | // for example) and so we do need to process the event immediately | |
2079 | wxYieldForCommandsOnly(); | |
2080 | ||
c50f1fb9 VZ |
2081 | wxCurrentPopupMenu = NULL; |
2082 | ||
2083 | menu->SetInvokingWindow(NULL); | |
2084 | ||
08158721 | 2085 | return true; |
c50f1fb9 VZ |
2086 | } |
2087 | ||
1e6feb95 VZ |
2088 | #endif // wxUSE_MENUS_NATIVE |
2089 | ||
42e69d6b VZ |
2090 | // =========================================================================== |
2091 | // pre/post message processing | |
2092 | // =========================================================================== | |
2bda0e17 | 2093 | |
c140b7e7 | 2094 | WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) |
42e69d6b VZ |
2095 | { |
2096 | if ( m_oldWndProc ) | |
2097 | return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); | |
2098 | else | |
2099 | return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam); | |
2100 | } | |
2bda0e17 | 2101 | |
1e6feb95 | 2102 | bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) |
42e69d6b | 2103 | { |
1e6feb95 VZ |
2104 | // wxUniversal implements tab traversal itself |
2105 | #ifndef __WXUNIVERSAL__ | |
42e69d6b | 2106 | if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) |
2d0a075d | 2107 | { |
42e69d6b VZ |
2108 | // intercept dialog navigation keys |
2109 | MSG *msg = (MSG *)pMsg; | |
d9317fd4 VZ |
2110 | |
2111 | // here we try to do all the job which ::IsDialogMessage() usually does | |
2112 | // internally | |
573a1586 | 2113 | if ( msg->message == WM_KEYDOWN ) |
42e69d6b | 2114 | { |
3f7bc32b VZ |
2115 | bool bCtrlDown = wxIsCtrlDown(); |
2116 | bool bShiftDown = wxIsShiftDown(); | |
a23fd0e1 | 2117 | |
42e69d6b VZ |
2118 | // WM_GETDLGCODE: ask the control if it wants the key for itself, |
2119 | // don't process it if it's the case (except for Ctrl-Tab/Enter | |
2120 | // combinations which are always processed) | |
977f50f3 VZ |
2121 | LONG lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0); |
2122 | ||
2123 | // surprizingly, DLGC_WANTALLKEYS bit mask doesn't contain the | |
2124 | // DLGC_WANTTAB nor DLGC_WANTARROWS bits although, logically, | |
2125 | // it, of course, implies them | |
2126 | if ( lDlgCode & DLGC_WANTALLKEYS ) | |
42e69d6b | 2127 | { |
977f50f3 | 2128 | lDlgCode |= DLGC_WANTTAB | DLGC_WANTARROWS; |
42e69d6b | 2129 | } |
a23fd0e1 | 2130 | |
08158721 | 2131 | bool bForward = true, |
298ca00c VZ |
2132 | bWindowChange = false, |
2133 | bFromTab = false; | |
a23fd0e1 | 2134 | |
573a1586 | 2135 | // should we process this message specially? |
08158721 | 2136 | bool bProcess = true; |
9145664b | 2137 | switch ( msg->wParam ) |
42e69d6b VZ |
2138 | { |
2139 | case VK_TAB: | |
7cc44669 VZ |
2140 | if ( (lDlgCode & DLGC_WANTTAB) && !bCtrlDown ) |
2141 | { | |
2142 | // let the control have the TAB | |
08158721 | 2143 | bProcess = false; |
42e69d6b | 2144 | } |
7cc44669 VZ |
2145 | else // use it for navigation |
2146 | { | |
42e69d6b VZ |
2147 | // Ctrl-Tab cycles thru notebook pages |
2148 | bWindowChange = bCtrlDown; | |
319fefa9 | 2149 | bForward = !bShiftDown; |
298ca00c | 2150 | bFromTab = true; |
42e69d6b VZ |
2151 | } |
2152 | break; | |
a23fd0e1 | 2153 | |
42e69d6b VZ |
2154 | case VK_UP: |
2155 | case VK_LEFT: | |
2156 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) | |
08158721 | 2157 | bProcess = false; |
42e69d6b | 2158 | else |
08158721 | 2159 | bForward = false; |
42e69d6b | 2160 | break; |
a02eb1d2 | 2161 | |
42e69d6b VZ |
2162 | case VK_DOWN: |
2163 | case VK_RIGHT: | |
2164 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) | |
08158721 | 2165 | bProcess = false; |
42e69d6b | 2166 | break; |
2bda0e17 | 2167 | |
efe5e221 VZ |
2168 | case VK_PRIOR: |
2169 | bForward = false; | |
2170 | // fall through | |
2171 | ||
2172 | case VK_NEXT: | |
2173 | // we treat PageUp/Dn as arrows because chances are that | |
2174 | // a control which needs arrows also needs them for | |
2175 | // navigation (e.g. wxTextCtrl, wxListCtrl, ...) | |
ada5f90d | 2176 | if ( (lDlgCode & DLGC_WANTARROWS) && !bCtrlDown ) |
efe5e221 | 2177 | bProcess = false; |
ada5f90d | 2178 | else // OTOH Ctrl-PageUp/Dn works as [Shift-]Ctrl-Tab |
efe5e221 VZ |
2179 | bWindowChange = true; |
2180 | break; | |
2181 | ||
42e69d6b VZ |
2182 | case VK_RETURN: |
2183 | { | |
edccf428 | 2184 | if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown ) |
42e69d6b VZ |
2185 | { |
2186 | // control wants to process Enter itself, don't | |
90c6edd7 | 2187 | // call IsDialogMessage() which would consume it |
08158721 | 2188 | return false; |
42e69d6b | 2189 | } |
3147bb58 | 2190 | |
90c6edd7 | 2191 | #if wxUSE_BUTTON |
3147bb58 | 2192 | // currently active button should get enter press even |
90c6edd7 VZ |
2193 | // if there is a default button elsewhere so check if |
2194 | // this window is a button first | |
2195 | wxWindow *btn = NULL; | |
3147bb58 | 2196 | if ( lDlgCode & DLGC_DEFPUSHBUTTON ) |
319fefa9 | 2197 | { |
3e79ed96 VZ |
2198 | // let IsDialogMessage() handle this for all |
2199 | // buttons except the owner-drawn ones which it | |
2200 | // just seems to ignore | |
2201 | long style = ::GetWindowLong(msg->hwnd, GWL_STYLE); | |
2202 | if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW ) | |
2203 | { | |
2204 | // emulate the button click | |
90c6edd7 | 2205 | btn = wxFindWinFromHandle((WXHWND)msg->hwnd); |
3e79ed96 VZ |
2206 | } |
2207 | ||
08158721 | 2208 | bProcess = false; |
319fefa9 | 2209 | } |
90c6edd7 | 2210 | else // not a button itself, do we have default button? |
c50f1fb9 | 2211 | { |
90c6edd7 VZ |
2212 | wxTopLevelWindow * |
2213 | tlw = wxDynamicCast(wxGetTopLevelParent(this), | |
2214 | wxTopLevelWindow); | |
6c20e8f8 | 2215 | if ( tlw ) |
c50f1fb9 | 2216 | { |
90c6edd7 VZ |
2217 | btn = wxDynamicCast(tlw->GetDefaultItem(), |
2218 | wxButton); | |
c50f1fb9 | 2219 | } |
90c6edd7 VZ |
2220 | } |
2221 | ||
2222 | if ( btn && btn->IsEnabled() ) | |
2223 | { | |
2224 | btn->MSWCommand(BN_CLICKED, 0 /* unused */); | |
2225 | return true; | |
2226 | } | |
2227 | ||
1e6feb95 | 2228 | #endif // wxUSE_BUTTON |
90c6edd7 | 2229 | |
7b504551 | 2230 | #ifdef __WXWINCE__ |
90c6edd7 VZ |
2231 | // map Enter presses into button presses on PDAs |
2232 | wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN); | |
2233 | event.SetEventObject(this); | |
2234 | if ( GetEventHandler()->ProcessEvent(event) ) | |
2235 | return true; | |
2236 | #endif // __WXWINCE__ | |
42e69d6b VZ |
2237 | } |
2238 | break; | |
2bda0e17 | 2239 | |
42e69d6b | 2240 | default: |
08158721 | 2241 | bProcess = false; |
42e69d6b | 2242 | } |
2bda0e17 | 2243 | |
42e69d6b VZ |
2244 | if ( bProcess ) |
2245 | { | |
2246 | wxNavigationKeyEvent event; | |
2247 | event.SetDirection(bForward); | |
2248 | event.SetWindowChange(bWindowChange); | |
298ca00c | 2249 | event.SetFromTab(bFromTab); |
42e69d6b | 2250 | event.SetEventObject(this); |
3572173c | 2251 | |
42e69d6b | 2252 | if ( GetEventHandler()->ProcessEvent(event) ) |
57c0af52 | 2253 | { |
d7e0024b VZ |
2254 | // as we don't call IsDialogMessage(), which would take of |
2255 | // this by default, we need to manually send this message | |
1ca78aa1 JS |
2256 | // so that controls can change their UI state if needed |
2257 | MSWUpdateUIState(UIS_CLEAR, UISF_HIDEFOCUS); | |
d7e0024b | 2258 | |
08158721 | 2259 | return true; |
57c0af52 | 2260 | } |
42e69d6b VZ |
2261 | } |
2262 | } | |
a23fd0e1 | 2263 | |
98ebf919 | 2264 | if ( ::IsDialogMessage(GetHwnd(), msg) ) |
f6bcfd97 | 2265 | { |
98ebf919 VZ |
2266 | // IsDialogMessage() did something... |
2267 | return true; | |
f6bcfd97 | 2268 | } |
42e69d6b | 2269 | } |
1e6feb95 | 2270 | #endif // __WXUNIVERSAL__ |
a23fd0e1 | 2271 | |
42e69d6b VZ |
2272 | #if wxUSE_TOOLTIPS |
2273 | if ( m_tooltip ) | |
387a3b02 | 2274 | { |
42e69d6b VZ |
2275 | // relay mouse move events to the tooltip control |
2276 | MSG *msg = (MSG *)pMsg; | |
2277 | if ( msg->message == WM_MOUSEMOVE ) | |
259a4264 | 2278 | wxToolTip::RelayEvent(pMsg); |
387a3b02 | 2279 | } |
42e69d6b | 2280 | #endif // wxUSE_TOOLTIPS |
a23fd0e1 | 2281 | |
08158721 | 2282 | return false; |
387a3b02 JS |
2283 | } |
2284 | ||
1e6feb95 | 2285 | bool wxWindowMSW::MSWTranslateMessage(WXMSG* pMsg) |
387a3b02 | 2286 | { |
1e6feb95 | 2287 | #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) |
c50f1fb9 | 2288 | return m_acceleratorTable.Translate(this, pMsg); |
1e6feb95 | 2289 | #else |
574c939e | 2290 | (void) pMsg; |
08158721 | 2291 | return false; |
1e6feb95 | 2292 | #endif // wxUSE_ACCEL |
387a3b02 JS |
2293 | } |
2294 | ||
98ebf919 | 2295 | bool wxWindowMSW::MSWShouldPreProcessMessage(WXMSG* msg) |
a37d422a | 2296 | { |
98ebf919 VZ |
2297 | // all tests below have to deal with various bugs/misfeatures of |
2298 | // IsDialogMessage(): we have to prevent it from being called from our | |
2299 | // MSWProcessMessage() in some situations | |
2300 | ||
2301 | // don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the | |
2302 | // message even when there is no cancel button and when the message is | |
2303 | // needed by the control itself: in particular, it prevents the tree in | |
2304 | // place edit control from being closed with Escape in a dialog | |
2305 | if ( msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE ) | |
2306 | { | |
2307 | return false; | |
2308 | } | |
2309 | ||
2310 | // ::IsDialogMessage() is broken and may sometimes hang the application by | |
2311 | // going into an infinite loop when it tries to find the control to give | |
2312 | // focus to when Alt-<key> is pressed, so we try to detect [some of] the | |
2313 | // situations when this may happen and not call it then | |
2314 | if ( msg->message != WM_SYSCHAR ) | |
2315 | return true; | |
2316 | ||
2317 | // assume we can call it by default | |
2318 | bool canSafelyCallIsDlgMsg = true; | |
2319 | ||
2320 | HWND hwndFocus = ::GetFocus(); | |
2321 | ||
2322 | // if the currently focused window itself has WS_EX_CONTROLPARENT style, | |
2323 | // ::IsDialogMessage() will also enter an infinite loop, because it will | |
2324 | // recursively check the child windows but not the window itself and so if | |
2325 | // none of the children accepts focus it loops forever (as it only stops | |
2326 | // when it gets back to the window it started from) | |
2327 | // | |
2328 | // while it is very unusual that a window with WS_EX_CONTROLPARENT | |
2329 | // style has the focus, it can happen. One such possibility is if | |
2330 | // all windows are either toplevel, wxDialog, wxPanel or static | |
2331 | // controls and no window can actually accept keyboard input. | |
2332 | #if !defined(__WXWINCE__) | |
2333 | if ( ::GetWindowLong(hwndFocus, GWL_EXSTYLE) & WS_EX_CONTROLPARENT ) | |
2334 | { | |
2335 | // pessimistic by default | |
2336 | canSafelyCallIsDlgMsg = false; | |
2337 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); | |
2338 | node; | |
2339 | node = node->GetNext() ) | |
2340 | { | |
2341 | wxWindow * const win = node->GetData(); | |
ad02525d | 2342 | if ( win->CanAcceptFocus() && |
98ebf919 VZ |
2343 | !(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) & |
2344 | WS_EX_CONTROLPARENT) ) | |
2345 | { | |
2346 | // it shouldn't hang... | |
2347 | canSafelyCallIsDlgMsg = true; | |
2348 | ||
2349 | break; | |
2350 | } | |
2351 | } | |
2352 | } | |
2353 | #endif // !__WXWINCE__ | |
2354 | ||
2355 | if ( canSafelyCallIsDlgMsg ) | |
2356 | { | |
2357 | // ::IsDialogMessage() can enter in an infinite loop when the | |
2358 | // currently focused window is disabled or hidden and its | |
2359 | // parent has WS_EX_CONTROLPARENT style, so don't call it in | |
2360 | // this case | |
2361 | while ( hwndFocus ) | |
2362 | { | |
2363 | if ( !::IsWindowEnabled(hwndFocus) || | |
2364 | !::IsWindowVisible(hwndFocus) ) | |
2365 | { | |
2366 | // it would enter an infinite loop if we do this! | |
2367 | canSafelyCallIsDlgMsg = false; | |
2368 | ||
2369 | break; | |
2370 | } | |
2371 | ||
2372 | if ( !(::GetWindowLong(hwndFocus, GWL_STYLE) & WS_CHILD) ) | |
2373 | { | |
2374 | // it's a top level window, don't go further -- e.g. even | |
2375 | // if the parent of a dialog is disabled, this doesn't | |
2376 | // break navigation inside the dialog | |
2377 | break; | |
2378 | } | |
2379 | ||
2380 | hwndFocus = ::GetParent(hwndFocus); | |
2381 | } | |
2382 | } | |
2383 | ||
2384 | return canSafelyCallIsDlgMsg; | |
a37d422a VZ |
2385 | } |
2386 | ||
42e69d6b | 2387 | // --------------------------------------------------------------------------- |
e39af974 | 2388 | // message params unpackers |
42e69d6b | 2389 | // --------------------------------------------------------------------------- |
2bda0e17 | 2390 | |
1e6feb95 | 2391 | void wxWindowMSW::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, |
42e69d6b VZ |
2392 | WORD *id, WXHWND *hwnd, WORD *cmd) |
2393 | { | |
2394 | *id = LOWORD(wParam); | |
2395 | *hwnd = (WXHWND)lParam; | |
2396 | *cmd = HIWORD(wParam); | |
2bda0e17 KB |
2397 | } |
2398 | ||
1e6feb95 | 2399 | void wxWindowMSW::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, |
42e69d6b | 2400 | WXWORD *state, WXWORD *minimized, WXHWND *hwnd) |
2bda0e17 | 2401 | { |
42e69d6b VZ |
2402 | *state = LOWORD(wParam); |
2403 | *minimized = HIWORD(wParam); | |
2404 | *hwnd = (WXHWND)lParam; | |
2bda0e17 KB |
2405 | } |
2406 | ||
1e6feb95 | 2407 | void wxWindowMSW::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, |
42e69d6b | 2408 | WXWORD *code, WXWORD *pos, WXHWND *hwnd) |
2bda0e17 | 2409 | { |
42e69d6b VZ |
2410 | *code = LOWORD(wParam); |
2411 | *pos = HIWORD(wParam); | |
2412 | *hwnd = (WXHWND)lParam; | |
2413 | } | |
a23fd0e1 | 2414 | |
1e6feb95 | 2415 | void wxWindowMSW::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, |
01c500af | 2416 | WXHDC *hdc, WXHWND *hwnd) |
42e69d6b | 2417 | { |
42e69d6b VZ |
2418 | *hwnd = (WXHWND)lParam; |
2419 | *hdc = (WXHDC)wParam; | |
2bda0e17 KB |
2420 | } |
2421 | ||
1e6feb95 | 2422 | void wxWindowMSW::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, |
42e69d6b | 2423 | WXWORD *item, WXWORD *flags, WXHMENU *hmenu) |
2bda0e17 | 2424 | { |
42e69d6b VZ |
2425 | *item = (WXWORD)wParam; |
2426 | *flags = HIWORD(wParam); | |
2427 | *hmenu = (WXHMENU)lParam; | |
2428 | } | |
c085e333 | 2429 | |
42e69d6b | 2430 | // --------------------------------------------------------------------------- |
77ffb593 | 2431 | // Main wxWidgets window proc and the window proc for wxWindow |
42e69d6b | 2432 | // --------------------------------------------------------------------------- |
2bda0e17 | 2433 | |
42e69d6b VZ |
2434 | // Hook for new window just as it's being created, when the window isn't yet |
2435 | // associated with the handle | |
b225f659 VZ |
2436 | static wxWindowMSW *gs_winBeingCreated = NULL; |
2437 | ||
2438 | // implementation of wxWindowCreationHook class: it just sets gs_winBeingCreated to the | |
2439 | // window being created and insures that it's always unset back later | |
2440 | wxWindowCreationHook::wxWindowCreationHook(wxWindowMSW *winBeingCreated) | |
2441 | { | |
2442 | gs_winBeingCreated = winBeingCreated; | |
2443 | } | |
2444 | ||
2445 | wxWindowCreationHook::~wxWindowCreationHook() | |
2446 | { | |
2447 | gs_winBeingCreated = NULL; | |
2448 | } | |
42e69d6b VZ |
2449 | |
2450 | // Main window proc | |
3135f4a7 | 2451 | LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
2bda0e17 | 2452 | { |
42e69d6b VZ |
2453 | // trace all messages - useful for the debugging |
2454 | #ifdef __WXDEBUG__ | |
13e4c4d9 VZ |
2455 | wxLogTrace(wxTraceMessages, |
2456 | wxT("Processing %s(hWnd=%08lx, wParam=%8lx, lParam=%8lx)"), | |
2457 | wxGetMessageName(message), (long)hWnd, (long)wParam, lParam); | |
42e69d6b | 2458 | #endif // __WXDEBUG__ |
2bda0e17 | 2459 | |
1e6feb95 | 2460 | wxWindowMSW *wnd = wxFindWinFromHandle((WXHWND) hWnd); |
c085e333 | 2461 | |
42e69d6b | 2462 | // when we get the first message for the HWND we just created, we associate |
b225f659 VZ |
2463 | // it with wxWindow stored in gs_winBeingCreated |
2464 | if ( !wnd && gs_winBeingCreated ) | |
2d0a075d | 2465 | { |
b225f659 VZ |
2466 | wxAssociateWinWithHandle(hWnd, gs_winBeingCreated); |
2467 | wnd = gs_winBeingCreated; | |
2468 | gs_winBeingCreated = NULL; | |
42e69d6b | 2469 | wnd->SetHWND((WXHWND)hWnd); |
2d0a075d | 2470 | } |
2bda0e17 | 2471 | |
42e69d6b | 2472 | LRESULT rc; |
a23fd0e1 | 2473 | |
a3dc1da9 | 2474 | if ( wnd && wxEventLoop::AllowProcessing(wnd) ) |
b225f659 | 2475 | rc = wnd->MSWWindowProc(message, wParam, lParam); |
a23fd0e1 | 2476 | else |
b225f659 | 2477 | rc = ::DefWindowProc(hWnd, message, wParam, lParam); |
2bda0e17 | 2478 | |
42e69d6b | 2479 | return rc; |
f7bd2698 JS |
2480 | } |
2481 | ||
c140b7e7 | 2482 | WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
f7bd2698 | 2483 | { |
42e69d6b | 2484 | // did we process the message? |
08158721 | 2485 | bool processed = false; |
f7bd2698 | 2486 | |
42e69d6b VZ |
2487 | // the return value |
2488 | union | |
2bda0e17 | 2489 | { |
42e69d6b | 2490 | bool allow; |
c140b7e7 | 2491 | WXLRESULT result; |
42e69d6b VZ |
2492 | WXHBRUSH hBrush; |
2493 | } rc; | |
2bda0e17 | 2494 | |
42e69d6b VZ |
2495 | // for most messages we should return 0 when we do process the message |
2496 | rc.result = 0; | |
2bda0e17 | 2497 | |
42e69d6b | 2498 | switch ( message ) |
39136494 | 2499 | { |
42e69d6b VZ |
2500 | case WM_CREATE: |
2501 | { | |
2502 | bool mayCreate; | |
2503 | processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate); | |
2504 | if ( processed ) | |
2505 | { | |
2506 | // return 0 to allow window creation | |
2507 | rc.result = mayCreate ? 0 : -1; | |
2508 | } | |
2509 | } | |
2510 | break; | |
47cbd6da | 2511 | |
42e69d6b | 2512 | case WM_DESTROY: |
08158721 | 2513 | // never set processed to true and *always* pass WM_DESTROY to |
ad4297f3 VZ |
2514 | // DefWindowProc() as Windows may do some internal cleanup when |
2515 | // processing it and failing to pass the message along may cause | |
2516 | // memory and resource leaks! | |
2517 | (void)HandleDestroy(); | |
42e69d6b VZ |
2518 | break; |
2519 | ||
9b6ae450 VZ |
2520 | case WM_SIZE: |
2521 | processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); | |
9b6ae450 VZ |
2522 | break; |
2523 | ||
42e69d6b | 2524 | case WM_MOVE: |
132cb640 | 2525 | processed = HandleMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); |
42e69d6b | 2526 | break; |
47cbd6da | 2527 | |
7f0586ef | 2528 | #if !defined(__WXWINCE__) |
5706de1c | 2529 | case WM_MOVING: |
540b6b09 VZ |
2530 | { |
2531 | LPRECT pRect = (LPRECT)lParam; | |
2532 | wxRect rc; | |
2533 | rc.SetLeft(pRect->left); | |
2534 | rc.SetTop(pRect->top); | |
2535 | rc.SetRight(pRect->right); | |
2536 | rc.SetBottom(pRect->bottom); | |
2537 | processed = HandleMoving(rc); | |
2538 | if (processed) { | |
2539 | pRect->left = rc.GetLeft(); | |
2540 | pRect->top = rc.GetTop(); | |
2541 | pRect->right = rc.GetRight(); | |
2542 | pRect->bottom = rc.GetBottom(); | |
2543 | } | |
2544 | } | |
5706de1c JS |
2545 | break; |
2546 | ||
5706de1c JS |
2547 | case WM_SIZING: |
2548 | { | |
2549 | LPRECT pRect = (LPRECT)lParam; | |
2550 | wxRect rc; | |
2551 | rc.SetLeft(pRect->left); | |
2552 | rc.SetTop(pRect->top); | |
2553 | rc.SetRight(pRect->right); | |
2554 | rc.SetBottom(pRect->bottom); | |
2555 | processed = HandleSizing(rc); | |
2556 | if (processed) { | |
2557 | pRect->left = rc.GetLeft(); | |
2558 | pRect->top = rc.GetTop(); | |
2559 | pRect->right = rc.GetRight(); | |
2560 | pRect->bottom = rc.GetBottom(); | |
2561 | } | |
2562 | } | |
2563 | break; | |
9b6ae450 | 2564 | #endif // !__WXWINCE__ |
5706de1c | 2565 | |
7f0586ef | 2566 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
1e6feb95 | 2567 | case WM_ACTIVATEAPP: |
afafd942 | 2568 | // This implicitly sends a wxEVT_ACTIVATE_APP event |
1e6feb95 | 2569 | wxTheApp->SetActive(wParam != 0, FindFocus()); |
42e69d6b | 2570 | break; |
8a46f9b1 | 2571 | #endif |
47cbd6da | 2572 | |
42e69d6b | 2573 | case WM_ACTIVATE: |
341c92a8 | 2574 | { |
42e69d6b VZ |
2575 | WXWORD state, minimized; |
2576 | WXHWND hwnd; | |
2577 | UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); | |
2578 | ||
2579 | processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd); | |
341c92a8 | 2580 | } |
42e69d6b | 2581 | break; |
341c92a8 | 2582 | |
42e69d6b VZ |
2583 | case WM_SETFOCUS: |
2584 | processed = HandleSetFocus((WXHWND)(HWND)wParam); | |
2585 | break; | |
47cbd6da | 2586 | |
42e69d6b VZ |
2587 | case WM_KILLFOCUS: |
2588 | processed = HandleKillFocus((WXHWND)(HWND)wParam); | |
2589 | break; | |
47cbd6da | 2590 | |
c3732409 | 2591 | case WM_PRINTCLIENT: |
1a784dfc | 2592 | processed = HandlePrintClient((WXHDC)wParam); |
07c19327 VZ |
2593 | break; |
2594 | ||
c3732409 VZ |
2595 | case WM_PAINT: |
2596 | if ( wParam ) | |
5c6c3176 | 2597 | { |
5c6c3176 | 2598 | wxPaintDCEx dc((wxWindow *)this, (WXHDC)wParam); |
07c19327 | 2599 | |
5c6c3176 RD |
2600 | processed = HandlePaint(); |
2601 | } | |
c3732409 VZ |
2602 | else // no DC given |
2603 | { | |
2604 | processed = HandlePaint(); | |
2605 | } | |
5c6c3176 RD |
2606 | break; |
2607 | ||
42e69d6b | 2608 | case WM_CLOSE: |
9fd9e47a JS |
2609 | #ifdef __WXUNIVERSAL__ |
2610 | // Universal uses its own wxFrame/wxDialog, so we don't receive | |
2611 | // close events unless we have this. | |
2612 | Close(); | |
c3732409 VZ |
2613 | #endif // __WXUNIVERSAL__ |
2614 | ||
42e69d6b VZ |
2615 | // don't let the DefWindowProc() destroy our window - we'll do it |
2616 | // ourselves in ~wxWindow | |
08158721 | 2617 | processed = true; |
42e69d6b VZ |
2618 | rc.result = TRUE; |
2619 | break; | |
47cbd6da | 2620 | |
42e69d6b VZ |
2621 | case WM_SHOWWINDOW: |
2622 | processed = HandleShow(wParam != 0, (int)lParam); | |
2623 | break; | |
3a19e16d | 2624 | |
42e69d6b | 2625 | case WM_MOUSEMOVE: |
132cb640 VZ |
2626 | processed = HandleMouseMove(GET_X_LPARAM(lParam), |
2627 | GET_Y_LPARAM(lParam), | |
2628 | wParam); | |
2629 | break; | |
0d0512bd | 2630 | |
4e5c6c33 | 2631 | #ifdef HAVE_TRACKMOUSEEVENT |
e5297b7f | 2632 | case WM_MOUSELEAVE: |
aafb9978 VZ |
2633 | // filter out excess WM_MOUSELEAVE events sent after PopupMenu() |
2634 | // (on XP at least) | |
4e5c6c33 | 2635 | if ( m_mouseInWindow ) |
e5297b7f | 2636 | { |
4e5c6c33 | 2637 | GenerateMouseLeave(); |
e5297b7f | 2638 | } |
4e5c6c33 VZ |
2639 | |
2640 | // always pass processed back as false, this allows the window | |
2641 | // manager to process the message too. This is needed to | |
2642 | // ensure windows XP themes work properly as the mouse moves | |
2643 | // over widgets like buttons. So don't set processed to true here. | |
51e4e266 | 2644 | break; |
4e5c6c33 | 2645 | #endif // HAVE_TRACKMOUSEEVENT |
35bbb0c6 | 2646 | |
d2c52078 RD |
2647 | #if wxUSE_MOUSEWHEEL |
2648 | case WM_MOUSEWHEEL: | |
2649 | processed = HandleMouseWheel(wParam, lParam); | |
2650 | break; | |
2651 | #endif | |
2652 | ||
42e69d6b VZ |
2653 | case WM_LBUTTONDOWN: |
2654 | case WM_LBUTTONUP: | |
2655 | case WM_LBUTTONDBLCLK: | |
2656 | case WM_RBUTTONDOWN: | |
2657 | case WM_RBUTTONUP: | |
2658 | case WM_RBUTTONDBLCLK: | |
2659 | case WM_MBUTTONDOWN: | |
2660 | case WM_MBUTTONUP: | |
2661 | case WM_MBUTTONDBLCLK: | |
dfafa702 | 2662 | { |
98363307 | 2663 | #ifdef __WXMICROWIN__ |
cd4453e5 VZ |
2664 | // MicroWindows seems to ignore the fact that a window is |
2665 | // disabled. So catch mouse events and throw them away if | |
2666 | // necessary. | |
d0a3d109 | 2667 | wxWindowMSW* win = this; |
dfafa702 | 2668 | for ( ;; ) |
d0a3d109 VZ |
2669 | { |
2670 | if (!win->IsEnabled()) | |
2671 | { | |
08158721 | 2672 | processed = true; |
d0a3d109 VZ |
2673 | break; |
2674 | } | |
dfafa702 | 2675 | |
d0a3d109 | 2676 | win = win->GetParent(); |
dfafa702 | 2677 | if ( !win || win->IsTopLevel() ) |
d0a3d109 VZ |
2678 | break; |
2679 | } | |
dfafa702 | 2680 | |
03e0b2b1 VZ |
2681 | if ( processed ) |
2682 | break; | |
2683 | ||
dfafa702 | 2684 | #endif // __WXMICROWIN__ |
03e0b2b1 VZ |
2685 | int x = GET_X_LPARAM(lParam), |
2686 | y = GET_Y_LPARAM(lParam); | |
dfafa702 | 2687 | |
42b1fb63 | 2688 | #ifdef __WXWINCE__ |
03e0b2b1 | 2689 | // redirect the event to a static control if necessary by |
42b1fb63 VZ |
2690 | // finding one under mouse because under CE the static controls |
2691 | // don't generate mouse events (even with SS_NOTIFY) | |
03e0b2b1 VZ |
2692 | wxWindowMSW *win; |
2693 | if ( GetCapture() == this ) | |
2694 | { | |
2695 | // but don't do it if the mouse is captured by this window | |
2696 | // because then it should really get this event itself | |
2697 | win = this; | |
d0a3d109 | 2698 | } |
03e0b2b1 VZ |
2699 | else |
2700 | { | |
2701 | win = FindWindowForMouseEvent(this, &x, &y); | |
2b5f62a0 VZ |
2702 | |
2703 | // this should never happen | |
2704 | wxCHECK_MSG( win, 0, | |
2705 | _T("FindWindowForMouseEvent() returned NULL") ); | |
9f011847 | 2706 | } |
7d4f65e3 JS |
2707 | #ifdef __POCKETPC__ |
2708 | if (IsContextMenuEnabled() && message == WM_LBUTTONDOWN) | |
2709 | { | |
2710 | SHRGINFO shrgi = {0}; | |
faa94f3e | 2711 | |
7d4f65e3 JS |
2712 | shrgi.cbSize = sizeof(SHRGINFO); |
2713 | shrgi.hwndClient = (HWND) GetHWND(); | |
2714 | shrgi.ptDown.x = x; | |
2715 | shrgi.ptDown.y = y; | |
faa94f3e | 2716 | |
7d4f65e3 JS |
2717 | shrgi.dwFlags = SHRG_RETURNCMD; |
2718 | // shrgi.dwFlags = SHRG_NOTIFYPARENT; | |
faa94f3e | 2719 | |
7d4f65e3 JS |
2720 | if (GN_CONTEXTMENU == ::SHRecognizeGesture(&shrgi)) |
2721 | { | |
2722 | wxPoint pt(x, y); | |
2723 | pt = ClientToScreen(pt); | |
faa94f3e | 2724 | |
7d4f65e3 | 2725 | wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt); |
faa94f3e | 2726 | |
7d4f65e3 JS |
2727 | evtCtx.SetEventObject(this); |
2728 | if (GetEventHandler()->ProcessEvent(evtCtx)) | |
f350d4b2 | 2729 | { |
7d4f65e3 | 2730 | processed = true; |
f350d4b2 JS |
2731 | return true; |
2732 | } | |
7d4f65e3 JS |
2733 | } |
2734 | } | |
2735 | #endif | |
2736 | ||
42b1fb63 VZ |
2737 | #else // !__WXWINCE__ |
2738 | wxWindowMSW *win = this; | |
2739 | #endif // __WXWINCE__/!__WXWINCE__ | |
9f011847 VZ |
2740 | |
2741 | processed = win->HandleMouseEvent(message, x, y, wParam); | |
2b5f62a0 | 2742 | |
9f011847 VZ |
2743 | // if the app didn't eat the event, handle it in the default |
2744 | // way, that is by giving this window the focus | |
2745 | if ( !processed ) | |
2746 | { | |
2b5f62a0 VZ |
2747 | // for the standard classes their WndProc sets the focus to |
2748 | // them anyhow and doing it from here results in some weird | |
9f011847 | 2749 | // problems, so don't do it for them (unnecessary anyhow) |
2b5f62a0 VZ |
2750 | if ( !win->IsOfStandardClass() ) |
2751 | { | |
ad02525d | 2752 | if ( message == WM_LBUTTONDOWN && win->CanAcceptFocus() ) |
2b5f62a0 VZ |
2753 | win->SetFocus(); |
2754 | } | |
03e0b2b1 | 2755 | } |
98363307 | 2756 | } |
dfafa702 | 2757 | break; |
d0a3d109 | 2758 | |
cd4453e5 | 2759 | #ifdef MM_JOY1MOVE |
42e69d6b VZ |
2760 | case MM_JOY1MOVE: |
2761 | case MM_JOY2MOVE: | |
2762 | case MM_JOY1ZMOVE: | |
2763 | case MM_JOY2ZMOVE: | |
2764 | case MM_JOY1BUTTONDOWN: | |
2765 | case MM_JOY2BUTTONDOWN: | |
2766 | case MM_JOY1BUTTONUP: | |
2767 | case MM_JOY2BUTTONUP: | |
132cb640 VZ |
2768 | processed = HandleJoystickEvent(message, |
2769 | GET_X_LPARAM(lParam), | |
2770 | GET_Y_LPARAM(lParam), | |
2771 | wParam); | |
42e69d6b | 2772 | break; |
cd4453e5 | 2773 | #endif // __WXMICROWIN__ |
47cbd6da | 2774 | |
42e69d6b VZ |
2775 | case WM_COMMAND: |
2776 | { | |
2777 | WORD id, cmd; | |
2778 | WXHWND hwnd; | |
2779 | UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); | |
47cbd6da | 2780 | |
42e69d6b VZ |
2781 | processed = HandleCommand(id, cmd, hwnd); |
2782 | } | |
2783 | break; | |
7d532b0c | 2784 | |
42e69d6b VZ |
2785 | case WM_NOTIFY: |
2786 | processed = HandleNotify((int)wParam, lParam, &rc.result); | |
2787 | break; | |
2bda0e17 | 2788 | |
27005f3a VZ |
2789 | // we only need to reply to WM_NOTIFYFORMAT manually when using MSLU, |
2790 | // otherwise DefWindowProc() does it perfectly fine for us, but MSLU | |
2791 | // apparently doesn't always behave properly and needs some help | |
2792 | #if wxUSE_UNICODE_MSLU && defined(NF_QUERY) | |
2793 | case WM_NOTIFYFORMAT: | |
2794 | if ( lParam == NF_QUERY ) | |
2795 | { | |
2796 | processed = true; | |
2797 | rc.result = NFR_UNICODE; | |
2798 | } | |
2799 | break; | |
2800 | #endif // wxUSE_UNICODE_MSLU | |
2801 | ||
08158721 | 2802 | // for these messages we must return true if process the message |
cd4453e5 | 2803 | #ifdef WM_DRAWITEM |
42e69d6b VZ |
2804 | case WM_DRAWITEM: |
2805 | case WM_MEASUREITEM: | |
2806 | { | |
2807 | int idCtrl = (UINT)wParam; | |
2808 | if ( message == WM_DRAWITEM ) | |
2809 | { | |
2810 | processed = MSWOnDrawItem(idCtrl, | |
2811 | (WXDRAWITEMSTRUCT *)lParam); | |
2812 | } | |
2813 | else | |
2814 | { | |
2815 | processed = MSWOnMeasureItem(idCtrl, | |
2816 | (WXMEASUREITEMSTRUCT *)lParam); | |
2817 | } | |
57a7b7c1 | 2818 | |
42e69d6b VZ |
2819 | if ( processed ) |
2820 | rc.result = TRUE; | |
2821 | } | |
2822 | break; | |
cd4453e5 VZ |
2823 | #endif // defined(WM_DRAWITEM) |
2824 | ||
9bf84618 | 2825 | case WM_GETDLGCODE: |
ff7282e1 | 2826 | if ( !IsOfStandardClass() || HasFlag(wxWANTS_CHARS) ) |
9bf84618 | 2827 | { |
5a403e3f VZ |
2828 | // we always want to get the char events |
2829 | rc.result = DLGC_WANTCHARS; | |
2830 | ||
ff7282e1 | 2831 | if ( HasFlag(wxWANTS_CHARS) ) |
5a403e3f VZ |
2832 | { |
2833 | // in fact, we want everything | |
2834 | rc.result |= DLGC_WANTARROWS | | |
2835 | DLGC_WANTTAB | | |
2836 | DLGC_WANTALLKEYS; | |
2837 | } | |
2838 | ||
08158721 | 2839 | processed = true; |
9bf84618 | 2840 | } |
101f488c | 2841 | //else: get the dlg code from the DefWindowProc() |
9bf84618 VZ |
2842 | break; |
2843 | ||
4004f41e | 2844 | case WM_SYSKEYDOWN: |
42e69d6b | 2845 | case WM_KEYDOWN: |
9c7df356 VZ |
2846 | // If this has been processed by an event handler, return 0 now |
2847 | // (we've handled it). | |
2848 | m_lastKeydownProcessed = HandleKeyDown((WORD) wParam, lParam); | |
2849 | if ( m_lastKeydownProcessed ) | |
2d0a075d | 2850 | { |
08158721 | 2851 | processed = true; |
2d0a075d | 2852 | } |
81d66cf3 | 2853 | |
2b5f62a0 | 2854 | if ( !processed ) |
42e69d6b | 2855 | { |
2b5f62a0 VZ |
2856 | switch ( wParam ) |
2857 | { | |
90e572f1 | 2858 | // we consider these messages "not interesting" to OnChar, so |
2b5f62a0 VZ |
2859 | // just don't do anything more with them |
2860 | case VK_SHIFT: | |
2861 | case VK_CONTROL: | |
2862 | case VK_MENU: | |
2863 | case VK_CAPITAL: | |
2864 | case VK_NUMLOCK: | |
2865 | case VK_SCROLL: | |
08158721 | 2866 | processed = true; |
2b5f62a0 | 2867 | break; |
2bda0e17 | 2868 | |
2b5f62a0 VZ |
2869 | // avoid duplicate messages to OnChar for these ASCII keys: |
2870 | // they will be translated by TranslateMessage() and received | |
2871 | // in WM_CHAR | |
2872 | case VK_ESCAPE: | |
2873 | case VK_SPACE: | |
2874 | case VK_RETURN: | |
2875 | case VK_BACK: | |
2876 | case VK_TAB: | |
2877 | case VK_ADD: | |
2878 | case VK_SUBTRACT: | |
2879 | case VK_MULTIPLY: | |
2880 | case VK_DIVIDE: | |
3f2174bb VZ |
2881 | case VK_NUMPAD0: |
2882 | case VK_NUMPAD1: | |
2883 | case VK_NUMPAD2: | |
2884 | case VK_NUMPAD3: | |
2885 | case VK_NUMPAD4: | |
2886 | case VK_NUMPAD5: | |
2887 | case VK_NUMPAD6: | |
2888 | case VK_NUMPAD7: | |
2889 | case VK_NUMPAD8: | |
2890 | case VK_NUMPAD9: | |
2b5f62a0 VZ |
2891 | case VK_OEM_1: |
2892 | case VK_OEM_2: | |
2893 | case VK_OEM_3: | |
2894 | case VK_OEM_4: | |
2895 | case VK_OEM_5: | |
2896 | case VK_OEM_6: | |
2897 | case VK_OEM_7: | |
2898 | case VK_OEM_PLUS: | |
2899 | case VK_OEM_COMMA: | |
2900 | case VK_OEM_MINUS: | |
2901 | case VK_OEM_PERIOD: | |
08158721 | 2902 | // but set processed to false, not true to still pass them |
2b5f62a0 VZ |
2903 | // to the control's default window proc - otherwise |
2904 | // built-in keyboard handling won't work | |
08158721 | 2905 | processed = false; |
2b5f62a0 | 2906 | break; |
2bda0e17 | 2907 | |
42e69d6b | 2908 | #ifdef VK_APPS |
2b5f62a0 VZ |
2909 | // special case of VK_APPS: treat it the same as right mouse |
2910 | // click because both usually pop up a context menu | |
2911 | case VK_APPS: | |
ae177b45 | 2912 | processed = HandleMouseEvent(WM_RBUTTONDOWN, -1, -1, 0); |
2b5f62a0 | 2913 | break; |
42e69d6b | 2914 | #endif // VK_APPS |
2bda0e17 | 2915 | |
2b5f62a0 VZ |
2916 | default: |
2917 | // do generate a CHAR event | |
2918 | processed = HandleChar((WORD)wParam, lParam); | |
2919 | } | |
42e69d6b | 2920 | } |
2b5f62a0 | 2921 | if (message == WM_SYSKEYDOWN) // Let Windows still handle the SYSKEYs |
08158721 | 2922 | processed = false; |
42e69d6b | 2923 | break; |
2bda0e17 | 2924 | |
4004f41e | 2925 | case WM_SYSKEYUP: |
42e69d6b | 2926 | case WM_KEYUP: |
4aff28fc VZ |
2927 | #ifdef VK_APPS |
2928 | // special case of VK_APPS: treat it the same as right mouse button | |
2929 | if ( wParam == VK_APPS ) | |
2930 | { | |
ae177b45 | 2931 | processed = HandleMouseEvent(WM_RBUTTONUP, -1, -1, 0); |
4aff28fc VZ |
2932 | } |
2933 | else | |
2934 | #endif // VK_APPS | |
2935 | { | |
2936 | processed = HandleKeyUp((WORD) wParam, lParam); | |
2937 | } | |
42e69d6b | 2938 | break; |
debe6624 | 2939 | |
170cbe33 | 2940 | case WM_SYSCHAR: |
42e69d6b | 2941 | case WM_CHAR: // Always an ASCII character |
d9f14e16 RD |
2942 | if ( m_lastKeydownProcessed ) |
2943 | { | |
2944 | // The key was handled in the EVT_KEY_DOWN and handling | |
2945 | // a key in an EVT_KEY_DOWN handler is meant, by | |
2946 | // design, to prevent EVT_CHARs from happening | |
08158721 DS |
2947 | m_lastKeydownProcessed = false; |
2948 | processed = true; | |
d9f14e16 RD |
2949 | } |
2950 | else | |
7de5bdf4 | 2951 | { |
08158721 | 2952 | processed = HandleChar((WORD)wParam, lParam, true); |
7de5bdf4 | 2953 | } |
42e69d6b | 2954 | break; |
2bda0e17 | 2955 | |
5048c832 JS |
2956 | #if wxUSE_HOTKEY |
2957 | case WM_HOTKEY: | |
2958 | processed = HandleHotKey((WORD)wParam, lParam); | |
2959 | break; | |
540b6b09 | 2960 | #endif // wxUSE_HOTKEY |
5048c832 | 2961 | |
42e69d6b VZ |
2962 | case WM_HSCROLL: |
2963 | case WM_VSCROLL: | |
a23fd0e1 | 2964 | { |
42e69d6b VZ |
2965 | WXWORD code, pos; |
2966 | WXHWND hwnd; | |
2967 | UnpackScroll(wParam, lParam, &code, &pos, &hwnd); | |
2bda0e17 | 2968 | |
42e69d6b VZ |
2969 | processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL |
2970 | : wxVERTICAL, | |
2971 | code, pos, hwnd); | |
a23fd0e1 | 2972 | } |
42e69d6b | 2973 | break; |
a23fd0e1 | 2974 | |
42e69d6b | 2975 | // CTLCOLOR messages are sent by children to query the parent for their |
01c500af | 2976 | // colors |
04ef50df | 2977 | #ifndef __WXMICROWIN__ |
42e69d6b VZ |
2978 | case WM_CTLCOLORMSGBOX: |
2979 | case WM_CTLCOLOREDIT: | |
2980 | case WM_CTLCOLORLISTBOX: | |
2981 | case WM_CTLCOLORBTN: | |
2982 | case WM_CTLCOLORDLG: | |
2983 | case WM_CTLCOLORSCROLLBAR: | |
2984 | case WM_CTLCOLORSTATIC: | |
a23fd0e1 | 2985 | { |
42e69d6b VZ |
2986 | WXHDC hdc; |
2987 | WXHWND hwnd; | |
01c500af | 2988 | UnpackCtlColor(wParam, lParam, &hdc, &hwnd); |
42e69d6b | 2989 | |
48fa6bd3 | 2990 | processed = HandleCtlColor(&rc.hBrush, (WXHDC)hdc, (WXHWND)hwnd); |
a23fd0e1 | 2991 | } |
42e69d6b | 2992 | break; |
cd4453e5 | 2993 | #endif // !__WXMICROWIN__ |
debe6624 | 2994 | |
42e69d6b | 2995 | case WM_SYSCOLORCHANGE: |
90c1530a | 2996 | // the return value for this message is ignored |
42e69d6b VZ |
2997 | processed = HandleSysColorChange(); |
2998 | break; | |
2bda0e17 | 2999 | |
7f0586ef | 3000 | #if !defined(__WXWINCE__) |
574c939e KB |
3001 | case WM_DISPLAYCHANGE: |
3002 | processed = HandleDisplayChange(); | |
3003 | break; | |
7f0586ef | 3004 | #endif |
574c939e | 3005 | |
42e69d6b VZ |
3006 | case WM_PALETTECHANGED: |
3007 | processed = HandlePaletteChanged((WXHWND) (HWND) wParam); | |
3008 | break; | |
2bda0e17 | 3009 | |
a5e84126 JS |
3010 | case WM_CAPTURECHANGED: |
3011 | processed = HandleCaptureChanged((WXHWND) (HWND) lParam); | |
3012 | break; | |
3013 | ||
3c96418b JG |
3014 | case WM_SETTINGCHANGE: |
3015 | processed = HandleSettingChange(wParam, lParam); | |
3016 | break; | |
3017 | ||
42e69d6b VZ |
3018 | case WM_QUERYNEWPALETTE: |
3019 | processed = HandleQueryNewPalette(); | |
3020 | break; | |
2bda0e17 | 3021 | |
42e69d6b VZ |
3022 | case WM_ERASEBKGND: |
3023 | processed = HandleEraseBkgnd((WXHDC)(HDC)wParam); | |
3024 | if ( processed ) | |
3025 | { | |
3026 | // we processed the message, i.e. erased the background | |
3027 | rc.result = TRUE; | |
3028 | } | |
3029 | break; | |
debe6624 | 3030 | |
7f0586ef | 3031 | #if !defined(__WXWINCE__) |
42e69d6b VZ |
3032 | case WM_DROPFILES: |
3033 | processed = HandleDropFiles(wParam); | |
3034 | break; | |
7f0586ef | 3035 | #endif |
2bda0e17 | 3036 | |
42e69d6b VZ |
3037 | case WM_INITDIALOG: |
3038 | processed = HandleInitDialog((WXHWND)(HWND)wParam); | |
a23fd0e1 | 3039 | |
42e69d6b VZ |
3040 | if ( processed ) |
3041 | { | |
3042 | // we never set focus from here | |
3043 | rc.result = FALSE; | |
3044 | } | |
3045 | break; | |
a23fd0e1 | 3046 | |
7f0586ef | 3047 | #if !defined(__WXWINCE__) |
42e69d6b VZ |
3048 | case WM_QUERYENDSESSION: |
3049 | processed = HandleQueryEndSession(lParam, &rc.allow); | |
3050 | break; | |
2bda0e17 | 3051 | |
42e69d6b VZ |
3052 | case WM_ENDSESSION: |
3053 | processed = HandleEndSession(wParam != 0, lParam); | |
3054 | break; | |
2bda0e17 | 3055 | |
42e69d6b | 3056 | case WM_GETMINMAXINFO: |
25889d3c | 3057 | processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam); |
42e69d6b | 3058 | break; |
7f0586ef | 3059 | #endif |
debe6624 | 3060 | |
42e69d6b VZ |
3061 | case WM_SETCURSOR: |
3062 | processed = HandleSetCursor((WXHWND)(HWND)wParam, | |
3063 | LOWORD(lParam), // hit test | |
3064 | HIWORD(lParam)); // mouse msg | |
3065 | ||
3066 | if ( processed ) | |
3067 | { | |
3068 | // returning TRUE stops the DefWindowProc() from further | |
3069 | // processing this message - exactly what we need because we've | |
3070 | // just set the cursor. | |
3071 | rc.result = TRUE; | |
3072 | } | |
3073 | break; | |
4cdc2c13 | 3074 | |
ed5317e5 JS |
3075 | #if wxUSE_ACCESSIBILITY |
3076 | case WM_GETOBJECT: | |
3077 | { | |
3078 | //WPARAM dwFlags = (WPARAM) (DWORD) wParam; | |
3079 | LPARAM dwObjId = (LPARAM) (DWORD) lParam; | |
3080 | ||
66b9ec3d | 3081 | if (dwObjId == (LPARAM)OBJID_CLIENT && GetOrCreateAccessible()) |
ed5317e5 JS |
3082 | { |
3083 | return LresultFromObject(IID_IAccessible, wParam, (IUnknown*) GetAccessible()->GetIAccessible()); | |
3084 | } | |
3085 | break; | |
3086 | } | |
3087 | #endif | |
3088 | ||
e39af974 | 3089 | #if defined(WM_HELP) |
b96340e6 | 3090 | case WM_HELP: |
b96340e6 | 3091 | { |
a9c11b71 VZ |
3092 | // by default, WM_HELP is propagated by DefWindowProc() upwards |
3093 | // to the window parent but as we do it ourselves already | |
3094 | // (wxHelpEvent is derived from wxCommandEvent), we don't want | |
3095 | // to get the other events if we process this message at all | |
3096 | processed = true; | |
3097 | ||
3098 | // WM_HELP doesn't use lParam under CE | |
7f0586ef | 3099 | #ifndef __WXWINCE__ |
4cdc2c13 | 3100 | HELPINFO* info = (HELPINFO*) lParam; |
a9c11b71 | 3101 | if ( info->iContextType == HELPINFO_WINDOW ) |
b96340e6 | 3102 | { |
a9c11b71 VZ |
3103 | #endif // !__WXWINCE__ |
3104 | wxHelpEvent helpEvent | |
3105 | ( | |
3106 | wxEVT_HELP, | |
3107 | GetId(), | |
7f0586ef | 3108 | #ifdef __WXWINCE__ |
2d4ec362 | 3109 | wxGetMousePosition() // what else? |
7f0586ef | 3110 | #else |
a9c11b71 | 3111 | wxPoint(info->MousePos.x, info->MousePos.y) |
7f0586ef | 3112 | #endif |
a9c11b71 | 3113 | ); |
b96340e6 | 3114 | |
a9c11b71 VZ |
3115 | helpEvent.SetEventObject(this); |
3116 | GetEventHandler()->ProcessEvent(helpEvent); | |
7f0586ef | 3117 | #ifndef __WXWINCE__ |
b96340e6 | 3118 | } |
a9c11b71 | 3119 | else if ( info->iContextType == HELPINFO_MENUITEM ) |
4cdc2c13 VZ |
3120 | { |
3121 | wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId); | |
3122 | helpEvent.SetEventObject(this); | |
a9c11b71 | 3123 | GetEventHandler()->ProcessEvent(helpEvent); |
69231000 | 3124 | |
4cdc2c13 | 3125 | } |
a9c11b71 VZ |
3126 | else // unknown help event? |
3127 | { | |
3128 | processed = false; | |
3129 | } | |
3130 | #endif // !__WXWINCE__ | |
b96340e6 | 3131 | } |
b96340e6 | 3132 | break; |
a9c11b71 | 3133 | #endif // WM_HELP |
4cdc2c13 | 3134 | |
7f0586ef | 3135 | #if !defined(__WXWINCE__) |
69231000 | 3136 | case WM_CONTEXTMENU: |
4cdc2c13 VZ |
3137 | { |
3138 | // we don't convert from screen to client coordinates as | |
3139 | // the event may be handled by a parent window | |
3140 | wxPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); | |
3141 | ||
3142 | wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt); | |
2d1715aa VZ |
3143 | |
3144 | // we could have got an event from our child, reflect it back | |
3145 | // to it if this is the case | |
d85c53a5 | 3146 | wxWindowMSW *win = NULL; |
c140b7e7 | 3147 | if ( (WXHWND)wParam != m_hWnd ) |
2d1715aa VZ |
3148 | { |
3149 | win = FindItemByHWND((WXHWND)wParam); | |
3150 | } | |
3151 | ||
3152 | if ( !win ) | |
3153 | win = this; | |
3154 | ||
3155 | evtCtx.SetEventObject(win); | |
3156 | processed = win->GetEventHandler()->ProcessEvent(evtCtx); | |
4cdc2c13 | 3157 | } |
69231000 | 3158 | break; |
7f0586ef | 3159 | #endif |
b74cce40 VZ |
3160 | |
3161 | case WM_MENUCHAR: | |
3162 | // we're only interested in our own menus, not MF_SYSMENU | |
3163 | if ( HIWORD(wParam) == MF_POPUP ) | |
3164 | { | |
3165 | // handle menu chars for ownerdrawn menu items | |
3166 | int i = HandleMenuChar(toupper(LOWORD(wParam)), lParam); | |
3167 | if ( i != wxNOT_FOUND ) | |
3168 | { | |
3169 | rc.result = MAKELRESULT(i, MNC_EXECUTE); | |
08158721 | 3170 | processed = true; |
b74cce40 VZ |
3171 | } |
3172 | } | |
3173 | break; | |
355debca | 3174 | |
dbc74bcc | 3175 | #ifndef __WXWINCE__ |
355debca VZ |
3176 | case WM_POWERBROADCAST: |
3177 | { | |
3178 | bool vetoed; | |
3179 | processed = HandlePower(wParam, lParam, &vetoed); | |
3180 | rc.result = processed && vetoed ? BROADCAST_QUERY_DENY : TRUE; | |
3181 | } | |
3182 | break; | |
dbc74bcc | 3183 | #endif // __WXWINCE__ |
5acec112 VZ |
3184 | |
3185 | default: | |
3186 | // try a custom message handler | |
3187 | const MSWMessageHandlers::const_iterator | |
3188 | i = gs_messageHandlers.find(message); | |
3189 | if ( i != gs_messageHandlers.end() ) | |
3190 | { | |
3191 | processed = (*i->second)(this, message, wParam, lParam); | |
3192 | } | |
a23fd0e1 | 3193 | } |
2d0a075d | 3194 | |
42e69d6b | 3195 | if ( !processed ) |
2d0a075d | 3196 | { |
42e69d6b | 3197 | #ifdef __WXDEBUG__ |
223d09f6 | 3198 | wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."), |
42e69d6b VZ |
3199 | wxGetMessageName(message)); |
3200 | #endif // __WXDEBUG__ | |
3201 | rc.result = MSWDefWindowProc(message, wParam, lParam); | |
a23fd0e1 | 3202 | } |
2bda0e17 | 3203 | |
42e69d6b | 3204 | return rc.result; |
2bda0e17 KB |
3205 | } |
3206 | ||
b225f659 VZ |
3207 | // ---------------------------------------------------------------------------- |
3208 | // wxWindow <-> HWND map | |
3209 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 3210 | |
1bffa913 | 3211 | wxWinHashTable *wxWinHandleHash = NULL; |
b225f659 | 3212 | |
42e69d6b | 3213 | wxWindow *wxFindWinFromHandle(WXHWND hWnd) |
4ce81a75 | 3214 | { |
40ad3426 | 3215 | return (wxWindow*)wxWinHandleHash->Get((long)hWnd); |
42e69d6b | 3216 | } |
4ce81a75 | 3217 | |
1e6feb95 | 3218 | void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win) |
42e69d6b VZ |
3219 | { |
3220 | // adding NULL hWnd is (first) surely a result of an error and | |
3221 | // (secondly) breaks menu command processing | |
3222 | wxCHECK_RET( hWnd != (HWND)NULL, | |
223d09f6 | 3223 | wxT("attempt to add a NULL hWnd to window list ignored") ); |
4ce81a75 | 3224 | |
c7527e3f | 3225 | wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd); |
b225f659 | 3226 | #ifdef __WXDEBUG__ |
c7527e3f JS |
3227 | if ( oldWin && (oldWin != win) ) |
3228 | { | |
b225f659 | 3229 | wxLogDebug(wxT("HWND %X already associated with another window (%s)"), |
9b601c24 | 3230 | (int) hWnd, win->GetClassInfo()->GetClassName()); |
c7527e3f | 3231 | } |
b225f659 VZ |
3232 | else |
3233 | #endif // __WXDEBUG__ | |
3234 | if (!oldWin) | |
c7527e3f | 3235 | { |
d2d14464 | 3236 | wxWinHandleHash->Put((long)hWnd, (wxWindow *)win); |
c7527e3f | 3237 | } |
42e69d6b | 3238 | } |
4ce81a75 | 3239 | |
1e6feb95 | 3240 | void wxRemoveHandleAssociation(wxWindowMSW *win) |
42e69d6b | 3241 | { |
1bffa913 | 3242 | wxWinHandleHash->Delete((long)win->GetHWND()); |
4ce81a75 JS |
3243 | } |
3244 | ||
b225f659 VZ |
3245 | // ---------------------------------------------------------------------------- |
3246 | // various MSW speciic class dependent functions | |
3247 | // ---------------------------------------------------------------------------- | |
3248 | ||
42e69d6b VZ |
3249 | // Default destroyer - override if you destroy it in some other way |
3250 | // (e.g. with MDI child windows) | |
1e6feb95 | 3251 | void wxWindowMSW::MSWDestroyWindow() |
4ce81a75 | 3252 | { |
42e69d6b | 3253 | } |
4ce81a75 | 3254 | |
b225f659 VZ |
3255 | bool wxWindowMSW::MSWGetCreateWindowCoords(const wxPoint& pos, |
3256 | const wxSize& size, | |
3257 | int& x, int& y, | |
3258 | int& w, int& h) const | |
2bda0e17 | 3259 | { |
9cb57df4 | 3260 | // yes, those are just some arbitrary hardcoded numbers |
2a77c8c4 | 3261 | static const int DEFAULT_Y = 200; |
2a77c8c4 | 3262 | |
08158721 | 3263 | bool nonDefault = false; |
c085e333 | 3264 | |
422d0ff0 | 3265 | if ( pos.x == wxDefaultCoord ) |
b225f659 | 3266 | { |
9cb57df4 VZ |
3267 | // if x is set to CW_USEDEFAULT, y parameter is ignored anyhow so we |
3268 | // can just as well set it to CW_USEDEFAULT as well | |
b225f659 VZ |
3269 | x = |
3270 | y = CW_USEDEFAULT; | |
3271 | } | |
3272 | else | |
a23fd0e1 | 3273 | { |
2a77c8c4 VZ |
3274 | // OTOH, if x is not set to CW_USEDEFAULT, y shouldn't be set to it |
3275 | // neither because it is not handled as a special value by Windows then | |
3276 | // and so we have to choose some default value for it | |
b225f659 | 3277 | x = pos.x; |
422d0ff0 | 3278 | y = pos.y == wxDefaultCoord ? DEFAULT_Y : pos.y; |
c085e333 | 3279 | |
08158721 | 3280 | nonDefault = true; |
42e69d6b | 3281 | } |
2bda0e17 | 3282 | |
b889a3a2 VZ |
3283 | /* |
3284 | NB: there used to be some code here which set the initial size of the | |
3285 | window to the client size of the parent if no explicit size was | |
77ffb593 | 3286 | specified. This was wrong because wxWidgets programs often assume |
b889a3a2 VZ |
3287 | that they get a WM_SIZE (EVT_SIZE) upon creation, however this broke |
3288 | it. To see why, you should understand that Windows sends WM_SIZE from | |
3289 | inside ::CreateWindow() anyhow. However, ::CreateWindow() is called | |
3290 | from some base class ctor and so this WM_SIZE is not processed in the | |
3291 | real class' OnSize() (because it's not fully constructed yet and the | |
3292 | event goes to some base class OnSize() instead). So the WM_SIZE we | |
3293 | rely on is the one sent when the parent frame resizes its children | |
3294 | but here is the problem: if the child already has just the right | |
77ffb593 | 3295 | size, nothing will happen as both wxWidgets and Windows check for |
b889a3a2 VZ |
3296 | this and ignore any attempts to change the window size to the size it |
3297 | already has - so no WM_SIZE would be sent. | |
3298 | */ | |
b225f659 | 3299 | |
35bbb0c6 | 3300 | |
426936d1 RD |
3301 | // we don't use CW_USEDEFAULT here for several reasons: |
3302 | // | |
3303 | // 1. it results in huge frames on modern screens (1000*800 is not | |
3304 | // uncommon on my 1280*1024 screen) which is way too big for a half | |
77ffb593 | 3305 | // empty frame of most of wxWidgets samples for example) |
426936d1 RD |
3306 | // |
3307 | // 2. it is buggy for frames with wxFRAME_TOOL_WINDOW style for which | |
3308 | // the default is for whatever reason 8*8 which breaks client <-> | |
3309 | // window size calculations (it would be nice if it didn't, but it | |
3310 | // does and the simplest way to fix it seemed to change the broken | |
3311 | // default size anyhow) | |
3312 | // | |
3313 | // 3. there is just no advantage in doing it: with x and y it is | |
3314 | // possible that [future versions of] Windows position the new top | |
3315 | // level window in some smart way which we can't do, but we can | |
3316 | // guess a reasonably good size for a new window just as well | |
3317 | // ourselves | |
960b193e | 3318 | |
3a3c8603 DS |
3319 | // However, on PocketPC devices, we must use the default |
3320 | // size if possible. | |
960b193e | 3321 | #ifdef _WIN32_WCE |
422d0ff0 | 3322 | if (size.x == wxDefaultCoord) |
3a3c8603 DS |
3323 | w = CW_USEDEFAULT; |
3324 | else | |
3325 | w = size.x; | |
422d0ff0 | 3326 | if (size.y == wxDefaultCoord) |
3a3c8603 DS |
3327 | h = CW_USEDEFAULT; |
3328 | else | |
3329 | h = size.y; | |
960b193e | 3330 | #else |
422d0ff0 | 3331 | if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord) |
426936d1 | 3332 | { |
08158721 | 3333 | nonDefault = true; |
8614c467 | 3334 | } |
426936d1 RD |
3335 | w = WidthDefault(size.x); |
3336 | h = HeightDefault(size.y); | |
960b193e | 3337 | #endif |
8614c467 | 3338 | |
4e9d23cd VZ |
3339 | AdjustForParentClientOrigin(x, y); |
3340 | ||
b225f659 VZ |
3341 | return nonDefault; |
3342 | } | |
3343 | ||
9dfef5ac VZ |
3344 | WXHWND wxWindowMSW::MSWGetParent() const |
3345 | { | |
d285d708 | 3346 | return m_parent ? m_parent->GetHWND() : WXHWND(NULL); |
9dfef5ac VZ |
3347 | } |
3348 | ||
b225f659 VZ |
3349 | bool wxWindowMSW::MSWCreate(const wxChar *wclass, |
3350 | const wxChar *title, | |
3351 | const wxPoint& pos, | |
3352 | const wxSize& size, | |
3353 | WXDWORD style, | |
3354 | WXDWORD extendedStyle) | |
3355 | { | |
3356 | // choose the position/size for the new window | |
3357 | int x, y, w, h; | |
3358 | (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); | |
3359 | ||
b225f659 VZ |
3360 | // controlId is menu handle for the top level windows, so set it to 0 |
3361 | // unless we're creating a child window | |
f586fde3 | 3362 | int controlId = style & WS_CHILD ? GetId() : 0; |
2bda0e17 | 3363 | |
b225f659 VZ |
3364 | // for each class "Foo" we have we also have "FooNR" ("no repaint") class |
3365 | // which is the same but without CS_[HV]REDRAW class styles so using it | |
3366 | // ensures that the window is not fully repainted on each resize | |
3367 | wxString className(wclass); | |
e441e1f4 | 3368 | if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) ) |
b225f659 VZ |
3369 | { |
3370 | className += wxT("NR"); | |
a23fd0e1 | 3371 | } |
c085e333 | 3372 | |
b225f659 VZ |
3373 | // do create the window |
3374 | wxWindowCreationHook hook(this); | |
b3daa5a3 | 3375 | |
5e67eb97 VZ |
3376 | m_hWnd = (WXHWND)::CreateWindowEx |
3377 | ( | |
3378 | extendedStyle, | |
3379 | className, | |
c9f78968 | 3380 | title ? title : (const wxChar*)m_windowName.c_str(), |
5e67eb97 VZ |
3381 | style, |
3382 | x, y, w, h, | |
3383 | (HWND)MSWGetParent(), | |
3384 | (HMENU)controlId, | |
3385 | wxGetInstance(), | |
3386 | NULL // no extra data | |
3387 | ); | |
b225f659 VZ |
3388 | |
3389 | if ( !m_hWnd ) | |
c7527e3f | 3390 | { |
5e67eb97 | 3391 | wxLogSysError(_("Can't create window of class %s"), className.c_str()); |
b225f659 | 3392 | |
08158721 | 3393 | return false; |
c7527e3f | 3394 | } |
b3daa5a3 | 3395 | |
b225f659 | 3396 | SubclassWin(m_hWnd); |
c085e333 | 3397 | |
08158721 | 3398 | return true; |
2bda0e17 KB |
3399 | } |
3400 | ||
42e69d6b VZ |
3401 | // =========================================================================== |
3402 | // MSW message handlers | |
3403 | // =========================================================================== | |
3404 | ||
3405 | // --------------------------------------------------------------------------- | |
3406 | // WM_NOTIFY | |
3407 | // --------------------------------------------------------------------------- | |
3408 | ||
1e6feb95 | 3409 | bool wxWindowMSW::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) |
2bda0e17 | 3410 | { |
04ef50df | 3411 | #ifndef __WXMICROWIN__ |
42e69d6b VZ |
3412 | LPNMHDR hdr = (LPNMHDR)lParam; |
3413 | HWND hWnd = hdr->hwndFrom; | |
3414 | wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd); | |
3415 | ||
2b15b970 | 3416 | // if the control is one of our windows, let it handle the message itself |
42e69d6b | 3417 | if ( win ) |
564b2609 | 3418 | { |
42e69d6b | 3419 | return win->MSWOnNotify(idCtrl, lParam, result); |
564b2609 | 3420 | } |
2bda0e17 | 3421 | |
2b15b970 VZ |
3422 | // VZ: why did we do it? normally this is unnecessary and, besides, it |
3423 | // breaks the message processing for the toolbars because the tooltip | |
3424 | // notifications were being forwarded to the toolbar child controls | |
3425 | // (if it had any) before being passed to the toolbar itself, so in my | |
3426 | // example the tooltip for the combobox was always shown instead of the | |
3427 | // correct button tooltips | |
3428 | #if 0 | |
42e69d6b | 3429 | // try all our children |
222ed1d6 | 3430 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
42e69d6b | 3431 | while ( node ) |
564b2609 | 3432 | { |
42e69d6b VZ |
3433 | wxWindow *child = node->GetData(); |
3434 | if ( child->MSWOnNotify(idCtrl, lParam, result) ) | |
3435 | { | |
08158721 | 3436 | return true; |
42e69d6b | 3437 | } |
2d0a075d | 3438 | |
42e69d6b VZ |
3439 | node = node->GetNext(); |
3440 | } | |
2b15b970 | 3441 | #endif // 0 |
2d0a075d | 3442 | |
2b15b970 | 3443 | // by default, handle it ourselves |
42e69d6b | 3444 | return MSWOnNotify(idCtrl, lParam, result); |
cd4453e5 | 3445 | #else // __WXMICROWIN__ |
08158721 | 3446 | return false; |
04ef50df | 3447 | #endif |
42e69d6b | 3448 | } |
2d0a075d | 3449 | |
bd9cd534 VZ |
3450 | #if wxUSE_TOOLTIPS |
3451 | ||
3452 | bool wxWindowMSW::HandleTooltipNotify(WXUINT code, | |
3453 | WXLPARAM lParam, | |
3454 | const wxString& ttip) | |
3455 | { | |
3456 | // I don't know why it happens, but the versions of comctl32.dll starting | |
3457 | // from 4.70 sometimes send TTN_NEEDTEXTW even to ANSI programs (normally, | |
3458 | // this message is supposed to be sent to Unicode programs only) -- hence | |
3459 | // we need to handle it as well, otherwise no tooltips will be shown in | |
3460 | // this case | |
7f0586ef | 3461 | #ifndef __WXWINCE__ |
118208ac VZ |
3462 | if ( !(code == (WXUINT) TTN_NEEDTEXTA || code == (WXUINT) TTN_NEEDTEXTW) |
3463 | || ttip.empty() ) | |
bd9cd534 VZ |
3464 | { |
3465 | // not a tooltip message or no tooltip to show anyhow | |
08158721 | 3466 | return false; |
bd9cd534 | 3467 | } |
7f0586ef | 3468 | #endif |
bd9cd534 VZ |
3469 | |
3470 | LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam; | |
3471 | ||
118208ac VZ |
3472 | // We don't want to use the szText buffer because it has a limit of 80 |
3473 | // bytes and this is not enough, especially for Unicode build where it | |
3474 | // limits the tooltip string length to only 40 characters | |
3475 | // | |
3476 | // The best would be, of course, to not impose any length limitations at | |
3477 | // all but then the buffer would have to be dynamic and someone would have | |
3478 | // to free it and we don't have the tooltip owner object here any more, so | |
3479 | // for now use our own static buffer with a higher fixed max length. | |
3480 | // | |
3481 | // Note that using a static buffer should not be a problem as only a single | |
3482 | // tooltip can be shown at the same time anyhow. | |
2b5f62a0 | 3483 | #if !wxUSE_UNICODE |
118208ac | 3484 | if ( code == (WXUINT) TTN_NEEDTEXTW ) |
bd9cd534 | 3485 | { |
118208ac VZ |
3486 | // We need to convert tooltip from multi byte to Unicode on the fly. |
3487 | static wchar_t buf[513]; | |
25c46fda | 3488 | |
118208ac VZ |
3489 | // Truncate tooltip length if needed as otherwise we might not have |
3490 | // enough space for it in the buffer and MultiByteToWideChar() would | |
3491 | // return an error | |
fec9cc08 | 3492 | size_t tipLength = wxMin(ttip.length(), WXSIZEOF(buf) - 1); |
7afebc8c JS |
3493 | |
3494 | // Convert to WideChar without adding the NULL character. The NULL | |
25c46fda | 3495 | // character is added afterwards (this is more efficient). |
118208ac VZ |
3496 | int len = ::MultiByteToWideChar |
3497 | ( | |
3498 | CP_ACP, | |
3499 | 0, // no flags | |
3500 | ttip, | |
3501 | tipLength, | |
3502 | buf, | |
3503 | WXSIZEOF(buf) - 1 | |
3504 | ); | |
3505 | ||
3506 | if ( !len ) | |
3507 | { | |
3508 | wxLogLastError(_T("MultiByteToWideChar()")); | |
3509 | } | |
7afebc8c | 3510 | |
118208ac VZ |
3511 | buf[len] = L'\0'; |
3512 | ttText->lpszText = (LPSTR) buf; | |
3513 | } | |
3514 | else // TTN_NEEDTEXTA | |
3515 | #endif // !wxUSE_UNICODE | |
3516 | { | |
3517 | // we get here if we got TTN_NEEDTEXTA (only happens in ANSI build) or | |
3518 | // if we got TTN_NEEDTEXTW in Unicode build: in this case we just have | |
3519 | // to copy the string we have into the buffer | |
3520 | static wxChar buf[513]; | |
3521 | wxStrncpy(buf, ttip.c_str(), WXSIZEOF(buf) - 1); | |
3522 | buf[WXSIZEOF(buf) - 1] = _T('\0'); | |
3523 | ttText->lpszText = buf; | |
bd9cd534 VZ |
3524 | } |
3525 | ||
08158721 | 3526 | return true; |
bd9cd534 VZ |
3527 | } |
3528 | ||
3529 | #endif // wxUSE_TOOLTIPS | |
3530 | ||
1e6feb95 | 3531 | bool wxWindowMSW::MSWOnNotify(int WXUNUSED(idCtrl), |
bd9cd534 VZ |
3532 | WXLPARAM lParam, |
3533 | WXLPARAM* WXUNUSED(result)) | |
42e69d6b VZ |
3534 | { |
3535 | #if wxUSE_TOOLTIPS | |
bd9cd534 | 3536 | if ( m_tooltip ) |
42e69d6b | 3537 | { |
bd9cd534 VZ |
3538 | NMHDR* hdr = (NMHDR *)lParam; |
3539 | if ( HandleTooltipNotify(hdr->code, lParam, m_tooltip->GetTip())) | |
3540 | { | |
3541 | // processed | |
08158721 | 3542 | return true; |
bd9cd534 | 3543 | } |
42e69d6b | 3544 | } |
f5dd1cf1 WS |
3545 | #else |
3546 | wxUnusedVar(lParam); | |
42e69d6b VZ |
3547 | #endif // wxUSE_TOOLTIPS |
3548 | ||
08158721 | 3549 | return false; |
42e69d6b | 3550 | } |
2b15b970 | 3551 | |
42e69d6b VZ |
3552 | // --------------------------------------------------------------------------- |
3553 | // end session messages | |
3554 | // --------------------------------------------------------------------------- | |
2d0a075d | 3555 | |
1e6feb95 | 3556 | bool wxWindowMSW::HandleQueryEndSession(long logOff, bool *mayEnd) |
42e69d6b | 3557 | { |
040e5f77 | 3558 | #ifdef ENDSESSION_LOGOFF |
abb74e0f | 3559 | wxCloseEvent event(wxEVT_QUERY_END_SESSION, wxID_ANY); |
42e69d6b | 3560 | event.SetEventObject(wxTheApp); |
08158721 | 3561 | event.SetCanVeto(true); |
a17e237f | 3562 | event.SetLoggingOff(logOff == (long)ENDSESSION_LOGOFF); |
2d0a075d | 3563 | |
42e69d6b VZ |
3564 | bool rc = wxTheApp->ProcessEvent(event); |
3565 | ||
3566 | if ( rc ) | |
3567 | { | |
3568 | // we may end only if the app didn't veto session closing (double | |
3569 | // negation...) | |
3570 | *mayEnd = !event.GetVeto(); | |
2d0a075d JS |
3571 | } |
3572 | ||
42e69d6b | 3573 | return rc; |
7f0586ef | 3574 | #else |
040e5f77 VZ |
3575 | wxUnusedVar(logOff); |
3576 | wxUnusedVar(mayEnd); | |
08158721 | 3577 | return false; |
7f0586ef | 3578 | #endif |
2bda0e17 KB |
3579 | } |
3580 | ||
1e6feb95 | 3581 | bool wxWindowMSW::HandleEndSession(bool endSession, long logOff) |
2bda0e17 | 3582 | { |
040e5f77 | 3583 | #ifdef ENDSESSION_LOGOFF |
42e69d6b VZ |
3584 | // do nothing if the session isn't ending |
3585 | if ( !endSession ) | |
08158721 | 3586 | return false; |
a23fd0e1 | 3587 | |
519dc37f VZ |
3588 | // only send once |
3589 | if ( (this != wxTheApp->GetTopWindow()) ) | |
08158721 | 3590 | return false; |
519dc37f | 3591 | |
abb74e0f | 3592 | wxCloseEvent event(wxEVT_END_SESSION, wxID_ANY); |
42e69d6b | 3593 | event.SetEventObject(wxTheApp); |
08158721 | 3594 | event.SetCanVeto(false); |
a17e237f | 3595 | event.SetLoggingOff( (logOff == (long)ENDSESSION_LOGOFF) ); |
519dc37f VZ |
3596 | |
3597 | return wxTheApp->ProcessEvent(event); | |
7f0586ef | 3598 | #else |
040e5f77 VZ |
3599 | wxUnusedVar(endSession); |
3600 | wxUnusedVar(logOff); | |
08158721 | 3601 | return false; |
7f0586ef | 3602 | #endif |
2bda0e17 KB |
3603 | } |
3604 | ||
42e69d6b VZ |
3605 | // --------------------------------------------------------------------------- |
3606 | // window creation/destruction | |
3607 | // --------------------------------------------------------------------------- | |
3608 | ||
0c0d1521 WS |
3609 | bool wxWindowMSW::HandleCreate(WXLPCREATESTRUCT WXUNUSED_IN_WINCE(cs), |
3610 | bool *mayCreate) | |
61179e28 | 3611 | { |
ee471817 VZ |
3612 | // VZ: why is this commented out for WinCE? If it doesn't support |
3613 | // WS_EX_CONTROLPARENT at all it should be somehow handled globally, | |
3614 | // not with multiple #ifdef's! | |
7f0586ef | 3615 | #ifndef __WXWINCE__ |
61179e28 | 3616 | if ( ((CREATESTRUCT *)cs)->dwExStyle & WS_EX_CONTROLPARENT ) |
ee471817 VZ |
3617 | EnsureParentHasControlParentStyle(GetParent()); |
3618 | #endif // !__WXWINCE__ | |
61179e28 | 3619 | |
08158721 | 3620 | *mayCreate = true; |
42e69d6b | 3621 | |
08158721 | 3622 | return true; |
2bda0e17 KB |
3623 | } |
3624 | ||
1e6feb95 | 3625 | bool wxWindowMSW::HandleDestroy() |
2bda0e17 | 3626 | { |
7de59551 | 3627 | SendDestroyEvent(); |
42e69d6b VZ |
3628 | |
3629 | // delete our drop target if we've got one | |
3630 | #if wxUSE_DRAG_AND_DROP | |
3631 | if ( m_dropTarget != NULL ) | |
2d0a075d | 3632 | { |
42e69d6b VZ |
3633 | m_dropTarget->Revoke(m_hWnd); |
3634 | ||
3635 | delete m_dropTarget; | |
3636 | m_dropTarget = NULL; | |
2d0a075d | 3637 | } |
42e69d6b | 3638 | #endif // wxUSE_DRAG_AND_DROP |
2bda0e17 | 3639 | |
42e69d6b | 3640 | // WM_DESTROY handled |
08158721 | 3641 | return true; |
2bda0e17 KB |
3642 | } |
3643 | ||
42e69d6b VZ |
3644 | // --------------------------------------------------------------------------- |
3645 | // activation/focus | |
3646 | // --------------------------------------------------------------------------- | |
3647 | ||
1e6feb95 | 3648 | bool wxWindowMSW::HandleActivate(int state, |
42e69d6b VZ |
3649 | bool WXUNUSED(minimized), |
3650 | WXHWND WXUNUSED(activate)) | |
2bda0e17 | 3651 | { |
42e69d6b VZ |
3652 | wxActivateEvent event(wxEVT_ACTIVATE, |
3653 | (state == WA_ACTIVE) || (state == WA_CLICKACTIVE), | |
3654 | m_windowId); | |
3655 | event.SetEventObject(this); | |
3656 | ||
3657 | return GetEventHandler()->ProcessEvent(event); | |
3658 | } | |
3659 | ||
1e6feb95 | 3660 | bool wxWindowMSW::HandleSetFocus(WXHWND hwnd) |
42e69d6b | 3661 | { |
c7aee865 RD |
3662 | // Strangly enough, some controls get set focus events when they are being |
3663 | // deleted, even if they already had focus before. | |
3664 | if ( m_isBeingDeleted ) | |
3665 | { | |
3666 | return false; | |
3667 | } | |
35bbb0c6 | 3668 | |
456bc6d9 VZ |
3669 | // notify the parent keeping track of focus for the kbd navigation |
3670 | // purposes that we got it | |
e72aa7f5 | 3671 | wxChildFocusEvent eventFocus((wxWindow *)this); |
456bc6d9 VZ |
3672 | (void)GetEventHandler()->ProcessEvent(eventFocus); |
3673 | ||
789295bf | 3674 | #if wxUSE_CARET |
42e69d6b | 3675 | // Deal with caret |
789295bf | 3676 | if ( m_caret ) |
2d0a075d | 3677 | { |
789295bf | 3678 | m_caret->OnSetFocus(); |
2bda0e17 | 3679 | } |
789295bf | 3680 | #endif // wxUSE_CARET |
42e69d6b | 3681 | |
ab93a576 RD |
3682 | #if wxUSE_TEXTCTRL |
3683 | // If it's a wxTextCtrl don't send the event as it will be done | |
456bc6d9 VZ |
3684 | // after the control gets to process it from EN_FOCUS handler |
3685 | if ( wxDynamicCastThis(wxTextCtrl) ) | |
ab93a576 | 3686 | { |
08158721 | 3687 | return false; |
ab93a576 | 3688 | } |
456bc6d9 | 3689 | #endif // wxUSE_TEXTCTRL |
ab93a576 | 3690 | |
42e69d6b VZ |
3691 | wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); |
3692 | event.SetEventObject(this); | |
3693 | ||
1e6feb95 VZ |
3694 | // wxFindWinFromHandle() may return NULL, it is ok |
3695 | event.SetWindow(wxFindWinFromHandle(hwnd)); | |
3696 | ||
42e69d6b | 3697 | return GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
3698 | } |
3699 | ||
1e6feb95 | 3700 | bool wxWindowMSW::HandleKillFocus(WXHWND hwnd) |
2bda0e17 | 3701 | { |
789295bf | 3702 | #if wxUSE_CARET |
42e69d6b | 3703 | // Deal with caret |
789295bf | 3704 | if ( m_caret ) |
2d0a075d | 3705 | { |
789295bf | 3706 | m_caret->OnKillFocus(); |
2bda0e17 | 3707 | } |
789295bf | 3708 | #endif // wxUSE_CARET |
42e69d6b | 3709 | |
ab93a576 RD |
3710 | #if wxUSE_TEXTCTRL |
3711 | // If it's a wxTextCtrl don't send the event as it will be done | |
3712 | // after the control gets to process it. | |
3713 | wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl); | |
3714 | if ( ctrl ) | |
3715 | { | |
08158721 | 3716 | return false; |
ab93a576 RD |
3717 | } |
3718 | #endif | |
3719 | ||
2913e597 RD |
3720 | // Don't send the event when in the process of being deleted. This can |
3721 | // only cause problems if the event handler tries to access the object. | |
3722 | if ( m_isBeingDeleted ) | |
3723 | { | |
08158721 | 3724 | return false; |
2913e597 RD |
3725 | } |
3726 | ||
42e69d6b VZ |
3727 | wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); |
3728 | event.SetEventObject(this); | |
3729 | ||
1e6feb95 VZ |
3730 | // wxFindWinFromHandle() may return NULL, it is ok |
3731 | event.SetWindow(wxFindWinFromHandle(hwnd)); | |
3732 | ||
42e69d6b | 3733 | return GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
3734 | } |
3735 | ||
faa49bfd WS |
3736 | // --------------------------------------------------------------------------- |
3737 | // labels | |
3738 | // --------------------------------------------------------------------------- | |
3739 | ||
3740 | void wxWindowMSW::SetLabel( const wxString& label) | |
3741 | { | |
3742 | SetWindowText(GetHwnd(), label.c_str()); | |
3743 | } | |
3744 | ||
3745 | wxString wxWindowMSW::GetLabel() const | |
3746 | { | |
3747 | return wxGetWindowText(GetHWND()); | |
3748 | } | |
3749 | ||
42e69d6b VZ |
3750 | // --------------------------------------------------------------------------- |
3751 | // miscellaneous | |
3752 | // --------------------------------------------------------------------------- | |
3753 | ||
1e6feb95 | 3754 | bool wxWindowMSW::HandleShow(bool show, int WXUNUSED(status)) |
2bda0e17 | 3755 | { |
42e69d6b | 3756 | wxShowEvent event(GetId(), show); |
687706f5 | 3757 | event.SetEventObject(this); |
42e69d6b VZ |
3758 | |
3759 | return GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
3760 | } |
3761 | ||
1e6feb95 | 3762 | bool wxWindowMSW::HandleInitDialog(WXHWND WXUNUSED(hWndFocus)) |
2bda0e17 | 3763 | { |
42e69d6b | 3764 | wxInitDialogEvent event(GetId()); |
687706f5 | 3765 | event.SetEventObject(this); |
42e69d6b VZ |
3766 | |
3767 | return GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
3768 | } |
3769 | ||
1e6feb95 | 3770 | bool wxWindowMSW::HandleDropFiles(WXWPARAM wParam) |
2bda0e17 | 3771 | { |
7f0586ef | 3772 | #if defined (__WXMICROWIN__) || defined(__WXWINCE__) |
35bbb0c6 | 3773 | wxUnusedVar(wParam); |
08158721 | 3774 | return false; |
4ce1efe1 | 3775 | #else // __WXMICROWIN__ |
42e69d6b | 3776 | HDROP hFilesInfo = (HDROP) wParam; |
42e69d6b VZ |
3777 | |
3778 | // Get the total number of files dropped | |
c3c39620 | 3779 | UINT gwFilesDropped = ::DragQueryFile |
f6bcfd97 BP |
3780 | ( |
3781 | (HDROP)hFilesInfo, | |
3782 | (UINT)-1, | |
3783 | (LPTSTR)0, | |
3784 | (UINT)0 | |
3785 | ); | |
42e69d6b VZ |
3786 | |
3787 | wxString *files = new wxString[gwFilesDropped]; | |
c3c39620 | 3788 | for ( UINT wIndex = 0; wIndex < gwFilesDropped; wIndex++ ) |
2d0a075d | 3789 | { |
c3c39620 VZ |
3790 | // first get the needed buffer length (+1 for terminating NUL) |
3791 | size_t len = ::DragQueryFile(hFilesInfo, wIndex, NULL, 0) + 1; | |
3792 | ||
3793 | // and now get the file name | |
3794 | ::DragQueryFile(hFilesInfo, wIndex, | |
de564874 | 3795 | wxStringBuffer(files[wIndex], len), len); |
2d0a075d | 3796 | } |
42e69d6b | 3797 | DragFinish (hFilesInfo); |
2bda0e17 | 3798 | |
42e69d6b | 3799 | wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files); |
687706f5 | 3800 | event.SetEventObject(this); |
c3c39620 VZ |
3801 | |
3802 | POINT dropPoint; | |
3803 | DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint); | |
b3dc8a3e VZ |
3804 | event.m_pos.x = dropPoint.x; |
3805 | event.m_pos.y = dropPoint.y; | |
42e69d6b | 3806 | |
c3c39620 | 3807 | return GetEventHandler()->ProcessEvent(event); |
04ef50df | 3808 | #endif |
2bda0e17 KB |
3809 | } |
3810 | ||
cc972ac6 | 3811 | |
1e6feb95 VZ |
3812 | bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd), |
3813 | short nHitTest, | |
3814 | int WXUNUSED(mouseMsg)) | |
2bda0e17 | 3815 | { |
04ef50df | 3816 | #ifndef __WXMICROWIN__ |
bfbd6dc1 | 3817 | // the logic is as follows: |
43b5058d VZ |
3818 | // -1. don't set cursor for non client area, including but not limited to |
3819 | // the title bar, scrollbars, &c | |
3820 | // 0. allow the user to override default behaviour by using EVT_SET_CURSOR | |
bfbd6dc1 VZ |
3821 | // 1. if we have the cursor set it unless wxIsBusy() |
3822 | // 2. if we're a top level window, set some cursor anyhow | |
3823 | // 3. if wxIsBusy(), set the busy cursor, otherwise the global one | |
42e69d6b | 3824 | |
43b5058d VZ |
3825 | if ( nHitTest != HTCLIENT ) |
3826 | { | |
08158721 | 3827 | return false; |
43b5058d VZ |
3828 | } |
3829 | ||
bfbd6dc1 | 3830 | HCURSOR hcursor = 0; |
43b5058d VZ |
3831 | |
3832 | // first ask the user code - it may wish to set the cursor in some very | |
3833 | // specific way (for example, depending on the current position) | |
3834 | POINT pt; | |
f2325516 | 3835 | #ifdef __WXWINCE__ |
7d30268c | 3836 | if ( !::GetCursorPosWinCE(&pt)) |
f2325516 | 3837 | #else |
43b5058d | 3838 | if ( !::GetCursorPos(&pt) ) |
3fca879c | 3839 | #endif |
43b5058d | 3840 | { |
f6bcfd97 | 3841 | wxLogLastError(wxT("GetCursorPos")); |
43b5058d VZ |
3842 | } |
3843 | ||
3844 | int x = pt.x, | |
3845 | y = pt.y; | |
3846 | ScreenToClient(&x, &y); | |
3847 | wxSetCursorEvent event(x, y); | |
3848 | ||
3849 | bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); | |
3850 | if ( processedEvtSetCursor && event.HasCursor() ) | |
bfbd6dc1 | 3851 | { |
43b5058d | 3852 | hcursor = GetHcursorOf(event.GetCursor()); |
bfbd6dc1 | 3853 | } |
42e69d6b | 3854 | |
43b5058d | 3855 | if ( !hcursor ) |
bfbd6dc1 | 3856 | { |
43b5058d VZ |
3857 | bool isBusy = wxIsBusy(); |
3858 | ||
3859 | // the test for processedEvtSetCursor is here to prevent using m_cursor | |
3860 | // if the user code caught EVT_SET_CURSOR() and returned nothing from | |
3861 | // it - this is a way to say that our cursor shouldn't be used for this | |
3862 | // point | |
3863 | if ( !processedEvtSetCursor && m_cursor.Ok() ) | |
bfbd6dc1 | 3864 | { |
43b5058d | 3865 | hcursor = GetHcursorOf(m_cursor); |
bfbd6dc1 | 3866 | } |
43b5058d VZ |
3867 | |
3868 | if ( !GetParent() ) | |
bfbd6dc1 | 3869 | { |
43b5058d | 3870 | if ( isBusy ) |
42e69d6b | 3871 | { |
43b5058d VZ |
3872 | hcursor = wxGetCurrentBusyCursor(); |
3873 | } | |
3874 | else if ( !hcursor ) | |
3875 | { | |
3876 | const wxCursor *cursor = wxGetGlobalCursor(); | |
3877 | if ( cursor && cursor->Ok() ) | |
3878 | { | |
3879 | hcursor = GetHcursorOf(*cursor); | |
3880 | } | |
42e69d6b VZ |
3881 | } |
3882 | } | |
3883 | } | |
3884 | ||
bfbd6dc1 VZ |
3885 | if ( hcursor ) |
3886 | { | |
2b5f62a0 VZ |
3887 | // wxLogDebug("HandleSetCursor: Setting cursor %ld", (long) hcursor); |
3888 | ||
bfbd6dc1 VZ |
3889 | ::SetCursor(hcursor); |
3890 | ||
3891 | // cursor set, stop here | |
08158721 | 3892 | return true; |
bfbd6dc1 | 3893 | } |
cd4453e5 VZ |
3894 | #endif // __WXMICROWIN__ |
3895 | ||
3ca6a5f0 | 3896 | // pass up the window chain |
08158721 | 3897 | return false; |
2bda0e17 KB |
3898 | } |
3899 | ||
dbc74bcc | 3900 | bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam), |
355debca | 3901 | WXLPARAM WXUNUSED(lParam), |
dbc74bcc | 3902 | bool *WXUNUSED_IN_WINCE(vetoed)) |
355debca | 3903 | { |
dbc74bcc WS |
3904 | #ifdef __WXWINCE__ |
3905 | // FIXME | |
3906 | return false; | |
3907 | #else | |
355debca VZ |
3908 | wxEventType evtType; |
3909 | switch ( wParam ) | |
3910 | { | |
3911 | case PBT_APMQUERYSUSPEND: | |
3912 | evtType = wxEVT_POWER_SUSPENDING; | |
3913 | break; | |
3914 | ||
3915 | case PBT_APMQUERYSUSPENDFAILED: | |
3916 | evtType = wxEVT_POWER_SUSPEND_CANCEL; | |
3917 | break; | |
3918 | ||
3919 | case PBT_APMSUSPEND: | |
3920 | evtType = wxEVT_POWER_SUSPENDED; | |
3921 | break; | |
3922 | ||
3923 | case PBT_APMRESUMESUSPEND: | |
d4cd85a0 VZ |
3924 | #ifdef PBT_APMRESUMEAUTOMATIC |
3925 | case PBT_APMRESUMEAUTOMATIC: | |
3926 | #endif | |
355debca VZ |
3927 | evtType = wxEVT_POWER_RESUME; |
3928 | break; | |
3929 | ||
3930 | default: | |
3931 | wxLogDebug(_T("Unknown WM_POWERBROADCAST(%d) event"), wParam); | |
3932 | // fall through | |
3933 | ||
3934 | // these messages are currently not mapped to wx events | |
3935 | case PBT_APMQUERYSTANDBY: | |
3936 | case PBT_APMQUERYSTANDBYFAILED: | |
3937 | case PBT_APMSTANDBY: | |
3938 | case PBT_APMRESUMESTANDBY: | |
3939 | case PBT_APMBATTERYLOW: | |
3940 | case PBT_APMPOWERSTATUSCHANGE: | |
3941 | case PBT_APMOEMEVENT: | |
355debca VZ |
3942 | case PBT_APMRESUMECRITICAL: |
3943 | evtType = wxEVT_NULL; | |
3944 | break; | |
3945 | } | |
3946 | ||
3947 | // don't handle unknown messages | |
3948 | if ( evtType == wxEVT_NULL ) | |
3949 | return false; | |
3950 | ||
3951 | // TODO: notify about PBTF_APMRESUMEFROMFAILURE in case of resume events? | |
3952 | ||
3953 | wxPowerEvent event(evtType); | |
3954 | if ( !GetEventHandler()->ProcessEvent(event) ) | |
3955 | return false; | |
3956 | ||
3957 | *vetoed = event.IsVetoed(); | |
3958 | ||
3959 | return true; | |
dbc74bcc | 3960 | #endif |
355debca VZ |
3961 | } |
3962 | ||
2e992e06 VZ |
3963 | bool wxWindowMSW::IsDoubleBuffered() const |
3964 | { | |
967acfb5 | 3965 | for ( const wxWindowMSW *wnd = this; |
c719013f VZ |
3966 | wnd && !wnd->IsTopLevel(); wnd = |
3967 | wnd->GetParent() ) | |
2e992e06 | 3968 | { |
c719013f | 3969 | if ( ::GetWindowLong(GetHwndOf(wnd), GWL_EXSTYLE) & WS_EX_COMPOSITED ) |
2e992e06 | 3970 | return true; |
2e992e06 VZ |
3971 | } |
3972 | ||
3973 | return false; | |
3974 | } | |
3975 | ||
42e69d6b VZ |
3976 | // --------------------------------------------------------------------------- |
3977 | // owner drawn stuff | |
3978 | // --------------------------------------------------------------------------- | |
3979 | ||
61fef19b VZ |
3980 | #if (wxUSE_OWNER_DRAWN && wxUSE_MENUS_NATIVE) || \ |
3981 | (wxUSE_CONTROLS && !defined(__WXUNIVERSAL__)) | |
3982 | #define WXUNUSED_UNLESS_ODRAWN(param) param | |
3983 | #else | |
3984 | #define WXUNUSED_UNLESS_ODRAWN(param) | |
3985 | #endif | |
3986 | ||
3987 | bool | |
3988 | wxWindowMSW::MSWOnDrawItem(int WXUNUSED_UNLESS_ODRAWN(id), | |
3989 | WXDRAWITEMSTRUCT * WXUNUSED_UNLESS_ODRAWN(itemStruct)) | |
2bda0e17 | 3990 | { |
4286a5b5 | 3991 | #if wxUSE_OWNER_DRAWN |
1e6feb95 VZ |
3992 | |
3993 | #if wxUSE_MENUS_NATIVE | |
42e69d6b | 3994 | // is it a menu item? |
6f806543 VZ |
3995 | DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; |
3996 | if ( id == 0 && pDrawStruct->CtlType == ODT_MENU ) | |
42e69d6b | 3997 | { |
42e69d6b | 3998 | wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); |
03cef643 | 3999 | |
2d29bf54 JS |
4000 | // see comment before the same test in MSWOnMeasureItem() below |
4001 | if ( !pMenuItem ) | |
4002 | return false; | |
4003 | ||
4004 | wxCHECK_MSG( wxDynamicCast(pMenuItem, wxMenuItem), | |
42f25dcf | 4005 | false, _T("MSWOnDrawItem: bad wxMenuItem pointer") ); |
42e69d6b | 4006 | |
7561aacd VZ |
4007 | // prepare to call OnDrawItem(): notice using of wxDCTemp to prevent |
4008 | // the DC from being released | |
4009 | wxDCTemp dc((WXHDC)pDrawStruct->hDC); | |
42e69d6b VZ |
4010 | wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, |
4011 | pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, | |
4012 | pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); | |
4013 | ||
4014 | return pMenuItem->OnDrawItem | |
7561aacd VZ |
4015 | ( |
4016 | dc, | |
4017 | rect, | |
4018 | (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, | |
4019 | (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState | |
4020 | ); | |
42e69d6b | 4021 | } |
1e6feb95 | 4022 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 4023 | |
c8e4fa8b JS |
4024 | #endif // USE_OWNER_DRAWN |
4025 | ||
6a89f9ee | 4026 | #if wxUSE_CONTROLS && !defined(__WXUNIVERSAL__) |
c8e4fa8b | 4027 | |
c8e4fa8b | 4028 | #if wxUSE_OWNER_DRAWN |
1384636d | 4029 | wxControl *item = wxDynamicCast(FindItem(id), wxControl); |
567be187 | 4030 | #else // !wxUSE_OWNER_DRAWN |
1384636d VS |
4031 | // we may still have owner-drawn buttons internally because we have to make |
4032 | // them owner-drawn to support colour change | |
35bbb0c6 | 4033 | wxControl *item = |
095b80e2 WS |
4034 | # if wxUSE_BUTTON |
4035 | wxDynamicCast(FindItem(id), wxButton) | |
4036 | # else | |
4037 | NULL | |
4038 | # endif | |
4039 | ; | |
cd0b1709 | 4040 | #endif // USE_OWNER_DRAWN |
567be187 VZ |
4041 | |
4042 | if ( item ) | |
4043 | { | |
4044 | return item->MSWOnDraw(itemStruct); | |
4045 | } | |
4286a5b5 | 4046 | |
c8e4fa8b JS |
4047 | #endif // wxUSE_CONTROLS |
4048 | ||
08158721 | 4049 | return false; |
2bda0e17 KB |
4050 | } |
4051 | ||
61fef19b | 4052 | bool |
d1d276f2 | 4053 | wxWindowMSW::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) |
2bda0e17 | 4054 | { |
61fef19b | 4055 | #if wxUSE_OWNER_DRAWN && wxUSE_MENUS_NATIVE |
42e69d6b | 4056 | // is it a menu item? |
6f806543 VZ |
4057 | MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; |
4058 | if ( id == 0 && pMeasureStruct->CtlType == ODT_MENU ) | |
2d0a075d | 4059 | { |
42e69d6b VZ |
4060 | wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); |
4061 | ||
b6afa1a3 VZ |
4062 | // according to Carsten Fuchs the pointer may be NULL under XP if an |
4063 | // MDI child frame is initially maximized, see this for more info: | |
4064 | // http://article.gmane.org/gmane.comp.lib.wxwidgets.general/27745 | |
4065 | // | |
4066 | // so silently ignore it instead of asserting | |
4067 | if ( !pMenuItem ) | |
4068 | return false; | |
4069 | ||
4070 | wxCHECK_MSG( wxDynamicCast(pMenuItem, wxMenuItem), | |
42f25dcf | 4071 | false, _T("MSWOnMeasureItem: bad wxMenuItem pointer") ); |
42e69d6b | 4072 | |
975b6bcf VZ |
4073 | size_t w, h; |
4074 | bool rc = pMenuItem->OnMeasureItem(&w, &h); | |
4075 | ||
4076 | pMeasureStruct->itemWidth = w; | |
4077 | pMeasureStruct->itemHeight = h; | |
4078 | ||
4079 | return rc; | |
2d0a075d | 4080 | } |
42e69d6b | 4081 | |
567be187 VZ |
4082 | wxControl *item = wxDynamicCast(FindItem(id), wxControl); |
4083 | if ( item ) | |
42e69d6b | 4084 | { |
567be187 | 4085 | return item->MSWOnMeasure(itemStruct); |
42e69d6b | 4086 | } |
d1d276f2 WS |
4087 | #else |
4088 | wxUnusedVar(id); | |
4089 | wxUnusedVar(itemStruct); | |
4090 | #endif // wxUSE_OWNER_DRAWN && wxUSE_MENUS_NATIVE | |
567be187 | 4091 | |
08158721 | 4092 | return false; |
2bda0e17 KB |
4093 | } |
4094 | ||
42e69d6b VZ |
4095 | // --------------------------------------------------------------------------- |
4096 | // colours and palettes | |
4097 | // --------------------------------------------------------------------------- | |
2bda0e17 | 4098 | |
1e6feb95 | 4099 | bool wxWindowMSW::HandleSysColorChange() |
2bda0e17 | 4100 | { |
42e69d6b VZ |
4101 | wxSysColourChangedEvent event; |
4102 | event.SetEventObject(this); | |
4103 | ||
23895080 VZ |
4104 | (void)GetEventHandler()->ProcessEvent(event); |
4105 | ||
4106 | // always let the system carry on the default processing to allow the | |
4107 | // native controls to react to the colours update | |
08158721 | 4108 | return false; |
42e69d6b VZ |
4109 | } |
4110 | ||
574c939e KB |
4111 | bool wxWindowMSW::HandleDisplayChange() |
4112 | { | |
4113 | wxDisplayChangedEvent event; | |
4114 | event.SetEventObject(this); | |
4115 | ||
4116 | return GetEventHandler()->ProcessEvent(event); | |
4117 | } | |
4118 | ||
04ef50df | 4119 | #ifndef __WXMICROWIN__ |
42e69d6b | 4120 | |
1a784dfc | 4121 | bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC hDC, WXHWND hWnd) |
01c500af | 4122 | { |
3d74a760 | 4123 | #if !wxUSE_CONTROLS || defined(__WXUNIVERSAL__) |
43bfb798 | 4124 | wxUnusedVar(hDC); |
3d74a760 WS |
4125 | wxUnusedVar(hWnd); |
4126 | #else | |
2bae4332 | 4127 | wxControl *item = wxDynamicCast(FindItemByHWND(hWnd, true), wxControl); |
c3732409 | 4128 | |
01c500af | 4129 | if ( item ) |
1a784dfc | 4130 | *brush = item->MSWControlColor(hDC, hWnd); |
2d0a075d | 4131 | else |
1e6feb95 | 4132 | #endif // wxUSE_CONTROLS |
01c500af | 4133 | *brush = NULL; |
42e69d6b | 4134 | |
01c500af | 4135 | return *brush != NULL; |
2bda0e17 KB |
4136 | } |
4137 | ||
01c500af VZ |
4138 | #endif // __WXMICROWIN__ |
4139 | ||
1e6feb95 | 4140 | bool wxWindowMSW::HandlePaletteChanged(WXHWND hWndPalChange) |
42e69d6b | 4141 | { |
574c939e | 4142 | #if wxUSE_PALETTE |
b95edd47 VZ |
4143 | // same as below except we don't respond to our own messages |
4144 | if ( hWndPalChange != GetHWND() ) | |
4145 | { | |
574c939e | 4146 | // check to see if we our our parents have a custom palette |
fa21d338 | 4147 | wxWindowMSW *win = this; |
b95edd47 VZ |
4148 | while ( win && !win->HasCustomPalette() ) |
4149 | { | |
4150 | win = win->GetParent(); | |
4151 | } | |
4152 | ||
4153 | if ( win && win->HasCustomPalette() ) | |
4154 | { | |
4155 | // realize the palette to see whether redrawing is needed | |
4156 | HDC hdc = ::GetDC((HWND) hWndPalChange); | |
4157 | win->m_palette.SetHPALETTE((WXHPALETTE) | |
4158 | ::SelectPalette(hdc, GetHpaletteOf(win->m_palette), FALSE)); | |
574c939e KB |
4159 | |
4160 | int result = ::RealizePalette(hdc); | |
b95edd47 VZ |
4161 | |
4162 | // restore the palette (before releasing the DC) | |
4163 | win->m_palette.SetHPALETTE((WXHPALETTE) | |
4164 | ::SelectPalette(hdc, GetHpaletteOf(win->m_palette), FALSE)); | |
4165 | ::RealizePalette(hdc); | |
4166 | ::ReleaseDC((HWND) hWndPalChange, hdc); | |
4167 | ||
4168 | // now check for the need to redraw | |
574c939e | 4169 | if (result > 0) |
08158721 | 4170 | ::InvalidateRect((HWND) hWndPalChange, NULL, TRUE); |
574c939e | 4171 | } |
b95edd47 VZ |
4172 | |
4173 | } | |
4174 | #endif // wxUSE_PALETTE | |
574c939e | 4175 | |
42e69d6b VZ |
4176 | wxPaletteChangedEvent event(GetId()); |
4177 | event.SetEventObject(this); | |
4178 | event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
2d0a075d | 4179 | |
42e69d6b VZ |
4180 | return GetEventHandler()->ProcessEvent(event); |
4181 | } | |
4182 | ||
a5e84126 JS |
4183 | bool wxWindowMSW::HandleCaptureChanged(WXHWND hWndGainedCapture) |
4184 | { | |
63e819f2 VS |
4185 | // notify windows on the capture stack about lost capture |
4186 | // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863): | |
72f8c792 | 4187 | wxWindowBase::NotifyCaptureLost(); |
a5e84126 | 4188 | |
72f8c792 | 4189 | wxWindow *win = wxFindWinFromHandle(hWndGainedCapture); |
63e819f2 VS |
4190 | wxMouseCaptureChangedEvent event(GetId(), win); |
4191 | event.SetEventObject(this); | |
a5e84126 JS |
4192 | return GetEventHandler()->ProcessEvent(event); |
4193 | } | |
4194 | ||
3c96418b JG |
4195 | bool wxWindowMSW::HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam) |
4196 | { | |
4197 | // despite MSDN saying "(This message cannot be sent directly to a window.)" | |
4198 | // we need to send this to child windows (it is only sent to top-level | |
4199 | // windows) so {list,tree}ctrls can adjust their font size if necessary | |
4200 | // this is exactly how explorer does it to enable the font size changes | |
4201 | ||
4202 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); | |
4203 | while ( node ) | |
4204 | { | |
4205 | // top-level windows already get this message from the system | |
4206 | wxWindow *win = node->GetData(); | |
4207 | if ( !win->IsTopLevel() ) | |
4208 | { | |
4209 | ::SendMessage(GetHwndOf(win), WM_SETTINGCHANGE, wParam, lParam); | |
4210 | } | |
4211 | ||
4212 | node = node->GetNext(); | |
4213 | } | |
4214 | ||
3c96418b JG |
4215 | // let the system handle it |
4216 | return false; | |
4217 | } | |
4218 | ||
1e6feb95 | 4219 | bool wxWindowMSW::HandleQueryNewPalette() |
42e69d6b | 4220 | { |
574c939e KB |
4221 | |
4222 | #if wxUSE_PALETTE | |
4223 | // check to see if we our our parents have a custom palette | |
fa21d338 | 4224 | wxWindowMSW *win = this; |
574c939e KB |
4225 | while (!win->HasCustomPalette() && win->GetParent()) win = win->GetParent(); |
4226 | if (win->HasCustomPalette()) { | |
4227 | /* realize the palette to see whether redrawing is needed */ | |
3a3c8603 | 4228 | HDC hdc = ::GetDC((HWND) GetHWND()); |
574c939e | 4229 | win->m_palette.SetHPALETTE( (WXHPALETTE) |
b95edd47 | 4230 | ::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), FALSE) ); |
574c939e KB |
4231 | |
4232 | int result = ::RealizePalette(hdc); | |
4233 | /* restore the palette (before releasing the DC) */ | |
4234 | win->m_palette.SetHPALETTE( (WXHPALETTE) | |
b95edd47 | 4235 | ::SelectPalette(hdc, (HPALETTE) win->m_palette.GetHPALETTE(), TRUE) ); |
574c939e KB |
4236 | ::RealizePalette(hdc); |
4237 | ::ReleaseDC((HWND) GetHWND(), hdc); | |
4238 | /* now check for the need to redraw */ | |
4239 | if (result > 0) | |
4240 | ::InvalidateRect((HWND) GetHWND(), NULL, TRUE); | |
4241 | } | |
b95edd47 | 4242 | #endif // wxUSE_PALETTE |
574c939e | 4243 | |
42e69d6b VZ |
4244 | wxQueryNewPaletteEvent event(GetId()); |
4245 | event.SetEventObject(this); | |
4246 | ||
4247 | return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized(); | |
4248 | } | |
4249 | ||
4250 | // Responds to colour changes: passes event on to children. | |
574c939e | 4251 | void wxWindowMSW::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) |
42e69d6b | 4252 | { |
90c1530a VZ |
4253 | // the top level window also reset the standard colour map as it might have |
4254 | // changed (there is no need to do it for the non top level windows as we | |
4255 | // only have to do it once) | |
4256 | if ( IsTopLevel() ) | |
4257 | { | |
4258 | // FIXME-MT | |
08158721 | 4259 | gs_hasStdCmap = false; |
90c1530a | 4260 | } |
222ed1d6 | 4261 | wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
42e69d6b VZ |
4262 | while ( node ) |
4263 | { | |
23895080 VZ |
4264 | // Only propagate to non-top-level windows because Windows already |
4265 | // sends this event to all top-level ones | |
4266 | wxWindow *win = node->GetData(); | |
4267 | if ( !win->IsTopLevel() ) | |
42e69d6b | 4268 | { |
23895080 VZ |
4269 | // we need to send the real WM_SYSCOLORCHANGE and not just trigger |
4270 | // EVT_SYS_COLOUR_CHANGED call because the latter wouldn't work for | |
4271 | // the standard controls | |
4272 | ::SendMessage(GetHwndOf(win), WM_SYSCOLORCHANGE, 0, 0); | |
564b2609 | 4273 | } |
42e69d6b | 4274 | |
23895080 VZ |
4275 | node = node->GetNext(); |
4276 | } | |
2bda0e17 KB |
4277 | } |
4278 | ||
90c1530a VZ |
4279 | extern wxCOLORMAP *wxGetStdColourMap() |
4280 | { | |
4281 | static COLORREF s_stdColours[wxSTD_COL_MAX]; | |
4282 | static wxCOLORMAP s_cmap[wxSTD_COL_MAX]; | |
4283 | ||
4284 | if ( !gs_hasStdCmap ) | |
4285 | { | |
08158721 | 4286 | static bool s_coloursInit = false; |
90c1530a VZ |
4287 | |
4288 | if ( !s_coloursInit ) | |
4289 | { | |
4290 | // When a bitmap is loaded, the RGB values can change (apparently | |
4291 | // because Windows adjusts them to care for the old programs always | |
4292 | // using 0xc0c0c0 while the transparent colour for the new Windows | |
4293 | // versions is different). But we do this adjustment ourselves so | |
4294 | // we want to avoid Windows' "help" and for this we need to have a | |
4295 | // reference bitmap which can tell us what the RGB values change | |
4296 | // to. | |
e5dbcb50 | 4297 | wxLogNull logNo; // suppress error if we couldn't load the bitmap |
90c1530a VZ |
4298 | wxBitmap stdColourBitmap(_T("wxBITMAP_STD_COLOURS")); |
4299 | if ( stdColourBitmap.Ok() ) | |
4300 | { | |
4301 | // the pixels in the bitmap must correspond to wxSTD_COL_XXX! | |
4302 | wxASSERT_MSG( stdColourBitmap.GetWidth() == wxSTD_COL_MAX, | |
4303 | _T("forgot to update wxBITMAP_STD_COLOURS!") ); | |
4304 | ||
4305 | wxMemoryDC memDC; | |
4306 | memDC.SelectObject(stdColourBitmap); | |
4307 | ||
4308 | wxColour colour; | |
4309 | for ( size_t i = 0; i < WXSIZEOF(s_stdColours); i++ ) | |
4310 | { | |
4311 | memDC.GetPixel(i, 0, &colour); | |
4312 | s_stdColours[i] = wxColourToRGB(colour); | |
4313 | } | |
4314 | } | |
4315 | else // wxBITMAP_STD_COLOURS couldn't be loaded | |
4316 | { | |
4317 | s_stdColours[0] = RGB(000,000,000); // black | |
4318 | s_stdColours[1] = RGB(128,128,128); // dark grey | |
4319 | s_stdColours[2] = RGB(192,192,192); // light grey | |
4320 | s_stdColours[3] = RGB(255,255,255); // white | |
4321 | //s_stdColours[4] = RGB(000,000,255); // blue | |
4322 | //s_stdColours[5] = RGB(255,000,255); // magenta | |
4323 | } | |
4324 | ||
08158721 | 4325 | s_coloursInit = true; |
90c1530a VZ |
4326 | } |
4327 | ||
08158721 | 4328 | gs_hasStdCmap = true; |
90c1530a VZ |
4329 | |
4330 | // create the colour map | |
4331 | #define INIT_CMAP_ENTRY(col) \ | |
4332 | s_cmap[wxSTD_COL_##col].from = s_stdColours[wxSTD_COL_##col]; \ | |
4333 | s_cmap[wxSTD_COL_##col].to = ::GetSysColor(COLOR_##col) | |
4334 | ||
4335 | INIT_CMAP_ENTRY(BTNTEXT); | |
4336 | INIT_CMAP_ENTRY(BTNSHADOW); | |
4337 | INIT_CMAP_ENTRY(BTNFACE); | |
4338 | INIT_CMAP_ENTRY(BTNHIGHLIGHT); | |
4339 | ||
4340 | #undef INIT_CMAP_ENTRY | |
4341 | } | |
4342 | ||
4343 | return s_cmap; | |
4344 | } | |
4345 | ||
42e69d6b VZ |
4346 | // --------------------------------------------------------------------------- |
4347 | // painting | |
4348 | // --------------------------------------------------------------------------- | |
4349 | ||
1e6feb95 | 4350 | bool wxWindowMSW::HandlePaint() |
2bda0e17 | 4351 | { |
42e69d6b VZ |
4352 | HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle |
4353 | if ( !hRegion ) | |
f6bcfd97 | 4354 | wxLogLastError(wxT("CreateRectRgn")); |
42e69d6b | 4355 | if ( ::GetUpdateRgn(GetHwnd(), hRegion, FALSE) == ERROR ) |
f6bcfd97 | 4356 | wxLogLastError(wxT("GetUpdateRgn")); |
c085e333 | 4357 | |
42e69d6b | 4358 | m_updateRegion = wxRegion((WXHRGN) hRegion); |
c085e333 | 4359 | |
42e69d6b VZ |
4360 | wxPaintEvent event(m_windowId); |
4361 | event.SetEventObject(this); | |
2bda0e17 | 4362 | |
1e6feb95 VZ |
4363 | bool processed = GetEventHandler()->ProcessEvent(event); |
4364 | ||
4365 | // note that we must generate NC event after the normal one as otherwise | |
4366 | // BeginPaint() will happily overwrite our decorations with the background | |
4367 | // colour | |
4368 | wxNcPaintEvent eventNc(m_windowId); | |
4369 | eventNc.SetEventObject(this); | |
4370 | GetEventHandler()->ProcessEvent(eventNc); | |
4371 | ||
4372 | return processed; | |
2bda0e17 KB |
4373 | } |
4374 | ||
63da7df7 | 4375 | // Can be called from an application's OnPaint handler |
1e6feb95 | 4376 | void wxWindowMSW::OnPaint(wxPaintEvent& event) |
63da7df7 | 4377 | { |
1e6feb95 VZ |
4378 | #ifdef __WXUNIVERSAL__ |
4379 | event.Skip(); | |
4380 | #else | |
63da7df7 JS |
4381 | HDC hDC = (HDC) wxPaintDC::FindDCInCache((wxWindow*) event.GetEventObject()); |
4382 | if (hDC != 0) | |
4383 | { | |
4384 | MSWDefWindowProc(WM_PAINT, (WPARAM) hDC, 0); | |
4385 | } | |
1e6feb95 | 4386 | #endif |
63da7df7 JS |
4387 | } |
4388 | ||
1e6feb95 | 4389 | bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc) |
a23fd0e1 | 4390 | { |
e0e6ac8a | 4391 | wxDCTemp dc(hdc, GetClientSize()); |
c085e333 | 4392 | |
1e6feb95 VZ |
4393 | dc.SetHDC(hdc); |
4394 | dc.SetWindow((wxWindow *)this); | |
c085e333 | 4395 | |
2bda0e17 | 4396 | wxEraseEvent event(m_windowId, &dc); |
42e69d6b | 4397 | event.SetEventObject(this); |
a23fd0e1 | 4398 | bool rc = GetEventHandler()->ProcessEvent(event); |
c085e333 | 4399 | |
7561aacd | 4400 | // must be called manually as ~wxDC doesn't do anything for wxDCTemp |
a23fd0e1 | 4401 | dc.SelectOldObjects(hdc); |
a23fd0e1 VZ |
4402 | |
4403 | return rc; | |
2bda0e17 KB |
4404 | } |
4405 | ||
8681b094 VZ |
4406 | void wxWindowMSW::OnEraseBackground(wxEraseEvent& event) |
4407 | { | |
52c3e064 VZ |
4408 | // standard non top level controls (i.e. except the dialogs) always erase |
4409 | // their background themselves in HandleCtlColor() or have some control- | |
4410 | // specific ways to set the colours (common controls) | |
4411 | if ( IsOfStandardClass() && !IsTopLevel() ) | |
b8335252 | 4412 | { |
c5bd3c62 VZ |
4413 | event.Skip(); |
4414 | return; | |
4415 | } | |
b8335252 | 4416 | |
c5bd3c62 VZ |
4417 | if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM ) |
4418 | { | |
4419 | // don't skip the event here, custom background means that the app | |
4420 | // is drawing it itself in its OnPaint(), so don't draw it at all | |
4421 | // now to avoid flicker | |
4422 | return; | |
4423 | } | |
8681b094 | 4424 | |
8681b094 | 4425 | |
c5bd3c62 | 4426 | // do default background painting |
c3732409 | 4427 | if ( !DoEraseBackground(GetHdcOf(*event.GetDC())) ) |
c5bd3c62 VZ |
4428 | { |
4429 | // let the system paint the background | |
4430 | event.Skip(); | |
4431 | } | |
4432 | } | |
4433 | ||
c3732409 | 4434 | bool wxWindowMSW::DoEraseBackground(WXHDC hDC) |
c581abbc | 4435 | { |
c3732409 VZ |
4436 | HBRUSH hbr = (HBRUSH)MSWGetBgBrush(hDC); |
4437 | if ( !hbr ) | |
c581abbc VZ |
4438 | return false; |
4439 | ||
c3732409 | 4440 | wxFillRect(GetHwnd(), (HDC)hDC, hbr); |
c581abbc VZ |
4441 | |
4442 | return true; | |
4443 | } | |
4444 | ||
c3732409 | 4445 | WXHBRUSH |
2bae4332 | 4446 | wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd) |
c5bd3c62 | 4447 | { |
accbb1e7 VZ |
4448 | if ( m_hasBgCol ) |
4449 | { | |
8d075f8d VZ |
4450 | // our background colour applies to: |
4451 | // 1. this window itself, always | |
4452 | // 2. all children unless the colour is "not inheritable" | |
c3732409 VZ |
4453 | // 3. even if it is not inheritable, our immediate transparent |
4454 | // children should still inherit it -- but not any transparent | |
4455 | // children because it would look wrong if a child of non | |
4456 | // transparent child would show our bg colour when the child itself | |
4457 | // does not | |
2bae4332 VZ |
4458 | wxWindow *win = wxFindWinFromHandle(hWnd); |
4459 | if ( win == this || | |
c3732409 | 4460 | m_inheritBgCol || |
2bae4332 VZ |
4461 | (win && win->HasTransparentBackground() && |
4462 | win->GetParent() == this) ) | |
accbb1e7 | 4463 | { |
c3732409 VZ |
4464 | // draw children with the same colour as the parent |
4465 | wxBrush * | |
4466 | brush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour()); | |
4467 | ||
4468 | return (WXHBRUSH)GetHbrushOf(*brush); | |
accbb1e7 VZ |
4469 | } |
4470 | } | |
4471 | ||
c3732409 | 4472 | return 0; |
c5bd3c62 | 4473 | } |
8681b094 | 4474 | |
2bae4332 | 4475 | WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint) |
bdd1a35d | 4476 | { |
2bae4332 VZ |
4477 | if ( !hWndToPaint ) |
4478 | hWndToPaint = GetHWND(); | |
bdd1a35d | 4479 | |
c3732409 | 4480 | for ( wxWindowMSW *win = this; win; win = win->GetParent() ) |
c5bd3c62 | 4481 | { |
2bae4332 | 4482 | WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, hWndToPaint); |
c5bd3c62 VZ |
4483 | if ( hBrush ) |
4484 | return hBrush; | |
24cb4019 | 4485 | |
c3732409 VZ |
4486 | // background is not inherited beyond top level windows |
4487 | if ( win->IsTopLevel() ) | |
24cb4019 | 4488 | break; |
01c500af | 4489 | } |
c5bd3c62 VZ |
4490 | |
4491 | return 0; | |
8681b094 VZ |
4492 | } |
4493 | ||
b728a212 | 4494 | bool wxWindowMSW::HandlePrintClient(WXHDC hDC) |
1a784dfc | 4495 | { |
b728a212 JG |
4496 | // we receive this message when DrawThemeParentBackground() is |
4497 | // called from def window proc of several controls under XP and we | |
4498 | // must draw properly themed background here | |
4499 | // | |
4500 | // note that naively I'd expect filling the client rect with the | |
4501 | // brush returned by MSWGetBgBrush() work -- but for some reason it | |
4502 | // doesn't and we have to call parents MSWPrintChild() which is | |
4503 | // supposed to call DrawThemeBackground() with appropriate params | |
4504 | // | |
4505 | // also note that in this case lParam == PRF_CLIENT but we're | |
4506 | // clearly expected to paint the background and nothing else! | |
4507 | ||
4508 | if ( IsTopLevel() || InheritsBackgroundColour() ) | |
4509 | return false; | |
4510 | ||
4511 | // sometimes we don't want the parent to handle it at all, instead | |
4512 | // return whatever value this window wants | |
4513 | if ( !MSWShouldPropagatePrintChild() ) | |
4514 | return MSWPrintChild(hDC, (wxWindow *)this); | |
4515 | ||
4516 | for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) | |
4517 | { | |
4518 | if ( win->MSWPrintChild(hDC, (wxWindow *)this) ) | |
4519 | return true; | |
4520 | ||
4521 | if ( win->IsTopLevel() || win->InheritsBackgroundColour() ) | |
4522 | break; | |
4523 | } | |
4524 | ||
1a784dfc VZ |
4525 | return false; |
4526 | } | |
4527 | ||
42e69d6b VZ |
4528 | // --------------------------------------------------------------------------- |
4529 | // moving and resizing | |
4530 | // --------------------------------------------------------------------------- | |
4531 | ||
1e6feb95 | 4532 | bool wxWindowMSW::HandleMinimize() |
42e69d6b VZ |
4533 | { |
4534 | wxIconizeEvent event(m_windowId); | |
4535 | event.SetEventObject(this); | |
2d0a075d | 4536 | |
42e69d6b | 4537 | return GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
4538 | } |
4539 | ||
1e6feb95 | 4540 | bool wxWindowMSW::HandleMaximize() |
2bda0e17 | 4541 | { |
42e69d6b VZ |
4542 | wxMaximizeEvent event(m_windowId); |
4543 | event.SetEventObject(this); | |
c085e333 | 4544 | |
42e69d6b VZ |
4545 | return GetEventHandler()->ProcessEvent(event); |
4546 | } | |
2bda0e17 | 4547 | |
1e6feb95 | 4548 | bool wxWindowMSW::HandleMove(int x, int y) |
42e69d6b | 4549 | { |
907173e5 WS |
4550 | wxPoint point(x,y); |
4551 | wxMoveEvent event(point, m_windowId); | |
42e69d6b VZ |
4552 | event.SetEventObject(this); |
4553 | ||
4554 | return GetEventHandler()->ProcessEvent(event); | |
4555 | } | |
4556 | ||
5706de1c JS |
4557 | bool wxWindowMSW::HandleMoving(wxRect& rect) |
4558 | { | |
4559 | wxMoveEvent event(rect, m_windowId); | |
4560 | event.SetEventObject(this); | |
577baeef | 4561 | |
5706de1c JS |
4562 | bool rc = GetEventHandler()->ProcessEvent(event); |
4563 | if (rc) | |
4564 | rect = event.GetRect(); | |
4565 | return rc; | |
4566 | } | |
4567 | ||
4bc0f25e | 4568 | bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam) |
42e69d6b | 4569 | { |
c3723477 JS |
4570 | #if USE_DEFERRED_SIZING |
4571 | // when we resize this window, its children are probably going to be | |
4572 | // repositioned as well, prepare to use DeferWindowPos() for them | |
4573 | int numChildren = 0; | |
4574 | for ( HWND child = ::GetWindow(GetHwndOf(this), GW_CHILD); | |
4575 | child; | |
4576 | child = ::GetWindow(child, GW_HWNDNEXT) ) | |
4577 | { | |
4578 | numChildren ++; | |
4579 | } | |
4580 | ||
3fca879c | 4581 | // Protect against valid m_hDWP being overwritten |
c3723477 JS |
4582 | bool useDefer = false; |
4583 | ||
3f48c8e2 VZ |
4584 | if ( numChildren > 1 ) |
4585 | { | |
c3723477 | 4586 | if (!m_hDWP) |
3fca879c | 4587 | { |
c3723477 JS |
4588 | m_hDWP = (WXHANDLE)::BeginDeferWindowPos(numChildren); |
4589 | if ( !m_hDWP ) | |
4590 | { | |
4591 | wxLogLastError(_T("BeginDeferWindowPos")); | |
4592 | } | |
4593 | if (m_hDWP) | |
4594 | useDefer = true; | |
3f48c8e2 VZ |
4595 | } |
4596 | } | |
f7040b5f | 4597 | #endif // USE_DEFERRED_SIZING |
42e69d6b | 4598 | |
3f48c8e2 VZ |
4599 | // update this window size |
4600 | bool processed = false; | |
4bc0f25e VZ |
4601 | switch ( wParam ) |
4602 | { | |
4603 | default: | |
4604 | wxFAIL_MSG( _T("unexpected WM_SIZE parameter") ); | |
4605 | // fall through nevertheless | |
4606 | ||
4607 | case SIZE_MAXHIDE: | |
4608 | case SIZE_MAXSHOW: | |
4609 | // we're not interested in these messages at all | |
4610 | break; | |
4611 | ||
4612 | case SIZE_MINIMIZED: | |
4613 | processed = HandleMinimize(); | |
4614 | break; | |
4615 | ||
4616 | case SIZE_MAXIMIZED: | |
a4d1972d | 4617 | /* processed = */ HandleMaximize(); |
4bc0f25e VZ |
4618 | // fall through to send a normal size event as well |
4619 | ||
4620 | case SIZE_RESTORED: | |
4621 | // don't use w and h parameters as they specify the client size | |
4622 | // while according to the docs EVT_SIZE handler is supposed to | |
4623 | // receive the total size | |
4624 | wxSizeEvent event(GetSize(), m_windowId); | |
4625 | event.SetEventObject(this); | |
4626 | ||
4627 | processed = GetEventHandler()->ProcessEvent(event); | |
4628 | } | |
4629 | ||
c3723477 | 4630 | #if USE_DEFERRED_SIZING |
3f48c8e2 | 4631 | // and finally change the positions of all child windows at once |
c3723477 | 4632 | if ( useDefer && m_hDWP ) |
3f48c8e2 VZ |
4633 | { |
4634 | // reset m_hDWP to NULL so that child windows don't try to use our | |
4635 | // m_hDWP after we call EndDeferWindowPos() on it (this shouldn't | |
4636 | // happen anyhow normally but who knows what weird flow of control we | |
4637 | // may have depending on what the users EVT_SIZE handler does...) | |
4638 | HDWP hDWP = (HDWP)m_hDWP; | |
4639 | m_hDWP = NULL; | |
3fca879c | 4640 | |
3f48c8e2 VZ |
4641 | // do put all child controls in place at once |
4642 | if ( !::EndDeferWindowPos(hDWP) ) | |
4643 | { | |
4644 | wxLogLastError(_T("EndDeferWindowPos")); | |
4645 | } | |
c3723477 | 4646 | |
da78f3b1 | 4647 | // Reset our children's pending pos/size values. |
c3723477 JS |
4648 | for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); |
4649 | node; | |
4650 | node = node->GetNext() ) | |
4651 | { | |
82e3664e | 4652 | wxWindowMSW *child = node->GetData(); |
67644c1d RD |
4653 | child->m_pendingPosition = wxDefaultPosition; |
4654 | child->m_pendingSize = wxDefaultSize; | |
c3723477 | 4655 | } |
3f48c8e2 | 4656 | } |
7d86a2d4 | 4657 | #endif // USE_DEFERRED_SIZING |
3f48c8e2 | 4658 | |
4bc0f25e | 4659 | return processed; |
42e69d6b VZ |
4660 | } |
4661 | ||
5706de1c JS |
4662 | bool wxWindowMSW::HandleSizing(wxRect& rect) |
4663 | { | |
4664 | wxSizeEvent event(rect, m_windowId); | |
4665 | event.SetEventObject(this); | |
577baeef | 4666 | |
5706de1c JS |
4667 | bool rc = GetEventHandler()->ProcessEvent(event); |
4668 | if (rc) | |
4669 | rect = event.GetRect(); | |
4670 | return rc; | |
4671 | } | |
4672 | ||
0c0d1521 | 4673 | bool wxWindowMSW::HandleGetMinMaxInfo(void *WXUNUSED_IN_WINCE(mmInfo)) |
42e69d6b | 4674 | { |
7f0586ef | 4675 | #ifdef __WXWINCE__ |
08158721 | 4676 | return false; |
7f0586ef | 4677 | #else |
42e69d6b VZ |
4678 | MINMAXINFO *info = (MINMAXINFO *)mmInfo; |
4679 | ||
08158721 | 4680 | bool rc = false; |
b2d5a7ee | 4681 | |
e7dda1ff VS |
4682 | int minWidth = GetMinWidth(), |
4683 | minHeight = GetMinHeight(), | |
4684 | maxWidth = GetMaxWidth(), | |
4685 | maxHeight = GetMaxHeight(); | |
42e69d6b | 4686 | |
422d0ff0 | 4687 | if ( minWidth != wxDefaultCoord ) |
2d0a075d | 4688 | { |
e7dda1ff | 4689 | info->ptMinTrackSize.x = minWidth; |
08158721 | 4690 | rc = true; |
2d0a075d | 4691 | } |
2bda0e17 | 4692 | |
422d0ff0 | 4693 | if ( minHeight != wxDefaultCoord ) |
42e69d6b | 4694 | { |
e7dda1ff | 4695 | info->ptMinTrackSize.y = minHeight; |
08158721 | 4696 | rc = true; |
42e69d6b | 4697 | } |
2bda0e17 | 4698 | |
422d0ff0 | 4699 | if ( maxWidth != wxDefaultCoord ) |
42e69d6b | 4700 | { |
e7dda1ff | 4701 | info->ptMaxTrackSize.x = maxWidth; |
08158721 | 4702 | rc = true; |
2d0a075d | 4703 | } |
2bda0e17 | 4704 | |
422d0ff0 | 4705 | if ( maxHeight != wxDefaultCoord ) |
42e69d6b | 4706 | { |
e7dda1ff | 4707 | info->ptMaxTrackSize.y = maxHeight; |
08158721 | 4708 | rc = true; |
42e69d6b | 4709 | } |
2bda0e17 | 4710 | |
42e69d6b | 4711 | return rc; |
7f0586ef | 4712 | #endif |
42e69d6b | 4713 | } |
2d0a075d | 4714 | |
42e69d6b VZ |
4715 | // --------------------------------------------------------------------------- |
4716 | // command messages | |
4717 | // --------------------------------------------------------------------------- | |
4718 | ||
1e6feb95 | 4719 | bool wxWindowMSW::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) |
42e69d6b | 4720 | { |
1e6feb95 | 4721 | #if wxUSE_MENUS_NATIVE |
8c290175 | 4722 | if ( !cmd && wxCurrentPopupMenu ) |
42e69d6b VZ |
4723 | { |
4724 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
4725 | wxCurrentPopupMenu = NULL; | |
4726 | ||
4727 | return popupMenu->MSWCommand(cmd, id); | |
4728 | } | |
1e6feb95 | 4729 | #endif // wxUSE_MENUS_NATIVE |
42e69d6b | 4730 | |
8c290175 | 4731 | wxWindow *win = NULL; |
71292fab VZ |
4732 | |
4733 | // first try to find it from HWND - this works even with the broken | |
4734 | // programs using the same ids for different controls | |
4735 | if ( control ) | |
42e69d6b | 4736 | { |
71292fab | 4737 | win = wxFindWinFromHandle(control); |
b853f898 | 4738 | } |
2f4ef631 | 4739 | |
71292fab VZ |
4740 | // try the id |
4741 | if ( !win ) | |
b853f898 | 4742 | { |
71292fab VZ |
4743 | // must cast to a signed type before comparing with other ids! |
4744 | win = FindItem((signed short)id); | |
42e69d6b VZ |
4745 | } |
4746 | ||
4747 | if ( win ) | |
b94ae1ea | 4748 | { |
42e69d6b | 4749 | return win->MSWCommand(cmd, id); |
b94ae1ea VZ |
4750 | } |
4751 | ||
4752 | // the messages sent from the in-place edit control used by the treectrl | |
4753 | // for label editing have id == 0, but they should _not_ be treated as menu | |
4754 | // messages (they are EN_XXX ones, in fact) so don't translate anything | |
4755 | // coming from a control to wxEVT_COMMAND_MENU_SELECTED | |
4756 | if ( !control ) | |
a84fc80b | 4757 | { |
b94ae1ea VZ |
4758 | // If no child window, it may be an accelerator, e.g. for a popup menu |
4759 | // command | |
a84fc80b JS |
4760 | |
4761 | wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED); | |
4762 | event.SetEventObject(this); | |
4763 | event.SetId(id); | |
4764 | event.SetInt(id); | |
b94ae1ea VZ |
4765 | |
4766 | return GetEventHandler()->ProcessEvent(event); | |
a84fc80b | 4767 | } |
6fe19057 VZ |
4768 | else |
4769 | { | |
01d2bf4d | 4770 | #if wxUSE_SPINCTRL && !defined(__WXUNIVERSAL__) |
6fe19057 VZ |
4771 | // the text ctrl which is logically part of wxSpinCtrl sends WM_COMMAND |
4772 | // notifications to its parent which we want to reflect back to | |
4773 | // wxSpinCtrl | |
4774 | wxSpinCtrl *spin = wxSpinCtrl::GetSpinForTextCtrl(control); | |
4775 | if ( spin && spin->ProcessTextCommand(cmd, id) ) | |
08158721 | 4776 | return true; |
6fe19057 | 4777 | #endif // wxUSE_SPINCTRL |
42e69d6b | 4778 | |
01d2bf4d WS |
4779 | #if wxUSE_CHOICE && defined(__SMARTPHONE__) |
4780 | // the listbox ctrl which is logically part of wxChoice sends WM_COMMAND | |
4781 | // notifications to its parent which we want to reflect back to | |
4782 | // wxChoice | |
4783 | wxChoice *choice = wxChoice::GetChoiceForListBox(control); | |
4784 | if ( choice && choice->MSWCommand(cmd, id) ) | |
4785 | return true; | |
4786 | #endif | |
4787 | } | |
4788 | ||
08158721 | 4789 | return false; |
2bda0e17 KB |
4790 | } |
4791 | ||
42e69d6b VZ |
4792 | // --------------------------------------------------------------------------- |
4793 | // mouse events | |
4794 | // --------------------------------------------------------------------------- | |
4795 | ||
1e6feb95 VZ |
4796 | void wxWindowMSW::InitMouseEvent(wxMouseEvent& event, |
4797 | int x, int y, | |
4798 | WXUINT flags) | |
42e69d6b | 4799 | { |
1e6feb95 VZ |
4800 | // our client coords are not quite the same as Windows ones |
4801 | wxPoint pt = GetClientAreaOrigin(); | |
4802 | event.m_x = x - pt.x; | |
4803 | event.m_y = y - pt.y; | |
4804 | ||
4805 | event.m_shiftDown = (flags & MK_SHIFT) != 0; | |
4806 | event.m_controlDown = (flags & MK_CONTROL) != 0; | |
4807 | event.m_leftDown = (flags & MK_LBUTTON) != 0; | |
4808 | event.m_middleDown = (flags & MK_MBUTTON) != 0; | |
4809 | event.m_rightDown = (flags & MK_RBUTTON) != 0; | |
1fdf858b | 4810 | event.m_altDown = ::GetKeyState(VK_MENU) < 0; |
1e6feb95 | 4811 | |
f0b1ccde | 4812 | #ifndef __WXWINCE__ |
1bf77ee5 | 4813 | event.SetTimestamp(::GetMessageTime()); |
f0b1ccde JS |
4814 | #endif |
4815 | ||
687706f5 | 4816 | event.SetEventObject(this); |
fb35f0c7 | 4817 | event.SetId(GetId()); |
42e69d6b VZ |
4818 | |
4819 | #if wxUSE_MOUSEEVENT_HACK | |
c358ea41 VZ |
4820 | gs_lastMouseEvent.pos = ClientToScreen(wxPoint(x, y)); |
4821 | gs_lastMouseEvent.type = event.GetEventType(); | |
42e69d6b | 4822 | #endif // wxUSE_MOUSEEVENT_HACK |
2bda0e17 KB |
4823 | } |
4824 | ||
42b1fb63 | 4825 | #ifdef __WXWINCE__ |
dfafa702 VZ |
4826 | // Windows doesn't send the mouse events to the static controls (which are |
4827 | // transparent in the sense that their WM_NCHITTEST handler returns | |
4828 | // HTTRANSPARENT) at all but we want all controls to receive the mouse events | |
4829 | // and so we manually check if we don't have a child window under mouse and if | |
4830 | // we do, send the event to it instead of the window Windows had sent WM_XXX | |
4831 | // to. | |
4832 | // | |
4833 | // Notice that this is not done for the mouse move events because this could | |
4834 | // (would?) be too slow, but only for clicks which means that the static texts | |
4835 | // still don't get move, enter nor leave events. | |
42b1fb63 | 4836 | static wxWindowMSW *FindWindowForMouseEvent(wxWindowMSW *win, int *x, int *y) |
dfafa702 VZ |
4837 | { |
4838 | wxCHECK_MSG( x && y, win, _T("NULL pointer in FindWindowForMouseEvent") ); | |
4839 | ||
4840 | // first try to find a non transparent child: this allows us to send events | |
4841 | // to a static text which is inside a static box, for example | |
4842 | POINT pt = { *x, *y }; | |
4843 | HWND hwnd = GetHwndOf(win), | |
4844 | hwndUnderMouse; | |
4845 | ||
7f0586ef JS |
4846 | #ifdef __WXWINCE__ |
4847 | hwndUnderMouse = ::ChildWindowFromPoint | |
4848 | ( | |
4849 | hwnd, | |
4850 | pt | |
4851 | ); | |
4852 | #else | |
dfafa702 VZ |
4853 | hwndUnderMouse = ::ChildWindowFromPointEx |
4854 | ( | |
4855 | hwnd, | |
4856 | pt, | |
4857 | CWP_SKIPINVISIBLE | | |
4858 | CWP_SKIPDISABLED | | |
4859 | CWP_SKIPTRANSPARENT | |
4860 | ); | |
7f0586ef | 4861 | #endif |
dfafa702 VZ |
4862 | |
4863 | if ( !hwndUnderMouse || hwndUnderMouse == hwnd ) | |
dfafa702 VZ |
4864 | { |
4865 | // now try any child window at all | |
4866 | hwndUnderMouse = ::ChildWindowFromPoint(hwnd, pt); | |
4867 | } | |
4868 | ||
4869 | // check that we have a child window which is susceptible to receive mouse | |
4870 | // events: for this it must be shown and enabled | |
4871 | if ( hwndUnderMouse && | |
4872 | hwndUnderMouse != hwnd && | |
4873 | ::IsWindowVisible(hwndUnderMouse) && | |
4874 | ::IsWindowEnabled(hwndUnderMouse) ) | |
4875 | { | |
4876 | wxWindow *winUnderMouse = wxFindWinFromHandle((WXHWND)hwndUnderMouse); | |
4877 | if ( winUnderMouse ) | |
4878 | { | |
4879 | // translate the mouse coords to the other window coords | |
4880 | win->ClientToScreen(x, y); | |
4881 | winUnderMouse->ScreenToClient(x, y); | |
4882 | ||
4883 | win = winUnderMouse; | |
4884 | } | |
4885 | } | |
4886 | ||
4887 | return win; | |
4888 | } | |
42b1fb63 | 4889 | #endif // __WXWINCE__ |
dfafa702 | 4890 | |
1e6feb95 | 4891 | bool wxWindowMSW::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags) |
2bda0e17 | 4892 | { |
42e69d6b | 4893 | // the mouse events take consecutive IDs from WM_MOUSEFIRST to |
34621cc5 | 4894 | // WM_MOUSELAST, so it's enough to subtract WM_MOUSEMOVE == WM_MOUSEFIRST |
42e69d6b VZ |
4895 | // from the message id and take the value in the table to get wxWin event |
4896 | // id | |
4897 | static const wxEventType eventsMouse[] = | |
4898 | { | |
4899 | wxEVT_MOTION, | |
4900 | wxEVT_LEFT_DOWN, | |
4901 | wxEVT_LEFT_UP, | |
4902 | wxEVT_LEFT_DCLICK, | |
4903 | wxEVT_RIGHT_DOWN, | |
4904 | wxEVT_RIGHT_UP, | |
4905 | wxEVT_RIGHT_DCLICK, | |
4906 | wxEVT_MIDDLE_DOWN, | |
4907 | wxEVT_MIDDLE_UP, | |
4908 | wxEVT_MIDDLE_DCLICK | |
4909 | }; | |
2bda0e17 | 4910 | |
42e69d6b VZ |
4911 | wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]); |
4912 | InitMouseEvent(event, x, y, flags); | |
4913 | ||
4914 | return GetEventHandler()->ProcessEvent(event); | |
4915 | } | |
4916 | ||
1e6feb95 | 4917 | bool wxWindowMSW::HandleMouseMove(int x, int y, WXUINT flags) |
42e69d6b VZ |
4918 | { |
4919 | if ( !m_mouseInWindow ) | |
2bda0e17 | 4920 | { |
1e6feb95 VZ |
4921 | // it would be wrong to assume that just because we get a mouse move |
4922 | // event that the mouse is inside the window: although this is usually | |
4923 | // true, it is not if we had captured the mouse, so we need to check | |
4924 | // the mouse coordinates here | |
4925 | if ( !HasCapture() || IsMouseInWindow() ) | |
4926 | { | |
4927 | // Generate an ENTER event | |
08158721 | 4928 | m_mouseInWindow = true; |
e5297b7f | 4929 | |
4e5c6c33 | 4930 | #ifdef HAVE_TRACKMOUSEEVENT |
aafb9978 VZ |
4931 | typedef BOOL (WINAPI *_TrackMouseEvent_t)(LPTRACKMOUSEEVENT); |
4932 | #ifdef __WXWINCE__ | |
4933 | static const _TrackMouseEvent_t | |
4934 | s_pfn_TrackMouseEvent = _TrackMouseEvent; | |
4935 | #else // !__WXWINCE__ | |
4936 | static _TrackMouseEvent_t s_pfn_TrackMouseEvent; | |
4937 | static bool s_initDone = false; | |
4938 | if ( !s_initDone ) | |
4939 | { | |
4940 | wxLogNull noLog; | |
4941 | ||
4942 | wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM); | |
4943 | if ( dllComCtl32.IsLoaded() ) | |
4944 | { | |
4945 | s_pfn_TrackMouseEvent = (_TrackMouseEvent_t) | |
4946 | dllComCtl32.GetSymbol(_T("_TrackMouseEvent")); | |
4947 | } | |
4948 | ||
4949 | s_initDone = true; | |
4e5c6c33 | 4950 | |
aafb9978 VZ |
4951 | // notice that it's ok to unload comctl32.dll here as it won't |
4952 | // be really unloaded, being still in use because we link to it | |
4953 | // statically too | |
4954 | } | |
4955 | ||
4956 | if ( s_pfn_TrackMouseEvent ) | |
4957 | #endif // __WXWINCE__/!__WXWINCE__ | |
4958 | { | |
4959 | WinStruct<TRACKMOUSEEVENT> trackinfo; | |
4e5c6c33 | 4960 | |
aafb9978 VZ |
4961 | trackinfo.dwFlags = TME_LEAVE; |
4962 | trackinfo.hwndTrack = GetHwnd(); | |
4963 | ||
4964 | (*s_pfn_TrackMouseEvent)(&trackinfo); | |
4965 | } | |
4e5c6c33 VZ |
4966 | #endif // HAVE_TRACKMOUSEEVENT |
4967 | ||
1e6feb95 VZ |
4968 | wxMouseEvent event(wxEVT_ENTER_WINDOW); |
4969 | InitMouseEvent(event, x, y, flags); | |
42e69d6b | 4970 | |
1e6feb95 VZ |
4971 | (void)GetEventHandler()->ProcessEvent(event); |
4972 | } | |
42e69d6b | 4973 | } |
cff58b52 | 4974 | #ifdef HAVE_TRACKMOUSEEVENT |
aafb9978 | 4975 | else // mouse not in window |
cff58b52 KH |
4976 | { |
4977 | // Check if we need to send a LEAVE event | |
4978 | // Windows doesn't send WM_MOUSELEAVE if the mouse has been captured so | |
4979 | // send it here if we are using native mouse leave tracking | |
4980 | if ( HasCapture() && !IsMouseInWindow() ) | |
4981 | { | |
4982 | GenerateMouseLeave(); | |
4983 | } | |
4984 | } | |
1ca78aa1 | 4985 | #endif // HAVE_TRACKMOUSEEVENT |
42e69d6b VZ |
4986 | |
4987 | #if wxUSE_MOUSEEVENT_HACK | |
c358ea41 VZ |
4988 | // Windows often generates mouse events even if mouse position hasn't |
4989 | // changed (http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/66576) | |
4990 | // | |
4991 | // Filter this out as it can result in unexpected behaviour compared to | |
4992 | // other platforms | |
4993 | if ( gs_lastMouseEvent.type == wxEVT_RIGHT_DOWN || | |
4994 | gs_lastMouseEvent.type == wxEVT_LEFT_DOWN || | |
4995 | gs_lastMouseEvent.type == wxEVT_MIDDLE_DOWN || | |
4996 | gs_lastMouseEvent.type == wxEVT_MOTION ) | |
4997 | { | |
4998 | if ( ClientToScreen(wxPoint(x, y)) == gs_lastMouseEvent.pos ) | |
4999 | { | |
5000 | gs_lastMouseEvent.type = wxEVT_MOTION; | |
42e69d6b | 5001 | |
c358ea41 VZ |
5002 | return false; |
5003 | } | |
42e69d6b VZ |
5004 | } |
5005 | #endif // wxUSE_MOUSEEVENT_HACK | |
5006 | ||
5007 | return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags); | |
5008 | } | |
5009 | ||
d2c52078 | 5010 | |
24ce4c18 | 5011 | bool wxWindowMSW::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam) |
d2c52078 RD |
5012 | { |
5013 | #if wxUSE_MOUSEWHEEL | |
3c297348 VZ |
5014 | // notice that WM_MOUSEWHEEL position is in screen coords (as it's |
5015 | // forwarded up to the parent by DefWindowProc()) and not in the client | |
5016 | // ones as all the other messages, translate them to the client coords for | |
5017 | // consistency | |
5018 | const wxPoint | |
5019 | pt = ScreenToClient(wxPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); | |
d2c52078 | 5020 | wxMouseEvent event(wxEVT_MOUSEWHEEL); |
3c297348 | 5021 | InitMouseEvent(event, pt.x, pt.y, LOWORD(wParam)); |
d2c52078 RD |
5022 | event.m_wheelRotation = (short)HIWORD(wParam); |
5023 | event.m_wheelDelta = WHEEL_DELTA; | |
5024 | ||
0f7a546d RD |
5025 | static int s_linesPerRotation = -1; |
5026 | if ( s_linesPerRotation == -1 ) | |
5027 | { | |
5028 | if ( !::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, | |
5029 | &s_linesPerRotation, 0)) | |
5030 | { | |
5031 | // this is not supposed to happen | |
5032 | wxLogLastError(_T("SystemParametersInfo(GETWHEELSCROLLLINES)")); | |
5033 | ||
5034 | // the default is 3, so use it if SystemParametersInfo() failed | |
5035 | s_linesPerRotation = 3; | |
5036 | } | |
5037 | } | |
d2c52078 | 5038 | |
0f7a546d | 5039 | event.m_linesPerAction = s_linesPerRotation; |
d2c52078 | 5040 | return GetEventHandler()->ProcessEvent(event); |
0f7a546d | 5041 | |
51e4e266 VZ |
5042 | #else // !wxUSE_MOUSEWHEEL |
5043 | wxUnusedVar(wParam); | |
5044 | wxUnusedVar(lParam); | |
38caaa61 | 5045 | |
08158721 | 5046 | return false; |
51e4e266 | 5047 | #endif // wxUSE_MOUSEWHEEL/!wxUSE_MOUSEWHEEL |
d2c52078 RD |
5048 | } |
5049 | ||
51e4e266 VZ |
5050 | void wxWindowMSW::GenerateMouseLeave() |
5051 | { | |
5052 | m_mouseInWindow = false; | |
5053 | ||
5054 | int state = 0; | |
5055 | if ( wxIsShiftDown() ) | |
5056 | state |= MK_SHIFT; | |
5057 | if ( wxIsCtrlDown() ) | |
5058 | state |= MK_CONTROL; | |
5059 | ||
5060 | // Only the high-order bit should be tested | |
5061 | if ( GetKeyState( VK_LBUTTON ) & (1<<15) ) | |
5062 | state |= MK_LBUTTON; | |
5063 | if ( GetKeyState( VK_MBUTTON ) & (1<<15) ) | |
5064 | state |= MK_MBUTTON; | |
5065 | if ( GetKeyState( VK_RBUTTON ) & (1<<15) ) | |
5066 | state |= MK_RBUTTON; | |
5067 | ||
5068 | POINT pt; | |
f2325516 JS |
5069 | #ifdef __WXWINCE__ |
5070 | if ( !::GetCursorPosWinCE(&pt) ) | |
5071 | #else | |
51e4e266 | 5072 | if ( !::GetCursorPos(&pt) ) |
f2325516 | 5073 | #endif |
51e4e266 VZ |
5074 | { |
5075 | wxLogLastError(_T("GetCursorPos")); | |
5076 | } | |
5077 | ||
5078 | // we need to have client coordinates here for symmetry with | |
5079 | // wxEVT_ENTER_WINDOW | |
5080 | RECT rect = wxGetWindowRect(GetHwnd()); | |
5081 | pt.x -= rect.left; | |
5082 | pt.y -= rect.top; | |
5083 | ||
5084 | wxMouseEvent event(wxEVT_LEAVE_WINDOW); | |
5085 | InitMouseEvent(event, pt.x, pt.y, state); | |
5086 | ||
5087 | (void)GetEventHandler()->ProcessEvent(event); | |
5088 | } | |
d2c52078 | 5089 | |
42e69d6b VZ |
5090 | // --------------------------------------------------------------------------- |
5091 | // keyboard handling | |
5092 | // --------------------------------------------------------------------------- | |
5093 | ||
c42404a5 VZ |
5094 | // create the key event of the given type for the given key - used by |
5095 | // HandleChar and HandleKeyDown/Up | |
1e6feb95 | 5096 | wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType, |
b09bda68 | 5097 | int id, |
9c7df356 VZ |
5098 | WXLPARAM lParam, |
5099 | WXWPARAM wParam) const | |
c42404a5 VZ |
5100 | { |
5101 | wxKeyEvent event(evType); | |
5102 | event.SetId(GetId()); | |
3f7bc32b VZ |
5103 | event.m_shiftDown = wxIsShiftDown(); |
5104 | event.m_controlDown = wxIsCtrlDown(); | |
c42404a5 VZ |
5105 | event.m_altDown = (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN; |
5106 | ||
687706f5 | 5107 | event.SetEventObject((wxWindow *)this); // const_cast |
c42404a5 | 5108 | event.m_keyCode = id; |
0d9b2c16 | 5109 | #if wxUSE_UNICODE |
32b13913 | 5110 | event.m_uniChar = (wxChar) wParam; |
0d9b2c16 | 5111 | #endif |
9c7df356 VZ |
5112 | event.m_rawCode = (wxUint32) wParam; |
5113 | event.m_rawFlags = (wxUint32) lParam; | |
f0b1ccde | 5114 | #ifndef __WXWINCE__ |
1bf77ee5 | 5115 | event.SetTimestamp(::GetMessageTime()); |
f0b1ccde | 5116 | #endif |
c42404a5 VZ |
5117 | |
5118 | // translate the position to client coords | |
5119 | POINT pt; | |
f2325516 JS |
5120 | #ifdef __WXWINCE__ |
5121 | GetCursorPosWinCE(&pt); | |
5122 | #else | |
c42404a5 | 5123 | GetCursorPos(&pt); |
f2325516 | 5124 | #endif |
c42404a5 VZ |
5125 | RECT rect; |
5126 | GetWindowRect(GetHwnd(),&rect); | |
5127 | pt.x -= rect.left; | |
5128 | pt.y -= rect.top; | |
5129 | ||
5130 | event.m_x = pt.x; | |
5131 | event.m_y = pt.y; | |
5132 | ||
5133 | return event; | |
5134 | } | |
5135 | ||
08158721 | 5136 | // isASCII is true only when we're called from WM_CHAR handler and not from |
42e69d6b | 5137 | // WM_KEYDOWN one |
1e6feb95 | 5138 | bool wxWindowMSW::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII) |
42e69d6b VZ |
5139 | { |
5140 | int id; | |
42e69d6b VZ |
5141 | if ( isASCII ) |
5142 | { | |
42e69d6b | 5143 | id = wParam; |
2d0a075d | 5144 | } |
9c7df356 | 5145 | else // we're called from WM_KEYDOWN |
c42404a5 | 5146 | { |
6121a198 VZ |
5147 | // don't pass lParam to wxCharCodeMSWToWX() here because we don't want |
5148 | // to get numpad key codes: CHAR events should use the logical keys | |
5149 | // such as WXK_HOME instead of WXK_NUMPAD_HOME which is for KEY events | |
5150 | id = wxCharCodeMSWToWX(wParam); | |
9c7df356 | 5151 | if ( id == 0 ) |
c42404a5 | 5152 | { |
9c7df356 | 5153 | // it's ASCII and will be processed here only when called from |
08158721 DS |
5154 | // WM_CHAR (i.e. when isASCII = true), don't process it now |
5155 | return false; | |
c42404a5 | 5156 | } |
9c7df356 | 5157 | } |
42e69d6b | 5158 | |
9c7df356 | 5159 | wxKeyEvent event(CreateKeyEvent(wxEVT_CHAR, id, lParam, wParam)); |
2b5f62a0 VZ |
5160 | |
5161 | // the alphanumeric keys produced by pressing AltGr+something on European | |
5162 | // keyboards have both Ctrl and Alt modifiers which may confuse the user | |
5163 | // code as, normally, keys with Ctrl and/or Alt don't result in anything | |
5164 | // alphanumeric, so pretend that there are no modifiers at all (the | |
5165 | // KEY_DOWN event would still have the correct modifiers if they're really | |
5166 | // needed) | |
5167 | if ( event.m_controlDown && event.m_altDown && | |
5168 | (id >= 32 && id < 256) ) | |
9c7df356 | 5169 | { |
2b5f62a0 | 5170 | event.m_controlDown = |
08158721 | 5171 | event.m_altDown = false; |
2d0a075d | 5172 | } |
c42404a5 | 5173 | |
9c7df356 | 5174 | return GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
5175 | } |
5176 | ||
1e6feb95 | 5177 | bool wxWindowMSW::HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 | 5178 | { |
ff792344 | 5179 | int id = wxCharCodeMSWToWX(wParam, lParam); |
2bda0e17 | 5180 | |
c42404a5 VZ |
5181 | if ( !id ) |
5182 | { | |
5183 | // normal ASCII char | |
42e69d6b VZ |
5184 | id = wParam; |
5185 | } | |
5186 | ||
b60978b2 VZ |
5187 | wxKeyEvent event(CreateKeyEvent(wxEVT_KEY_DOWN, id, lParam, wParam)); |
5188 | return GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
5189 | } |
5190 | ||
1e6feb95 | 5191 | bool wxWindowMSW::HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 | 5192 | { |
ff792344 | 5193 | int id = wxCharCodeMSWToWX(wParam, lParam); |
2bda0e17 | 5194 | |
c42404a5 VZ |
5195 | if ( !id ) |
5196 | { | |
5197 | // normal ASCII char | |
42e69d6b | 5198 | id = wParam; |
2d0a075d | 5199 | } |
2bda0e17 | 5200 | |
b60978b2 VZ |
5201 | wxKeyEvent event(CreateKeyEvent(wxEVT_KEY_UP, id, lParam, wParam)); |
5202 | return GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
5203 | } |
5204 | ||
0c0d1521 WS |
5205 | int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel), |
5206 | WXLPARAM WXUNUSED_IN_WINCE(lParam)) | |
b74cce40 | 5207 | { |
7f0586ef JS |
5208 | // FIXME: implement GetMenuItemCount for WinCE, possibly |
5209 | // in terms of GetMenuItemInfo | |
5210 | #ifndef __WXWINCE__ | |
b74cce40 VZ |
5211 | const HMENU hmenu = (HMENU)lParam; |
5212 | ||
5213 | MENUITEMINFO mii; | |
5214 | wxZeroMemory(mii); | |
5215 | mii.cbSize = sizeof(MENUITEMINFO); | |
c70ffbdb VZ |
5216 | |
5217 | // we could use MIIM_FTYPE here as we only need to know if the item is | |
5218 | // ownerdrawn or not and not dwTypeData which MIIM_TYPE also returns, but | |
5219 | // MIIM_FTYPE is not supported under Win95 | |
b74cce40 VZ |
5220 | mii.fMask = MIIM_TYPE | MIIM_DATA; |
5221 | ||
5222 | // find if we have this letter in any owner drawn item | |
5223 | const int count = ::GetMenuItemCount(hmenu); | |
5224 | for ( int i = 0; i < count; i++ ) | |
5225 | { | |
c70ffbdb VZ |
5226 | // previous loop iteration could modify it, reset it back before |
5227 | // calling GetMenuItemInfo() to prevent it from overflowing dwTypeData | |
5228 | mii.cch = 0; | |
5229 | ||
b74cce40 VZ |
5230 | if ( ::GetMenuItemInfo(hmenu, i, TRUE, &mii) ) |
5231 | { | |
5232 | if ( mii.fType == MFT_OWNERDRAW ) | |
5233 | { | |
5234 | // dwItemData member of the MENUITEMINFO is a | |
5235 | // pointer to the associated wxMenuItem -- see the | |
5236 | // menu creation code | |
5237 | wxMenuItem *item = (wxMenuItem*)mii.dwItemData; | |
5238 | ||
5239 | const wxChar *p = wxStrchr(item->GetText(), _T('&')); | |
5240 | while ( p++ ) | |
5241 | { | |
5242 | if ( *p == _T('&') ) | |
5243 | { | |
5244 | // this is not the accel char, find the real one | |
5245 | p = wxStrchr(p + 1, _T('&')); | |
5246 | } | |
5247 | else // got the accel char | |
5248 | { | |
5249 | // FIXME-UNICODE: this comparison doesn't risk to work | |
5250 | // for non ASCII accelerator characters I'm afraid, but | |
5251 | // what can we do? | |
907173e5 | 5252 | if ( (wchar_t)wxToupper(*p) == (wchar_t)chAccel ) |
b74cce40 VZ |
5253 | { |
5254 | return i; | |
5255 | } | |
5256 | else | |
5257 | { | |
5258 | // this one doesn't match | |
5259 | break; | |
5260 | } | |
5261 | } | |
5262 | } | |
5263 | } | |
5264 | } | |
e39af974 | 5265 | else // failed to get the menu text? |
b74cce40 | 5266 | { |
c70ffbdb | 5267 | // it's not fatal, so don't show error, but still log it |
b74cce40 VZ |
5268 | wxLogLastError(_T("GetMenuItemInfo")); |
5269 | } | |
5270 | } | |
7f0586ef | 5271 | #endif |
b74cce40 VZ |
5272 | return wxNOT_FOUND; |
5273 | } | |
5274 | ||
78c91815 VZ |
5275 | bool wxWindowMSW::HandleClipboardEvent( WXUINT nMsg ) |
5276 | { | |
5277 | const wxEventType type = ( nMsg == WM_CUT ) ? wxEVT_COMMAND_TEXT_CUT : | |
5278 | ( nMsg == WM_COPY ) ? wxEVT_COMMAND_TEXT_COPY : | |
5279 | /*( nMsg == WM_PASTE ) ? */ wxEVT_COMMAND_TEXT_PASTE; | |
5280 | wxClipboardTextEvent evt(type, GetId()); | |
5281 | ||
5282 | evt.SetEventObject(this); | |
5283 | ||
5284 | return GetEventHandler()->ProcessEvent(evt); | |
5285 | } | |
5286 | ||
42e69d6b VZ |
5287 | // --------------------------------------------------------------------------- |
5288 | // joystick | |
5289 | // --------------------------------------------------------------------------- | |
5290 | ||
1e6feb95 | 5291 | bool wxWindowMSW::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags) |
2bda0e17 | 5292 | { |
8cb172b4 | 5293 | #ifdef JOY_BUTTON1 |
42e69d6b VZ |
5294 | int change = 0; |
5295 | if ( flags & JOY_BUTTON1CHG ) | |
5296 | change = wxJOY_BUTTON1; | |
5297 | if ( flags & JOY_BUTTON2CHG ) | |
5298 | change = wxJOY_BUTTON2; | |
5299 | if ( flags & JOY_BUTTON3CHG ) | |
5300 | change = wxJOY_BUTTON3; | |
5301 | if ( flags & JOY_BUTTON4CHG ) | |
5302 | change = wxJOY_BUTTON4; | |
2bda0e17 | 5303 | |
42e69d6b VZ |
5304 | int buttons = 0; |
5305 | if ( flags & JOY_BUTTON1 ) | |
5306 | buttons |= wxJOY_BUTTON1; | |
5307 | if ( flags & JOY_BUTTON2 ) | |
5308 | buttons |= wxJOY_BUTTON2; | |
5309 | if ( flags & JOY_BUTTON3 ) | |
5310 | buttons |= wxJOY_BUTTON3; | |
5311 | if ( flags & JOY_BUTTON4 ) | |
5312 | buttons |= wxJOY_BUTTON4; | |
c085e333 | 5313 | |
42e69d6b VZ |
5314 | // the event ids aren't consecutive so we can't use table based lookup |
5315 | int joystick; | |
5316 | wxEventType eventType; | |
5317 | switch ( msg ) | |
5318 | { | |
5319 | case MM_JOY1MOVE: | |
5320 | joystick = 1; | |
5321 | eventType = wxEVT_JOY_MOVE; | |
5322 | break; | |
2bda0e17 | 5323 | |
42e69d6b VZ |
5324 | case MM_JOY2MOVE: |
5325 | joystick = 2; | |
5326 | eventType = wxEVT_JOY_MOVE; | |
5327 | break; | |
2bda0e17 | 5328 | |
42e69d6b VZ |
5329 | case MM_JOY1ZMOVE: |
5330 | joystick = 1; | |
5331 | eventType = wxEVT_JOY_ZMOVE; | |
5332 | break; | |
2bda0e17 | 5333 | |
42e69d6b VZ |
5334 | case MM_JOY2ZMOVE: |
5335 | joystick = 2; | |
5336 | eventType = wxEVT_JOY_ZMOVE; | |
5337 | break; | |
2bda0e17 | 5338 | |
42e69d6b VZ |
5339 | case MM_JOY1BUTTONDOWN: |
5340 | joystick = 1; | |
5341 | eventType = wxEVT_JOY_BUTTON_DOWN; | |
5342 | break; | |
2bda0e17 | 5343 | |
42e69d6b VZ |
5344 | case MM_JOY2BUTTONDOWN: |
5345 | joystick = 2; | |
5346 | eventType = wxEVT_JOY_BUTTON_DOWN; | |
5347 | break; | |
2bda0e17 | 5348 | |
42e69d6b VZ |
5349 | case MM_JOY1BUTTONUP: |
5350 | joystick = 1; | |
5351 | eventType = wxEVT_JOY_BUTTON_UP; | |
5352 | break; | |
5353 | ||
5354 | case MM_JOY2BUTTONUP: | |
5355 | joystick = 2; | |
5356 | eventType = wxEVT_JOY_BUTTON_UP; | |
5357 | break; | |
5358 | ||
5359 | default: | |
223d09f6 | 5360 | wxFAIL_MSG(wxT("no such joystick event")); |
2d0a075d | 5361 | |
08158721 | 5362 | return false; |
2d0a075d | 5363 | } |
2bda0e17 | 5364 | |
42e69d6b VZ |
5365 | wxJoystickEvent event(eventType, buttons, joystick, change); |
5366 | event.SetPosition(wxPoint(x, y)); | |
5367 | event.SetEventObject(this); | |
c085e333 | 5368 | |
42e69d6b | 5369 | return GetEventHandler()->ProcessEvent(event); |
8cb172b4 | 5370 | #else |
991420e6 WS |
5371 | wxUnusedVar(msg); |
5372 | wxUnusedVar(x); | |
5373 | wxUnusedVar(y); | |
5374 | wxUnusedVar(flags); | |
08158721 | 5375 | return false; |
8cb172b4 | 5376 | #endif |
2bda0e17 KB |
5377 | } |
5378 | ||
42e69d6b VZ |
5379 | // --------------------------------------------------------------------------- |
5380 | // scrolling | |
5381 | // --------------------------------------------------------------------------- | |
5382 | ||
1e6feb95 | 5383 | bool wxWindowMSW::MSWOnScroll(int orientation, WXWORD wParam, |
f4f734c1 | 5384 | WXWORD pos, WXHWND control) |
35bbb0c6 | 5385 | { |
a0d924c6 | 5386 | if ( control && control != m_hWnd ) // Prevent infinite recursion |
cc2b7472 | 5387 | { |
42e69d6b VZ |
5388 | wxWindow *child = wxFindWinFromHandle(control); |
5389 | if ( child ) | |
5390 | return child->MSWOnScroll(orientation, wParam, pos, control); | |
cc2b7472 | 5391 | } |
2bda0e17 | 5392 | |
9145664b | 5393 | wxScrollWinEvent event; |
42e69d6b VZ |
5394 | event.SetPosition(pos); |
5395 | event.SetOrientation(orientation); | |
687706f5 | 5396 | event.SetEventObject(this); |
cc2b7472 | 5397 | |
42e69d6b VZ |
5398 | switch ( wParam ) |
5399 | { | |
5400 | case SB_TOP: | |
687706f5 | 5401 | event.SetEventType(wxEVT_SCROLLWIN_TOP); |
42e69d6b | 5402 | break; |
cc2b7472 | 5403 | |
42e69d6b | 5404 | case SB_BOTTOM: |
687706f5 | 5405 | event.SetEventType(wxEVT_SCROLLWIN_BOTTOM); |
42e69d6b | 5406 | break; |
cc2b7472 | 5407 | |
42e69d6b | 5408 | case SB_LINEUP: |
687706f5 | 5409 | event.SetEventType(wxEVT_SCROLLWIN_LINEUP); |
42e69d6b | 5410 | break; |
2bda0e17 | 5411 | |
42e69d6b | 5412 | case SB_LINEDOWN: |
687706f5 | 5413 | event.SetEventType(wxEVT_SCROLLWIN_LINEDOWN); |
42e69d6b | 5414 | break; |
a02eb1d2 | 5415 | |
42e69d6b | 5416 | case SB_PAGEUP: |
687706f5 | 5417 | event.SetEventType(wxEVT_SCROLLWIN_PAGEUP); |
42e69d6b | 5418 | break; |
2bda0e17 | 5419 | |
42e69d6b | 5420 | case SB_PAGEDOWN: |
687706f5 | 5421 | event.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN); |
42e69d6b | 5422 | break; |
2bda0e17 | 5423 | |
42e69d6b | 5424 | case SB_THUMBPOSITION: |
feda3011 | 5425 | case SB_THUMBTRACK: |
f6bcfd97 BP |
5426 | // under Win32, the scrollbar range and position are 32 bit integers, |
5427 | // but WM_[HV]SCROLL only carry the low 16 bits of them, so we must | |
5428 | // explicitly query the scrollbar for the correct position (this must | |
5429 | // be done only for these two SB_ events as they are the only one | |
5430 | // carrying the scrollbar position) | |
5431 | { | |
0cf5de11 | 5432 | WinStruct<SCROLLINFO> scrollInfo; |
f6bcfd97 BP |
5433 | scrollInfo.fMask = SIF_TRACKPOS; |
5434 | ||
5435 | if ( !::GetScrollInfo(GetHwnd(), | |
5436 | orientation == wxHORIZONTAL ? SB_HORZ | |
5437 | : SB_VERT, | |
5438 | &scrollInfo) ) | |
5439 | { | |
3103e8a9 | 5440 | // Not necessarily an error, if there are no scrollbars yet. |
f676b387 | 5441 | // wxLogLastError(_T("GetScrollInfo")); |
f6bcfd97 BP |
5442 | } |
5443 | ||
5444 | event.SetPosition(scrollInfo.nTrackPos); | |
5445 | } | |
f6bcfd97 | 5446 | |
687706f5 | 5447 | event.SetEventType( wParam == SB_THUMBPOSITION |
f6bcfd97 | 5448 | ? wxEVT_SCROLLWIN_THUMBRELEASE |
687706f5 | 5449 | : wxEVT_SCROLLWIN_THUMBTRACK ); |
42e69d6b | 5450 | break; |
c085e333 | 5451 | |
42e69d6b | 5452 | default: |
08158721 | 5453 | return false; |
564b2609 | 5454 | } |
2bda0e17 | 5455 | |
42e69d6b | 5456 | return GetEventHandler()->ProcessEvent(event); |
2bda0e17 KB |
5457 | } |
5458 | ||
5acec112 VZ |
5459 | // ---------------------------------------------------------------------------- |
5460 | // custom message handlers | |
5461 | // ---------------------------------------------------------------------------- | |
5462 | ||
5463 | /* static */ bool | |
5464 | wxWindowMSW::MSWRegisterMessageHandler(int msg, MSWMessageHandler handler) | |
5465 | { | |
5466 | wxCHECK_MSG( gs_messageHandlers.find(msg) == gs_messageHandlers.end(), | |
5467 | false, _T("registering handler for the same message twice") ); | |
5468 | ||
5469 | gs_messageHandlers[msg] = handler; | |
5470 | return true; | |
5471 | } | |
5472 | ||
5473 | /* static */ void | |
5474 | wxWindowMSW::MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler) | |
5475 | { | |
5476 | const MSWMessageHandlers::iterator i = gs_messageHandlers.find(msg); | |
5477 | wxCHECK_RET( i != gs_messageHandlers.end() && i->second == handler, | |
5478 | _T("unregistering non-registered handler?") ); | |
5479 | ||
5480 | gs_messageHandlers.erase(i); | |
5481 | } | |
5482 | ||
42e69d6b VZ |
5483 | // =========================================================================== |
5484 | // global functions | |
5485 | // =========================================================================== | |
5486 | ||
7a5e53ab | 5487 | void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font) |
2bda0e17 | 5488 | { |
42e69d6b VZ |
5489 | TEXTMETRIC tm; |
5490 | HDC dc = ::GetDC((HWND) wnd); | |
42e69d6b | 5491 | HFONT was = 0; |
35bbb0c6 | 5492 | |
7a5e53ab VS |
5493 | // the_font.UseResource(); |
5494 | // the_font.RealizeResource(); | |
c57c2993 | 5495 | HFONT fnt = (HFONT)the_font.GetResourceHandle(); // const_cast |
7a5e53ab VS |
5496 | if ( fnt ) |
5497 | was = (HFONT) SelectObject(dc,fnt); | |
35bbb0c6 | 5498 | |
42e69d6b | 5499 | GetTextMetrics(dc, &tm); |
7a5e53ab | 5500 | if ( fnt && was ) |
2d0a075d | 5501 | { |
42e69d6b | 5502 | SelectObject(dc,was); |
2d0a075d | 5503 | } |
42e69d6b | 5504 | ReleaseDC((HWND)wnd, dc); |
0655ad29 VZ |
5505 | |
5506 | if ( x ) | |
5507 | *x = tm.tmAveCharWidth; | |
5508 | if ( y ) | |
5509 | *y = tm.tmHeight + tm.tmExternalLeading; | |
2bda0e17 | 5510 | |
7a5e53ab | 5511 | // the_font.ReleaseResource(); |
42e69d6b | 5512 | } |
c085e333 | 5513 | |
5004c3ad JG |
5514 | // use the "extended" bit (24) of lParam to distinguish extended keys |
5515 | // from normal keys as the same key is sent | |
ed5bc8f1 VZ |
5516 | static inline |
5517 | int ChooseNormalOrExtended(int lParam, int keyNormal, int keyExtended) | |
5004c3ad | 5518 | { |
ed5bc8f1 VZ |
5519 | // except that if lParam is 0, it means we don't have real lParam from |
5520 | // WM_KEYDOWN but are just translating just a VK constant (e.g. done from | |
5521 | // msw/treectrl.cpp when processing TVN_KEYDOWN) -- then assume this is a | |
5522 | // non-numpad (hence extended) key as this is a more common case | |
5523 | return !lParam || (lParam & (1 << 24)) ? keyExtended : keyNormal; | |
5004c3ad JG |
5524 | } |
5525 | ||
d5c21b02 VZ |
5526 | // this array contains the Windows virtual key codes which map one to one to |
5527 | // WXK_xxx constants and is used in wxCharCodeMSWToWX/WXToMSW() below | |
5528 | // | |
5529 | // note that keys having a normal and numpad version (e.g. WXK_HOME and | |
5530 | // WXK_NUMPAD_HOME) are not included in this table as the mapping is not 1-to-1 | |
5531 | static const struct wxKeyMapping | |
5532 | { | |
5533 | int vk; | |
5534 | wxKeyCode wxk; | |
5535 | } gs_specialKeys[] = | |
5536 | { | |
5537 | { VK_CANCEL, WXK_CANCEL }, | |
5538 | { VK_BACK, WXK_BACK }, | |
5539 | { VK_TAB, WXK_TAB }, | |
5540 | { VK_CLEAR, WXK_CLEAR }, | |
5541 | { VK_SHIFT, WXK_SHIFT }, | |
5542 | { VK_CONTROL, WXK_CONTROL }, | |
5543 | { VK_MENU , WXK_ALT }, | |
5544 | { VK_PAUSE, WXK_PAUSE }, | |
5545 | { VK_CAPITAL, WXK_CAPITAL }, | |
5546 | { VK_SPACE, WXK_SPACE }, | |
5547 | { VK_ESCAPE, WXK_ESCAPE }, | |
5548 | { VK_SELECT, WXK_SELECT }, | |
5549 | { VK_PRINT, WXK_PRINT }, | |
5550 | { VK_EXECUTE, WXK_EXECUTE }, | |
e59c2b2d VZ |
5551 | { VK_SNAPSHOT, WXK_SNAPSHOT }, |
5552 | { VK_HELP, WXK_HELP }, | |
d5c21b02 VZ |
5553 | |
5554 | { VK_NUMPAD0, WXK_NUMPAD0 }, | |
5555 | { VK_NUMPAD1, WXK_NUMPAD1 }, | |
5556 | { VK_NUMPAD2, WXK_NUMPAD2 }, | |
5557 | { VK_NUMPAD3, WXK_NUMPAD3 }, | |
5558 | { VK_NUMPAD4, WXK_NUMPAD4 }, | |
5559 | { VK_NUMPAD5, WXK_NUMPAD5 }, | |
5560 | { VK_NUMPAD6, WXK_NUMPAD6 }, | |
5561 | { VK_NUMPAD7, WXK_NUMPAD7 }, | |
5562 | { VK_NUMPAD8, WXK_NUMPAD8 }, | |
5563 | { VK_NUMPAD9, WXK_NUMPAD9 }, | |
5564 | { VK_MULTIPLY, WXK_NUMPAD_MULTIPLY }, | |
5565 | { VK_ADD, WXK_NUMPAD_ADD }, | |
5566 | { VK_SUBTRACT, WXK_NUMPAD_SUBTRACT }, | |
5567 | { VK_DECIMAL, WXK_NUMPAD_DECIMAL }, | |
5568 | { VK_DIVIDE, WXK_NUMPAD_DIVIDE }, | |
5569 | ||
5570 | { VK_F1, WXK_F1 }, | |
5571 | { VK_F2, WXK_F2 }, | |
5572 | { VK_F3, WXK_F3 }, | |
5573 | { VK_F4, WXK_F4 }, | |
5574 | { VK_F5, WXK_F5 }, | |
5575 | { VK_F6, WXK_F6 }, | |
5576 | { VK_F7, WXK_F7 }, | |
5577 | { VK_F8, WXK_F8 }, | |
5578 | { VK_F9, WXK_F9 }, | |
5579 | { VK_F10, WXK_F10 }, | |
5580 | { VK_F11, WXK_F11 }, | |
5581 | { VK_F12, WXK_F12 }, | |
5582 | { VK_F13, WXK_F13 }, | |
5583 | { VK_F14, WXK_F14 }, | |
5584 | { VK_F15, WXK_F15 }, | |
5585 | { VK_F16, WXK_F16 }, | |
5586 | { VK_F17, WXK_F17 }, | |
5587 | { VK_F18, WXK_F18 }, | |
5588 | { VK_F19, WXK_F19 }, | |
5589 | { VK_F20, WXK_F20 }, | |
5590 | { VK_F21, WXK_F21 }, | |
5591 | { VK_F22, WXK_F22 }, | |
5592 | { VK_F23, WXK_F23 }, | |
5593 | { VK_F24, WXK_F24 }, | |
5594 | ||
5595 | { VK_NUMLOCK, WXK_NUMLOCK }, | |
5596 | { VK_SCROLL, WXK_SCROLL }, | |
5597 | ||
5598 | #ifdef VK_APPS | |
5599 | { VK_LWIN, WXK_WINDOWS_LEFT }, | |
5600 | { VK_RWIN, WXK_WINDOWS_RIGHT }, | |
5601 | { VK_APPS, WXK_WINDOWS_MENU }, | |
5602 | #endif // VK_APPS defined | |
5603 | }; | |
5604 | ||
42e69d6b VZ |
5605 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that |
5606 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
d5c21b02 | 5607 | int wxCharCodeMSWToWX(int vk, WXLPARAM lParam) |
42e69d6b | 5608 | { |
d5c21b02 VZ |
5609 | // check the table first |
5610 | for ( size_t n = 0; n < WXSIZEOF(gs_specialKeys); n++ ) | |
5611 | { | |
5612 | if ( gs_specialKeys[n].vk == vk ) | |
5613 | return gs_specialKeys[n].wxk; | |
5614 | } | |
9c7df356 | 5615 | |
d5c21b02 VZ |
5616 | // keys requiring special handling |
5617 | int wxk; | |
5618 | switch ( vk ) | |
5619 | { | |
e77c5d96 VZ |
5620 | // the mapping for these keys may be incorrect on non-US keyboards so |
5621 | // maybe we shouldn't map them to ASCII values at all | |
d5c21b02 VZ |
5622 | case VK_OEM_1: wxk = ';'; break; |
5623 | case VK_OEM_PLUS: wxk = '+'; break; | |
5624 | case VK_OEM_COMMA: wxk = ','; break; | |
5625 | case VK_OEM_MINUS: wxk = '-'; break; | |
5626 | case VK_OEM_PERIOD: wxk = '.'; break; | |
5627 | case VK_OEM_2: wxk = '/'; break; | |
5628 | case VK_OEM_3: wxk = '~'; break; | |
5629 | case VK_OEM_4: wxk = '['; break; | |
5630 | case VK_OEM_5: wxk = '\\'; break; | |
5631 | case VK_OEM_6: wxk = ']'; break; | |
5632 | case VK_OEM_7: wxk = '\''; break; | |
702c4208 | 5633 | |
5004c3ad | 5634 | // handle extended keys |
413553cc | 5635 | case VK_PRIOR: |
d5c21b02 | 5636 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_PAGEUP, WXK_PAGEUP); |
413553cc | 5637 | break; |
d5c21b02 | 5638 | |
413553cc | 5639 | case VK_NEXT: |
d5c21b02 | 5640 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_PAGEDOWN, WXK_PAGEDOWN); |
413553cc | 5641 | break; |
d5c21b02 | 5642 | |
413553cc | 5643 | case VK_END: |
d5c21b02 | 5644 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_END, WXK_END); |
413553cc | 5645 | break; |
d5c21b02 | 5646 | |
413553cc | 5647 | case VK_HOME: |
d5c21b02 | 5648 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_HOME, WXK_HOME); |
413553cc | 5649 | break; |
d5c21b02 | 5650 | |
413553cc | 5651 | case VK_LEFT: |
d5c21b02 | 5652 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_LEFT, WXK_LEFT); |
413553cc | 5653 | break; |
d5c21b02 | 5654 | |
413553cc | 5655 | case VK_UP: |
d5c21b02 | 5656 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_UP, WXK_UP); |
413553cc | 5657 | break; |
d5c21b02 | 5658 | |
413553cc | 5659 | case VK_RIGHT: |
d5c21b02 | 5660 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_RIGHT, WXK_RIGHT); |
413553cc | 5661 | break; |
d5c21b02 | 5662 | |
413553cc | 5663 | case VK_DOWN: |
d5c21b02 | 5664 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DOWN, WXK_DOWN); |
413553cc | 5665 | break; |
d5c21b02 | 5666 | |
413553cc | 5667 | case VK_INSERT: |
d5c21b02 | 5668 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_INSERT, WXK_INSERT); |
413553cc | 5669 | break; |
d5c21b02 | 5670 | |
413553cc | 5671 | case VK_DELETE: |
d5c21b02 | 5672 | wxk = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DELETE, WXK_DELETE); |
413553cc | 5673 | break; |
d5c21b02 | 5674 | |
ff792344 | 5675 | case VK_RETURN: |
ed5bc8f1 VZ |
5676 | // don't use ChooseNormalOrExtended() here as the keys are reversed |
5677 | // here: numpad enter is the extended one | |
d5c21b02 | 5678 | wxk = lParam && (lParam & (1 << 24)) ? WXK_NUMPAD_ENTER : WXK_RETURN; |
ff792344 VZ |
5679 | break; |
5680 | ||
f6bcfd97 | 5681 | default: |
d5c21b02 VZ |
5682 | wxk = 0; |
5683 | } | |
5684 | ||
5685 | return wxk; | |
5686 | } | |
5687 | ||
5688 | WXWORD wxCharCodeWXToMSW(int wxk, bool *isVirtual) | |
5689 | { | |
5690 | if ( isVirtual ) | |
5691 | *isVirtual = true; | |
5692 | ||
5693 | // check the table first | |
5694 | for ( size_t n = 0; n < WXSIZEOF(gs_specialKeys); n++ ) | |
5695 | { | |
5696 | if ( gs_specialKeys[n].wxk == wxk ) | |
5697 | return gs_specialKeys[n].vk; | |
5698 | } | |
5699 | ||
5700 | // and then check for special keys not included in the table | |
5701 | WXWORD vk; | |
5702 | switch ( wxk ) | |
5703 | { | |
71403278 VZ |
5704 | case WXK_PAGEUP: |
5705 | case WXK_NUMPAD_PAGEUP: | |
5706 | vk = VK_PRIOR; | |
5707 | break; | |
5708 | ||
5709 | case WXK_PAGEDOWN: | |
5710 | case WXK_NUMPAD_PAGEDOWN: | |
5711 | vk = VK_NEXT; | |
5712 | break; | |
5713 | ||
5714 | case WXK_END: | |
5715 | case WXK_NUMPAD_END: | |
5716 | vk = VK_END; | |
5717 | break; | |
5718 | ||
5719 | case WXK_HOME: | |
5720 | case WXK_NUMPAD_HOME: | |
5721 | vk = VK_HOME; | |
5722 | break; | |
5723 | ||
5724 | case WXK_LEFT: | |
5725 | case WXK_NUMPAD_LEFT: | |
5726 | vk = VK_LEFT; | |
5727 | break; | |
5728 | ||
5729 | case WXK_UP: | |
5730 | case WXK_NUMPAD_UP: | |
5731 | vk = VK_UP; | |
5732 | break; | |
5733 | ||
5734 | case WXK_RIGHT: | |
5735 | case WXK_NUMPAD_RIGHT: | |
5736 | vk = VK_RIGHT; | |
5737 | break; | |
5738 | ||
5739 | case WXK_DOWN: | |
5740 | case WXK_NUMPAD_DOWN: | |
5741 | vk = VK_DOWN; | |
5742 | break; | |
5743 | ||
5744 | case WXK_INSERT: | |
5745 | case WXK_NUMPAD_INSERT: | |
5746 | vk = VK_INSERT; | |
5747 | break; | |
5748 | ||
5749 | case WXK_DELETE: | |
5750 | case WXK_NUMPAD_DELETE: | |
5751 | vk = VK_DELETE; | |
5752 | break; | |
d5c21b02 VZ |
5753 | |
5754 | default: | |
5755 | if ( isVirtual ) | |
5756 | *isVirtual = false; | |
5757 | vk = (WXWORD)wxk; | |
42e69d6b | 5758 | break; |
2bda0e17 | 5759 | } |
d5c21b02 VZ |
5760 | |
5761 | return vk; | |
5762 | } | |
5763 | ||
b8f434e7 JS |
5764 | #ifndef SM_SWAPBUTTON |
5765 | #define SM_SWAPBUTTON 23 | |
5766 | #endif | |
5767 | ||
d5c21b02 VZ |
5768 | // small helper for wxGetKeyState() and wxGetMouseState() |
5769 | static inline bool wxIsKeyDown(WXWORD vk) | |
5770 | { | |
b8f434e7 JS |
5771 | switch (vk) |
5772 | { | |
5773 | case VK_LBUTTON: | |
f4322df6 | 5774 | if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON; |
b8f434e7 JS |
5775 | break; |
5776 | case VK_RBUTTON: | |
5777 | if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_LBUTTON; | |
5778 | break; | |
5779 | } | |
d5c21b02 VZ |
5780 | // the low order bit indicates whether the key was pressed since the last |
5781 | // call and the high order one indicates whether it is down right now and | |
5782 | // we only want that one | |
b8f434e7 | 5783 | return (GetAsyncKeyState(vk) & (1<<15)) != 0; |
2bda0e17 KB |
5784 | } |
5785 | ||
1751226c | 5786 | bool wxGetKeyState(wxKeyCode key) |
6ed892f3 | 5787 | { |
d5c21b02 VZ |
5788 | // although this does work under Windows, it is not supported under other |
5789 | // platforms so don't allow it, you must use wxGetMouseState() instead | |
5790 | wxASSERT_MSG( key != VK_LBUTTON && | |
5791 | key != VK_RBUTTON && | |
5792 | key != VK_MBUTTON, | |
5793 | wxT("can't use wxGetKeyState() for mouse buttons") ); | |
6ed892f3 | 5794 | |
d5c21b02 | 5795 | const WXWORD vk = wxCharCodeWXToMSW(key); |
44353523 | 5796 | |
d5c21b02 VZ |
5797 | // if the requested key is a LED key, return true if the led is pressed |
5798 | if ( key == WXK_NUMLOCK || key == WXK_CAPITAL || key == WXK_SCROLL ) | |
fdec2c05 | 5799 | { |
d5c21b02 VZ |
5800 | // low order bit means LED is highlighted and high order one means the |
5801 | // key is down; for compatibility with the other ports return true if | |
5802 | // either one is set | |
b8f434e7 | 5803 | return GetKeyState(vk) != 0; |
35bbb0c6 | 5804 | |
fdec2c05 | 5805 | } |
d5c21b02 | 5806 | else // normal key |
84c51ddf | 5807 | { |
d5c21b02 | 5808 | return wxIsKeyDown(vk); |
84c51ddf | 5809 | } |
6ed892f3 RN |
5810 | } |
5811 | ||
7dd40b6f RD |
5812 | |
5813 | wxMouseState wxGetMouseState() | |
5814 | { | |
5815 | wxMouseState ms; | |
5816 | POINT pt; | |
5817 | GetCursorPos( &pt ); | |
5818 | ||
5819 | ms.SetX(pt.x); | |
5820 | ms.SetY(pt.y); | |
d5c21b02 VZ |
5821 | ms.SetLeftDown(wxIsKeyDown(VK_LBUTTON)); |
5822 | ms.SetMiddleDown(wxIsKeyDown(VK_MBUTTON)); | |
5823 | ms.SetRightDown(wxIsKeyDown(VK_RBUTTON)); | |
dd28827a | 5824 | |
d5c21b02 VZ |
5825 | ms.SetControlDown(wxIsKeyDown(VK_CONTROL)); |
5826 | ms.SetShiftDown(wxIsKeyDown(VK_SHIFT)); | |
5827 | ms.SetAltDown(wxIsKeyDown(VK_MENU)); | |
7dd40b6f | 5828 | // ms.SetMetaDown(); |
dd28827a | 5829 | |
7dd40b6f RD |
5830 | return ms; |
5831 | } | |
5832 | ||
5833 | ||
42e69d6b | 5834 | wxWindow *wxGetActiveWindow() |
2bda0e17 | 5835 | { |
42e69d6b VZ |
5836 | HWND hWnd = GetActiveWindow(); |
5837 | if ( hWnd != 0 ) | |
2d0a075d | 5838 | { |
42e69d6b | 5839 | return wxFindWinFromHandle((WXHWND) hWnd); |
2d0a075d | 5840 | } |
42e69d6b | 5841 | return NULL; |
2bda0e17 KB |
5842 | } |
5843 | ||
8614c467 VZ |
5844 | extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd) |
5845 | { | |
5846 | HWND hwnd = (HWND)hWnd; | |
5847 | ||
5848 | // For a radiobutton, we get the radiobox from GWL_USERDATA (which is set | |
5849 | // by code in msw/radiobox.cpp), for all the others we just search up the | |
5850 | // window hierarchy | |
5851 | wxWindow *win = (wxWindow *)NULL; | |
5852 | if ( hwnd ) | |
5853 | { | |
5854 | win = wxFindWinFromHandle((WXHWND)hwnd); | |
5855 | if ( !win ) | |
5856 | { | |
a2242341 | 5857 | #if wxUSE_RADIOBOX |
8614c467 VZ |
5858 | // native radiobuttons return DLGC_RADIOBUTTON here and for any |
5859 | // wxWindow class which overrides WM_GETDLGCODE processing to | |
5860 | // do it as well, win would be already non NULL | |
a2242341 | 5861 | if ( ::SendMessage(hwnd, WM_GETDLGCODE, 0, 0) & DLGC_RADIOBUTTON ) |
8614c467 | 5862 | { |
975b6bcf | 5863 | win = (wxWindow *)wxGetWindowUserData(hwnd); |
8614c467 | 5864 | } |
a2242341 VZ |
5865 | //else: it's a wxRadioButton, not a radiobutton from wxRadioBox |
5866 | #endif // wxUSE_RADIOBOX | |
5867 | ||
5868 | // spin control text buddy window should be mapped to spin ctrl | |
5869 | // itself so try it too | |
24ce4c18 | 5870 | #if wxUSE_SPINCTRL && !defined(__WXUNIVERSAL__) |
a2242341 VZ |
5871 | if ( !win ) |
5872 | { | |
5873 | win = wxSpinCtrl::GetSpinForTextCtrl((WXHWND)hwnd); | |
5874 | } | |
5875 | #endif // wxUSE_SPINCTRL | |
8614c467 | 5876 | } |
8614c467 VZ |
5877 | } |
5878 | ||
5879 | while ( hwnd && !win ) | |
5880 | { | |
761989ff VZ |
5881 | // this is a really ugly hack needed to avoid mistakenly returning the |
5882 | // parent frame wxWindow for the find/replace modeless dialog HWND - | |
5883 | // this, in turn, is needed to call IsDialogMessage() from | |
5884 | // wxApp::ProcessMessage() as for this we must return NULL from here | |
5885 | // | |
5886 | // FIXME: this is clearly not the best way to do it but I think we'll | |
5887 | // need to change HWND <-> wxWindow code more heavily than I can | |
5888 | // do it now to fix it | |
c67d6888 | 5889 | #ifndef __WXMICROWIN__ |
761989ff VZ |
5890 | if ( ::GetWindow(hwnd, GW_OWNER) ) |
5891 | { | |
5892 | // it's a dialog box, don't go upwards | |
5893 | break; | |
5894 | } | |
c67d6888 | 5895 | #endif |
761989ff | 5896 | |
8614c467 | 5897 | hwnd = ::GetParent(hwnd); |
761989ff | 5898 | win = wxFindWinFromHandle((WXHWND)hwnd); |
8614c467 VZ |
5899 | } |
5900 | ||
5901 | return win; | |
5902 | } | |
5903 | ||
7f0586ef | 5904 | #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) |
04ef50df | 5905 | |
42e69d6b VZ |
5906 | // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE |
5907 | // in active frames and dialogs, regardless of where the focus is. | |
5908 | static HHOOK wxTheKeyboardHook = 0; | |
5909 | static FARPROC wxTheKeyboardHookProc = 0; | |
5910 | int APIENTRY _EXPORT | |
5911 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); | |
2bda0e17 | 5912 | |
42e69d6b | 5913 | void wxSetKeyboardHook(bool doIt) |
2bda0e17 | 5914 | { |
42e69d6b | 5915 | if ( doIt ) |
2d0a075d | 5916 | { |
42e69d6b VZ |
5917 | wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance()); |
5918 | wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(), | |
c7527e3f | 5919 | |
8614c467 | 5920 | GetCurrentThreadId() |
42e69d6b | 5921 | // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right? |
8614c467 | 5922 | ); |
2d0a075d | 5923 | } |
2d0a075d | 5924 | else |
2d0a075d | 5925 | { |
42e69d6b | 5926 | UnhookWindowsHookEx(wxTheKeyboardHook); |
2d0a075d | 5927 | } |
2bda0e17 KB |
5928 | } |
5929 | ||
42e69d6b VZ |
5930 | int APIENTRY _EXPORT |
5931 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) | |
2bda0e17 | 5932 | { |
42e69d6b VZ |
5933 | DWORD hiWord = HIWORD(lParam); |
5934 | if ( nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0) ) | |
43d811ea | 5935 | { |
ff792344 | 5936 | int id = wxCharCodeMSWToWX(wParam, lParam); |
32de7d24 | 5937 | if ( id != 0 ) |
43d811ea | 5938 | { |
42e69d6b VZ |
5939 | wxKeyEvent event(wxEVT_CHAR_HOOK); |
5940 | if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN ) | |
08158721 | 5941 | event.m_altDown = true; |
c085e333 | 5942 | |
687706f5 | 5943 | event.SetEventObject(NULL); |
42e69d6b | 5944 | event.m_keyCode = id; |
3f7bc32b VZ |
5945 | event.m_shiftDown = wxIsShiftDown(); |
5946 | event.m_controlDown = wxIsCtrlDown(); | |
f0b1ccde | 5947 | #ifndef __WXWINCE__ |
1bf77ee5 | 5948 | event.SetTimestamp(::GetMessageTime()); |
f0b1ccde | 5949 | #endif |
42e69d6b | 5950 | wxWindow *win = wxGetActiveWindow(); |
32de7d24 | 5951 | wxEvtHandler *handler; |
42e69d6b VZ |
5952 | if ( win ) |
5953 | { | |
32de7d24 VZ |
5954 | handler = win->GetEventHandler(); |
5955 | event.SetId(win->GetId()); | |
42e69d6b VZ |
5956 | } |
5957 | else | |
5958 | { | |
32de7d24 | 5959 | handler = wxTheApp; |
abb74e0f | 5960 | event.SetId(wxID_ANY); |
32de7d24 VZ |
5961 | } |
5962 | ||
5963 | if ( handler && handler->ProcessEvent(event) ) | |
5964 | { | |
5965 | // processed | |
5966 | return 1; | |
42e69d6b | 5967 | } |
43d811ea JS |
5968 | } |
5969 | } | |
32de7d24 | 5970 | |
42e69d6b | 5971 | return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam); |
4fabb575 | 5972 | } |
cd4453e5 VZ |
5973 | |
5974 | #endif // !__WXMICROWIN__ | |
4fabb575 | 5975 | |
b2aef89b | 5976 | #ifdef __WXDEBUG__ |
4a712ba3 | 5977 | const wxChar *wxGetMessageName(int message) |
47cbd6da | 5978 | { |
42e69d6b VZ |
5979 | switch ( message ) |
5980 | { | |
4a712ba3 VZ |
5981 | case 0x0000: return wxT("WM_NULL"); |
5982 | case 0x0001: return wxT("WM_CREATE"); | |
5983 | case 0x0002: return wxT("WM_DESTROY"); | |
5984 | case 0x0003: return wxT("WM_MOVE"); | |
5985 | case 0x0005: return wxT("WM_SIZE"); | |
5986 | case 0x0006: return wxT("WM_ACTIVATE"); | |
5987 | case 0x0007: return wxT("WM_SETFOCUS"); | |
5988 | case 0x0008: return wxT("WM_KILLFOCUS"); | |
5989 | case 0x000A: return wxT("WM_ENABLE"); | |
5990 | case 0x000B: return wxT("WM_SETREDRAW"); | |
5991 | case 0x000C: return wxT("WM_SETTEXT"); | |
5992 | case 0x000D: return wxT("WM_GETTEXT"); | |
5993 | case 0x000E: return wxT("WM_GETTEXTLENGTH"); | |
5994 | case 0x000F: return wxT("WM_PAINT"); | |
5995 | case 0x0010: return wxT("WM_CLOSE"); | |
5996 | case 0x0011: return wxT("WM_QUERYENDSESSION"); | |
5997 | case 0x0012: return wxT("WM_QUIT"); | |
5998 | case 0x0013: return wxT("WM_QUERYOPEN"); | |
5999 | case 0x0014: return wxT("WM_ERASEBKGND"); | |
6000 | case 0x0015: return wxT("WM_SYSCOLORCHANGE"); | |
6001 | case 0x0016: return wxT("WM_ENDSESSION"); | |
6002 | case 0x0017: return wxT("WM_SYSTEMERROR"); | |
6003 | case 0x0018: return wxT("WM_SHOWWINDOW"); | |
6004 | case 0x0019: return wxT("WM_CTLCOLOR"); | |
6005 | case 0x001A: return wxT("WM_WININICHANGE"); | |
6006 | case 0x001B: return wxT("WM_DEVMODECHANGE"); | |
6007 | case 0x001C: return wxT("WM_ACTIVATEAPP"); | |
6008 | case 0x001D: return wxT("WM_FONTCHANGE"); | |
6009 | case 0x001E: return wxT("WM_TIMECHANGE"); | |
6010 | case 0x001F: return wxT("WM_CANCELMODE"); | |
6011 | case 0x0020: return wxT("WM_SETCURSOR"); | |
6012 | case 0x0021: return wxT("WM_MOUSEACTIVATE"); | |
6013 | case 0x0022: return wxT("WM_CHILDACTIVATE"); | |
6014 | case 0x0023: return wxT("WM_QUEUESYNC"); | |
6015 | case 0x0024: return wxT("WM_GETMINMAXINFO"); | |
6016 | case 0x0026: return wxT("WM_PAINTICON"); | |
6017 | case 0x0027: return wxT("WM_ICONERASEBKGND"); | |
6018 | case 0x0028: return wxT("WM_NEXTDLGCTL"); | |
6019 | case 0x002A: return wxT("WM_SPOOLERSTATUS"); | |
6020 | case 0x002B: return wxT("WM_DRAWITEM"); | |
6021 | case 0x002C: return wxT("WM_MEASUREITEM"); | |
6022 | case 0x002D: return wxT("WM_DELETEITEM"); | |
6023 | case 0x002E: return wxT("WM_VKEYTOITEM"); | |
6024 | case 0x002F: return wxT("WM_CHARTOITEM"); | |
6025 | case 0x0030: return wxT("WM_SETFONT"); | |
6026 | case 0x0031: return wxT("WM_GETFONT"); | |
6027 | case 0x0037: return wxT("WM_QUERYDRAGICON"); | |
6028 | case 0x0039: return wxT("WM_COMPAREITEM"); | |
6029 | case 0x0041: return wxT("WM_COMPACTING"); | |
6030 | case 0x0044: return wxT("WM_COMMNOTIFY"); | |
6031 | case 0x0046: return wxT("WM_WINDOWPOSCHANGING"); | |
6032 | case 0x0047: return wxT("WM_WINDOWPOSCHANGED"); | |
6033 | case 0x0048: return wxT("WM_POWER"); | |
6034 | ||
6035 | case 0x004A: return wxT("WM_COPYDATA"); | |
6036 | case 0x004B: return wxT("WM_CANCELJOURNAL"); | |
6037 | case 0x004E: return wxT("WM_NOTIFY"); | |
6038 | case 0x0050: return wxT("WM_INPUTLANGCHANGEREQUEST"); | |
6039 | case 0x0051: return wxT("WM_INPUTLANGCHANGE"); | |
6040 | case 0x0052: return wxT("WM_TCARD"); | |
6041 | case 0x0053: return wxT("WM_HELP"); | |
6042 | case 0x0054: return wxT("WM_USERCHANGED"); | |
6043 | case 0x0055: return wxT("WM_NOTIFYFORMAT"); | |
6044 | case 0x007B: return wxT("WM_CONTEXTMENU"); | |
6045 | case 0x007C: return wxT("WM_STYLECHANGING"); | |
6046 | case 0x007D: return wxT("WM_STYLECHANGED"); | |
6047 | case 0x007E: return wxT("WM_DISPLAYCHANGE"); | |
6048 | case 0x007F: return wxT("WM_GETICON"); | |
6049 | case 0x0080: return wxT("WM_SETICON"); | |
6050 | ||
6051 | case 0x0081: return wxT("WM_NCCREATE"); | |
6052 | case 0x0082: return wxT("WM_NCDESTROY"); | |
6053 | case 0x0083: return wxT("WM_NCCALCSIZE"); | |
6054 | case 0x0084: return wxT("WM_NCHITTEST"); | |
6055 | case 0x0085: return wxT("WM_NCPAINT"); | |
6056 | case 0x0086: return wxT("WM_NCACTIVATE"); | |
6057 | case 0x0087: return wxT("WM_GETDLGCODE"); | |
6058 | case 0x00A0: return wxT("WM_NCMOUSEMOVE"); | |
6059 | case 0x00A1: return wxT("WM_NCLBUTTONDOWN"); | |
6060 | case 0x00A2: return wxT("WM_NCLBUTTONUP"); | |
6061 | case 0x00A3: return wxT("WM_NCLBUTTONDBLCLK"); | |
6062 | case 0x00A4: return wxT("WM_NCRBUTTONDOWN"); | |
6063 | case 0x00A5: return wxT("WM_NCRBUTTONUP"); | |
6064 | case 0x00A6: return wxT("WM_NCRBUTTONDBLCLK"); | |
6065 | case 0x00A7: return wxT("WM_NCMBUTTONDOWN"); | |
6066 | case 0x00A8: return wxT("WM_NCMBUTTONUP"); | |
6067 | case 0x00A9: return wxT("WM_NCMBUTTONDBLCLK"); | |
609da8bb VZ |
6068 | |
6069 | case 0x00B0: return wxT("EM_GETSEL"); | |
6070 | case 0x00B1: return wxT("EM_SETSEL"); | |
6071 | case 0x00B2: return wxT("EM_GETRECT"); | |
6072 | case 0x00B3: return wxT("EM_SETRECT"); | |
6073 | case 0x00B4: return wxT("EM_SETRECTNP"); | |
6074 | case 0x00B5: return wxT("EM_SCROLL"); | |
6075 | case 0x00B6: return wxT("EM_LINESCROLL"); | |
6076 | case 0x00B7: return wxT("EM_SCROLLCARET"); | |
6077 | case 0x00B8: return wxT("EM_GETMODIFY"); | |
6078 | case 0x00B9: return wxT("EM_SETMODIFY"); | |
6079 | case 0x00BA: return wxT("EM_GETLINECOUNT"); | |
6080 | case 0x00BB: return wxT("EM_LINEINDEX"); | |
6081 | case 0x00BC: return wxT("EM_SETHANDLE"); | |
6082 | case 0x00BD: return wxT("EM_GETHANDLE"); | |
6083 | case 0x00BE: return wxT("EM_GETTHUMB"); | |
6084 | case 0x00C1: return wxT("EM_LINELENGTH"); | |
6085 | case 0x00C2: return wxT("EM_REPLACESEL"); | |
6086 | case 0x00C4: return wxT("EM_GETLINE"); | |
6087 | case 0x00C5: return wxT("EM_LIMITTEXT/EM_SETLIMITTEXT"); /* ;win40 Name change */ | |
6088 | case 0x00C6: return wxT("EM_CANUNDO"); | |
6089 | case 0x00C7: return wxT("EM_UNDO"); | |
6090 | case 0x00C8: return wxT("EM_FMTLINES"); | |
6091 | case 0x00C9: return wxT("EM_LINEFROMCHAR"); | |
6092 | case 0x00CB: return wxT("EM_SETTABSTOPS"); | |
6093 | case 0x00CC: return wxT("EM_SETPASSWORDCHAR"); | |
6094 | case 0x00CD: return wxT("EM_EMPTYUNDOBUFFER"); | |
6095 | case 0x00CE: return wxT("EM_GETFIRSTVISIBLELINE"); | |
6096 | case 0x00CF: return wxT("EM_SETREADONLY"); | |
6097 | case 0x00D0: return wxT("EM_SETWORDBREAKPROC"); | |
6098 | case 0x00D1: return wxT("EM_GETWORDBREAKPROC"); | |
6099 | case 0x00D2: return wxT("EM_GETPASSWORDCHAR"); | |
6100 | case 0x00D3: return wxT("EM_SETMARGINS"); | |
6101 | case 0x00D4: return wxT("EM_GETMARGINS"); | |
6102 | case 0x00D5: return wxT("EM_GETLIMITTEXT"); | |
6103 | case 0x00D6: return wxT("EM_POSFROMCHAR"); | |
6104 | case 0x00D7: return wxT("EM_CHARFROMPOS"); | |
6105 | case 0x00D8: return wxT("EM_SETIMESTATUS"); | |
6106 | case 0x00D9: return wxT("EM_GETIMESTATUS"); | |
6107 | ||
4a712ba3 VZ |
6108 | case 0x0100: return wxT("WM_KEYDOWN"); |
6109 | case 0x0101: return wxT("WM_KEYUP"); | |
6110 | case 0x0102: return wxT("WM_CHAR"); | |
6111 | case 0x0103: return wxT("WM_DEADCHAR"); | |
6112 | case 0x0104: return wxT("WM_SYSKEYDOWN"); | |
6113 | case 0x0105: return wxT("WM_SYSKEYUP"); | |
6114 | case 0x0106: return wxT("WM_SYSCHAR"); | |
6115 | case 0x0107: return wxT("WM_SYSDEADCHAR"); | |
6116 | case 0x0108: return wxT("WM_KEYLAST"); | |
6117 | ||
6118 | case 0x010D: return wxT("WM_IME_STARTCOMPOSITION"); | |
6119 | case 0x010E: return wxT("WM_IME_ENDCOMPOSITION"); | |
6120 | case 0x010F: return wxT("WM_IME_COMPOSITION"); | |
6121 | ||
6122 | case 0x0110: return wxT("WM_INITDIALOG"); | |
6123 | case 0x0111: return wxT("WM_COMMAND"); | |
6124 | case 0x0112: return wxT("WM_SYSCOMMAND"); | |
6125 | case 0x0113: return wxT("WM_TIMER"); | |
6126 | case 0x0114: return wxT("WM_HSCROLL"); | |
6127 | case 0x0115: return wxT("WM_VSCROLL"); | |
6128 | case 0x0116: return wxT("WM_INITMENU"); | |
6129 | case 0x0117: return wxT("WM_INITMENUPOPUP"); | |
6130 | case 0x011F: return wxT("WM_MENUSELECT"); | |
6131 | case 0x0120: return wxT("WM_MENUCHAR"); | |
6132 | case 0x0121: return wxT("WM_ENTERIDLE"); | |
609da8bb VZ |
6133 | |
6134 | case 0x0132: return wxT("WM_CTLCOLORMSGBOX"); | |
6135 | case 0x0133: return wxT("WM_CTLCOLOREDIT"); | |
6136 | case 0x0134: return wxT("WM_CTLCOLORLISTBOX"); | |
6137 | case 0x0135: return wxT("WM_CTLCOLORBTN"); | |
6138 | case 0x0136: return wxT("WM_CTLCOLORDLG"); | |
6139 | case 0x0137: return wxT("WM_CTLCOLORSCROLLBAR"); | |
6140 | case 0x0138: return wxT("WM_CTLCOLORSTATIC"); | |
6141 | case 0x01E1: return wxT("MN_GETHMENU"); | |
6142 | ||
4a712ba3 VZ |
6143 | case 0x0200: return wxT("WM_MOUSEMOVE"); |
6144 | case 0x0201: return wxT("WM_LBUTTONDOWN"); | |
6145 | case 0x0202: return wxT("WM_LBUTTONUP"); | |
6146 | case 0x0203: return wxT("WM_LBUTTONDBLCLK"); | |
6147 | case 0x0204: return wxT("WM_RBUTTONDOWN"); | |
6148 | case 0x0205: return wxT("WM_RBUTTONUP"); | |
6149 | case 0x0206: return wxT("WM_RBUTTONDBLCLK"); | |
6150 | case 0x0207: return wxT("WM_MBUTTONDOWN"); | |
6151 | case 0x0208: return wxT("WM_MBUTTONUP"); | |
6152 | case 0x0209: return wxT("WM_MBUTTONDBLCLK"); | |
6153 | case 0x020A: return wxT("WM_MOUSEWHEEL"); | |
6154 | case 0x0210: return wxT("WM_PARENTNOTIFY"); | |
6155 | case 0x0211: return wxT("WM_ENTERMENULOOP"); | |
6156 | case 0x0212: return wxT("WM_EXITMENULOOP"); | |
6157 | ||
6158 | case 0x0213: return wxT("WM_NEXTMENU"); | |
6159 | case 0x0214: return wxT("WM_SIZING"); | |
6160 | case 0x0215: return wxT("WM_CAPTURECHANGED"); | |
6161 | case 0x0216: return wxT("WM_MOVING"); | |
6162 | case 0x0218: return wxT("WM_POWERBROADCAST"); | |
6163 | case 0x0219: return wxT("WM_DEVICECHANGE"); | |
6164 | ||
6165 | case 0x0220: return wxT("WM_MDICREATE"); | |
6166 | case 0x0221: return wxT("WM_MDIDESTROY"); | |
6167 | case 0x0222: return wxT("WM_MDIACTIVATE"); | |
6168 | case 0x0223: return wxT("WM_MDIRESTORE"); | |
6169 | case 0x0224: return wxT("WM_MDINEXT"); | |
6170 | case 0x0225: return wxT("WM_MDIMAXIMIZE"); | |
6171 | case 0x0226: return wxT("WM_MDITILE"); | |
6172 | case 0x0227: return wxT("WM_MDICASCADE"); | |
6173 | case 0x0228: return wxT("WM_MDIICONARRANGE"); | |
6174 | case 0x0229: return wxT("WM_MDIGETACTIVE"); | |
6175 | case 0x0230: return wxT("WM_MDISETMENU"); | |
6176 | case 0x0233: return wxT("WM_DROPFILES"); | |
6177 | ||
6178 | case 0x0281: return wxT("WM_IME_SETCONTEXT"); | |
6179 | case 0x0282: return wxT("WM_IME_NOTIFY"); | |
6180 | case 0x0283: return wxT("WM_IME_CONTROL"); | |
6181 | case 0x0284: return wxT("WM_IME_COMPOSITIONFULL"); | |
6182 | case 0x0285: return wxT("WM_IME_SELECT"); | |
6183 | case 0x0286: return wxT("WM_IME_CHAR"); | |
6184 | case 0x0290: return wxT("WM_IME_KEYDOWN"); | |
6185 | case 0x0291: return wxT("WM_IME_KEYUP"); | |
6186 | ||
609da8bb VZ |
6187 | case 0x02A0: return wxT("WM_NCMOUSEHOVER"); |
6188 | case 0x02A1: return wxT("WM_MOUSEHOVER"); | |
6189 | case 0x02A2: return wxT("WM_NCMOUSELEAVE"); | |
6190 | case 0x02A3: return wxT("WM_MOUSELEAVE"); | |
6191 | ||
4a712ba3 VZ |
6192 | case 0x0300: return wxT("WM_CUT"); |
6193 | case 0x0301: return wxT("WM_COPY"); | |
6194 | case 0x0302: return wxT("WM_PASTE"); | |
6195 | case 0x0303: return wxT("WM_CLEAR"); | |
6196 | case 0x0304: return wxT("WM_UNDO"); | |
6197 | case 0x0305: return wxT("WM_RENDERFORMAT"); | |
6198 | case 0x0306: return wxT("WM_RENDERALLFORMATS"); | |
6199 | case 0x0307: return wxT("WM_DESTROYCLIPBOARD"); | |
6200 | case 0x0308: return wxT("WM_DRAWCLIPBOARD"); | |
6201 | case 0x0309: return wxT("WM_PAINTCLIPBOARD"); | |
6202 | case 0x030A: return wxT("WM_VSCROLLCLIPBOARD"); | |
6203 | case 0x030B: return wxT("WM_SIZECLIPBOARD"); | |
6204 | case 0x030C: return wxT("WM_ASKCBFORMATNAME"); | |
6205 | case 0x030D: return wxT("WM_CHANGECBCHAIN"); | |
6206 | case 0x030E: return wxT("WM_HSCROLLCLIPBOARD"); | |
6207 | case 0x030F: return wxT("WM_QUERYNEWPALETTE"); | |
6208 | case 0x0310: return wxT("WM_PALETTEISCHANGING"); | |
6209 | case 0x0311: return wxT("WM_PALETTECHANGED"); | |
4a712ba3 | 6210 | case 0x0312: return wxT("WM_HOTKEY"); |
609da8bb VZ |
6211 | |
6212 | case 0x0317: return wxT("WM_PRINT"); | |
6213 | case 0x0318: return wxT("WM_PRINTCLIENT"); | |
c085e333 | 6214 | |
2d0a075d JS |
6215 | // common controls messages - although they're not strictly speaking |
6216 | // standard, it's nice to decode them nevertheless | |
a02eb1d2 | 6217 | |
2d0a075d | 6218 | // listview |
4a712ba3 VZ |
6219 | case 0x1000 + 0: return wxT("LVM_GETBKCOLOR"); |
6220 | case 0x1000 + 1: return wxT("LVM_SETBKCOLOR"); | |
6221 | case 0x1000 + 2: return wxT("LVM_GETIMAGELIST"); | |
6222 | case 0x1000 + 3: return wxT("LVM_SETIMAGELIST"); | |
6223 | case 0x1000 + 4: return wxT("LVM_GETITEMCOUNT"); | |
6224 | case 0x1000 + 5: return wxT("LVM_GETITEMA"); | |
6225 | case 0x1000 + 75: return wxT("LVM_GETITEMW"); | |
6226 | case 0x1000 + 6: return wxT("LVM_SETITEMA"); | |
6227 | case 0x1000 + 76: return wxT("LVM_SETITEMW"); | |
6228 | case 0x1000 + 7: return wxT("LVM_INSERTITEMA"); | |
6229 | case 0x1000 + 77: return wxT("LVM_INSERTITEMW"); | |
6230 | case 0x1000 + 8: return wxT("LVM_DELETEITEM"); | |
6231 | case 0x1000 + 9: return wxT("LVM_DELETEALLITEMS"); | |
6232 | case 0x1000 + 10: return wxT("LVM_GETCALLBACKMASK"); | |
6233 | case 0x1000 + 11: return wxT("LVM_SETCALLBACKMASK"); | |
6234 | case 0x1000 + 12: return wxT("LVM_GETNEXTITEM"); | |
6235 | case 0x1000 + 13: return wxT("LVM_FINDITEMA"); | |
6236 | case 0x1000 + 83: return wxT("LVM_FINDITEMW"); | |
6237 | case 0x1000 + 14: return wxT("LVM_GETITEMRECT"); | |
6238 | case 0x1000 + 15: return wxT("LVM_SETITEMPOSITION"); | |
6239 | case 0x1000 + 16: return wxT("LVM_GETITEMPOSITION"); | |
6240 | case 0x1000 + 17: return wxT("LVM_GETSTRINGWIDTHA"); | |
6241 | case 0x1000 + 87: return wxT("LVM_GETSTRINGWIDTHW"); | |
6242 | case 0x1000 + 18: return wxT("LVM_HITTEST"); | |
6243 | case 0x1000 + 19: return wxT("LVM_ENSUREVISIBLE"); | |
6244 | case 0x1000 + 20: return wxT("LVM_SCROLL"); | |
6245 | case 0x1000 + 21: return wxT("LVM_REDRAWITEMS"); | |
6246 | case 0x1000 + 22: return wxT("LVM_ARRANGE"); | |
6247 | case 0x1000 + 23: return wxT("LVM_EDITLABELA"); | |
6248 | case 0x1000 + 118: return wxT("LVM_EDITLABELW"); | |
6249 | case 0x1000 + 24: return wxT("LVM_GETEDITCONTROL"); | |
6250 | case 0x1000 + 25: return wxT("LVM_GETCOLUMNA"); | |
6251 | case 0x1000 + 95: return wxT("LVM_GETCOLUMNW"); | |
6252 | case 0x1000 + 26: return wxT("LVM_SETCOLUMNA"); | |
6253 | case 0x1000 + 96: return wxT("LVM_SETCOLUMNW"); | |
6254 | case 0x1000 + 27: return wxT("LVM_INSERTCOLUMNA"); | |
6255 | case 0x1000 + 97: return wxT("LVM_INSERTCOLUMNW"); | |
6256 | case 0x1000 + 28: return wxT("LVM_DELETECOLUMN"); | |
6257 | case 0x1000 + 29: return wxT("LVM_GETCOLUMNWIDTH"); | |
6258 | case 0x1000 + 30: return wxT("LVM_SETCOLUMNWIDTH"); | |
6259 | case 0x1000 + 31: return wxT("LVM_GETHEADER"); | |
6260 | case 0x1000 + 33: return wxT("LVM_CREATEDRAGIMAGE"); | |
6261 | case 0x1000 + 34: return wxT("LVM_GETVIEWRECT"); | |
6262 | case 0x1000 + 35: return wxT("LVM_GETTEXTCOLOR"); | |
6263 | case 0x1000 + 36: return wxT("LVM_SETTEXTCOLOR"); | |
6264 | case 0x1000 + 37: return wxT("LVM_GETTEXTBKCOLOR"); | |
6265 | case 0x1000 + 38: return wxT("LVM_SETTEXTBKCOLOR"); | |
6266 | case 0x1000 + 39: return wxT("LVM_GETTOPINDEX"); | |
6267 | case 0x1000 + 40: return wxT("LVM_GETCOUNTPERPAGE"); | |
6268 | case 0x1000 + 41: return wxT("LVM_GETORIGIN"); | |
6269 | case 0x1000 + 42: return wxT("LVM_UPDATE"); | |
6270 | case 0x1000 + 43: return wxT("LVM_SETITEMSTATE"); | |
6271 | case 0x1000 + 44: return wxT("LVM_GETITEMSTATE"); | |
6272 | case 0x1000 + 45: return wxT("LVM_GETITEMTEXTA"); | |
6273 | case 0x1000 + 115: return wxT("LVM_GETITEMTEXTW"); | |
6274 | case 0x1000 + 46: return wxT("LVM_SETITEMTEXTA"); | |
6275 | case 0x1000 + 116: return wxT("LVM_SETITEMTEXTW"); | |
6276 | case 0x1000 + 47: return wxT("LVM_SETITEMCOUNT"); | |
6277 | case 0x1000 + 48: return wxT("LVM_SORTITEMS"); | |
6278 | case 0x1000 + 49: return wxT("LVM_SETITEMPOSITION32"); | |
6279 | case 0x1000 + 50: return wxT("LVM_GETSELECTEDCOUNT"); | |
6280 | case 0x1000 + 51: return wxT("LVM_GETITEMSPACING"); | |
6281 | case 0x1000 + 52: return wxT("LVM_GETISEARCHSTRINGA"); | |
6282 | case 0x1000 + 117: return wxT("LVM_GETISEARCHSTRINGW"); | |
6283 | case 0x1000 + 53: return wxT("LVM_SETICONSPACING"); | |
6284 | case 0x1000 + 54: return wxT("LVM_SETEXTENDEDLISTVIEWSTYLE"); | |
6285 | case 0x1000 + 55: return wxT("LVM_GETEXTENDEDLISTVIEWSTYLE"); | |
6286 | case 0x1000 + 56: return wxT("LVM_GETSUBITEMRECT"); | |
6287 | case 0x1000 + 57: return wxT("LVM_SUBITEMHITTEST"); | |
6288 | case 0x1000 + 58: return wxT("LVM_SETCOLUMNORDERARRAY"); | |
6289 | case 0x1000 + 59: return wxT("LVM_GETCOLUMNORDERARRAY"); | |
6290 | case 0x1000 + 60: return wxT("LVM_SETHOTITEM"); | |
6291 | case 0x1000 + 61: return wxT("LVM_GETHOTITEM"); | |
6292 | case 0x1000 + 62: return wxT("LVM_SETHOTCURSOR"); | |
6293 | case 0x1000 + 63: return wxT("LVM_GETHOTCURSOR"); | |
6294 | case 0x1000 + 64: return wxT("LVM_APPROXIMATEVIEWRECT"); | |
6295 | case 0x1000 + 65: return wxT("LVM_SETWORKAREA"); | |
c085e333 | 6296 | |
2d0a075d | 6297 | // tree view |
4a712ba3 VZ |
6298 | case 0x1100 + 0: return wxT("TVM_INSERTITEMA"); |
6299 | case 0x1100 + 50: return wxT("TVM_INSERTITEMW"); | |
6300 | case 0x1100 + 1: return wxT("TVM_DELETEITEM"); | |
6301 | case 0x1100 + 2: return wxT("TVM_EXPAND"); | |
6302 | case 0x1100 + 4: return wxT("TVM_GETITEMRECT"); | |
6303 | case 0x1100 + 5: return wxT("TVM_GETCOUNT"); | |
6304 | case 0x1100 + 6: return wxT("TVM_GETINDENT"); | |
6305 | case 0x1100 + 7: return wxT("TVM_SETINDENT"); | |
6306 | case 0x1100 + 8: return wxT("TVM_GETIMAGELIST"); | |
6307 | case 0x1100 + 9: return wxT("TVM_SETIMAGELIST"); | |
6308 | case 0x1100 + 10: return wxT("TVM_GETNEXTITEM"); | |
6309 | case 0x1100 + 11: return wxT("TVM_SELECTITEM"); | |
6310 | case 0x1100 + 12: return wxT("TVM_GETITEMA"); | |
6311 | case 0x1100 + 62: return wxT("TVM_GETITEMW"); | |
6312 | case 0x1100 + 13: return wxT("TVM_SETITEMA"); | |
6313 | case 0x1100 + 63: return wxT("TVM_SETITEMW"); | |
6314 | case 0x1100 + 14: return wxT("TVM_EDITLABELA"); | |
6315 | case 0x1100 + 65: return wxT("TVM_EDITLABELW"); | |
6316 | case 0x1100 + 15: return wxT("TVM_GETEDITCONTROL"); | |
6317 | case 0x1100 + 16: return wxT("TVM_GETVISIBLECOUNT"); | |
6318 | case 0x1100 + 17: return wxT("TVM_HITTEST"); | |
6319 | case 0x1100 + 18: return wxT("TVM_CREATEDRAGIMAGE"); | |
6320 | case 0x1100 + 19: return wxT("TVM_SORTCHILDREN"); | |
6321 | case 0x1100 + 20: return wxT("TVM_ENSUREVISIBLE"); | |
6322 | case 0x1100 + 21: return wxT("TVM_SORTCHILDRENCB"); | |
6323 | case 0x1100 + 22: return wxT("TVM_ENDEDITLABELNOW"); | |
6324 | case 0x1100 + 23: return wxT("TVM_GETISEARCHSTRINGA"); | |
6325 | case 0x1100 + 64: return wxT("TVM_GETISEARCHSTRINGW"); | |
6326 | case 0x1100 + 24: return wxT("TVM_SETTOOLTIPS"); | |
6327 | case 0x1100 + 25: return wxT("TVM_GETTOOLTIPS"); | |
c085e333 | 6328 | |
2d0a075d | 6329 | // header |
4a712ba3 VZ |
6330 | case 0x1200 + 0: return wxT("HDM_GETITEMCOUNT"); |
6331 | case 0x1200 + 1: return wxT("HDM_INSERTITEMA"); | |
6332 | case 0x1200 + 10: return wxT("HDM_INSERTITEMW"); | |
6333 | case 0x1200 + 2: return wxT("HDM_DELETEITEM"); | |
6334 | case 0x1200 + 3: return wxT("HDM_GETITEMA"); | |
6335 | case 0x1200 + 11: return wxT("HDM_GETITEMW"); | |
6336 | case 0x1200 + 4: return wxT("HDM_SETITEMA"); | |
6337 | case 0x1200 + 12: return wxT("HDM_SETITEMW"); | |
6338 | case 0x1200 + 5: return wxT("HDM_LAYOUT"); | |
6339 | case 0x1200 + 6: return wxT("HDM_HITTEST"); | |
6340 | case 0x1200 + 7: return wxT("HDM_GETITEMRECT"); | |
6341 | case 0x1200 + 8: return wxT("HDM_SETIMAGELIST"); | |
6342 | case 0x1200 + 9: return wxT("HDM_GETIMAGELIST"); | |
6343 | case 0x1200 + 15: return wxT("HDM_ORDERTOINDEX"); | |
6344 | case 0x1200 + 16: return wxT("HDM_CREATEDRAGIMAGE"); | |
6345 | case 0x1200 + 17: return wxT("HDM_GETORDERARRAY"); | |
6346 | case 0x1200 + 18: return wxT("HDM_SETORDERARRAY"); | |
6347 | case 0x1200 + 19: return wxT("HDM_SETHOTDIVIDER"); | |
c085e333 | 6348 | |
2d0a075d | 6349 | // tab control |
4a712ba3 VZ |
6350 | case 0x1300 + 2: return wxT("TCM_GETIMAGELIST"); |
6351 | case 0x1300 + 3: return wxT("TCM_SETIMAGELIST"); | |
6352 | case 0x1300 + 4: return wxT("TCM_GETITEMCOUNT"); | |
6353 | case 0x1300 + 5: return wxT("TCM_GETITEMA"); | |
6354 | case 0x1300 + 60: return wxT("TCM_GETITEMW"); | |
6355 | case 0x1300 + 6: return wxT("TCM_SETITEMA"); | |
6356 | case 0x1300 + 61: return wxT("TCM_SETITEMW"); | |
6357 | case 0x1300 + 7: return wxT("TCM_INSERTITEMA"); | |
6358 | case 0x1300 + 62: return wxT("TCM_INSERTITEMW"); | |
6359 | case 0x1300 + 8: return wxT("TCM_DELETEITEM"); | |
6360 | case 0x1300 + 9: return wxT("TCM_DELETEALLITEMS"); | |
6361 | case 0x1300 + 10: return wxT("TCM_GETITEMRECT"); | |
6362 | case 0x1300 + 11: return wxT("TCM_GETCURSEL"); | |
6363 | case 0x1300 + 12: return wxT("TCM_SETCURSEL"); | |
6364 | case 0x1300 + 13: return wxT("TCM_HITTEST"); | |
6365 | case 0x1300 + 14: return wxT("TCM_SETITEMEXTRA"); | |
6366 | case 0x1300 + 40: return wxT("TCM_ADJUSTRECT"); | |
6367 | case 0x1300 + 41: return wxT("TCM_SETITEMSIZE"); | |
6368 | case 0x1300 + 42: return wxT("TCM_REMOVEIMAGE"); | |
6369 | case 0x1300 + 43: return wxT("TCM_SETPADDING"); | |
6370 | case 0x1300 + 44: return wxT("TCM_GETROWCOUNT"); | |
6371 | case 0x1300 + 45: return wxT("TCM_GETTOOLTIPS"); | |
6372 | case 0x1300 + 46: return wxT("TCM_SETTOOLTIPS"); | |
6373 | case 0x1300 + 47: return wxT("TCM_GETCURFOCUS"); | |
6374 | case 0x1300 + 48: return wxT("TCM_SETCURFOCUS"); | |
6375 | case 0x1300 + 49: return wxT("TCM_SETMINTABWIDTH"); | |
6376 | case 0x1300 + 50: return wxT("TCM_DESELECTALL"); | |
c085e333 | 6377 | |
2d0a075d | 6378 | // toolbar |
4a712ba3 VZ |
6379 | case WM_USER+1: return wxT("TB_ENABLEBUTTON"); |
6380 | case WM_USER+2: return wxT("TB_CHECKBUTTON"); | |
6381 | case WM_USER+3: return wxT("TB_PRESSBUTTON"); | |
6382 | case WM_USER+4: return wxT("TB_HIDEBUTTON"); | |
6383 | case WM_USER+5: return wxT("TB_INDETERMINATE"); | |
6384 | case WM_USER+9: return wxT("TB_ISBUTTONENABLED"); | |
6385 | case WM_USER+10: return wxT("TB_ISBUTTONCHECKED"); | |
6386 | case WM_USER+11: return wxT("TB_ISBUTTONPRESSED"); | |
6387 | case WM_USER+12: return wxT("TB_ISBUTTONHIDDEN"); | |
6388 | case WM_USER+13: return wxT("TB_ISBUTTONINDETERMINATE"); | |
6389 | case WM_USER+17: return wxT("TB_SETSTATE"); | |
6390 | case WM_USER+18: return wxT("TB_GETSTATE"); | |
6391 | case WM_USER+19: return wxT("TB_ADDBITMAP"); | |
6392 | case WM_USER+20: return wxT("TB_ADDBUTTONS"); | |
6393 | case WM_USER+21: return wxT("TB_INSERTBUTTON"); | |
6394 | case WM_USER+22: return wxT("TB_DELETEBUTTON"); | |
6395 | case WM_USER+23: return wxT("TB_GETBUTTON"); | |
6396 | case WM_USER+24: return wxT("TB_BUTTONCOUNT"); | |
6397 | case WM_USER+25: return wxT("TB_COMMANDTOINDEX"); | |
6398 | case WM_USER+26: return wxT("TB_SAVERESTOREA"); | |
6399 | case WM_USER+76: return wxT("TB_SAVERESTOREW"); | |
6400 | case WM_USER+27: return wxT("TB_CUSTOMIZE"); | |
6401 | case WM_USER+28: return wxT("TB_ADDSTRINGA"); | |
6402 | case WM_USER+77: return wxT("TB_ADDSTRINGW"); | |
6403 | case WM_USER+29: return wxT("TB_GETITEMRECT"); | |
6404 | case WM_USER+30: return wxT("TB_BUTTONSTRUCTSIZE"); | |
6405 | case WM_USER+31: return wxT("TB_SETBUTTONSIZE"); | |
6406 | case WM_USER+32: return wxT("TB_SETBITMAPSIZE"); | |
6407 | case WM_USER+33: return wxT("TB_AUTOSIZE"); | |
6408 | case WM_USER+35: return wxT("TB_GETTOOLTIPS"); | |
6409 | case WM_USER+36: return wxT("TB_SETTOOLTIPS"); | |
6410 | case WM_USER+37: return wxT("TB_SETPARENT"); | |
6411 | case WM_USER+39: return wxT("TB_SETROWS"); | |
6412 | case WM_USER+40: return wxT("TB_GETROWS"); | |
6413 | case WM_USER+42: return wxT("TB_SETCMDID"); | |
6414 | case WM_USER+43: return wxT("TB_CHANGEBITMAP"); | |
6415 | case WM_USER+44: return wxT("TB_GETBITMAP"); | |
6416 | case WM_USER+45: return wxT("TB_GETBUTTONTEXTA"); | |
6417 | case WM_USER+75: return wxT("TB_GETBUTTONTEXTW"); | |
6418 | case WM_USER+46: return wxT("TB_REPLACEBITMAP"); | |
6419 | case WM_USER+47: return wxT("TB_SETINDENT"); | |
6420 | case WM_USER+48: return wxT("TB_SETIMAGELIST"); | |
6421 | case WM_USER+49: return wxT("TB_GETIMAGELIST"); | |
6422 | case WM_USER+50: return wxT("TB_LOADIMAGES"); | |
6423 | case WM_USER+51: return wxT("TB_GETRECT"); | |
6424 | case WM_USER+52: return wxT("TB_SETHOTIMAGELIST"); | |
6425 | case WM_USER+53: return wxT("TB_GETHOTIMAGELIST"); | |
6426 | case WM_USER+54: return wxT("TB_SETDISABLEDIMAGELIST"); | |
6427 | case WM_USER+55: return wxT("TB_GETDISABLEDIMAGELIST"); | |
6428 | case WM_USER+56: return wxT("TB_SETSTYLE"); | |
6429 | case WM_USER+57: return wxT("TB_GETSTYLE"); | |
6430 | case WM_USER+58: return wxT("TB_GETBUTTONSIZE"); | |
6431 | case WM_USER+59: return wxT("TB_SETBUTTONWIDTH"); | |
6432 | case WM_USER+60: return wxT("TB_SETMAXTEXTROWS"); | |
6433 | case WM_USER+61: return wxT("TB_GETTEXTROWS"); | |
6434 | case WM_USER+41: return wxT("TB_GETBITMAPFLAGS"); | |
c085e333 | 6435 | |
42e69d6b | 6436 | default: |
4a712ba3 VZ |
6437 | static wxString s_szBuf; |
6438 | s_szBuf.Printf(wxT("<unknown message = %d>"), message); | |
6439 | return s_szBuf.c_str(); | |
42e69d6b | 6440 | } |
47cbd6da | 6441 | } |
ea57084d | 6442 | #endif //__WXDEBUG__ |
4aff28fc | 6443 | |
1e6feb95 | 6444 | static TEXTMETRIC wxGetTextMetrics(const wxWindowMSW *win) |
f6bcfd97 BP |
6445 | { |
6446 | // prepare the DC | |
6447 | TEXTMETRIC tm; | |
6448 | HWND hwnd = GetHwndOf(win); | |
6449 | HDC hdc = ::GetDC(hwnd); | |
6450 | ||
6451 | #if !wxDIALOG_UNIT_COMPATIBILITY | |
6452 | // and select the current font into it | |
6453 | HFONT hfont = GetHfontOf(win->GetFont()); | |
6454 | if ( hfont ) | |
6455 | { | |
6456 | hfont = (HFONT)::SelectObject(hdc, hfont); | |
6457 | } | |
6458 | #endif | |
6459 | ||
6460 | // finally retrieve the text metrics from it | |
6461 | GetTextMetrics(hdc, &tm); | |
6462 | ||
6463 | #if !wxDIALOG_UNIT_COMPATIBILITY | |
6464 | // and clean up | |
6465 | if ( hfont ) | |
6466 | { | |
6467 | (void)::SelectObject(hdc, hfont); | |
6468 | } | |
6469 | #endif | |
6470 | ||
6471 | ::ReleaseDC(hwnd, hdc); | |
6472 | ||
6473 | return tm; | |
6474 | } | |
3723b7b1 JS |
6475 | |
6476 | // Find the wxWindow at the current mouse position, returning the mouse | |
6477 | // position. | |
2b5f62a0 | 6478 | wxWindow* wxFindWindowAtPointer(wxPoint& pt) |
3723b7b1 | 6479 | { |
2b5f62a0 VZ |
6480 | pt = wxGetMousePosition(); |
6481 | return wxFindWindowAtPoint(pt); | |
57591e0e JS |
6482 | } |
6483 | ||
6484 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt) | |
6485 | { | |
6486 | POINT pt2; | |
6487 | pt2.x = pt.x; | |
6488 | pt2.y = pt.y; | |
3723b7b1 | 6489 | |
ab3eae34 | 6490 | HWND hWnd = ::WindowFromPoint(pt2); |
3723b7b1 | 6491 | |
ab3eae34 | 6492 | return wxGetWindowFromHWND((WXHWND)hWnd); |
3723b7b1 JS |
6493 | } |
6494 | ||
6495 | // Get the current mouse position. | |
6496 | wxPoint wxGetMousePosition() | |
6497 | { | |
1772ead0 | 6498 | POINT pt; |
f2325516 JS |
6499 | #ifdef __WXWINCE__ |
6500 | GetCursorPosWinCE(&pt); | |
6501 | #else | |
1772ead0 | 6502 | GetCursorPos( & pt ); |
f2325516 | 6503 | #endif |
5cd16c0c | 6504 | |
1772ead0 | 6505 | return wxPoint(pt.x, pt.y); |
3723b7b1 JS |
6506 | } |
6507 | ||
5048c832 | 6508 | #if wxUSE_HOTKEY |
540b6b09 | 6509 | |
afafd942 JS |
6510 | #if defined(__SMARTPHONE__) || defined(__POCKETPC__) |
6511 | static void WinCEUnregisterHotKey(int modifiers, int id) | |
6512 | { | |
6513 | // Register hotkeys for the hardware buttons | |
6514 | HINSTANCE hCoreDll; | |
6515 | typedef BOOL (WINAPI *UnregisterFunc1Proc)(UINT, UINT); | |
6516 | ||
6517 | UnregisterFunc1Proc procUnregisterFunc; | |
6518 | hCoreDll = LoadLibrary(_T("coredll.dll")); | |
6519 | if (hCoreDll) | |
6520 | { | |
6521 | procUnregisterFunc = (UnregisterFunc1Proc)GetProcAddress(hCoreDll, _T("UnregisterFunc1")); | |
6522 | if (procUnregisterFunc) | |
6523 | procUnregisterFunc(modifiers, id); | |
6524 | FreeLibrary(hCoreDll); | |
6525 | } | |
6526 | } | |
6527 | #endif | |
6528 | ||
540b6b09 | 6529 | bool wxWindowMSW::RegisterHotKey(int hotkeyId, int modifiers, int keycode) |
5048c832 JS |
6530 | { |
6531 | UINT win_modifiers=0; | |
540b6b09 VZ |
6532 | if ( modifiers & wxMOD_ALT ) |
6533 | win_modifiers |= MOD_ALT; | |
6534 | if ( modifiers & wxMOD_SHIFT ) | |
6535 | win_modifiers |= MOD_SHIFT; | |
6536 | if ( modifiers & wxMOD_CONTROL ) | |
6537 | win_modifiers |= MOD_CONTROL; | |
6538 | if ( modifiers & wxMOD_WIN ) | |
6539 | win_modifiers |= MOD_WIN; | |
6540 | ||
afafd942 JS |
6541 | #if defined(__SMARTPHONE__) || defined(__POCKETPC__) |
6542 | // Required for PPC and Smartphone hardware buttons | |
6543 | if (keycode >= WXK_SPECIAL1 && keycode <= WXK_SPECIAL20) | |
6544 | WinCEUnregisterHotKey(win_modifiers, hotkeyId); | |
6545 | #endif | |
6546 | ||
540b6b09 VZ |
6547 | if ( !::RegisterHotKey(GetHwnd(), hotkeyId, win_modifiers, keycode) ) |
6548 | { | |
6549 | wxLogLastError(_T("RegisterHotKey")); | |
5048c832 | 6550 | |
08158721 | 6551 | return false; |
540b6b09 VZ |
6552 | } |
6553 | ||
08158721 | 6554 | return true; |
5048c832 JS |
6555 | } |
6556 | ||
6557 | bool wxWindowMSW::UnregisterHotKey(int hotkeyId) | |
6558 | { | |
afafd942 JS |
6559 | #if defined(__SMARTPHONE__) || defined(__POCKETPC__) |
6560 | WinCEUnregisterHotKey(MOD_WIN, hotkeyId); | |
6561 | #endif | |
6562 | ||
540b6b09 VZ |
6563 | if ( !::UnregisterHotKey(GetHwnd(), hotkeyId) ) |
6564 | { | |
6565 | wxLogLastError(_T("UnregisterHotKey")); | |
6566 | ||
08158721 | 6567 | return false; |
540b6b09 VZ |
6568 | } |
6569 | ||
08158721 | 6570 | return true; |
5048c832 JS |
6571 | } |
6572 | ||
0b4f47a3 DS |
6573 | #if wxUSE_ACCEL |
6574 | ||
5048c832 JS |
6575 | bool wxWindowMSW::HandleHotKey(WXWPARAM wParam, WXLPARAM lParam) |
6576 | { | |
540b6b09 VZ |
6577 | int hotkeyId = wParam; |
6578 | int virtualKey = HIWORD(lParam); | |
6579 | int win_modifiers = LOWORD(lParam); | |
6580 | ||
5048c832 JS |
6581 | wxKeyEvent event(CreateKeyEvent(wxEVT_HOTKEY, virtualKey, wParam, lParam)); |
6582 | event.SetId(hotkeyId); | |
6583 | event.m_shiftDown = (win_modifiers & MOD_SHIFT) != 0; | |
6584 | event.m_controlDown = (win_modifiers & MOD_CONTROL) != 0; | |
6585 | event.m_altDown = (win_modifiers & MOD_ALT) != 0; | |
6586 | event.m_metaDown = (win_modifiers & MOD_WIN) != 0; | |
540b6b09 VZ |
6587 | |
6588 | return GetEventHandler()->ProcessEvent(event); | |
5048c832 | 6589 | } |
540b6b09 | 6590 | |
0b4f47a3 DS |
6591 | #endif // wxUSE_ACCEL |
6592 | ||
540b6b09 | 6593 | #endif // wxUSE_HOTKEY |
5048c832 | 6594 | |
550049c2 | 6595 | // Not tested under WinCE |
d79df32c | 6596 | #ifndef __WXWINCE__ |
d79df32c | 6597 | |
550049c2 VZ |
6598 | // this class installs a message hook which really wakes up our idle processing |
6599 | // each time a WM_NULL is received (wxWakeUpIdle does this), even if we're | |
6600 | // sitting inside a local modal loop (e.g. a menu is opened or scrollbar is | |
6601 | // being dragged or even inside ::MessageBox()) and so don't control message | |
6602 | // dispatching otherwise | |
6603 | class wxIdleWakeUpModule : public wxModule | |
6604 | { | |
d79df32c | 6605 | public: |
3a3c8603 | 6606 | virtual bool OnInit() |
550049c2 | 6607 | { |
3a3c8603 | 6608 | ms_hMsgHookProc = ::SetWindowsHookEx |
550049c2 VZ |
6609 | ( |
6610 | WH_GETMESSAGE, | |
6611 | &wxIdleWakeUpModule::MsgHookProc, | |
6612 | NULL, | |
6613 | GetCurrentThreadId() | |
6614 | ); | |
d79df32c | 6615 | |
550049c2 VZ |
6616 | if ( !ms_hMsgHookProc ) |
6617 | { | |
6618 | wxLogLastError(_T("SetWindowsHookEx(WH_GETMESSAGE)")); | |
6619 | ||
6620 | return false; | |
6621 | } | |
6622 | ||
6623 | return true; | |
3a3c8603 | 6624 | } |
550049c2 | 6625 | |
3a3c8603 | 6626 | virtual void OnExit() |
550049c2 | 6627 | { |
3a3c8603 DS |
6628 | ::UnhookWindowsHookEx(wxIdleWakeUpModule::ms_hMsgHookProc); |
6629 | } | |
550049c2 | 6630 | |
3a3c8603 | 6631 | static LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam) |
550049c2 | 6632 | { |
3a3c8603 | 6633 | MSG *msg = (MSG*)lParam; |
34ea3c74 VZ |
6634 | |
6635 | // only process the message if it is actually going to be removed from | |
6636 | // the message queue, this prevents that the same event from being | |
6637 | // processed multiple times if now someone just called PeekMessage() | |
6638 | if ( msg->message == WM_NULL && wParam == PM_REMOVE ) | |
3a3c8603 | 6639 | { |
550049c2 | 6640 | wxTheApp->ProcessPendingEvents(); |
3a3c8603 | 6641 | } |
550049c2 | 6642 | |
3a3c8603 | 6643 | return CallNextHookEx(ms_hMsgHookProc, nCode, wParam, lParam); |
47b378bd | 6644 | } |
550049c2 | 6645 | |
d79df32c | 6646 | private: |
3a3c8603 | 6647 | static HHOOK ms_hMsgHookProc; |
550049c2 VZ |
6648 | |
6649 | DECLARE_DYNAMIC_CLASS(wxIdleWakeUpModule) | |
d79df32c | 6650 | }; |
d79df32c | 6651 | |
550049c2 VZ |
6652 | HHOOK wxIdleWakeUpModule::ms_hMsgHookProc = 0; |
6653 | ||
6654 | IMPLEMENT_DYNAMIC_CLASS(wxIdleWakeUpModule, wxModule) | |
6655 | ||
6656 | #endif // __WXWINCE__ | |
3a3c8603 | 6657 | |
d26e1ab2 JS |
6658 | #ifdef __WXWINCE__ |
6659 | ||
6660 | #if wxUSE_STATBOX | |
6661 | static void wxAdjustZOrder(wxWindow* parent) | |
6662 | { | |
6663 | if (parent->IsKindOf(CLASSINFO(wxStaticBox))) | |
6664 | { | |
6665 | // Set the z-order correctly | |
6666 | SetWindowPos((HWND) parent->GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); | |
6667 | } | |
35bbb0c6 | 6668 | |
d26e1ab2 JS |
6669 | wxWindowList::compatibility_iterator current = parent->GetChildren().GetFirst(); |
6670 | while (current) | |
6671 | { | |
6672 | wxWindow *childWin = current->GetData(); | |
6673 | wxAdjustZOrder(childWin); | |
6674 | current = current->GetNext(); | |
6675 | } | |
6676 | } | |
6677 | #endif | |
6678 | ||
6679 | // We need to adjust the z-order of static boxes in WinCE, to | |
6680 | // make 'contained' controls visible | |
6681 | void wxWindowMSW::OnInitDialog( wxInitDialogEvent& event ) | |
6682 | { | |
6683 | #if wxUSE_STATBOX | |
6684 | wxAdjustZOrder(this); | |
6685 | #endif | |
35bbb0c6 | 6686 | |
d26e1ab2 JS |
6687 | event.Skip(); |
6688 | } | |
6689 | #endif |