]> git.saurik.com Git - wxWidgets.git/blame - src/msw/window.cpp
why cvs thinks that I modified these files?
[wxWidgets.git] / src / msw / window.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: windows.cpp
3// Purpose: wxWindow
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$
8// Copyright: (c) Julian Smart and Markus Holzem
a3622daa 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
a23fd0e1
VZ
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
2bda0e17 20#ifdef __GNUG__
a23fd0e1 21 #pragma implementation "window.h"
2bda0e17
KB
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
09914df7 28 #pragma hdrstop
2bda0e17
KB
29#endif
30
31#ifndef WX_PRECOMP
0c589ad0
BM
32 #include <windows.h>
33 #include "wx/msw/winundef.h"
34 #include "wx/accel.h"
3a19e16d
VZ
35 #include "wx/setup.h"
36 #include "wx/menu.h"
37 #include "wx/dc.h"
38 #include "wx/dcclient.h"
39 #include "wx/utils.h"
40 #include "wx/app.h"
41 #include "wx/panel.h"
42 #include "wx/layout.h"
43 #include "wx/dialog.h"
44 #include "wx/frame.h"
45 #include "wx/listbox.h"
46 #include "wx/button.h"
3a19e16d 47 #include "wx/msgdlg.h"
341c92a8
VZ
48
49 #include <stdio.h>
2bda0e17
KB
50#endif
51
47d67540 52#if wxUSE_OWNER_DRAWN
09914df7 53 #include "wx/ownerdrw.h"
2bda0e17
KB
54#endif
55
47d67540 56#if wxUSE_DRAG_AND_DROP
3f480da3 57 #include "wx/dataobj.h"
09914df7 58 #include "wx/msw/ole/droptgt.h"
2bda0e17
KB
59#endif
60
61#include "wx/menuitem.h"
47cbd6da 62#include "wx/log.h"
750b78ba 63
0c589ad0
BM
64#include "wx/msw/private.h"
65
750b78ba 66#if wxUSE_TOOLTIPS
42e69d6b 67 #include "wx/tooltip.h"
750b78ba
JS
68#endif
69
789295bf
VZ
70#if wxUSE_CARET
71 #include "wx/caret.h"
72#endif // wxUSE_CARET
73
dbda9e86
JS
74#include "wx/intl.h"
75#include "wx/log.h"
3a19e16d 76
2bda0e17 77
2a47d3c1
JS
78#include "wx/textctrl.h"
79
2bda0e17
KB
80#include <string.h>
81
82#ifndef __GNUWIN32__
3a19e16d
VZ
83 #include <shellapi.h>
84 #include <mmsystem.h>
2bda0e17
KB
85#endif
86
87#ifdef __WIN32__
3a19e16d 88 #include <windowsx.h>
2bda0e17
KB
89#endif
90
cc2b7472 91#if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ )
42e69d6b 92 #include <commctrl.h>
acbd13a3 93#endif
3a19e16d 94
57c208c5 95#ifndef __TWIN32__
3a19e16d
VZ
96 #ifdef __GNUWIN32__
97 #include <wx/msw/gnuwin32/extra.h>
98 #endif
57c208c5 99#endif
2bda0e17 100
a23fd0e1
VZ
101// ---------------------------------------------------------------------------
102// macros
103// ---------------------------------------------------------------------------
104
105// standard macros missing from some compilers headers
106#ifndef GET_X_LPARAM
c6eba8f8
VZ
107 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
108 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
a23fd0e1
VZ
109#endif // GET_X_LPARAM
110
111// ---------------------------------------------------------------------------
42e69d6b 112// global variables
a23fd0e1 113// ---------------------------------------------------------------------------
47cbd6da 114
42e69d6b
VZ
115// the last Windows message we got (MT-UNSAFE)
116extern MSG s_currentMsg;
2bda0e17
KB
117
118wxMenu *wxCurrentPopupMenu = NULL;
cde9f08e 119extern wxList WXDLLEXPORT wxPendingDelete;
837e5743 120extern wxChar wxCanvasClassName[];
42e69d6b
VZ
121
122// ---------------------------------------------------------------------------
123// private functions
124// ---------------------------------------------------------------------------
125
126// the window proc for all our windows
127LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
128 WPARAM wParam, LPARAM lParam);
129
130#ifdef __WXDEBUG__
131 const char *wxGetMessageName(int message);
132#endif //__WXDEBUG__
2bda0e17
KB
133
134void wxRemoveHandleAssociation(wxWindow *win);
135void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
136wxWindow *wxFindWinFromHandle(WXHWND hWnd);
137
a23fd0e1
VZ
138// ---------------------------------------------------------------------------
139// event tables
140// ---------------------------------------------------------------------------
141
42e69d6b
VZ
142#if !USE_SHARED_LIBRARY
143 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
144#endif
145
cc2b7472 146BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
cf65ad8d
VZ
147 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
148 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
149 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
150 EVT_IDLE(wxWindow::OnIdle)
2bda0e17
KB
151END_EVENT_TABLE()
152
a23fd0e1
VZ
153// ===========================================================================
154// implementation
155// ===========================================================================
156
42e69d6b
VZ
157// ---------------------------------------------------------------------------
158// wxWindow utility functions
159// ---------------------------------------------------------------------------
160
2bda0e17 161// Find an item given the MS Windows id
debe6624 162wxWindow *wxWindow::FindItem(int id) const
2bda0e17 163{
42e69d6b 164 wxWindowList::Node *current = GetChildren().GetFirst();
2d0a075d
JS
165 while (current)
166 {
42e69d6b 167 wxWindow *childWin = current->GetData();
2bda0e17 168
42e69d6b 169 wxWindow *wnd = childWin->FindItem(id);
cc2b7472 170 if ( wnd )
42e69d6b 171 return wnd;
2bda0e17 172
cc2b7472 173 if ( childWin->IsKindOf(CLASSINFO(wxControl)) )
2d0a075d
JS
174 {
175 wxControl *item = (wxControl *)childWin;
cc2b7472 176 if ( item->GetId() == id )
2d0a075d
JS
177 return item;
178 else
179 {
180 // In case it's a 'virtual' control (e.g. radiobox)
cc2b7472 181 if ( item->GetSubcontrols().Member((wxObject *)id) )
2d0a075d
JS
182 return item;
183 }
184 }
42e69d6b
VZ
185
186 current = current->GetNext();
2bda0e17 187 }
42e69d6b 188
2d0a075d 189 return NULL;
2bda0e17
KB
190}
191
192// Find an item given the MS Windows handle
debe6624 193wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const
2bda0e17 194{
42e69d6b 195 wxWindowList::Node *current = GetChildren().GetFirst();
2d0a075d 196 while (current)
2bda0e17 197 {
42e69d6b
VZ
198 wxWindow *parent = current->GetData();
199
2d0a075d 200 // Do a recursive search.
42e69d6b 201 wxWindow *wnd = parent->FindItemByHWND(hWnd);
cc2b7472 202 if ( wnd )
42e69d6b 203 return wnd;
2d0a075d 204
42e69d6b 205 if ( !controlOnly || parent->IsKindOf(CLASSINFO(wxControl)) )
2d0a075d 206 {
42e69d6b
VZ
207 wxWindow *item = current->GetData();
208 if ( item->GetHWND() == hWnd )
2d0a075d
JS
209 return item;
210 else
211 {
212 if ( item->ContainsHWND(hWnd) )
213 return item;
214 }
215 }
42e69d6b
VZ
216
217 current = current->GetNext();
2bda0e17 218 }
2d0a075d 219 return NULL;
2bda0e17
KB
220}
221
222// Default command handler
debe6624 223bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
2bda0e17 224{
2d0a075d 225 return FALSE;
2bda0e17
KB
226}
227
fd3f686c
VZ
228// ----------------------------------------------------------------------------
229// constructors and such
230// ----------------------------------------------------------------------------
231
232void wxWindow::Init()
2bda0e17 233{
cc2b7472
VZ
234 // generic
235 InitBase();
634903fd 236
cc2b7472 237 // MSW specific
42e69d6b 238 m_doubleClickAllowed = 0;
2d0a075d 239 m_winCaptured = FALSE;
cc2b7472 240
2d0a075d
JS
241 m_isBeingDeleted = FALSE;
242 m_oldWndProc = 0;
2d0a075d 243 m_useCtl3D = FALSE;
fd3f686c 244 m_mouseInWindow = FALSE;
2bda0e17 245
2d0a075d 246 // wxWnd
2d0a075d 247 m_hMenu = 0;
2bda0e17 248
319fefa9
VZ
249 m_hWnd = 0;
250
251 // pass WM_GETDLGCODE to DefWindowProc()
252 m_lDlgCode = 0;
253
2d0a075d
JS
254 m_xThumbSize = 0;
255 m_yThumbSize = 0;
256 m_backgroundTransparent = FALSE;
2bda0e17 257
85d10d9b
VZ
258 // as all windows are created with WS_VISIBLE style...
259 m_isShown = TRUE;
260
a23fd0e1 261#if wxUSE_MOUSEEVENT_HACK
cc2b7472
VZ
262 m_lastMouseX =
263 m_lastMouseY = -1;
264 m_lastMouseEvent = -1;
a23fd0e1 265#endif // wxUSE_MOUSEEVENT_HACK
fd3f686c
VZ
266}
267
2bda0e17 268// Destructor
fd3f686c 269wxWindow::~wxWindow()
2bda0e17 270{
2d0a075d 271 m_isBeingDeleted = TRUE;
2bda0e17 272
2d0a075d 273 MSWDetachWindowMenu();
2bda0e17 274
a23fd0e1
VZ
275 if ( m_parent )
276 m_parent->RemoveChild(this);
277
278 DestroyChildren();
279
cc2b7472 280 if ( m_hWnd )
42e69d6b
VZ
281 {
282 if ( !::DestroyWindow(GetHwnd()) )
283 wxLogLastError("DestroyWindow");
2bda0e17 284
c50f1fb9
VZ
285 // remove hWnd <-> wxWindow association
286 wxRemoveHandleAssociation(this);
287 }
2bda0e17
KB
288}
289
fd3f686c 290// real construction (Init() must have been called before!)
debe6624 291bool wxWindow::Create(wxWindow *parent, wxWindowID id,
2d0a075d
JS
292 const wxPoint& pos,
293 const wxSize& size,
294 long style,
295 const wxString& name)
296{
837e5743 297 wxCHECK_MSG( parent, FALSE, _T("can't create wxWindow without parent") );
2bda0e17 298
42e69d6b
VZ
299 CreateBase(parent, id, pos, size, style, name);
300
fd3f686c 301 parent->AddChild(this);
2bda0e17 302
2d0a075d 303 DWORD msflags = 0;
cc2b7472 304 if ( style & wxBORDER )
2d0a075d 305 msflags |= WS_BORDER;
cc2b7472 306 if ( style & wxTHICK_FRAME )
2d0a075d 307 msflags |= WS_THICKFRAME;
1c089c47 308
2d0a075d 309 msflags |= WS_CHILD | WS_VISIBLE;
cc2b7472 310 if ( style & wxCLIP_CHILDREN )
2d0a075d 311 msflags |= WS_CLIPCHILDREN;
2bda0e17 312
2d0a075d 313 bool want3D;
42e69d6b 314 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
2bda0e17 315
2d0a075d
JS
316 // Even with extended styles, need to combine with WS_BORDER
317 // for them to look right.
cc2b7472 318 if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
2d0a075d 319 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
cc2b7472 320 {
2d0a075d 321 msflags |= WS_BORDER;
cc2b7472 322 }
2bda0e17 323
101f488c
VZ
324 // calculate the value to return from WM_GETDLGCODE handler
325 if ( GetWindowStyleFlag() & wxWANTS_CHARS )
326 {
327 // want everything: i.e. all keys and WM_CHAR message
328 m_lDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS |
329 DLGC_WANTTAB | DLGC_WANTMESSAGE;
101f488c 330 }
101f488c 331
2d0a075d 332 MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
cc2b7472
VZ
333 pos.x, pos.y,
334 WidthDefault(size.x), HeightDefault(size.y),
335 msflags, NULL, exStyle);
2bda0e17 336
2d0a075d 337 return TRUE;
2bda0e17
KB
338}
339
42e69d6b
VZ
340// ---------------------------------------------------------------------------
341// basic operations
342// ---------------------------------------------------------------------------
343
fd3f686c 344void wxWindow::SetFocus()
2bda0e17 345{
a23fd0e1 346 HWND hWnd = GetHwnd();
cc2b7472 347 if ( hWnd )
2d0a075d 348 ::SetFocus(hWnd);
2bda0e17
KB
349}
350
42e69d6b
VZ
351// Get the window with the focus
352wxWindow *wxWindowBase::FindFocus()
353{
354 HWND hWnd = ::GetFocus();
355 if ( hWnd )
356 {
357 return wxFindWinFromHandle((WXHWND) hWnd);
358 }
359
360 return NULL;
361}
362
cc2b7472 363bool wxWindow::Enable(bool enable)
2bda0e17 364{
cc2b7472
VZ
365 if ( !wxWindowBase::Enable(enable) )
366 return FALSE;
367
a23fd0e1 368 HWND hWnd = GetHwnd();
cc2b7472 369 if ( hWnd )
2d0a075d 370 ::EnableWindow(hWnd, (BOOL)enable);
cc2b7472
VZ
371
372 return TRUE;
2bda0e17
KB
373}
374
42e69d6b
VZ
375bool wxWindow::Show(bool show)
376{
377 if ( !wxWindowBase::Show(show) )
378 return FALSE;
379
380 HWND hWnd = GetHwnd();
381 int cshow = show ? SW_SHOW : SW_HIDE;
382 ::ShowWindow(hWnd, cshow);
383
384 if ( show )
385 {
386 BringWindowToTop(hWnd);
387 }
388
389 return TRUE;
390}
391
392// Raise the window to the top of the Z order
393void wxWindow::Raise()
394{
395 ::BringWindowToTop(GetHwnd());
396}
397
398// Lower the window to the bottom of the Z order
399void wxWindow::Lower()
400{
401 ::SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0,
402 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
403}
404
405void wxWindow::SetTitle( const wxString& title)
406{
407 SetWindowText(GetHwnd(), title.c_str());
408}
409
410wxString wxWindow::GetTitle() const
411{
412 return wxGetWindowText(GetHWND());
413}
414
fd3f686c 415void wxWindow::CaptureMouse()
2bda0e17 416{
a23fd0e1 417 HWND hWnd = GetHwnd();
cc2b7472 418 if ( hWnd && !m_winCaptured )
2d0a075d
JS
419 {
420 SetCapture(hWnd);
421 m_winCaptured = TRUE;
422 }
2bda0e17
KB
423}
424
fd3f686c 425void wxWindow::ReleaseMouse()
2bda0e17 426{
cc2b7472 427 if ( m_winCaptured )
2d0a075d
JS
428 {
429 ReleaseCapture();
430 m_winCaptured = FALSE;
431 }
2bda0e17
KB
432}
433
42e69d6b 434bool wxWindow::SetFont(const wxFont& font)
2bda0e17 435{
42e69d6b
VZ
436 if ( !wxWindowBase::SetFont(font) )
437 {
438 // nothing to do
439 return FALSE;
2d0a075d 440 }
195896c7 441
42e69d6b
VZ
442 HWND hWnd = GetHwnd();
443 if ( hWnd != 0 )
444 {
445 WXHANDLE hFont = m_font.GetResourceHandle();
2bda0e17 446
42e69d6b 447 wxASSERT_MSG( hFont, _T("should have valid font") );
3a19e16d 448
c50f1fb9 449 ::SendMessage(hWnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
42e69d6b 450 }
2bda0e17 451
42e69d6b
VZ
452 return TRUE;
453}
454bool wxWindow::SetCursor(const wxCursor& cursor)
2bda0e17 455{
42e69d6b
VZ
456 if ( !wxWindowBase::SetCursor(cursor) )
457 {
458 // no change
459 return FALSE;
460 }
461
462 wxASSERT_MSG( m_cursor.Ok(),
463 _T("cursor must be valid after call to the base version"));
464
a23fd0e1 465 HWND hWnd = GetHwnd();
2bda0e17 466
42e69d6b
VZ
467 // Change the cursor NOW if we're within the correct window
468 POINT point;
469 ::GetCursorPos(&point);
3a19e16d 470
42e69d6b
VZ
471 RECT rect;
472 ::GetWindowRect(hWnd, &rect);
cb1a1dc9 473
42e69d6b
VZ
474 if ( ::PtInRect(&rect, point) && !wxIsBusy() )
475 ::SetCursor((HCURSOR)m_cursor.GetHCURSOR());
3a19e16d 476
42e69d6b 477 return TRUE;
3a19e16d
VZ
478}
479
42e69d6b 480void wxWindow::WarpPointer (int x_pos, int y_pos)
2bda0e17 481{
42e69d6b
VZ
482 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
483 // pixel coordinates, relatives to the canvas -- So, we first need to
484 // substract origin of the window, then convert to screen position
485
486 int x = x_pos; int y = y_pos;
2d0a075d 487 RECT rect;
42e69d6b 488 GetWindowRect (GetHwnd(), &rect);
cc2b7472 489
42e69d6b
VZ
490 x += rect.left;
491 y += rect.top;
492
493 SetCursorPos (x, y);
2bda0e17
KB
494}
495
42e69d6b
VZ
496#if WXWIN_COMPATIBILITY
497void wxWindow::MSWDeviceToLogical (float *x, float *y) const
2bda0e17 498{
42e69d6b
VZ
499}
500#endif // WXWIN_COMPATIBILITY
81d66cf3 501
42e69d6b
VZ
502// ---------------------------------------------------------------------------
503// scrolling stuff
504// ---------------------------------------------------------------------------
2d0a075d 505
42e69d6b
VZ
506#if WXWIN_COMPATIBILITY
507void wxWindow::SetScrollRange(int orient, int range, bool refresh)
508{
509#if defined(__WIN95__)
510
511 int range1 = range;
512
513 // Try to adjust the range to cope with page size > 1
514 // - a Windows API quirk
515 int pageSize = GetScrollPage(orient);
516 if ( pageSize > 1 && range > 0)
2d0a075d 517 {
42e69d6b 518 range1 += (pageSize - 1);
2d0a075d
JS
519 }
520
42e69d6b
VZ
521 SCROLLINFO info;
522 int dir;
523
524 if ( orient == wxHORIZONTAL ) {
525 dir = SB_HORZ;
526 } else {
527 dir = SB_VERT;
2d0a075d 528 }
cc2b7472 529
42e69d6b
VZ
530 info.cbSize = sizeof(SCROLLINFO);
531 info.nPage = pageSize; // Have to set this, or scrollbar goes awry
532 info.nMin = 0;
533 info.nMax = range1;
534 info.nPos = 0;
535 info.fMask = SIF_RANGE | SIF_PAGE;
536
537 HWND hWnd = GetHwnd();
538 if ( hWnd )
539 ::SetScrollInfo(hWnd, dir, &info, refresh);
540#else
541 int wOrient;
542 if ( orient == wxHORIZONTAL )
543 wOrient = SB_HORZ;
544 else
545 wOrient = SB_VERT;
546
547 HWND hWnd = GetHwnd();
548 if ( hWnd )
549 ::SetScrollRange(hWnd, wOrient, 0, range, refresh);
550#endif
2bda0e17
KB
551}
552
42e69d6b 553void wxWindow::SetScrollPage(int orient, int page, bool refresh)
2bda0e17 554{
42e69d6b
VZ
555#if defined(__WIN95__)
556 SCROLLINFO info;
557 int dir;
2d0a075d 558
42e69d6b
VZ
559 if ( orient == wxHORIZONTAL ) {
560 dir = SB_HORZ;
561 m_xThumbSize = page;
562 } else {
563 dir = SB_VERT;
564 m_yThumbSize = page;
565 }
0757d27c 566
42e69d6b
VZ
567 info.cbSize = sizeof(SCROLLINFO);
568 info.nPage = page;
569 info.nMin = 0;
570 info.fMask = SIF_PAGE;
571
572 HWND hWnd = GetHwnd();
573 if ( hWnd )
574 ::SetScrollInfo(hWnd, dir, &info, refresh);
575#else
576 if ( orient == wxHORIZONTAL )
577 m_xThumbSize = page;
578 else
579 m_yThumbSize = page;
580#endif
2bda0e17
KB
581}
582
42e69d6b 583int wxWindow::OldGetScrollRange(int orient) const
2bda0e17 584{
42e69d6b
VZ
585 int wOrient;
586 if ( orient == wxHORIZONTAL )
587 wOrient = SB_HORZ;
588 else
589 wOrient = SB_VERT;
2d0a075d 590
42e69d6b
VZ
591#if __WATCOMC__ && defined(__WINDOWS_386__)
592 short minPos, maxPos;
593#else
594 int minPos, maxPos;
595#endif
a23fd0e1 596 HWND hWnd = GetHwnd();
42e69d6b
VZ
597 if ( hWnd )
598 {
599 ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
600#if defined(__WIN95__)
601 // Try to adjust the range to cope with page size > 1
602 // - a Windows API quirk
603 int pageSize = GetScrollPage(orient);
604 if ( pageSize > 1 )
605 {
606 maxPos -= (pageSize - 1);
607 }
608#endif
609 return maxPos;
610 }
611 else
612 return 0;
613}
2bda0e17 614
42e69d6b
VZ
615int wxWindow::GetScrollPage(int orient) const
616{
617 if ( orient == wxHORIZONTAL )
618 return m_xThumbSize;
619 else
620 return m_yThumbSize;
2bda0e17
KB
621}
622
42e69d6b
VZ
623#endif // WXWIN_COMPATIBILITY
624
625int wxWindow::GetScrollPos(int orient) const
2bda0e17 626{
42e69d6b
VZ
627 int wOrient;
628 if ( orient == wxHORIZONTAL )
629 wOrient = SB_HORZ;
630 else
631 wOrient = SB_VERT;
632 HWND hWnd = GetHwnd();
633 if ( hWnd )
2d0a075d 634 {
42e69d6b 635 return ::GetScrollPos(hWnd, wOrient);
cc2b7472 636 }
42e69d6b
VZ
637 else
638 return 0;
639}
2bda0e17 640
42e69d6b
VZ
641// This now returns the whole range, not just the number
642// of positions that we can scroll.
643int wxWindow::GetScrollRange(int orient) const
644{
645 int wOrient;
646 if ( orient == wxHORIZONTAL )
647 wOrient = SB_HORZ;
648 else
649 wOrient = SB_VERT;
2bda0e17 650
42e69d6b
VZ
651#if __WATCOMC__ && defined(__WINDOWS_386__)
652 short minPos, maxPos;
653#else
654 int minPos, maxPos;
655#endif
a23fd0e1 656 HWND hWnd = GetHwnd();
42e69d6b
VZ
657 if ( hWnd )
658 {
659 ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
660#if defined(__WIN95__)
661 // Try to adjust the range to cope with page size > 1
662 // - a Windows API quirk
663 int pageSize = GetScrollThumb(orient);
664 if ( pageSize > 1 )
665 {
666 maxPos -= (pageSize - 1);
667 }
668 // October 10th: new range concept.
669 maxPos += pageSize;
670#endif
2bda0e17 671
42e69d6b
VZ
672 return maxPos;
673 }
674 else
675 return 0;
cc2b7472 676}
2bda0e17 677
42e69d6b 678int wxWindow::GetScrollThumb(int orient) const
2bda0e17 679{
42e69d6b
VZ
680 if ( orient == wxHORIZONTAL )
681 return m_xThumbSize;
682 else
683 return m_yThumbSize;
2bda0e17
KB
684}
685
42e69d6b 686void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
2bda0e17 687{
42e69d6b
VZ
688#if defined(__WIN95__)
689 SCROLLINFO info;
690 int dir;
72fd19a1 691
42e69d6b
VZ
692 if ( orient == wxHORIZONTAL ) {
693 dir = SB_HORZ;
694 } else {
695 dir = SB_VERT;
696 }
2d0a075d 697
42e69d6b
VZ
698 info.cbSize = sizeof(SCROLLINFO);
699 info.nPage = 0;
700 info.nMin = 0;
701 info.nPos = pos;
702 info.fMask = SIF_POS;
2d0a075d 703
42e69d6b
VZ
704 HWND hWnd = GetHwnd();
705 if ( hWnd )
706 ::SetScrollInfo(hWnd, dir, &info, refresh);
707#else
708 int wOrient;
709 if ( orient == wxHORIZONTAL )
710 wOrient = SB_HORZ;
711 else
712 wOrient = SB_VERT;
81d66cf3 713
a23fd0e1 714 HWND hWnd = GetHwnd();
cc2b7472 715 if ( hWnd )
42e69d6b
VZ
716 ::SetScrollPos(hWnd, wOrient, pos, refresh);
717#endif
2bda0e17
KB
718}
719
42e69d6b
VZ
720// New function that will replace some of the above.
721void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
722 int range, bool refresh)
2bda0e17 723{
42e69d6b
VZ
724#if defined(__WIN95__)
725 int oldRange = range - thumbVisible;
2bda0e17 726
42e69d6b 727 int range1 = oldRange;
2bda0e17 728
42e69d6b
VZ
729 // Try to adjust the range to cope with page size > 1
730 // - a Windows API quirk
731 int pageSize = thumbVisible;
732 if ( pageSize > 1 && range > 0)
733 {
734 range1 += (pageSize - 1);
735 }
2bda0e17 736
42e69d6b
VZ
737 SCROLLINFO info;
738 int dir;
2bda0e17 739
42e69d6b
VZ
740 if ( orient == wxHORIZONTAL ) {
741 dir = SB_HORZ;
742 } else {
743 dir = SB_VERT;
2d0a075d 744 }
2bda0e17 745
42e69d6b
VZ
746 info.cbSize = sizeof(SCROLLINFO);
747 info.nPage = pageSize; // Have to set this, or scrollbar goes awry
748 info.nMin = 0;
749 info.nMax = range1;
750 info.nPos = pos;
751 info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
2bda0e17 752
42e69d6b
VZ
753 HWND hWnd = GetHwnd();
754 if ( hWnd )
755 ::SetScrollInfo(hWnd, dir, &info, refresh);
756#else
757 int wOrient;
758 if ( orient == wxHORIZONTAL )
759 wOrient = SB_HORZ;
760 else
761 wOrient = SB_VERT;
81d66cf3 762
42e69d6b
VZ
763 HWND hWnd = GetHwnd();
764 if ( hWnd )
81d66cf3 765 {
42e69d6b
VZ
766 ::SetScrollRange(hWnd, wOrient, 0, range, FALSE);
767 ::SetScrollPos(hWnd, wOrient, pos, refresh);
768 }
769#endif
770 if ( orient == wxHORIZONTAL ) {
771 m_xThumbSize = thumbVisible;
772 } else {
773 m_yThumbSize = thumbVisible;
81d66cf3
JS
774 }
775}
776
42e69d6b 777void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
2bda0e17 778{
42e69d6b
VZ
779 RECT rect2;
780 if ( rect )
2d0a075d 781 {
42e69d6b
VZ
782 rect2.left = rect->x;
783 rect2.top = rect->y;
784 rect2.right = rect->x + rect->width;
785 rect2.bottom = rect->y + rect->height;
2d0a075d 786 }
2bda0e17 787
42e69d6b
VZ
788 if ( rect )
789 ::ScrollWindow(GetHwnd(), dx, dy, &rect2, NULL);
790 else
791 ::ScrollWindow(GetHwnd(), dx, dy, NULL, NULL);
2bda0e17
KB
792}
793
42e69d6b
VZ
794// ---------------------------------------------------------------------------
795// subclassing
796// ---------------------------------------------------------------------------
797
798void wxWindow::SubclassWin(WXHWND hWnd)
2bda0e17 799{
837e5743 800 wxASSERT_MSG( !m_oldWndProc, _T("subclassing window twice?") );
2bda0e17 801
c50f1fb9
VZ
802 HWND hwnd = (HWND)hWnd;
803 wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in SubclassWin") );
804
805 wxAssociateWinWithHandle(hwnd, this);
2bda0e17 806
c50f1fb9
VZ
807 m_oldWndProc = (WXFARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
808 SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
2bda0e17
KB
809}
810
42e69d6b 811void wxWindow::UnsubclassWin()
2bda0e17 812{
42e69d6b 813 wxRemoveHandleAssociation(this);
2bda0e17 814
42e69d6b 815 // Restore old Window proc
c50f1fb9
VZ
816 HWND hwnd = GetHwnd();
817 if ( hwnd )
42e69d6b 818 {
c50f1fb9
VZ
819 m_hWnd = 0;
820
821 wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in SubclassWin") );
822
823 FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
42e69d6b
VZ
824 if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
825 {
c50f1fb9 826 SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc);
42e69d6b
VZ
827 m_oldWndProc = 0;
828 }
42e69d6b 829 }
2bda0e17
KB
830}
831
42e69d6b
VZ
832// Make a Windows extended style from the given wxWindows window style
833WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
2bda0e17 834{
42e69d6b
VZ
835 WXDWORD exStyle = 0;
836 if ( style & wxTRANSPARENT_WINDOW )
837 exStyle |= WS_EX_TRANSPARENT;
2bda0e17 838
42e69d6b 839 if ( !eliminateBorders )
2d0a075d 840 {
42e69d6b
VZ
841 if ( style & wxSUNKEN_BORDER )
842 exStyle |= WS_EX_CLIENTEDGE;
843 if ( style & wxDOUBLE_BORDER )
844 exStyle |= WS_EX_DLGMODALFRAME;
845#if defined(__WIN95__)
846 if ( style & wxRAISED_BORDER )
847 exStyle |= WS_EX_WINDOWEDGE;
848 if ( style & wxSTATIC_BORDER )
849 exStyle |= WS_EX_STATICEDGE;
850#endif
2d0a075d 851 }
42e69d6b 852 return exStyle;
2bda0e17
KB
853}
854
42e69d6b
VZ
855// Determines whether native 3D effects or CTL3D should be used,
856// applying a default border style if required, and returning an extended
857// style to pass to CreateWindowEx.
858WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
2bda0e17 859{
42e69d6b
VZ
860 // If matches certain criteria, then assume no 3D effects
861 // unless specifically requested (dealt with in MakeExtendedStyle)
862 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
2bda0e17 863 {
42e69d6b
VZ
864 *want3D = FALSE;
865 return MakeExtendedStyle(m_windowStyle, FALSE);
2bda0e17 866 }
2bda0e17 867
42e69d6b
VZ
868 // Determine whether we should be using 3D effects or not.
869 bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
a02eb1d2 870
42e69d6b
VZ
871 // 1) App can specify global 3D effects
872 *want3D = wxTheApp->GetAuto3D();
2bda0e17 873
42e69d6b
VZ
874 // 2) If the parent is being drawn with user colours, or simple border specified,
875 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
876 if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER) )
877 *want3D = FALSE;
a23fd0e1 878
42e69d6b
VZ
879 // 3) Control can override this global setting by defining
880 // a border style, e.g. wxSUNKEN_BORDER
881 if ( m_windowStyle & wxSUNKEN_BORDER )
882 *want3D = TRUE;
2bda0e17 883
42e69d6b
VZ
884 // 4) If it's a special border, CTL3D can't cope so we want a native border
885 if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
886 (m_windowStyle & wxSTATIC_BORDER) )
2d0a075d 887 {
42e69d6b
VZ
888 *want3D = TRUE;
889 nativeBorder = TRUE;
2d0a075d 890 }
ea57084d 891
42e69d6b
VZ
892 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
893 // effects from extended style
894#if wxUSE_CTL3D
895 if ( *want3D )
896 nativeBorder = FALSE;
897#endif
a23fd0e1 898
42e69d6b 899 DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
2bda0e17 900
42e69d6b
VZ
901 // If we want 3D, but haven't specified a border here,
902 // apply the default border style specified.
903 // TODO what about non-Win95 WIN32? Does it have borders?
904#if defined(__WIN95__) && !wxUSE_CTL3D
905 if ( defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
906 (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
907 exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE;
908#endif
909
910 return exStyle;
a23fd0e1 911}
2bda0e17 912
c455ab93 913#if WXWIN_COMPATIBILITY
42e69d6b
VZ
914// If nothing defined for this, try the parent.
915// E.g. we may be a button loaded from a resource, with no callback function
916// defined.
917void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
2bda0e17 918{
42e69d6b
VZ
919 if ( GetEventHandler()->ProcessEvent(event) )
920 return;
921 if ( m_parent )
922 m_parent->GetEventHandler()->OnCommand(win, event);
923}
924#endif // WXWIN_COMPATIBILITY_2
c085e333 925
42e69d6b
VZ
926#if WXWIN_COMPATIBILITY
927wxObject* wxWindow::GetChild(int number) const
928{
929 // Return a pointer to the Nth object in the Panel
930 wxNode *node = GetChildren().First();
931 int n = number;
932 while (node && n--)
933 node = node->Next();
934 if ( node )
935 {
936 wxObject *obj = (wxObject *)node->Data();
937 return(obj);
938 }
939 else
940 return NULL;
941}
942#endif // WXWIN_COMPATIBILITY
2bda0e17 943
42e69d6b
VZ
944// Setup background and foreground colours correctly
945void wxWindow::SetupColours()
946{
947 if ( GetParent() )
948 SetBackgroundColour(GetParent()->GetBackgroundColour());
949}
a23fd0e1 950
42e69d6b
VZ
951void wxWindow::OnIdle(wxIdleEvent& event)
952{
953 // Check if we need to send a LEAVE event
954 if ( m_mouseInWindow )
2d0a075d 955 {
42e69d6b
VZ
956 POINT pt;
957 ::GetCursorPos(&pt);
958 if ( ::WindowFromPoint(pt) != GetHwnd() )
959 {
960 // Generate a LEAVE event
961 m_mouseInWindow = FALSE;
2bda0e17 962
42e69d6b
VZ
963 // Unfortunately the mouse button and keyboard state may have changed
964 // by the time the OnIdle function is called, so 'state' may be
965 // meaningless.
966 int state = 0;
967 if ( ::GetKeyState(VK_SHIFT) != 0 )
968 state |= MK_SHIFT;
969 if ( ::GetKeyState(VK_CONTROL) != 0 )
970 state |= MK_CONTROL;
a23fd0e1 971
42e69d6b
VZ
972 wxMouseEvent event(wxEVT_LEAVE_WINDOW);
973 InitMouseEvent(event, pt.x, pt.y, state);
c085e333 974
42e69d6b
VZ
975 (void)GetEventHandler()->ProcessEvent(event);
976 }
977 }
c085e333 978
42e69d6b
VZ
979 UpdateWindowUI();
980}
568cb543 981
42e69d6b
VZ
982// Set this window to be the child of 'parent'.
983bool wxWindow::Reparent(wxWindow *parent)
984{
985 if ( !wxWindowBase::Reparent(parent) )
986 return FALSE;
c085e333 987
42e69d6b
VZ
988 HWND hWndChild = GetHwnd();
989 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
a23fd0e1 990
42e69d6b 991 ::SetParent(hWndChild, hWndParent);
a23fd0e1 992
42e69d6b
VZ
993 return TRUE;
994}
a23fd0e1 995
42e69d6b
VZ
996void wxWindow::Clear()
997{
998 wxClientDC dc(this);
999 wxBrush brush(GetBackgroundColour(), wxSOLID);
1000 dc.SetBackground(brush);
1001 dc.Clear();
1002}
a23fd0e1 1003
42e69d6b
VZ
1004void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
1005{
1006 HWND hWnd = GetHwnd();
1007 if ( hWnd )
1008 {
1009 if ( rect )
1010 {
1011 RECT mswRect;
1012 mswRect.left = rect->x;
1013 mswRect.top = rect->y;
1014 mswRect.right = rect->x + rect->width;
1015 mswRect.bottom = rect->y + rect->height;
a23fd0e1 1016
42e69d6b
VZ
1017 ::InvalidateRect(hWnd, &mswRect, eraseBack);
1018 }
1019 else
1020 ::InvalidateRect(hWnd, NULL, eraseBack);
1021 }
1022}
a23fd0e1 1023
42e69d6b
VZ
1024// ---------------------------------------------------------------------------
1025// drag and drop
1026// ---------------------------------------------------------------------------
a23fd0e1 1027
34636400 1028#if wxUSE_DRAG_AND_DROP
a23fd0e1 1029
42e69d6b
VZ
1030void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
1031{
1032 if ( m_dropTarget != 0 ) {
1033 m_dropTarget->Revoke(m_hWnd);
1034 delete m_dropTarget;
1035 }
a23fd0e1 1036
42e69d6b
VZ
1037 m_dropTarget = pDropTarget;
1038 if ( m_dropTarget != 0 )
1039 m_dropTarget->Register(m_hWnd);
1040}
a23fd0e1 1041
42e69d6b 1042#endif // wxUSE_DRAG_AND_DROP
2a47d3c1 1043
42e69d6b
VZ
1044// old style file-manager drag&drop support: we retain the old-style
1045// DragAcceptFiles in parallel with SetDropTarget.
1046void wxWindow::DragAcceptFiles(bool accept)
1047{
1048 HWND hWnd = GetHwnd();
1049 if ( hWnd )
1050 ::DragAcceptFiles(hWnd, (BOOL)accept);
1051}
a23fd0e1 1052
42e69d6b
VZ
1053// ----------------------------------------------------------------------------
1054// tooltips
1055// ----------------------------------------------------------------------------
dbda9e86 1056
42e69d6b 1057#if wxUSE_TOOLTIPS
2d0a075d 1058
42e69d6b
VZ
1059void wxWindow::DoSetToolTip(wxToolTip *tooltip)
1060{
1061 wxWindowBase::DoSetToolTip(tooltip);
839b865d 1062
42e69d6b
VZ
1063 if ( m_tooltip )
1064 m_tooltip->SetWindow(this);
1065}
9a05fd8d 1066
42e69d6b 1067#endif // wxUSE_TOOLTIPS
9a05fd8d 1068
42e69d6b
VZ
1069// ---------------------------------------------------------------------------
1070// moving and resizing
1071// ---------------------------------------------------------------------------
839b865d 1072
42e69d6b
VZ
1073// Get total size
1074void wxWindow::DoGetSize(int *x, int *y) const
1075{
1076 HWND hWnd = GetHwnd();
1077 RECT rect;
1078 GetWindowRect(hWnd, &rect);
1079
1080 if ( x )
1081 *x = rect.right - rect.left;
1082 if ( y )
1083 *y = rect.bottom - rect.top;
1084}
1085
1086void wxWindow::DoGetPosition(int *x, int *y) const
1087{
1088 HWND hWnd = GetHwnd();
42e69d6b
VZ
1089
1090 RECT rect;
1091 GetWindowRect(hWnd, &rect);
1092
42e69d6b
VZ
1093 POINT point;
1094 point.x = rect.left;
1095 point.y = rect.top;
42e69d6b 1096
92049cd4
VZ
1097 // we do the adjustments with respect to the parent only for the "real"
1098 // children, not for the dialogs/frames
1099 if ( !IsTopLevel() )
42e69d6b 1100 {
92049cd4
VZ
1101 HWND hParentWnd = 0;
1102 wxWindow *parent = GetParent();
1103 if ( parent )
1104 hParentWnd = GetWinHwnd(parent);
1105
1106 // Since we now have the absolute screen coords, if there's a parent we
1107 // must subtract its top left corner
1108 if ( hParentWnd )
1109 {
1110 ::ScreenToClient(hParentWnd, &point);
1111 }
1112
1113 // We may be faking the client origin. So a window that's really at (0,
1114 // 30) may appear (to wxWin apps) to be at (0, 0).
1115 if ( parent )
1116 {
1117 wxPoint pt(parent->GetClientAreaOrigin());
1118 point.x -= pt.x;
1119 point.y -= pt.y;
1120 }
42e69d6b
VZ
1121 }
1122
1123 if ( x )
1124 *x = point.x;
1125 if ( y )
1126 *y = point.y;
1127}
54bdd8b0 1128
dabc0cd5 1129void wxWindow::DoScreenToClient(int *x, int *y) const
42e69d6b
VZ
1130{
1131 POINT pt;
1132 if ( x )
1133 pt.x = *x;
1134 if ( y )
1135 pt.y = *y;
54bdd8b0 1136
42e69d6b
VZ
1137 HWND hWnd = GetHwnd();
1138 ::ScreenToClient(hWnd, &pt);
a23fd0e1 1139
42e69d6b
VZ
1140 if ( x )
1141 *x = pt.x;
1142 if ( y )
1143 *y = pt.y;
1144}
a23fd0e1 1145
dabc0cd5 1146void wxWindow::DoClientToScreen(int *x, int *y) const
42e69d6b
VZ
1147{
1148 POINT pt;
1149 if ( x )
1150 pt.x = *x;
1151 if ( y )
1152 pt.y = *y;
54bdd8b0 1153
42e69d6b
VZ
1154 HWND hWnd = GetHwnd();
1155 ::ClientToScreen(hWnd, &pt);
a23fd0e1 1156
42e69d6b
VZ
1157 if ( x )
1158 *x = pt.x;
1159 if ( y )
1160 *y = pt.y;
1161}
a23fd0e1 1162
42e69d6b
VZ
1163// Get size *available for subwindows* i.e. excluding menu bar etc.
1164void wxWindow::DoGetClientSize(int *x, int *y) const
1165{
1166 HWND hWnd = GetHwnd();
1167 RECT rect;
1168 ::GetClientRect(hWnd, &rect);
1169 if ( x )
1170 *x = rect.right;
1171 if ( y )
1172 *y = rect.bottom;
1173}
a23fd0e1 1174
42e69d6b
VZ
1175void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
1176{
1177 int currentX, currentY;
1178 GetPosition(&currentX, &currentY);
1179 int currentW,currentH;
1180 GetSize(&currentW, &currentH);
a23fd0e1 1181
42e69d6b
VZ
1182 if ( x == currentX && y == currentY && width == currentW && height == currentH )
1183 return;
a23fd0e1 1184
42e69d6b
VZ
1185 int actualWidth = width;
1186 int actualHeight = height;
1187 int actualX = x;
1188 int actualY = y;
1189 if ( x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
1190 actualX = currentX;
1191 if ( y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
1192 actualY = currentY;
a23fd0e1 1193
42e69d6b 1194 AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
a23fd0e1 1195
42e69d6b
VZ
1196 if ( width == -1 )
1197 actualWidth = currentW;
1198 if ( height == -1 )
1199 actualHeight = currentH;
a23fd0e1 1200
42e69d6b
VZ
1201 HWND hWnd = GetHwnd();
1202 if ( hWnd )
1203 MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE);
1204}
a23fd0e1 1205
42e69d6b
VZ
1206void wxWindow::DoSetClientSize(int width, int height)
1207{
1208 wxWindow *parent = GetParent();
1209 HWND hWnd = GetHwnd();
1210 HWND hParentWnd = (HWND) 0;
1211 if ( parent )
1212 hParentWnd = (HWND) parent->GetHWND();
2bda0e17 1213
42e69d6b
VZ
1214 RECT rect;
1215 ::GetClientRect(hWnd, &rect);
a23fd0e1 1216
42e69d6b
VZ
1217 RECT rect2;
1218 GetWindowRect(hWnd, &rect2);
a23fd0e1 1219
42e69d6b
VZ
1220 // Find the difference between the entire window (title bar and all)
1221 // and the client area; add this to the new client size to move the
1222 // window
1223 int actual_width = rect2.right - rect2.left - rect.right + width;
1224 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
a23fd0e1 1225
42e69d6b
VZ
1226 // If there's a parent, must subtract the parent's top left corner
1227 // since MoveWindow moves relative to the parent
a23fd0e1 1228
42e69d6b
VZ
1229 POINT point;
1230 point.x = rect2.left;
1231 point.y = rect2.top;
1232 if ( parent )
1233 {
1234 ::ScreenToClient(hParentWnd, &point);
1235 }
387a3b02 1236
42e69d6b 1237 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
a23fd0e1 1238
42e69d6b
VZ
1239 wxSizeEvent event(wxSize(width, height), m_windowId);
1240 event.SetEventObject(this);
1241 GetEventHandler()->ProcessEvent(event);
1242}
a23fd0e1 1243
42e69d6b
VZ
1244// For implementation purposes - sometimes decorations make the client area
1245// smaller
1246wxPoint wxWindow::GetClientAreaOrigin() const
1247{
1248 return wxPoint(0, 0);
1249}
a23fd0e1 1250
42e69d6b
VZ
1251// Makes an adjustment to the window position (for example, a frame that has
1252// a toolbar that it manages itself).
1253void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
1254{
92049cd4
VZ
1255 // don't do it for the dialogs/frames - they float independently of their
1256 // parent
1257 if ( !IsTopLevel() )
42e69d6b 1258 {
92049cd4
VZ
1259 wxWindow *parent = GetParent();
1260 if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
1261 {
1262 wxPoint pt(parent->GetClientAreaOrigin());
1263 x += pt.x; y += pt.y;
1264 }
42e69d6b
VZ
1265 }
1266}
a23fd0e1 1267
42e69d6b
VZ
1268// ---------------------------------------------------------------------------
1269// text metrics
1270// ---------------------------------------------------------------------------
a23fd0e1 1271
42e69d6b
VZ
1272int wxWindow::GetCharHeight() const
1273{
1274 TEXTMETRIC lpTextMetric;
1275 HWND hWnd = GetHwnd();
1276 HDC dc = ::GetDC(hWnd);
a23fd0e1 1277
42e69d6b
VZ
1278 GetTextMetrics(dc, &lpTextMetric);
1279 ::ReleaseDC(hWnd, dc);
3eddf563 1280
42e69d6b
VZ
1281 return lpTextMetric.tmHeight;
1282}
3eddf563 1283
42e69d6b
VZ
1284int wxWindow::GetCharWidth() const
1285{
1286 TEXTMETRIC lpTextMetric;
1287 HWND hWnd = GetHwnd();
1288 HDC dc = ::GetDC(hWnd);
3eddf563 1289
42e69d6b
VZ
1290 GetTextMetrics(dc, &lpTextMetric);
1291 ::ReleaseDC(hWnd, dc);
3eddf563 1292
42e69d6b
VZ
1293 return lpTextMetric.tmAveCharWidth;
1294}
f4621a09 1295
34636400
VZ
1296void wxWindow::GetTextExtent(const wxString& string,
1297 int *x, int *y,
42e69d6b
VZ
1298 int *descent, int *externalLeading,
1299 const wxFont *theFont) const
1300{
1301 const wxFont *fontToUse = theFont;
1302 if ( !fontToUse )
1303 fontToUse = &m_font;
634903fd 1304
42e69d6b
VZ
1305 HWND hWnd = GetHwnd();
1306 HDC dc = ::GetDC(hWnd);
634903fd 1307
42e69d6b
VZ
1308 HFONT fnt = 0;
1309 HFONT hfontOld = 0;
1310 if ( fontToUse && fontToUse->Ok() )
1311 {
1312 fnt = (HFONT)((wxFont *)fontToUse)->GetResourceHandle(); // const_cast
1313 if ( fnt )
1314 hfontOld = (HFONT)SelectObject(dc,fnt);
2bda0e17 1315 }
341c92a8 1316
42e69d6b
VZ
1317 SIZE sizeRect;
1318 TEXTMETRIC tm;
837e5743 1319 GetTextExtentPoint(dc, (const wxChar *)string, (int)string.Length(), &sizeRect);
42e69d6b
VZ
1320 GetTextMetrics(dc, &tm);
1321
1322 if ( fontToUse && fnt && hfontOld )
1323 SelectObject(dc, hfontOld);
1324
1325 ReleaseDC(hWnd, dc);
1326
1327 if ( x ) *x = sizeRect.cx;
1328 if ( y ) *y = sizeRect.cy;
1329 if ( descent ) *descent = tm.tmDescent;
1330 if ( externalLeading ) *externalLeading = tm.tmExternalLeading;
2bda0e17
KB
1331}
1332
c455ab93 1333#if wxUSE_CARET && WXWIN_COMPATIBILITY
42e69d6b
VZ
1334// ---------------------------------------------------------------------------
1335// Caret manipulation
1336// ---------------------------------------------------------------------------
1337
1338void wxWindow::CreateCaret(int w, int h)
2bda0e17 1339{
789295bf 1340 SetCaret(new wxCaret(this, w, h));
2bda0e17
KB
1341}
1342
42e69d6b 1343void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
2bda0e17 1344{
789295bf 1345 wxFAIL_MSG("not implemented");
2bda0e17
KB
1346}
1347
42e69d6b 1348void wxWindow::ShowCaret(bool show)
2bda0e17 1349{
789295bf
VZ
1350 wxCHECK_RET( m_caret, "no caret to show" );
1351
1352 m_caret->Show(show);
2bda0e17
KB
1353}
1354
42e69d6b 1355void wxWindow::DestroyCaret()
2bda0e17 1356{
789295bf 1357 SetCaret(NULL);
2bda0e17
KB
1358}
1359
42e69d6b 1360void wxWindow::SetCaretPos(int x, int y)
2bda0e17 1361{
789295bf
VZ
1362 wxCHECK_RET( m_caret, "no caret to move" );
1363
1364 m_caret->Move(x, y);
2bda0e17
KB
1365}
1366
42e69d6b 1367void wxWindow::GetCaretPos(int *x, int *y) const
2d0a075d 1368{
789295bf
VZ
1369 wxCHECK_RET( m_caret, "no caret to get position of" );
1370
1371 m_caret->GetPosition(x, y);
42e69d6b 1372}
789295bf 1373#endif // wxUSE_CARET
2bda0e17 1374
c50f1fb9
VZ
1375// ---------------------------------------------------------------------------
1376// popup menu
1377// ---------------------------------------------------------------------------
1378
1379bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
1380{
1381 menu->SetInvokingWindow(this);
1382 menu->UpdateUI();
1383
1384 HWND hWnd = GetHwnd();
1385 HMENU hMenu = GetHmenuOf(menu);
1386 POINT point;
1387 point.x = x;
1388 point.y = y;
1389 ::ClientToScreen(hWnd, &point);
1390 wxCurrentPopupMenu = menu;
1391 ::TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL);
1392 wxYield();
1393 wxCurrentPopupMenu = NULL;
1394
1395 menu->SetInvokingWindow(NULL);
1396
1397 return TRUE;
1398}
1399
42e69d6b
VZ
1400// ===========================================================================
1401// pre/post message processing
1402// ===========================================================================
2bda0e17 1403
42e69d6b
VZ
1404long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
1405{
1406 if ( m_oldWndProc )
1407 return ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
1408 else
1409 return ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
1410}
2bda0e17 1411
42e69d6b
VZ
1412bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
1413{
1414 if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) )
2d0a075d 1415 {
42e69d6b
VZ
1416 // intercept dialog navigation keys
1417 MSG *msg = (MSG *)pMsg;
1418 bool bProcess = TRUE;
1419 if ( msg->message != WM_KEYDOWN )
1420 bProcess = FALSE;
c085e333 1421
42e69d6b
VZ
1422 if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
1423 bProcess = FALSE;
a23fd0e1 1424
42e69d6b
VZ
1425 if ( bProcess )
1426 {
1427 bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
319fefa9 1428 bool bShiftDown = (::GetKeyState(VK_SHIFT) & 0x100) != 0;
a23fd0e1 1429
42e69d6b
VZ
1430 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1431 // don't process it if it's the case (except for Ctrl-Tab/Enter
1432 // combinations which are always processed)
1433 LONG lDlgCode = 0;
1434 if ( !bCtrlDown )
1435 {
1436 lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
1437 }
a23fd0e1 1438
42e69d6b
VZ
1439 bool bForward = TRUE,
1440 bWindowChange = FALSE;
a23fd0e1 1441
9145664b 1442 switch ( msg->wParam )
42e69d6b
VZ
1443 {
1444 case VK_TAB:
319fefa9
VZ
1445 // assume that nobody wants Shift-TAB for himself - if we
1446 // don't do it there is no easy way for a control to grab
1447 // TABs but still let Shift-TAB work as navugation key
1448 if ( (lDlgCode & DLGC_WANTTAB) && !bShiftDown ) {
42e69d6b
VZ
1449 bProcess = FALSE;
1450 }
1451 else {
1452 // Ctrl-Tab cycles thru notebook pages
1453 bWindowChange = bCtrlDown;
319fefa9 1454 bForward = !bShiftDown;
42e69d6b
VZ
1455 }
1456 break;
a23fd0e1 1457
42e69d6b
VZ
1458 case VK_UP:
1459 case VK_LEFT:
1460 if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown )
1461 bProcess = FALSE;
1462 else
1463 bForward = FALSE;
1464 break;
a02eb1d2 1465
42e69d6b
VZ
1466 case VK_DOWN:
1467 case VK_RIGHT:
1468 if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown )
1469 bProcess = FALSE;
1470 break;
2bda0e17 1471
42e69d6b
VZ
1472 case VK_RETURN:
1473 {
edccf428 1474 if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
42e69d6b
VZ
1475 {
1476 // control wants to process Enter itself, don't
1477 // call IsDialogMessage() which would interpret
1478 // it
1479 return FALSE;
1480 }
319fefa9
VZ
1481 else if ( lDlgCode & DLGC_BUTTON )
1482 {
1483 // buttons want process Enter themselevs
1484 bProcess = FALSE;
1485 }
c50f1fb9
VZ
1486 else
1487 {
1488 wxPanel *panel = wxDynamicCast(this, wxPanel);
1489 wxButton *btn = NULL;
1490 if ( panel )
1491 {
1492 // panel may have a default button which should
1493 // be activated by Enter
1494 btn = panel->GetDefaultItem();
1495 }
1496
1497 if ( btn )
1498 {
1499 // if we do have a default button, do press it
1500 btn->MSWCommand(BN_CLICKED, 0 /* unused */);
1501
1502 return TRUE;
1503 }
1504 // else: but if it does not it makes sense to make
1505 // it work like a TAB - and that's what we do.
1506 // Note that Ctrl-Enter always works this way.
1507 }
42e69d6b
VZ
1508 }
1509 break;
2bda0e17 1510
42e69d6b
VZ
1511 default:
1512 bProcess = FALSE;
1513 }
2bda0e17 1514
42e69d6b
VZ
1515 if ( bProcess )
1516 {
1517 wxNavigationKeyEvent event;
1518 event.SetDirection(bForward);
1519 event.SetWindowChange(bWindowChange);
1520 event.SetEventObject(this);
3572173c 1521
42e69d6b 1522 if ( GetEventHandler()->ProcessEvent(event) )
57c0af52
VZ
1523 {
1524 wxButton *btn = wxDynamicCast(FindFocus(), wxButton);
1525 if ( btn )
1526 {
1527 // the button which has focus should be default
1528 btn->SetDefault();
1529 }
1530
42e69d6b 1531 return TRUE;
57c0af52 1532 }
42e69d6b
VZ
1533 }
1534 }
a23fd0e1 1535
42e69d6b
VZ
1536 if ( ::IsDialogMessage(GetHwnd(), msg) )
1537 return TRUE;
1538 }
a23fd0e1 1539
42e69d6b
VZ
1540#if wxUSE_TOOLTIPS
1541 if ( m_tooltip )
387a3b02 1542 {
42e69d6b
VZ
1543 // relay mouse move events to the tooltip control
1544 MSG *msg = (MSG *)pMsg;
1545 if ( msg->message == WM_MOUSEMOVE )
1546 m_tooltip->RelayEvent(pMsg);
387a3b02 1547 }
42e69d6b 1548#endif // wxUSE_TOOLTIPS
a23fd0e1 1549
42e69d6b 1550 return FALSE;
387a3b02
JS
1551}
1552
42e69d6b 1553bool wxWindow::MSWTranslateMessage(WXMSG* pMsg)
387a3b02 1554{
c50f1fb9 1555 return m_acceleratorTable.Translate(this, pMsg);
387a3b02
JS
1556}
1557
42e69d6b
VZ
1558// ---------------------------------------------------------------------------
1559// message params unpackers (different for Win16 and Win32)
1560// ---------------------------------------------------------------------------
2bda0e17 1561
42e69d6b 1562#ifdef __WIN32__
c085e333 1563
42e69d6b
VZ
1564void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
1565 WORD *id, WXHWND *hwnd, WORD *cmd)
1566{
1567 *id = LOWORD(wParam);
1568 *hwnd = (WXHWND)lParam;
1569 *cmd = HIWORD(wParam);
2bda0e17
KB
1570}
1571
42e69d6b
VZ
1572void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
1573 WXWORD *state, WXWORD *minimized, WXHWND *hwnd)
2bda0e17 1574{
42e69d6b
VZ
1575 *state = LOWORD(wParam);
1576 *minimized = HIWORD(wParam);
1577 *hwnd = (WXHWND)lParam;
2bda0e17
KB
1578}
1579
42e69d6b
VZ
1580void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
1581 WXWORD *code, WXWORD *pos, WXHWND *hwnd)
2bda0e17 1582{
42e69d6b
VZ
1583 *code = LOWORD(wParam);
1584 *pos = HIWORD(wParam);
1585 *hwnd = (WXHWND)lParam;
1586}
a23fd0e1 1587
42e69d6b
VZ
1588void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
1589 WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
1590{
1591 *nCtlColor = CTLCOLOR_BTN;
1592 *hwnd = (WXHWND)lParam;
1593 *hdc = (WXHDC)wParam;
2bda0e17
KB
1594}
1595
42e69d6b
VZ
1596void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
1597 WXWORD *item, WXWORD *flags, WXHMENU *hmenu)
2bda0e17 1598{
42e69d6b
VZ
1599 *item = (WXWORD)wParam;
1600 *flags = HIWORD(wParam);
1601 *hmenu = (WXHMENU)lParam;
1602}
c085e333 1603
42e69d6b 1604#else // Win16
341c92a8 1605
42e69d6b
VZ
1606void wxWindow::UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
1607 WXWORD *id, WXHWND *hwnd, WXWORD *cmd)
1608{
1609 *id = (WXWORD)wParam;
1610 *hwnd = (WXHWND)LOWORD(lParam);
1611 *cmd = HIWORD(lParam);
2bda0e17
KB
1612}
1613
42e69d6b
VZ
1614void wxWindow::UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
1615 WXWORD *state, WXWORD *minimized, WXHWND *hwnd)
2bda0e17 1616{
42e69d6b
VZ
1617 *state = (WXWORD)wParam;
1618 *minimized = LOWORD(lParam);
1619 *hwnd = (WXHWND)HIWORD(lParam);
2bda0e17
KB
1620}
1621
42e69d6b
VZ
1622void wxWindow::UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
1623 WXWORD *code, WXWORD *pos, WXHWND *hwnd)
2bda0e17 1624{
42e69d6b
VZ
1625 *code = (WXWORD)wParam;
1626 *pos = LOWORD(lParam);
1627 *hwnd = (WXHWND)HIWORD(lParam);
1628}
c085e333 1629
42e69d6b
VZ
1630void wxWindow::UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
1631 WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd)
1632{
25889d3c 1633 *hwnd = (WXHWND)LOWORD(lParam);
42e69d6b
VZ
1634 *nCtlColor = (int)HIWORD(lParam);
1635 *hdc = (WXHDC)wParam;
2bda0e17
KB
1636}
1637
42e69d6b
VZ
1638void wxWindow::UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
1639 WXWORD *item, WXWORD *flags, WXHMENU *hmenu)
2bda0e17 1640{
42e69d6b
VZ
1641 *item = (WXWORD)wParam;
1642 *flags = LOWORD(lParam);
1643 *hmenu = (WXHMENU)HIWORD(lParam);
1644}
2d0a075d 1645
42e69d6b 1646#endif // Win32/16
c085e333 1647
42e69d6b
VZ
1648// ---------------------------------------------------------------------------
1649// Main wxWindows window proc and the window proc for wxWindow
1650// ---------------------------------------------------------------------------
2bda0e17 1651
42e69d6b
VZ
1652// Hook for new window just as it's being created, when the window isn't yet
1653// associated with the handle
1654wxWindow *wxWndHook = NULL;
1655
1656// Main window proc
1657LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
2bda0e17 1658{
42e69d6b
VZ
1659 // trace all messages - useful for the debugging
1660#ifdef __WXDEBUG__
837e5743 1661 wxLogTrace(wxTraceMessages, _T("Processing %s(wParam=%8lx, lParam=%8lx)"),
42e69d6b
VZ
1662 wxGetMessageName(message), wParam, lParam);
1663#endif // __WXDEBUG__
2bda0e17 1664
42e69d6b 1665 wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
c085e333 1666
42e69d6b
VZ
1667 // when we get the first message for the HWND we just created, we associate
1668 // it with wxWindow stored in wxWndHook
1669 if ( !wnd && wxWndHook )
2d0a075d 1670 {
42e69d6b
VZ
1671 wxAssociateWinWithHandle(hWnd, wxWndHook);
1672 wnd = wxWndHook;
1673 wxWndHook = NULL;
1674 wnd->SetHWND((WXHWND)hWnd);
2d0a075d 1675 }
2bda0e17 1676
42e69d6b 1677 LRESULT rc;
a23fd0e1 1678
42e69d6b
VZ
1679 // Stop right here if we don't have a valid handle in our wxWindow object.
1680 if ( wnd && !wnd->GetHWND() )
2d0a075d 1681 {
42e69d6b
VZ
1682 // FIXME: why do we do this?
1683 wnd->SetHWND((WXHWND) hWnd);
1684 rc = wnd->MSWDefWindowProc(message, wParam, lParam );
1685 wnd->SetHWND(0);
a23fd0e1
VZ
1686 }
1687 else
1688 {
42e69d6b
VZ
1689 if ( wnd )
1690 rc = wnd->MSWWindowProc(message, wParam, lParam);
1691 else
1692 rc = DefWindowProc( hWnd, message, wParam, lParam );
2d0a075d 1693 }
2bda0e17 1694
42e69d6b 1695 return rc;
f7bd2698
JS
1696}
1697
42e69d6b 1698long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
f7bd2698 1699{
42e69d6b
VZ
1700 // did we process the message?
1701 bool processed = FALSE;
f7bd2698 1702
42e69d6b
VZ
1703 // the return value
1704 union
2bda0e17 1705 {
42e69d6b
VZ
1706 bool allow;
1707 long result;
1708 WXHICON hIcon;
1709 WXHBRUSH hBrush;
1710 } rc;
2bda0e17 1711
42e69d6b
VZ
1712 // for most messages we should return 0 when we do process the message
1713 rc.result = 0;
2bda0e17 1714
42e69d6b 1715 switch ( message )
39136494 1716 {
42e69d6b
VZ
1717 case WM_CREATE:
1718 {
1719 bool mayCreate;
1720 processed = HandleCreate((WXLPCREATESTRUCT)lParam, &mayCreate);
1721 if ( processed )
1722 {
1723 // return 0 to allow window creation
1724 rc.result = mayCreate ? 0 : -1;
1725 }
1726 }
1727 break;
47cbd6da 1728
42e69d6b
VZ
1729 case WM_DESTROY:
1730 processed = HandleDestroy();
1731 break;
1732
1733 case WM_MOVE:
1734 processed = HandleMove(LOWORD(lParam), HIWORD(lParam));
1735 break;
47cbd6da 1736
42e69d6b
VZ
1737 case WM_SIZE:
1738 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
1739 break;
47cbd6da 1740
42e69d6b 1741 case WM_ACTIVATE:
341c92a8 1742 {
42e69d6b
VZ
1743 WXWORD state, minimized;
1744 WXHWND hwnd;
1745 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
1746
1747 processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd);
341c92a8 1748 }
42e69d6b 1749 break;
341c92a8 1750
42e69d6b
VZ
1751 case WM_SETFOCUS:
1752 processed = HandleSetFocus((WXHWND)(HWND)wParam);
1753 break;
47cbd6da 1754
42e69d6b
VZ
1755 case WM_KILLFOCUS:
1756 processed = HandleKillFocus((WXHWND)(HWND)wParam);
1757 break;
47cbd6da 1758
42e69d6b
VZ
1759 case WM_PAINT:
1760 processed = HandlePaint();
1761 break;
47cbd6da 1762
42e69d6b
VZ
1763 case WM_CLOSE:
1764 // don't let the DefWindowProc() destroy our window - we'll do it
1765 // ourselves in ~wxWindow
1766 processed = TRUE;
1767 rc.result = TRUE;
1768 break;
47cbd6da 1769
42e69d6b
VZ
1770 case WM_SHOWWINDOW:
1771 processed = HandleShow(wParam != 0, (int)lParam);
1772 break;
3a19e16d 1773
42e69d6b
VZ
1774 case WM_MOUSEMOVE:
1775 case WM_LBUTTONDOWN:
1776 case WM_LBUTTONUP:
1777 case WM_LBUTTONDBLCLK:
1778 case WM_RBUTTONDOWN:
1779 case WM_RBUTTONUP:
1780 case WM_RBUTTONDBLCLK:
1781 case WM_MBUTTONDOWN:
1782 case WM_MBUTTONUP:
1783 case WM_MBUTTONDBLCLK:
1784 {
1785 int x = LOWORD(lParam);
1786 int y = HIWORD(lParam);
1787
1788 processed = HandleMouseEvent(message, x, y, wParam);
2d0a075d 1789 }
42e69d6b 1790 break;
47cbd6da 1791
42e69d6b
VZ
1792 case MM_JOY1MOVE:
1793 case MM_JOY2MOVE:
1794 case MM_JOY1ZMOVE:
1795 case MM_JOY2ZMOVE:
1796 case MM_JOY1BUTTONDOWN:
1797 case MM_JOY2BUTTONDOWN:
1798 case MM_JOY1BUTTONUP:
1799 case MM_JOY2BUTTONUP:
341c92a8 1800 {
42e69d6b
VZ
1801 int x = LOWORD(lParam);
1802 int y = HIWORD(lParam);
47cbd6da 1803
42e69d6b 1804 processed = HandleJoystickEvent(message, x, y, wParam);
341c92a8 1805 }
42e69d6b 1806 break;
47cbd6da 1807
42e69d6b
VZ
1808 case WM_SYSCOMMAND:
1809 processed = HandleSysCommand(wParam, lParam);
1810 break;
2a47d3c1 1811
42e69d6b
VZ
1812 case WM_COMMAND:
1813 {
1814 WORD id, cmd;
1815 WXHWND hwnd;
1816 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
47cbd6da 1817
42e69d6b
VZ
1818 processed = HandleCommand(id, cmd, hwnd);
1819 }
1820 break;
7d532b0c 1821
42e69d6b
VZ
1822#ifdef __WIN95__
1823 case WM_NOTIFY:
1824 processed = HandleNotify((int)wParam, lParam, &rc.result);
1825 break;
1826#endif // Win95
2bda0e17 1827
42e69d6b
VZ
1828 // for these messages we must return TRUE if process the message
1829 case WM_DRAWITEM:
1830 case WM_MEASUREITEM:
1831 {
1832 int idCtrl = (UINT)wParam;
1833 if ( message == WM_DRAWITEM )
1834 {
1835 processed = MSWOnDrawItem(idCtrl,
1836 (WXDRAWITEMSTRUCT *)lParam);
1837 }
1838 else
1839 {
1840 processed = MSWOnMeasureItem(idCtrl,
1841 (WXMEASUREITEMSTRUCT *)lParam);
1842 }
57a7b7c1 1843
42e69d6b
VZ
1844 if ( processed )
1845 rc.result = TRUE;
1846 }
1847 break;
1848
9bf84618 1849 case WM_GETDLGCODE:
101f488c 1850 if ( m_lDlgCode )
9bf84618 1851 {
101f488c 1852 rc.result = m_lDlgCode;
9bf84618
VZ
1853 processed = TRUE;
1854 }
101f488c 1855 //else: get the dlg code from the DefWindowProc()
9bf84618
VZ
1856 break;
1857
42e69d6b
VZ
1858 case WM_KEYDOWN:
1859 // If this has been processed by an event handler,
1860 // return 0 now (we've handled it).
1861 if ( HandleKeyDown((WORD) wParam, lParam) )
2d0a075d 1862 {
42e69d6b
VZ
1863 processed = TRUE;
1864
2d0a075d
JS
1865 break;
1866 }
81d66cf3 1867
42e69d6b
VZ
1868 // we consider these message "not interesting" to OnChar
1869 if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
1870 {
1871 processed = TRUE;
81d66cf3 1872
42e69d6b
VZ
1873 break;
1874 }
debe6624 1875
42e69d6b
VZ
1876 switch ( wParam )
1877 {
1878 // avoid duplicate messages to OnChar for these ASCII keys: they
1879 // will be translated by TranslateMessage() and received in WM_CHAR
1880 case VK_ESCAPE:
1881 case VK_SPACE:
1882 case VK_RETURN:
1883 case VK_BACK:
1884 case VK_TAB:
edccf428
VZ
1885 // but set processed to FALSE, not TRUE to still pass them to
1886 // the control's default window proc - otherwise built-in
1887 // keyboard handling won't work
1888 processed = FALSE;
2bda0e17 1889
42e69d6b 1890 break;
2bda0e17 1891
42e69d6b
VZ
1892#ifdef VK_APPS
1893 // special case of VK_APPS: treat it the same as right mouse
1894 // click because both usually pop up a context menu
1895 case VK_APPS:
1896 {
1897 // construct the key mask
1898 WPARAM fwKeys = MK_RBUTTON;
1899 if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 )
1900 fwKeys |= MK_CONTROL;
1901 if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 )
1902 fwKeys |= MK_SHIFT;
2bda0e17 1903
42e69d6b
VZ
1904 // simulate right mouse button click
1905 DWORD dwPos = ::GetMessagePos();
1906 int x = GET_X_LPARAM(dwPos),
1907 y = GET_Y_LPARAM(dwPos);
debe6624 1908
42e69d6b
VZ
1909 ScreenToClient(&x, &y);
1910 processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, fwKeys);
1911 }
1912 break;
1913#endif // VK_APPS
2bda0e17 1914
42e69d6b
VZ
1915 case VK_LEFT:
1916 case VK_RIGHT:
1917 case VK_DOWN:
1918 case VK_UP:
1919 default:
1920 processed = HandleChar((WORD)wParam, lParam);
1921 }
1922 break;
2bda0e17 1923
42e69d6b
VZ
1924 case WM_KEYUP:
1925 processed = HandleKeyUp((WORD) wParam, lParam);
1926 break;
debe6624 1927
42e69d6b
VZ
1928 case WM_CHAR: // Always an ASCII character
1929 processed = HandleChar((WORD)wParam, lParam, TRUE);
1930 break;
2bda0e17 1931
42e69d6b
VZ
1932 case WM_HSCROLL:
1933 case WM_VSCROLL:
a23fd0e1 1934 {
42e69d6b
VZ
1935 WXWORD code, pos;
1936 WXHWND hwnd;
1937 UnpackScroll(wParam, lParam, &code, &pos, &hwnd);
2bda0e17 1938
42e69d6b
VZ
1939 processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL
1940 : wxVERTICAL,
1941 code, pos, hwnd);
a23fd0e1 1942 }
42e69d6b 1943 break;
a23fd0e1 1944
42e69d6b
VZ
1945 // CTLCOLOR messages are sent by children to query the parent for their
1946 // colors
1947#ifdef __WIN32__
1948 case WM_CTLCOLORMSGBOX:
1949 case WM_CTLCOLOREDIT:
1950 case WM_CTLCOLORLISTBOX:
1951 case WM_CTLCOLORBTN:
1952 case WM_CTLCOLORDLG:
1953 case WM_CTLCOLORSCROLLBAR:
1954 case WM_CTLCOLORSTATIC:
1955#else // Win16
1956 case WM_CTLCOLOR:
1957#endif // Win32/16
a23fd0e1 1958 {
42e69d6b
VZ
1959 WXWORD nCtlColor;
1960 WXHDC hdc;
1961 WXHWND hwnd;
1962 UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
1963
1964 processed = HandleCtlColor(&rc.hBrush,
1965 (WXHDC)hdc,
1966 (WXHWND)hwnd,
1967 nCtlColor,
1968 message,
1969 wParam,
1970 lParam);
a23fd0e1 1971 }
42e69d6b 1972 break;
debe6624 1973
42e69d6b
VZ
1974 // the return value for this message is ignored
1975 case WM_SYSCOLORCHANGE:
1976 processed = HandleSysColorChange();
1977 break;
2bda0e17 1978
42e69d6b
VZ
1979 case WM_PALETTECHANGED:
1980 processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
1981 break;
2bda0e17 1982
42e69d6b
VZ
1983 case WM_QUERYNEWPALETTE:
1984 processed = HandleQueryNewPalette();
1985 break;
2bda0e17 1986
42e69d6b
VZ
1987 case WM_ERASEBKGND:
1988 processed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
1989 if ( processed )
1990 {
1991 // we processed the message, i.e. erased the background
1992 rc.result = TRUE;
1993 }
1994 break;
debe6624 1995
42e69d6b
VZ
1996 case WM_DROPFILES:
1997 processed = HandleDropFiles(wParam);
1998 break;
2bda0e17 1999
42e69d6b
VZ
2000 case WM_INITDIALOG:
2001 processed = HandleInitDialog((WXHWND)(HWND)wParam);
a23fd0e1 2002
42e69d6b
VZ
2003 if ( processed )
2004 {
2005 // we never set focus from here
2006 rc.result = FALSE;
2007 }
2008 break;
a23fd0e1 2009
42e69d6b
VZ
2010 case WM_QUERYENDSESSION:
2011 processed = HandleQueryEndSession(lParam, &rc.allow);
2012 break;
2bda0e17 2013
42e69d6b
VZ
2014 case WM_ENDSESSION:
2015 processed = HandleEndSession(wParam != 0, lParam);
2016 break;
2bda0e17 2017
42e69d6b 2018 case WM_GETMINMAXINFO:
25889d3c 2019 processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam);
42e69d6b 2020 break;
debe6624 2021
42e69d6b
VZ
2022 case WM_SETCURSOR:
2023 processed = HandleSetCursor((WXHWND)(HWND)wParam,
2024 LOWORD(lParam), // hit test
2025 HIWORD(lParam)); // mouse msg
2026
2027 if ( processed )
2028 {
2029 // returning TRUE stops the DefWindowProc() from further
2030 // processing this message - exactly what we need because we've
2031 // just set the cursor.
2032 rc.result = TRUE;
2033 }
2034 break;
a23fd0e1 2035 }
2d0a075d 2036
42e69d6b 2037 if ( !processed )
2d0a075d 2038 {
42e69d6b 2039#ifdef __WXDEBUG__
837e5743 2040 wxLogTrace(wxTraceMessages, _T("Forwarding %s to DefWindowProc."),
42e69d6b
VZ
2041 wxGetMessageName(message));
2042#endif // __WXDEBUG__
2043 rc.result = MSWDefWindowProc(message, wParam, lParam);
a23fd0e1 2044 }
2bda0e17 2045
42e69d6b 2046 return rc.result;
2bda0e17
KB
2047}
2048
42e69d6b
VZ
2049// Dialog window proc
2050LONG APIENTRY _EXPORT
2051wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
2bda0e17 2052{
42e69d6b 2053 if ( message == WM_INITDIALOG )
2bda0e17 2054 {
42e69d6b
VZ
2055 // for this message, returning TRUE tells system to set focus to the
2056 // first control in the dialog box
2057 return TRUE;
2d0a075d 2058 }
42e69d6b 2059 else
2d0a075d 2060 {
42e69d6b
VZ
2061 // for all the other ones, FALSE means that we didn't process the
2062 // message
2063 return 0;
2d0a075d 2064 }
2bda0e17
KB
2065}
2066
42e69d6b
VZ
2067wxList *wxWinHandleList = NULL;
2068wxWindow *wxFindWinFromHandle(WXHWND hWnd)
4ce81a75 2069{
42e69d6b
VZ
2070 wxNode *node = wxWinHandleList->Find((long)hWnd);
2071 if ( !node )
2072 return NULL;
2073 return (wxWindow *)node->Data();
2074}
4ce81a75 2075
42e69d6b
VZ
2076void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
2077{
2078 // adding NULL hWnd is (first) surely a result of an error and
2079 // (secondly) breaks menu command processing
2080 wxCHECK_RET( hWnd != (HWND)NULL,
837e5743 2081 _T("attempt to add a NULL hWnd to window list ignored") );
4ce81a75 2082
42e69d6b
VZ
2083 if ( !wxWinHandleList->Find((long)hWnd) )
2084 wxWinHandleList->Append((long)hWnd, win);
2085}
4ce81a75 2086
42e69d6b
VZ
2087void wxRemoveHandleAssociation(wxWindow *win)
2088{
2089 wxWinHandleList->DeleteObject(win);
4ce81a75
JS
2090}
2091
42e69d6b
VZ
2092// Default destroyer - override if you destroy it in some other way
2093// (e.g. with MDI child windows)
2094void wxWindow::MSWDestroyWindow()
4ce81a75 2095{
42e69d6b 2096}
4ce81a75 2097
42e69d6b
VZ
2098void wxWindow::MSWDetachWindowMenu()
2099{
2100 if ( m_hMenu )
4ce81a75 2101 {
42e69d6b 2102 HMENU hMenu = (HMENU)m_hMenu;
4ce81a75 2103
42e69d6b
VZ
2104 int N = ::GetMenuItemCount(hMenu);
2105 int i;
2106 for (i = 0; i < N; i++)
2107 {
837e5743 2108 wxChar buf[100];
42e69d6b
VZ
2109 int chars = GetMenuString(hMenu, i, buf, 100, MF_BYPOSITION);
2110 if ( !chars )
2111 {
837e5743 2112 wxLogLastError(_T("GetMenuString"));
4ce81a75 2113
42e69d6b
VZ
2114 continue;
2115 }
4ce81a75 2116
837e5743 2117 if ( wxStrcmp(buf, _T("&Window")) == 0 )
42e69d6b
VZ
2118 {
2119 RemoveMenu(hMenu, i, MF_BYPOSITION);
4ce81a75 2120
42e69d6b
VZ
2121 break;
2122 }
2123 }
4ce81a75
JS
2124 }
2125}
2126
42e69d6b
VZ
2127bool wxWindow::MSWCreate(int id,
2128 wxWindow *parent,
837e5743 2129 const wxChar *wclass,
42e69d6b 2130 wxWindow *wx_win,
837e5743 2131 const wxChar *title,
42e69d6b
VZ
2132 int x,
2133 int y,
2134 int width,
2135 int height,
2136 WXDWORD style,
837e5743 2137 const wxChar *dialog_template,
42e69d6b 2138 WXDWORD extendedStyle)
2bda0e17 2139{
42e69d6b
VZ
2140 int x1 = CW_USEDEFAULT;
2141 int y1 = 0;
2142 int width1 = CW_USEDEFAULT;
2143 int height1 = 100;
c085e333 2144
42e69d6b
VZ
2145 // Find parent's size, if it exists, to set up a possible default
2146 // panel size the size of the parent window
2147 RECT parent_rect;
2148 if ( parent )
a23fd0e1 2149 {
42e69d6b 2150 ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
c085e333 2151
42e69d6b
VZ
2152 width1 = parent_rect.right - parent_rect.left;
2153 height1 = parent_rect.bottom - parent_rect.top;
2154 }
2bda0e17 2155
42e69d6b
VZ
2156 if ( x > -1 ) x1 = x;
2157 if ( y > -1 ) y1 = y;
2158 if ( width > -1 ) width1 = width;
2159 if ( height > -1 ) height1 = height;
c085e333 2160
c455ab93
RR
2161#ifdef __WXWINE__
2162 HWND hParent = (HWND)NULL;
2163#else
42e69d6b 2164 HWND hParent = NULL;
c455ab93 2165#endif
42e69d6b
VZ
2166 if ( parent )
2167 hParent = (HWND) parent->GetHWND();
c085e333 2168
42e69d6b 2169 wxWndHook = this;
c085e333 2170
42e69d6b
VZ
2171 if ( dialog_template )
2172 {
2173 m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
2174 dialog_template,
2175 hParent,
2176 (DLGPROC)wxDlgProc);
2bda0e17 2177
42e69d6b
VZ
2178 if ( m_hWnd == 0 )
2179 {
2180 wxLogError(_("Can't find dummy dialog template!\n"
2181 "Check resource include path for finding wx.rc."));
c085e333 2182
42e69d6b
VZ
2183 return FALSE;
2184 }
c085e333 2185
789295bf
VZ
2186 // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try
2187 // to take care of (at least some) extended style flags ourselves
2188 if ( extendedStyle & WS_EX_TOPMOST )
2189 {
2190 if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
2191 SWP_NOSIZE | SWP_NOMOVE) )
2192 {
837e5743 2193 wxLogLastError(_T("SetWindowPos"));
789295bf
VZ
2194 }
2195 }
2196
2197 // move the dialog to its initial position without forcing repainting
2198 if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) )
2199 {
837e5743 2200 wxLogLastError(_T("MoveWindow"));
789295bf 2201 }
42e69d6b
VZ
2202 }
2203 else
2204 {
2205 int controlId = 0;
2206 if ( style & WS_CHILD )
2207 controlId = id;
2208
2209 m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
2210 wclass,
837e5743 2211 title ? title : _T(""),
42e69d6b
VZ
2212 style,
2213 x1, y1,
2214 width1, height1,
2215 hParent, (HMENU)controlId,
2216 wxGetInstance(),
2217 NULL);
2218
2219 if ( !m_hWnd )
2220 {
2221 wxLogError(_("Can't create window of class %s!\n"
2222 "Possible Windows 3.x compatibility problem?"),
2223 wclass);
2bda0e17 2224
a23fd0e1 2225 return FALSE;
42e69d6b 2226 }
a23fd0e1 2227 }
c085e333 2228
42e69d6b
VZ
2229 wxWndHook = NULL;
2230 wxWinHandleList->Append((long)m_hWnd, this);
c085e333 2231
42e69d6b 2232 return TRUE;
2bda0e17
KB
2233}
2234
42e69d6b
VZ
2235// ===========================================================================
2236// MSW message handlers
2237// ===========================================================================
2238
2239// ---------------------------------------------------------------------------
2240// WM_NOTIFY
2241// ---------------------------------------------------------------------------
2242
2243#ifdef __WIN95__
2244// FIXME: VZ: I'm not sure at all that the order of processing is correct
2245bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
2bda0e17 2246{
42e69d6b
VZ
2247 LPNMHDR hdr = (LPNMHDR)lParam;
2248 HWND hWnd = hdr->hwndFrom;
2249 wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd);
2250
2251 // is this one of our windows?
2252 if ( win )
564b2609 2253 {
42e69d6b 2254 return win->MSWOnNotify(idCtrl, lParam, result);
564b2609 2255 }
2bda0e17 2256
42e69d6b
VZ
2257 // try all our children
2258 wxWindowList::Node *node = GetChildren().GetFirst();
2259 while ( node )
564b2609 2260 {
42e69d6b
VZ
2261 wxWindow *child = node->GetData();
2262 if ( child->MSWOnNotify(idCtrl, lParam, result) )
2263 {
2264 return TRUE;
2d0a075d 2265
42e69d6b
VZ
2266 break;
2267 }
2d0a075d 2268
42e69d6b
VZ
2269 node = node->GetNext();
2270 }
2d0a075d 2271
42e69d6b
VZ
2272 // finally try this window too (catches toolbar case)
2273 return MSWOnNotify(idCtrl, lParam, result);
2274}
2d0a075d 2275
42e69d6b
VZ
2276bool wxWindow::MSWOnNotify(int WXUNUSED(idCtrl),
2277 WXLPARAM lParam,
2278 WXLPARAM* WXUNUSED(result))
2279{
2280#if wxUSE_TOOLTIPS
2281 NMHDR* hdr = (NMHDR *)lParam;
2282 if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
2283 {
2284 TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
837e5743 2285 ttt->lpszText = (wxChar *)m_tooltip->GetTip().c_str();
2d0a075d 2286
42e69d6b
VZ
2287 // processed
2288 return TRUE;
2289 }
2290#endif // wxUSE_TOOLTIPS
2291
2292 return FALSE;
2293}
2294#endif // __WIN95__
2295
2296// ---------------------------------------------------------------------------
2297// end session messages
2298// ---------------------------------------------------------------------------
2d0a075d 2299
42e69d6b
VZ
2300bool wxWindow::HandleQueryEndSession(long logOff, bool *mayEnd)
2301{
2302 wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
2303 event.SetEventObject(wxTheApp);
2304 event.SetCanVeto(TRUE);
2305 event.SetLoggingOff(logOff == ENDSESSION_LOGOFF);
2d0a075d 2306
42e69d6b
VZ
2307 bool rc = wxTheApp->ProcessEvent(event);
2308
2309 if ( rc )
2310 {
2311 // we may end only if the app didn't veto session closing (double
2312 // negation...)
2313 *mayEnd = !event.GetVeto();
2d0a075d
JS
2314 }
2315
42e69d6b 2316 return rc;
2bda0e17
KB
2317}
2318
42e69d6b 2319bool wxWindow::HandleEndSession(bool endSession, long logOff)
2bda0e17 2320{
42e69d6b
VZ
2321 // do nothing if the session isn't ending
2322 if ( !endSession )
2323 return FALSE;
a23fd0e1 2324
42e69d6b
VZ
2325 wxCloseEvent event(wxEVT_END_SESSION, -1);
2326 event.SetEventObject(wxTheApp);
2327 event.SetCanVeto(FALSE);
2328 event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
2329 if ( (this == wxTheApp->GetTopWindow()) && // Only send once
2330 wxTheApp->ProcessEvent(event))
2331 {
2332 }
2333 return TRUE;
2bda0e17
KB
2334}
2335
42e69d6b
VZ
2336// ---------------------------------------------------------------------------
2337// window creation/destruction
2338// ---------------------------------------------------------------------------
2339
2340bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate)
2bda0e17 2341{
42e69d6b
VZ
2342 // TODO: should generate this event from WM_NCCREATE
2343 wxWindowCreateEvent event(this);
2344 (void)GetEventHandler()->ProcessEvent(event);
a23fd0e1 2345
42e69d6b
VZ
2346 *mayCreate = TRUE;
2347
2348 return TRUE;
2bda0e17
KB
2349}
2350
42e69d6b 2351bool wxWindow::HandleDestroy()
2bda0e17 2352{
42e69d6b
VZ
2353 wxWindowDestroyEvent event(this);
2354 (void)GetEventHandler()->ProcessEvent(event);
2355
2356 // delete our drop target if we've got one
2357#if wxUSE_DRAG_AND_DROP
2358 if ( m_dropTarget != NULL )
2d0a075d 2359 {
42e69d6b
VZ
2360 m_dropTarget->Revoke(m_hWnd);
2361
2362 delete m_dropTarget;
2363 m_dropTarget = NULL;
2d0a075d 2364 }
42e69d6b 2365#endif // wxUSE_DRAG_AND_DROP
2bda0e17 2366
42e69d6b
VZ
2367 // WM_DESTROY handled
2368 return TRUE;
2bda0e17
KB
2369}
2370
42e69d6b
VZ
2371// ---------------------------------------------------------------------------
2372// activation/focus
2373// ---------------------------------------------------------------------------
2374
2375bool wxWindow::HandleActivate(int state,
2376 bool WXUNUSED(minimized),
2377 WXHWND WXUNUSED(activate))
2bda0e17 2378{
42e69d6b
VZ
2379 wxActivateEvent event(wxEVT_ACTIVATE,
2380 (state == WA_ACTIVE) || (state == WA_CLICKACTIVE),
2381 m_windowId);
2382 event.SetEventObject(this);
2383
2384 return GetEventHandler()->ProcessEvent(event);
2385}
2386
2387bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd))
2388{
789295bf 2389#if wxUSE_CARET
42e69d6b 2390 // Deal with caret
789295bf 2391 if ( m_caret )
2d0a075d 2392 {
789295bf 2393 m_caret->OnSetFocus();
2bda0e17 2394 }
789295bf 2395#endif // wxUSE_CARET
42e69d6b
VZ
2396
2397 // panel wants to track the window which was the last to have focus in it
319fefa9
VZ
2398 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
2399 if ( panel )
42e69d6b 2400 {
319fefa9 2401 panel->SetLastFocus(this);
42e69d6b
VZ
2402 }
2403
2404 wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
2405 event.SetEventObject(this);
2406
2407 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2408}
2409
42e69d6b 2410bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd))
2bda0e17 2411{
789295bf 2412#if wxUSE_CARET
42e69d6b 2413 // Deal with caret
789295bf 2414 if ( m_caret )
2d0a075d 2415 {
789295bf 2416 m_caret->OnKillFocus();
2bda0e17 2417 }
789295bf 2418#endif // wxUSE_CARET
42e69d6b
VZ
2419
2420 wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
2421 event.SetEventObject(this);
2422
2423 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2424}
2425
42e69d6b
VZ
2426// ---------------------------------------------------------------------------
2427// miscellaneous
2428// ---------------------------------------------------------------------------
2429
2430bool wxWindow::HandleShow(bool show, int status)
2bda0e17 2431{
42e69d6b
VZ
2432 wxShowEvent event(GetId(), show);
2433 event.m_eventObject = this;
2434
2435 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2436}
2437
42e69d6b 2438bool wxWindow::HandleInitDialog(WXHWND WXUNUSED(hWndFocus))
2bda0e17 2439{
42e69d6b
VZ
2440 wxInitDialogEvent event(GetId());
2441 event.m_eventObject = this;
2442
2443 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2444}
2445
42e69d6b 2446bool wxWindow::HandleDropFiles(WXWPARAM wParam)
2bda0e17 2447{
42e69d6b
VZ
2448 HDROP hFilesInfo = (HDROP) wParam;
2449 POINT dropPoint;
2450 DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
2451
2452 // Get the total number of files dropped
2453 WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo,
2454 (UINT)-1,
2455 (LPSTR)0,
2456 (UINT)0);
2457
2458 wxString *files = new wxString[gwFilesDropped];
2459 int wIndex;
2460 for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++)
2d0a075d 2461 {
837e5743 2462 DragQueryFile (hFilesInfo, wIndex, (LPTSTR) wxBuffer, 1000);
42e69d6b 2463 files[wIndex] = wxBuffer;
2d0a075d 2464 }
42e69d6b 2465 DragFinish (hFilesInfo);
2bda0e17 2466
42e69d6b
VZ
2467 wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files);
2468 event.m_eventObject = this;
2469 event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
2470
2471 bool rc = GetEventHandler()->ProcessEvent(event);
2472
2473 delete[] files;
2474
2475 return rc;
2bda0e17
KB
2476}
2477
42e69d6b
VZ
2478bool wxWindow::HandleSetCursor(WXHWND hWnd,
2479 short nHitTest,
2480 int WXUNUSED(mouseMsg))
2bda0e17 2481{
42e69d6b
VZ
2482 // don't set cursor for other windows, only for this one: this prevents
2483 // children of this window from getting the same cursor as the parent has
2484 // (don't forget that this message is propagated by default up the window
2485 // parent-child hierarchy)
2486 if ( GetHWND() == hWnd )
2487 {
2488 // don't set cursor when the mouse is not in the client part
2489 if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
2490 {
2491 HCURSOR hcursor = 0;
2492 if ( wxIsBusy() )
2493 {
2494 // from msw\utils.cpp
2495 extern HCURSOR gs_wxBusyCursor;
2496
2497 hcursor = gs_wxBusyCursor;
2498 }
2499 else
2500 {
2501 wxCursor *cursor = NULL;
2502
2503 if ( m_cursor.Ok() )
2504 {
2505 cursor = &m_cursor;
2506 }
2507 else
2508 {
2509 // from msw\data.cpp
2510 extern wxCursor *g_globalCursor;
2511
2512 if ( g_globalCursor && g_globalCursor->Ok() )
2513 cursor = g_globalCursor;
2514 }
2515
2516 if ( cursor )
2517 hcursor = (HCURSOR)cursor->GetHCURSOR();
2518 }
2519
2520 if ( hcursor )
2521 {
2522 ::SetCursor(hcursor);
2523
2524 return TRUE;
2525 }
2526 }
2527 }
2528
2529 return FALSE;
2bda0e17
KB
2530}
2531
42e69d6b
VZ
2532// ---------------------------------------------------------------------------
2533// owner drawn stuff
2534// ---------------------------------------------------------------------------
2535
2536bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
2bda0e17 2537{
4286a5b5 2538#if wxUSE_OWNER_DRAWN
42e69d6b
VZ
2539 // is it a menu item?
2540 if ( id == 0 )
2541 {
2542 DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
2543 wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
2544
2545 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2546
2547 // prepare to call OnDrawItem()
2548 wxDC dc;
2549 dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
2550 wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
2551 pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
2552 pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
2553
2554 return pMenuItem->OnDrawItem
2555 (
2556 dc, rect,
2557 (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
2558 (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
2559 );
2560 }
2561
2562 wxWindow *item = FindItem(id);
2563 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2564 {
2565 return ((wxControl *)item)->MSWOnDraw(itemStruct);
2566 }
2567 else
4286a5b5 2568#endif
42e69d6b 2569 return FALSE;
4286a5b5 2570
2bda0e17
KB
2571}
2572
42e69d6b 2573bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
2bda0e17 2574{
4286a5b5 2575#if wxUSE_OWNER_DRAWN
42e69d6b
VZ
2576 // is it a menu item?
2577 if ( id == 0 )
2d0a075d 2578 {
42e69d6b
VZ
2579 MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
2580 wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
2581
2582 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2583
2584 return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
2585 &pMeasureStruct->itemHeight);
2d0a075d 2586 }
42e69d6b
VZ
2587
2588 wxWindow *item = FindItem(id);
2589 if ( item && item->IsKindOf(CLASSINFO(wxControl)) )
2590 {
2591 return ((wxControl *)item)->MSWOnMeasure(itemStruct);
2592 }
4286a5b5 2593#endif // owner-drawn menus
42e69d6b 2594 return FALSE;
2bda0e17
KB
2595}
2596
42e69d6b
VZ
2597// ---------------------------------------------------------------------------
2598// colours and palettes
2599// ---------------------------------------------------------------------------
2bda0e17 2600
42e69d6b 2601bool wxWindow::HandleSysColorChange()
2bda0e17 2602{
42e69d6b
VZ
2603 wxSysColourChangedEvent event;
2604 event.SetEventObject(this);
2605
2606 return GetEventHandler()->ProcessEvent(event);
2607}
2608
2609bool wxWindow::HandleCtlColor(WXHBRUSH *brush,
2610 WXHDC pDC,
2611 WXHWND pWnd,
2612 WXUINT nCtlColor,
2613 WXUINT message,
2614 WXWPARAM wParam,
2615 WXLPARAM lParam)
2616{
2617 WXHBRUSH hBrush = 0;
2618
2619 if ( nCtlColor == CTLCOLOR_DLG )
2d0a075d 2620 {
42e69d6b 2621 hBrush = OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2d0a075d
JS
2622 }
2623 else
2624 {
42e69d6b
VZ
2625 wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
2626 if ( item )
2627 hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2d0a075d 2628 }
42e69d6b
VZ
2629
2630 if ( hBrush )
2631 *brush = hBrush;
2632
2633 return hBrush != 0;
2bda0e17
KB
2634}
2635
42e69d6b
VZ
2636// Define for each class of dialog and control
2637WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
2638 WXHWND hWnd,
2639 WXUINT nCtlColor,
2640 WXUINT message,
2641 WXWPARAM wParam,
2642 WXLPARAM lParam)
2bda0e17 2643{
42e69d6b
VZ
2644 return (WXHBRUSH)0;
2645}
2d0a075d 2646
42e69d6b
VZ
2647bool wxWindow::HandlePaletteChanged(WXHWND hWndPalChange)
2648{
2649 wxPaletteChangedEvent event(GetId());
2650 event.SetEventObject(this);
2651 event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
2d0a075d 2652
42e69d6b
VZ
2653 return GetEventHandler()->ProcessEvent(event);
2654}
2655
2656bool wxWindow::HandleQueryNewPalette()
2657{
2658 wxQueryNewPaletteEvent event(GetId());
2659 event.SetEventObject(this);
2660
2661 return GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
2662}
2663
2664// Responds to colour changes: passes event on to children.
2665void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
2666{
2667 wxNode *node = GetChildren().First();
2668 while ( node )
2669 {
2670 // Only propagate to non-top-level windows
2671 wxWindow *win = (wxWindow *)node->Data();
2672 if ( win->GetParent() )
2673 {
2674 wxSysColourChangedEvent event2;
2675 event.m_eventObject = win;
2676 win->GetEventHandler()->ProcessEvent(event2);
564b2609 2677 }
42e69d6b
VZ
2678
2679 node = node->Next();
2bda0e17 2680 }
2bda0e17
KB
2681}
2682
42e69d6b
VZ
2683// ---------------------------------------------------------------------------
2684// painting
2685// ---------------------------------------------------------------------------
2686
2687bool wxWindow::HandlePaint()
2bda0e17 2688{
42e69d6b
VZ
2689#ifdef __WIN32__
2690 HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2691 if ( !hRegion )
2692 wxLogLastError("CreateRectRgn");
2693 if ( ::GetUpdateRgn(GetHwnd(), hRegion, FALSE) == ERROR )
2694 wxLogLastError("GetUpdateRgn");
c085e333 2695
42e69d6b
VZ
2696 m_updateRegion = wxRegion((WXHRGN) hRegion);
2697#else
2698 RECT updateRect;
2699 ::GetUpdateRect(GetHwnd(), & updateRect, FALSE);
c085e333 2700
42e69d6b
VZ
2701 m_updateRegion = wxRegion(updateRect.left, updateRect.top,
2702 updateRect.right - updateRect.left,
2703 updateRect.bottom - updateRect.top);
2704#endif
c085e333 2705
42e69d6b
VZ
2706 wxPaintEvent event(m_windowId);
2707 event.SetEventObject(this);
2bda0e17 2708
42e69d6b 2709 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2710}
2711
42e69d6b 2712bool wxWindow::HandleEraseBkgnd(WXHDC hdc)
a23fd0e1 2713{
42e69d6b
VZ
2714 // Prevents flicker when dragging
2715 if ( ::IsIconic(GetHwnd()) )
2716 return TRUE;
a23fd0e1 2717
a23fd0e1 2718 wxDC dc;
c085e333 2719
a23fd0e1 2720 dc.SetHDC(hdc);
564b2609
VZ
2721 dc.SetWindow(this);
2722 dc.BeginDrawing();
c085e333 2723
2bda0e17 2724 wxEraseEvent event(m_windowId, &dc);
42e69d6b 2725 event.SetEventObject(this);
a23fd0e1 2726 bool rc = GetEventHandler()->ProcessEvent(event);
c085e333 2727
a23fd0e1
VZ
2728 dc.EndDrawing();
2729 dc.SelectOldObjects(hdc);
2bda0e17 2730 dc.SetHDC((WXHDC) NULL);
a23fd0e1
VZ
2731
2732 return rc;
2bda0e17
KB
2733}
2734
2735void wxWindow::OnEraseBackground(wxEraseEvent& event)
2736{
2d0a075d 2737 RECT rect;
a23fd0e1 2738 ::GetClientRect(GetHwnd(), &rect);
2bda0e17 2739
42e69d6b
VZ
2740 COLORREF ref = PALETTERGB(m_backgroundColour.Red(),
2741 m_backgroundColour.Green(),
2742 m_backgroundColour.Blue());
ce3ed50d 2743 HBRUSH hBrush = ::CreateSolidBrush(ref);
42e69d6b
VZ
2744 if ( !hBrush )
2745 wxLogLastError("CreateSolidBrush");
2746
2747 HDC hdc = (HDC)event.GetDC()->GetHDC();
2bda0e17 2748
42e69d6b
VZ
2749 int mode = ::SetMapMode(hdc, MM_TEXT);
2750
2751 ::FillRect(hdc, &rect, hBrush);
2d0a075d 2752 ::DeleteObject(hBrush);
42e69d6b
VZ
2753 ::SetMapMode(hdc, mode);
2754}
2755
2756// ---------------------------------------------------------------------------
2757// moving and resizing
2758// ---------------------------------------------------------------------------
2759
2760bool wxWindow::HandleMinimize()
2761{
2762 wxIconizeEvent event(m_windowId);
2763 event.SetEventObject(this);
2d0a075d 2764
42e69d6b 2765 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2766}
2767
42e69d6b 2768bool wxWindow::HandleMaximize()
2bda0e17 2769{
42e69d6b
VZ
2770 wxMaximizeEvent event(m_windowId);
2771 event.SetEventObject(this);
c085e333 2772
42e69d6b
VZ
2773 return GetEventHandler()->ProcessEvent(event);
2774}
2bda0e17 2775
42e69d6b
VZ
2776bool wxWindow::HandleMove(int x, int y)
2777{
2778 wxMoveEvent event(wxPoint(x, y), m_windowId);
2779 event.SetEventObject(this);
2780
2781 return GetEventHandler()->ProcessEvent(event);
2782}
2783
2784bool wxWindow::HandleSize(int w, int h, WXUINT WXUNUSED(flag))
2785{
2786 wxSizeEvent event(wxSize(w, h), m_windowId);
2787 event.SetEventObject(this);
2788
2789 return GetEventHandler()->ProcessEvent(event);
2790}
2791
2792bool wxWindow::HandleGetMinMaxInfo(void *mmInfo)
2793{
2794 MINMAXINFO *info = (MINMAXINFO *)mmInfo;
2795
2796 bool rc = FALSE;
2797
2798 if ( m_minWidth != -1 )
2d0a075d 2799 {
42e69d6b
VZ
2800 info->ptMinTrackSize.x = m_minWidth;
2801 rc = TRUE;
2d0a075d 2802 }
2bda0e17 2803
42e69d6b
VZ
2804 if ( m_minHeight != -1 )
2805 {
2806 info->ptMinTrackSize.y = m_minHeight;
2807 rc = TRUE;
2808 }
2bda0e17 2809
42e69d6b
VZ
2810 if ( m_maxWidth != -1 )
2811 {
2812 info->ptMaxTrackSize.x = m_maxWidth;
2813 rc = TRUE;
2d0a075d 2814 }
2bda0e17 2815
42e69d6b
VZ
2816 if ( m_maxHeight != -1 )
2817 {
2818 info->ptMaxTrackSize.y = m_maxHeight;
2819 rc = TRUE;
2820 }
2bda0e17 2821
42e69d6b
VZ
2822 return rc;
2823}
2d0a075d 2824
42e69d6b
VZ
2825// ---------------------------------------------------------------------------
2826// command messages
2827// ---------------------------------------------------------------------------
2828
2829bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
2830{
2831 if ( wxCurrentPopupMenu )
2832 {
2833 wxMenu *popupMenu = wxCurrentPopupMenu;
2834 wxCurrentPopupMenu = NULL;
2835
2836 return popupMenu->MSWCommand(cmd, id);
2837 }
2838
2839 wxWindow *win = FindItem(id);
2840 if ( !win )
2841 {
2842 win = wxFindWinFromHandle(control);
2843 }
2844
2845 if ( win )
2846 return win->MSWCommand(cmd, id);
2847
2848 return FALSE;
2bda0e17
KB
2849}
2850
42e69d6b 2851bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam)
2bda0e17 2852{
42e69d6b
VZ
2853 // 4 bits are reserved
2854 switch ( wParam & 0xFFFFFFF0 )
2855 {
2856 case SC_MAXIMIZE:
2857 return HandleMaximize();
2d0a075d 2858
42e69d6b
VZ
2859 case SC_MINIMIZE:
2860 return HandleMinimize();
2d0a075d 2861 }
2bda0e17 2862
42e69d6b
VZ
2863 return FALSE;
2864}
2865
2866// ---------------------------------------------------------------------------
2867// mouse events
2868// ---------------------------------------------------------------------------
2869
2870void wxWindow::InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags)
2871{
2872 event.m_x = x;
2873 event.m_y = y;
2874 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2875 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2876 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2877 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2878 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2879 event.SetTimestamp(s_currentMsg.time);
2880 event.m_eventObject = this;
2881
2882#if wxUSE_MOUSEEVENT_HACK
2883 m_lastMouseX = x;
2884 m_lastMouseY = y;
2885 m_lastMouseEvent = event.GetEventType();
2886#endif // wxUSE_MOUSEEVENT_HACK
2bda0e17 2887
2bda0e17
KB
2888}
2889
42e69d6b 2890bool wxWindow::HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags)
2bda0e17 2891{
42e69d6b
VZ
2892 // the mouse events take consecutive IDs from WM_MOUSEFIRST to
2893 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
2894 // from the message id and take the value in the table to get wxWin event
2895 // id
2896 static const wxEventType eventsMouse[] =
2897 {
2898 wxEVT_MOTION,
2899 wxEVT_LEFT_DOWN,
2900 wxEVT_LEFT_UP,
2901 wxEVT_LEFT_DCLICK,
2902 wxEVT_RIGHT_DOWN,
2903 wxEVT_RIGHT_UP,
2904 wxEVT_RIGHT_DCLICK,
2905 wxEVT_MIDDLE_DOWN,
2906 wxEVT_MIDDLE_UP,
2907 wxEVT_MIDDLE_DCLICK
2908 };
2bda0e17 2909
42e69d6b
VZ
2910 wxMouseEvent event(eventsMouse[msg - WM_MOUSEMOVE]);
2911 InitMouseEvent(event, x, y, flags);
2912
2913 return GetEventHandler()->ProcessEvent(event);
2914}
2915
2916bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags)
2917{
2918 if ( !m_mouseInWindow )
2bda0e17 2919 {
42e69d6b
VZ
2920 // Generate an ENTER event
2921 m_mouseInWindow = TRUE;
2922
2923 wxMouseEvent event(wxEVT_ENTER_WINDOW);
2924 InitMouseEvent(event, x, y, flags);
2925
2926 (void)GetEventHandler()->ProcessEvent(event);
2927 }
2928
2929#if wxUSE_MOUSEEVENT_HACK
2930 // Window gets a click down message followed by a mouse move message even
2931 // if position isn't changed! We want to discard the trailing move event
2932 // if x and y are the same.
2933 if ( (m_lastMouseEvent == wxEVT_RIGHT_DOWN ||
2934 m_lastMouseEvent == wxEVT_LEFT_DOWN ||
2935 m_lastMouseEvent == wxEVT_MIDDLE_DOWN) &&
2936 (m_lastMouseX == event.m_x && m_lastMouseY == event.m_y) )
2937 {
2938 m_lastMouseEvent = wxEVT_MOTION;
2939
2940 return FALSE;
2941 }
2942#endif // wxUSE_MOUSEEVENT_HACK
2943
2944 return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags);
2945}
2946
2947// ---------------------------------------------------------------------------
2948// keyboard handling
2949// ---------------------------------------------------------------------------
2950
2951// isASCII is TRUE only when we're called from WM_CHAR handler and not from
2952// WM_KEYDOWN one
2953bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2954{
2955 int id;
2956 bool tempControlDown = FALSE;
2957 if ( isASCII )
2958 {
2959 // If 1 -> 26, translate to CTRL plus a letter.
2960 id = wParam;
2961 if ( (id > 0) && (id < 27) )
2d0a075d 2962 {
42e69d6b
VZ
2963 switch (id)
2964 {
2965 case 13:
2966 {
2967 id = WXK_RETURN;
2968 break;
2969 }
2970 case 8:
2971 {
2972 id = WXK_BACK;
2973 break;
2974 }
2975 case 9:
2976 {
2977 id = WXK_TAB;
2978 break;
2979 }
2980 default:
2981 {
2982 tempControlDown = TRUE;
2983 id = id + 96;
2984 }
2985 }
2d0a075d 2986 }
2d0a075d 2987 }
42e69d6b
VZ
2988 else if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
2989 // it's ASCII and will be processed here only when called from
2990 // WM_CHAR (i.e. when isASCII = TRUE)
2991 id = -1;
2992 }
2bda0e17 2993
42e69d6b 2994 if ( id != -1 )
2d0a075d 2995 {
42e69d6b
VZ
2996 wxKeyEvent event(wxEVT_CHAR);
2997 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
2998 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
2999 if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
3000 event.m_altDown = TRUE;
3001
3002 event.m_eventObject = this;
3003 event.m_keyCode = id;
3004 event.SetTimestamp(s_currentMsg.time);
3005
3006 POINT pt;
3007 GetCursorPos(&pt);
3008 RECT rect;
3009 GetWindowRect(GetHwnd(),&rect);
3010 pt.x -= rect.left;
3011 pt.y -= rect.top;
3012
3013 event.m_x = pt.x; event.m_y = pt.y;
3014
3015 if ( GetEventHandler()->ProcessEvent(event) )
3016 return TRUE;
3017 else
3018 return FALSE;
2d0a075d
JS
3019 }
3020 else
42e69d6b 3021 return FALSE;
2bda0e17
KB
3022}
3023
42e69d6b 3024bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam)
2bda0e17 3025{
42e69d6b 3026 int id;
2bda0e17 3027
42e69d6b
VZ
3028 if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
3029 id = wParam;
3030 }
3031
3032 if ( id != -1 )
2bda0e17 3033 {
42e69d6b
VZ
3034 wxKeyEvent event(wxEVT_KEY_DOWN);
3035 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
3036 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
3037 if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
3038 event.m_altDown = TRUE;
3039
3040 event.m_eventObject = this;
3041 event.m_keyCode = id;
3042 event.SetTimestamp(s_currentMsg.time);
3043
3044 POINT pt;
3045 GetCursorPos(&pt);
3046 RECT rect;
3047 GetWindowRect(GetHwnd(),&rect);
3048 pt.x -= rect.left;
3049 pt.y -= rect.top;
3050
3051 event.m_x = pt.x; event.m_y = pt.y;
3052
3053 if ( GetEventHandler()->ProcessEvent(event) )
2d0a075d 3054 {
42e69d6b 3055 return TRUE;
2d0a075d 3056 }
42e69d6b 3057 else return FALSE;
2d0a075d
JS
3058 }
3059 else
42e69d6b
VZ
3060 {
3061 return FALSE;
3062 }
2bda0e17
KB
3063}
3064
42e69d6b 3065bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam)
2bda0e17 3066{
42e69d6b 3067 int id;
2bda0e17 3068
42e69d6b
VZ
3069 if ( (id = wxCharCodeMSWToWX(wParam)) == 0 ) {
3070 id = wParam;
2d0a075d 3071 }
2bda0e17 3072
42e69d6b
VZ
3073 if ( id != -1 )
3074 {
3075 wxKeyEvent event(wxEVT_KEY_UP);
3076 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
3077 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
3078 if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
3079 event.m_altDown = TRUE;
2bda0e17 3080
42e69d6b
VZ
3081 event.m_eventObject = this;
3082 event.m_keyCode = id;
3083 event.SetTimestamp(s_currentMsg.time);
2d0a075d 3084
42e69d6b
VZ
3085 POINT pt;
3086 GetCursorPos(&pt);
3087 RECT rect;
3088 GetWindowRect(GetHwnd(),&rect);
3089 pt.x -= rect.left;
3090 pt.y -= rect.top;
3091
3092 event.m_x = pt.x; event.m_y = pt.y;
3093
3094 if ( GetEventHandler()->ProcessEvent(event) )
3095 return TRUE;
3096 else
3097 return FALSE;
3098 }
3099 else
3100 return FALSE;
2bda0e17
KB
3101}
3102
42e69d6b
VZ
3103// ---------------------------------------------------------------------------
3104// joystick
3105// ---------------------------------------------------------------------------
3106
3107bool wxWindow::HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags)
2bda0e17 3108{
42e69d6b
VZ
3109 int change = 0;
3110 if ( flags & JOY_BUTTON1CHG )
3111 change = wxJOY_BUTTON1;
3112 if ( flags & JOY_BUTTON2CHG )
3113 change = wxJOY_BUTTON2;
3114 if ( flags & JOY_BUTTON3CHG )
3115 change = wxJOY_BUTTON3;
3116 if ( flags & JOY_BUTTON4CHG )
3117 change = wxJOY_BUTTON4;
2bda0e17 3118
42e69d6b
VZ
3119 int buttons = 0;
3120 if ( flags & JOY_BUTTON1 )
3121 buttons |= wxJOY_BUTTON1;
3122 if ( flags & JOY_BUTTON2 )
3123 buttons |= wxJOY_BUTTON2;
3124 if ( flags & JOY_BUTTON3 )
3125 buttons |= wxJOY_BUTTON3;
3126 if ( flags & JOY_BUTTON4 )
3127 buttons |= wxJOY_BUTTON4;
c085e333 3128
42e69d6b
VZ
3129 // the event ids aren't consecutive so we can't use table based lookup
3130 int joystick;
3131 wxEventType eventType;
3132 switch ( msg )
3133 {
3134 case MM_JOY1MOVE:
3135 joystick = 1;
3136 eventType = wxEVT_JOY_MOVE;
3137 break;
2bda0e17 3138
42e69d6b
VZ
3139 case MM_JOY2MOVE:
3140 joystick = 2;
3141 eventType = wxEVT_JOY_MOVE;
3142 break;
2bda0e17 3143
42e69d6b
VZ
3144 case MM_JOY1ZMOVE:
3145 joystick = 1;
3146 eventType = wxEVT_JOY_ZMOVE;
3147 break;
2bda0e17 3148
42e69d6b
VZ
3149 case MM_JOY2ZMOVE:
3150 joystick = 2;
3151 eventType = wxEVT_JOY_ZMOVE;
3152 break;
2bda0e17 3153
42e69d6b
VZ
3154 case MM_JOY1BUTTONDOWN:
3155 joystick = 1;
3156 eventType = wxEVT_JOY_BUTTON_DOWN;
3157 break;
2bda0e17 3158
42e69d6b
VZ
3159 case MM_JOY2BUTTONDOWN:
3160 joystick = 2;
3161 eventType = wxEVT_JOY_BUTTON_DOWN;
3162 break;
2bda0e17 3163
42e69d6b
VZ
3164 case MM_JOY1BUTTONUP:
3165 joystick = 1;
3166 eventType = wxEVT_JOY_BUTTON_UP;
3167 break;
3168
3169 case MM_JOY2BUTTONUP:
3170 joystick = 2;
3171 eventType = wxEVT_JOY_BUTTON_UP;
3172 break;
3173
3174 default:
837e5743 3175 wxFAIL_MSG(_T("no such joystick event"));
2d0a075d 3176
42e69d6b 3177 return FALSE;
2d0a075d 3178 }
2bda0e17 3179
42e69d6b
VZ
3180 wxJoystickEvent event(eventType, buttons, joystick, change);
3181 event.SetPosition(wxPoint(x, y));
3182 event.SetEventObject(this);
c085e333 3183
42e69d6b 3184 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
3185}
3186
42e69d6b
VZ
3187// ---------------------------------------------------------------------------
3188// scrolling
3189// ---------------------------------------------------------------------------
3190
3191bool wxWindow::MSWOnScroll(int orientation, WXWORD wParam,
3192 WXWORD pos, WXHWND control)
2bda0e17 3193{
42e69d6b 3194 if ( control )
cc2b7472 3195 {
42e69d6b
VZ
3196 wxWindow *child = wxFindWinFromHandle(control);
3197 if ( child )
3198 return child->MSWOnScroll(orientation, wParam, pos, control);
cc2b7472 3199 }
2bda0e17 3200
9145664b 3201 wxScrollWinEvent event;
42e69d6b
VZ
3202 event.SetPosition(pos);
3203 event.SetOrientation(orientation);
3204 event.m_eventObject = this;
cc2b7472 3205
42e69d6b
VZ
3206 switch ( wParam )
3207 {
3208 case SB_TOP:
9145664b 3209 event.m_eventType = wxEVT_SCROLLWIN_TOP;
42e69d6b 3210 break;
cc2b7472 3211
42e69d6b 3212 case SB_BOTTOM:
9145664b 3213 event.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
42e69d6b 3214 break;
cc2b7472 3215
42e69d6b 3216 case SB_LINEUP:
9145664b 3217 event.m_eventType = wxEVT_SCROLLWIN_LINEUP;
42e69d6b 3218 break;
2bda0e17 3219
42e69d6b 3220 case SB_LINEDOWN:
9145664b 3221 event.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
42e69d6b 3222 break;
a02eb1d2 3223
42e69d6b 3224 case SB_PAGEUP:
9145664b 3225 event.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
42e69d6b 3226 break;
2bda0e17 3227
42e69d6b 3228 case SB_PAGEDOWN:
9145664b 3229 event.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
42e69d6b 3230 break;
2bda0e17 3231
42e69d6b
VZ
3232 case SB_THUMBTRACK:
3233 case SB_THUMBPOSITION:
9145664b 3234 event.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
42e69d6b 3235 break;
c085e333 3236
42e69d6b
VZ
3237 default:
3238 return FALSE;
564b2609 3239 }
2bda0e17 3240
42e69d6b 3241 return GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
3242}
3243
42e69d6b
VZ
3244// ===========================================================================
3245// global functions
3246// ===========================================================================
3247
3248void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
2bda0e17 3249{
42e69d6b
VZ
3250 TEXTMETRIC tm;
3251 HDC dc = ::GetDC((HWND) wnd);
3252 HFONT fnt =0;
3253 HFONT was = 0;
3254 if ( the_font )
2d0a075d 3255 {
42e69d6b
VZ
3256 // the_font->UseResource();
3257 // the_font->RealizeResource();
3258 fnt = (HFONT)the_font->GetResourceHandle();
3259 if ( fnt )
3260 was = (HFONT) SelectObject(dc,fnt);
2d0a075d 3261 }
42e69d6b
VZ
3262 GetTextMetrics(dc, &tm);
3263 if ( the_font && fnt && was )
2d0a075d 3264 {
42e69d6b 3265 SelectObject(dc,was);
2d0a075d 3266 }
42e69d6b
VZ
3267 ReleaseDC((HWND)wnd, dc);
3268 *x = tm.tmAveCharWidth;
3269 *y = tm.tmHeight + tm.tmExternalLeading;
2bda0e17 3270
42e69d6b
VZ
3271 // if ( the_font )
3272 // the_font->ReleaseResource();
3273}
c085e333 3274
42e69d6b
VZ
3275// Returns 0 if was a normal ASCII value, not a special key. This indicates that
3276// the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3277int wxCharCodeMSWToWX(int keySym)
3278{
3279 int id = 0;
3280 switch (keySym)
3281 {
3282 case VK_CANCEL: id = WXK_CANCEL; break;
3283 case VK_BACK: id = WXK_BACK; break;
3284 case VK_TAB: id = WXK_TAB; break;
3285 case VK_CLEAR: id = WXK_CLEAR; break;
3286 case VK_RETURN: id = WXK_RETURN; break;
3287 case VK_SHIFT: id = WXK_SHIFT; break;
3288 case VK_CONTROL: id = WXK_CONTROL; break;
3289 case VK_MENU : id = WXK_MENU; break;
3290 case VK_PAUSE: id = WXK_PAUSE; break;
3291 case VK_SPACE: id = WXK_SPACE; break;
3292 case VK_ESCAPE: id = WXK_ESCAPE; break;
3293 case VK_PRIOR: id = WXK_PRIOR; break;
3294 case VK_NEXT : id = WXK_NEXT; break;
3295 case VK_END: id = WXK_END; break;
3296 case VK_HOME : id = WXK_HOME; break;
3297 case VK_LEFT : id = WXK_LEFT; break;
3298 case VK_UP: id = WXK_UP; break;
3299 case VK_RIGHT: id = WXK_RIGHT; break;
3300 case VK_DOWN : id = WXK_DOWN; break;
3301 case VK_SELECT: id = WXK_SELECT; break;
3302 case VK_PRINT: id = WXK_PRINT; break;
3303 case VK_EXECUTE: id = WXK_EXECUTE; break;
3304 case VK_INSERT: id = WXK_INSERT; break;
3305 case VK_DELETE: id = WXK_DELETE; break;
3306 case VK_HELP : id = WXK_HELP; break;
3307 case VK_NUMPAD0: id = WXK_NUMPAD0; break;
3308 case VK_NUMPAD1: id = WXK_NUMPAD1; break;
3309 case VK_NUMPAD2: id = WXK_NUMPAD2; break;
3310 case VK_NUMPAD3: id = WXK_NUMPAD3; break;
3311 case VK_NUMPAD4: id = WXK_NUMPAD4; break;
3312 case VK_NUMPAD5: id = WXK_NUMPAD5; break;
3313 case VK_NUMPAD6: id = WXK_NUMPAD6; break;
3314 case VK_NUMPAD7: id = WXK_NUMPAD7; break;
3315 case VK_NUMPAD8: id = WXK_NUMPAD8; break;
3316 case VK_NUMPAD9: id = WXK_NUMPAD9; break;
3317 case VK_MULTIPLY: id = WXK_MULTIPLY; break;
3318 case VK_ADD: id = WXK_ADD; break;
3319 case VK_SUBTRACT: id = WXK_SUBTRACT; break;
3320 case VK_DECIMAL: id = WXK_DECIMAL; break;
3321 case VK_DIVIDE: id = WXK_DIVIDE; break;
3322 case VK_F1: id = WXK_F1; break;
3323 case VK_F2: id = WXK_F2; break;
3324 case VK_F3: id = WXK_F3; break;
3325 case VK_F4: id = WXK_F4; break;
3326 case VK_F5: id = WXK_F5; break;
3327 case VK_F6: id = WXK_F6; break;
3328 case VK_F7: id = WXK_F7; break;
3329 case VK_F8: id = WXK_F8; break;
3330 case VK_F9: id = WXK_F9; break;
3331 case VK_F10: id = WXK_F10; break;
3332 case VK_F11: id = WXK_F11; break;
3333 case VK_F12: id = WXK_F12; break;
3334 case VK_F13: id = WXK_F13; break;
3335 case VK_F14: id = WXK_F14; break;
3336 case VK_F15: id = WXK_F15; break;
3337 case VK_F16: id = WXK_F16; break;
3338 case VK_F17: id = WXK_F17; break;
3339 case VK_F18: id = WXK_F18; break;
3340 case VK_F19: id = WXK_F19; break;
3341 case VK_F20: id = WXK_F20; break;
3342 case VK_F21: id = WXK_F21; break;
3343 case VK_F22: id = WXK_F22; break;
3344 case VK_F23: id = WXK_F23; break;
3345 case VK_F24: id = WXK_F24; break;
3346 case VK_NUMLOCK: id = WXK_NUMLOCK; break;
3347 case VK_SCROLL: id = WXK_SCROLL; break;
3348 default:
3349 {
3350 return 0;
3351 }
3352 }
3353 return id;
2bda0e17
KB
3354}
3355
42e69d6b 3356int wxCharCodeWXToMSW(int id, bool *isVirtual)
2bda0e17 3357{
42e69d6b
VZ
3358 *isVirtual = TRUE;
3359 int keySym = 0;
3360 switch (id)
2bda0e17 3361 {
42e69d6b
VZ
3362 case WXK_CANCEL: keySym = VK_CANCEL; break;
3363 case WXK_CLEAR: keySym = VK_CLEAR; break;
3364 case WXK_SHIFT: keySym = VK_SHIFT; break;
3365 case WXK_CONTROL: keySym = VK_CONTROL; break;
3366 case WXK_MENU : keySym = VK_MENU; break;
3367 case WXK_PAUSE: keySym = VK_PAUSE; break;
3368 case WXK_PRIOR: keySym = VK_PRIOR; break;
3369 case WXK_NEXT : keySym = VK_NEXT; break;
3370 case WXK_END: keySym = VK_END; break;
3371 case WXK_HOME : keySym = VK_HOME; break;
3372 case WXK_LEFT : keySym = VK_LEFT; break;
3373 case WXK_UP: keySym = VK_UP; break;
3374 case WXK_RIGHT: keySym = VK_RIGHT; break;
3375 case WXK_DOWN : keySym = VK_DOWN; break;
3376 case WXK_SELECT: keySym = VK_SELECT; break;
3377 case WXK_PRINT: keySym = VK_PRINT; break;
3378 case WXK_EXECUTE: keySym = VK_EXECUTE; break;
3379 case WXK_INSERT: keySym = VK_INSERT; break;
3380 case WXK_DELETE: keySym = VK_DELETE; break;
3381 case WXK_HELP : keySym = VK_HELP; break;
3382 case WXK_NUMPAD0: keySym = VK_NUMPAD0; break;
3383 case WXK_NUMPAD1: keySym = VK_NUMPAD1; break;
3384 case WXK_NUMPAD2: keySym = VK_NUMPAD2; break;
3385 case WXK_NUMPAD3: keySym = VK_NUMPAD3; break;
3386 case WXK_NUMPAD4: keySym = VK_NUMPAD4; break;
3387 case WXK_NUMPAD5: keySym = VK_NUMPAD5; break;
3388 case WXK_NUMPAD6: keySym = VK_NUMPAD6; break;
3389 case WXK_NUMPAD7: keySym = VK_NUMPAD7; break;
3390 case WXK_NUMPAD8: keySym = VK_NUMPAD8; break;
3391 case WXK_NUMPAD9: keySym = VK_NUMPAD9; break;
3392 case WXK_MULTIPLY: keySym = VK_MULTIPLY; break;
3393 case WXK_ADD: keySym = VK_ADD; break;
3394 case WXK_SUBTRACT: keySym = VK_SUBTRACT; break;
3395 case WXK_DECIMAL: keySym = VK_DECIMAL; break;
3396 case WXK_DIVIDE: keySym = VK_DIVIDE; break;
3397 case WXK_F1: keySym = VK_F1; break;
3398 case WXK_F2: keySym = VK_F2; break;
3399 case WXK_F3: keySym = VK_F3; break;
3400 case WXK_F4: keySym = VK_F4; break;
3401 case WXK_F5: keySym = VK_F5; break;
3402 case WXK_F6: keySym = VK_F6; break;
3403 case WXK_F7: keySym = VK_F7; break;
3404 case WXK_F8: keySym = VK_F8; break;
3405 case WXK_F9: keySym = VK_F9; break;
3406 case WXK_F10: keySym = VK_F10; break;
3407 case WXK_F11: keySym = VK_F11; break;
3408 case WXK_F12: keySym = VK_F12; break;
3409 case WXK_F13: keySym = VK_F13; break;
3410 case WXK_F14: keySym = VK_F14; break;
3411 case WXK_F15: keySym = VK_F15; break;
3412 case WXK_F16: keySym = VK_F16; break;
3413 case WXK_F17: keySym = VK_F17; break;
3414 case WXK_F18: keySym = VK_F18; break;
3415 case WXK_F19: keySym = VK_F19; break;
3416 case WXK_F20: keySym = VK_F20; break;
3417 case WXK_F21: keySym = VK_F21; break;
3418 case WXK_F22: keySym = VK_F22; break;
3419 case WXK_F23: keySym = VK_F23; break;
3420 case WXK_F24: keySym = VK_F24; break;
3421 case WXK_NUMLOCK: keySym = VK_NUMLOCK; break;
3422 case WXK_SCROLL: keySym = VK_SCROLL; break;
3423 default:
3424 {
3425 *isVirtual = FALSE;
3426 keySym = id;
3427 break;
3428 }
2bda0e17 3429 }
42e69d6b 3430 return keySym;
2bda0e17
KB
3431}
3432
42e69d6b 3433wxWindow *wxGetActiveWindow()
2bda0e17 3434{
42e69d6b
VZ
3435 HWND hWnd = GetActiveWindow();
3436 if ( hWnd != 0 )
2d0a075d 3437 {
42e69d6b 3438 return wxFindWinFromHandle((WXHWND) hWnd);
2d0a075d 3439 }
42e69d6b 3440 return NULL;
2bda0e17
KB
3441}
3442
42e69d6b
VZ
3443// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3444// in active frames and dialogs, regardless of where the focus is.
3445static HHOOK wxTheKeyboardHook = 0;
3446static FARPROC wxTheKeyboardHookProc = 0;
3447int APIENTRY _EXPORT
3448wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
2bda0e17 3449
42e69d6b 3450void wxSetKeyboardHook(bool doIt)
2bda0e17 3451{
42e69d6b 3452 if ( doIt )
2d0a075d 3453 {
42e69d6b
VZ
3454 wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
3455 wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
3456#if defined(__WIN32__) && !defined(__TWIN32__)
3457 GetCurrentThreadId());
3458 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3459#else
3460 GetCurrentTask());
3461#endif
2d0a075d 3462 }
2d0a075d 3463 else
2d0a075d 3464 {
42e69d6b
VZ
3465 UnhookWindowsHookEx(wxTheKeyboardHook);
3466 FreeProcInstance(wxTheKeyboardHookProc);
2d0a075d 3467 }
2bda0e17
KB
3468}
3469
42e69d6b
VZ
3470int APIENTRY _EXPORT
3471wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
2bda0e17 3472{
42e69d6b
VZ
3473 DWORD hiWord = HIWORD(lParam);
3474 if ( nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0) )
43d811ea 3475 {
42e69d6b
VZ
3476 int id;
3477 if ( (id = wxCharCodeMSWToWX(wParam)) != 0 )
43d811ea 3478 {
42e69d6b
VZ
3479 wxKeyEvent event(wxEVT_CHAR_HOOK);
3480 if ( (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN )
3481 event.m_altDown = TRUE;
c085e333 3482
42e69d6b
VZ
3483 event.m_eventObject = NULL;
3484 event.m_keyCode = id;
3485 /* begin Albert's fix for control and shift key 26.5 */
3486 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
3487 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
3488 /* end Albert's fix for control and shift key 26.5 */
3489 event.SetTimestamp(s_currentMsg.time);
c085e333 3490
42e69d6b
VZ
3491 wxWindow *win = wxGetActiveWindow();
3492 if ( win )
3493 {
3494 if ( win->GetEventHandler()->ProcessEvent(event) )
3495 return 1;
3496 }
3497 else
3498 {
3499 if ( wxTheApp && wxTheApp->ProcessEvent(event) )
3500 return 1;
3501 }
43d811ea
JS
3502 }
3503 }
42e69d6b 3504 return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam);
4fabb575
JS
3505}
3506
b2aef89b 3507#ifdef __WXDEBUG__
f449ef69 3508const char *wxGetMessageName(int message)
47cbd6da 3509{
42e69d6b
VZ
3510 switch ( message )
3511 {
3512 case 0x0000: return "WM_NULL";
3513 case 0x0001: return "WM_CREATE";
3514 case 0x0002: return "WM_DESTROY";
3515 case 0x0003: return "WM_MOVE";
3516 case 0x0005: return "WM_SIZE";
3517 case 0x0006: return "WM_ACTIVATE";
3518 case 0x0007: return "WM_SETFOCUS";
3519 case 0x0008: return "WM_KILLFOCUS";
3520 case 0x000A: return "WM_ENABLE";
3521 case 0x000B: return "WM_SETREDRAW";
3522 case 0x000C: return "WM_SETTEXT";
3523 case 0x000D: return "WM_GETTEXT";
3524 case 0x000E: return "WM_GETTEXTLENGTH";
3525 case 0x000F: return "WM_PAINT";
3526 case 0x0010: return "WM_CLOSE";
3527 case 0x0011: return "WM_QUERYENDSESSION";
3528 case 0x0012: return "WM_QUIT";
3529 case 0x0013: return "WM_QUERYOPEN";
3530 case 0x0014: return "WM_ERASEBKGND";
3531 case 0x0015: return "WM_SYSCOLORCHANGE";
3532 case 0x0016: return "WM_ENDSESSION";
3533 case 0x0017: return "WM_SYSTEMERROR";
3534 case 0x0018: return "WM_SHOWWINDOW";
3535 case 0x0019: return "WM_CTLCOLOR";
3536 case 0x001A: return "WM_WININICHANGE";
3537 case 0x001B: return "WM_DEVMODECHANGE";
3538 case 0x001C: return "WM_ACTIVATEAPP";
3539 case 0x001D: return "WM_FONTCHANGE";
3540 case 0x001E: return "WM_TIMECHANGE";
3541 case 0x001F: return "WM_CANCELMODE";
3542 case 0x0020: return "WM_SETCURSOR";
3543 case 0x0021: return "WM_MOUSEACTIVATE";
3544 case 0x0022: return "WM_CHILDACTIVATE";
3545 case 0x0023: return "WM_QUEUESYNC";
3546 case 0x0024: return "WM_GETMINMAXINFO";
3547 case 0x0026: return "WM_PAINTICON";
3548 case 0x0027: return "WM_ICONERASEBKGND";
3549 case 0x0028: return "WM_NEXTDLGCTL";
3550 case 0x002A: return "WM_SPOOLERSTATUS";
3551 case 0x002B: return "WM_DRAWITEM";
3552 case 0x002C: return "WM_MEASUREITEM";
3553 case 0x002D: return "WM_DELETEITEM";
3554 case 0x002E: return "WM_VKEYTOITEM";
3555 case 0x002F: return "WM_CHARTOITEM";
3556 case 0x0030: return "WM_SETFONT";
3557 case 0x0031: return "WM_GETFONT";
3558 case 0x0037: return "WM_QUERYDRAGICON";
3559 case 0x0039: return "WM_COMPAREITEM";
3560 case 0x0041: return "WM_COMPACTING";
3561 case 0x0044: return "WM_COMMNOTIFY";
3562 case 0x0046: return "WM_WINDOWPOSCHANGING";
3563 case 0x0047: return "WM_WINDOWPOSCHANGED";
3564 case 0x0048: return "WM_POWER";
c085e333 3565
a02eb1d2 3566#ifdef __WIN32__
42e69d6b
VZ
3567 case 0x004A: return "WM_COPYDATA";
3568 case 0x004B: return "WM_CANCELJOURNAL";
3569 case 0x004E: return "WM_NOTIFY";
3570 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
3571 case 0x0051: return "WM_INPUTLANGCHANGE";
3572 case 0x0052: return "WM_TCARD";
3573 case 0x0053: return "WM_HELP";
3574 case 0x0054: return "WM_USERCHANGED";
3575 case 0x0055: return "WM_NOTIFYFORMAT";
3576 case 0x007B: return "WM_CONTEXTMENU";
3577 case 0x007C: return "WM_STYLECHANGING";
3578 case 0x007D: return "WM_STYLECHANGED";
3579 case 0x007E: return "WM_DISPLAYCHANGE";
3580 case 0x007F: return "WM_GETICON";
3581 case 0x0080: return "WM_SETICON";
a02eb1d2 3582#endif //WIN32
c085e333 3583
42e69d6b
VZ
3584 case 0x0081: return "WM_NCCREATE";
3585 case 0x0082: return "WM_NCDESTROY";
3586 case 0x0083: return "WM_NCCALCSIZE";
3587 case 0x0084: return "WM_NCHITTEST";
3588 case 0x0085: return "WM_NCPAINT";
3589 case 0x0086: return "WM_NCACTIVATE";
3590 case 0x0087: return "WM_GETDLGCODE";
3591 case 0x00A0: return "WM_NCMOUSEMOVE";
3592 case 0x00A1: return "WM_NCLBUTTONDOWN";
3593 case 0x00A2: return "WM_NCLBUTTONUP";
3594 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
3595 case 0x00A4: return "WM_NCRBUTTONDOWN";
3596 case 0x00A5: return "WM_NCRBUTTONUP";
3597 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
3598 case 0x00A7: return "WM_NCMBUTTONDOWN";
3599 case 0x00A8: return "WM_NCMBUTTONUP";
3600 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
3601 case 0x0100: return "WM_KEYDOWN";
3602 case 0x0101: return "WM_KEYUP";
3603 case 0x0102: return "WM_CHAR";
3604 case 0x0103: return "WM_DEADCHAR";
3605 case 0x0104: return "WM_SYSKEYDOWN";
3606 case 0x0105: return "WM_SYSKEYUP";
3607 case 0x0106: return "WM_SYSCHAR";
3608 case 0x0107: return "WM_SYSDEADCHAR";
3609 case 0x0108: return "WM_KEYLAST";
c085e333 3610
a02eb1d2 3611#ifdef __WIN32__
42e69d6b
VZ
3612 case 0x010D: return "WM_IME_STARTCOMPOSITION";
3613 case 0x010E: return "WM_IME_ENDCOMPOSITION";
3614 case 0x010F: return "WM_IME_COMPOSITION";
a02eb1d2 3615#endif //WIN32
c085e333 3616
42e69d6b
VZ
3617 case 0x0110: return "WM_INITDIALOG";
3618 case 0x0111: return "WM_COMMAND";
3619 case 0x0112: return "WM_SYSCOMMAND";
3620 case 0x0113: return "WM_TIMER";
3621 case 0x0114: return "WM_HSCROLL";
3622 case 0x0115: return "WM_VSCROLL";
3623 case 0x0116: return "WM_INITMENU";
3624 case 0x0117: return "WM_INITMENUPOPUP";
3625 case 0x011F: return "WM_MENUSELECT";
3626 case 0x0120: return "WM_MENUCHAR";
3627 case 0x0121: return "WM_ENTERIDLE";
3628 case 0x0200: return "WM_MOUSEMOVE";
3629 case 0x0201: return "WM_LBUTTONDOWN";
3630 case 0x0202: return "WM_LBUTTONUP";
3631 case 0x0203: return "WM_LBUTTONDBLCLK";
3632 case 0x0204: return "WM_RBUTTONDOWN";
3633 case 0x0205: return "WM_RBUTTONUP";
3634 case 0x0206: return "WM_RBUTTONDBLCLK";
3635 case 0x0207: return "WM_MBUTTONDOWN";
3636 case 0x0208: return "WM_MBUTTONUP";
3637 case 0x0209: return "WM_MBUTTONDBLCLK";
3638 case 0x0210: return "WM_PARENTNOTIFY";
3639 case 0x0211: return "WM_ENTERMENULOOP";
3640 case 0x0212: return "WM_EXITMENULOOP";
c085e333 3641
a02eb1d2 3642#ifdef __WIN32__
42e69d6b
VZ
3643 case 0x0213: return "WM_NEXTMENU";
3644 case 0x0214: return "WM_SIZING";
3645 case 0x0215: return "WM_CAPTURECHANGED";
3646 case 0x0216: return "WM_MOVING";
3647 case 0x0218: return "WM_POWERBROADCAST";
3648 case 0x0219: return "WM_DEVICECHANGE";
a02eb1d2 3649#endif //WIN32
c085e333 3650
42e69d6b
VZ
3651 case 0x0220: return "WM_MDICREATE";
3652 case 0x0221: return "WM_MDIDESTROY";
3653 case 0x0222: return "WM_MDIACTIVATE";
3654 case 0x0223: return "WM_MDIRESTORE";
3655 case 0x0224: return "WM_MDINEXT";
3656 case 0x0225: return "WM_MDIMAXIMIZE";
3657 case 0x0226: return "WM_MDITILE";
3658 case 0x0227: return "WM_MDICASCADE";
3659 case 0x0228: return "WM_MDIICONARRANGE";
3660 case 0x0229: return "WM_MDIGETACTIVE";
3661 case 0x0230: return "WM_MDISETMENU";
3662 case 0x0233: return "WM_DROPFILES";
c085e333 3663
a02eb1d2 3664#ifdef __WIN32__
42e69d6b
VZ
3665 case 0x0281: return "WM_IME_SETCONTEXT";
3666 case 0x0282: return "WM_IME_NOTIFY";
3667 case 0x0283: return "WM_IME_CONTROL";
3668 case 0x0284: return "WM_IME_COMPOSITIONFULL";
3669 case 0x0285: return "WM_IME_SELECT";
3670 case 0x0286: return "WM_IME_CHAR";
3671 case 0x0290: return "WM_IME_KEYDOWN";
3672 case 0x0291: return "WM_IME_KEYUP";
a02eb1d2 3673#endif //WIN32
c085e333 3674
42e69d6b
VZ
3675 case 0x0300: return "WM_CUT";
3676 case 0x0301: return "WM_COPY";
3677 case 0x0302: return "WM_PASTE";
3678 case 0x0303: return "WM_CLEAR";
3679 case 0x0304: return "WM_UNDO";
3680 case 0x0305: return "WM_RENDERFORMAT";
3681 case 0x0306: return "WM_RENDERALLFORMATS";
3682 case 0x0307: return "WM_DESTROYCLIPBOARD";
3683 case 0x0308: return "WM_DRAWCLIPBOARD";
3684 case 0x0309: return "WM_PAINTCLIPBOARD";
3685 case 0x030A: return "WM_VSCROLLCLIPBOARD";
3686 case 0x030B: return "WM_SIZECLIPBOARD";
3687 case 0x030C: return "WM_ASKCBFORMATNAME";
3688 case 0x030D: return "WM_CHANGECBCHAIN";
3689 case 0x030E: return "WM_HSCROLLCLIPBOARD";
3690 case 0x030F: return "WM_QUERYNEWPALETTE";
3691 case 0x0310: return "WM_PALETTEISCHANGING";
3692 case 0x0311: return "WM_PALETTECHANGED";
c085e333 3693
a02eb1d2 3694#ifdef __WIN32__
2d0a075d
JS
3695 // common controls messages - although they're not strictly speaking
3696 // standard, it's nice to decode them nevertheless
a02eb1d2 3697
2d0a075d 3698 // listview
42e69d6b
VZ
3699 case 0x1000 + 0: return "LVM_GETBKCOLOR";
3700 case 0x1000 + 1: return "LVM_SETBKCOLOR";
3701 case 0x1000 + 2: return "LVM_GETIMAGELIST";
3702 case 0x1000 + 3: return "LVM_SETIMAGELIST";
3703 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
3704 case 0x1000 + 5: return "LVM_GETITEMA";
3705 case 0x1000 + 75: return "LVM_GETITEMW";
3706 case 0x1000 + 6: return "LVM_SETITEMA";
3707 case 0x1000 + 76: return "LVM_SETITEMW";
3708 case 0x1000 + 7: return "LVM_INSERTITEMA";
3709 case 0x1000 + 77: return "LVM_INSERTITEMW";
3710 case 0x1000 + 8: return "LVM_DELETEITEM";
3711 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
3712 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
3713 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
3714 case 0x1000 + 12: return "LVM_GETNEXTITEM";
3715 case 0x1000 + 13: return "LVM_FINDITEMA";
3716 case 0x1000 + 83: return "LVM_FINDITEMW";
3717 case 0x1000 + 14: return "LVM_GETITEMRECT";
3718 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
3719 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
3720 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
3721 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
3722 case 0x1000 + 18: return "LVM_HITTEST";
3723 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
3724 case 0x1000 + 20: return "LVM_SCROLL";
3725 case 0x1000 + 21: return "LVM_REDRAWITEMS";
3726 case 0x1000 + 22: return "LVM_ARRANGE";
3727 case 0x1000 + 23: return "LVM_EDITLABELA";
3728 case 0x1000 + 118: return "LVM_EDITLABELW";
3729 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
3730 case 0x1000 + 25: return "LVM_GETCOLUMNA";
3731 case 0x1000 + 95: return "LVM_GETCOLUMNW";
3732 case 0x1000 + 26: return "LVM_SETCOLUMNA";
3733 case 0x1000 + 96: return "LVM_SETCOLUMNW";
3734 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
3735 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
3736 case 0x1000 + 28: return "LVM_DELETECOLUMN";
3737 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
3738 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
3739 case 0x1000 + 31: return "LVM_GETHEADER";
3740 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
3741 case 0x1000 + 34: return "LVM_GETVIEWRECT";
3742 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
3743 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
3744 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
3745 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
3746 case 0x1000 + 39: return "LVM_GETTOPINDEX";
3747 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
3748 case 0x1000 + 41: return "LVM_GETORIGIN";
3749 case 0x1000 + 42: return "LVM_UPDATE";
3750 case 0x1000 + 43: return "LVM_SETITEMSTATE";
3751 case 0x1000 + 44: return "LVM_GETITEMSTATE";
3752 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
3753 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
3754 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
3755 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
3756 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
3757 case 0x1000 + 48: return "LVM_SORTITEMS";
3758 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
3759 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
3760 case 0x1000 + 51: return "LVM_GETITEMSPACING";
3761 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
3762 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
3763 case 0x1000 + 53: return "LVM_SETICONSPACING";
3764 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
3765 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
3766 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
3767 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
3768 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
3769 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
3770 case 0x1000 + 60: return "LVM_SETHOTITEM";
3771 case 0x1000 + 61: return "LVM_GETHOTITEM";
3772 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
3773 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
3774 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
3775 case 0x1000 + 65: return "LVM_SETWORKAREA";
c085e333 3776
2d0a075d 3777 // tree view
42e69d6b
VZ
3778 case 0x1100 + 0: return "TVM_INSERTITEMA";
3779 case 0x1100 + 50: return "TVM_INSERTITEMW";
3780 case 0x1100 + 1: return "TVM_DELETEITEM";
3781 case 0x1100 + 2: return "TVM_EXPAND";
3782 case 0x1100 + 4: return "TVM_GETITEMRECT";
3783 case 0x1100 + 5: return "TVM_GETCOUNT";
3784 case 0x1100 + 6: return "TVM_GETINDENT";
3785 case 0x1100 + 7: return "TVM_SETINDENT";
3786 case 0x1100 + 8: return "TVM_GETIMAGELIST";
3787 case 0x1100 + 9: return "TVM_SETIMAGELIST";
3788 case 0x1100 + 10: return "TVM_GETNEXTITEM";
3789 case 0x1100 + 11: return "TVM_SELECTITEM";
3790 case 0x1100 + 12: return "TVM_GETITEMA";
3791 case 0x1100 + 62: return "TVM_GETITEMW";
3792 case 0x1100 + 13: return "TVM_SETITEMA";
3793 case 0x1100 + 63: return "TVM_SETITEMW";
3794 case 0x1100 + 14: return "TVM_EDITLABELA";
3795 case 0x1100 + 65: return "TVM_EDITLABELW";
3796 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
3797 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
3798 case 0x1100 + 17: return "TVM_HITTEST";
3799 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
3800 case 0x1100 + 19: return "TVM_SORTCHILDREN";
3801 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
3802 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
3803 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
3804 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
3805 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
3806 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
3807 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
c085e333 3808
2d0a075d 3809 // header
42e69d6b
VZ
3810 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
3811 case 0x1200 + 1: return "HDM_INSERTITEMA";
3812 case 0x1200 + 10: return "HDM_INSERTITEMW";
3813 case 0x1200 + 2: return "HDM_DELETEITEM";
3814 case 0x1200 + 3: return "HDM_GETITEMA";
3815 case 0x1200 + 11: return "HDM_GETITEMW";
3816 case 0x1200 + 4: return "HDM_SETITEMA";
3817 case 0x1200 + 12: return "HDM_SETITEMW";
3818 case 0x1200 + 5: return "HDM_LAYOUT";
3819 case 0x1200 + 6: return "HDM_HITTEST";
3820 case 0x1200 + 7: return "HDM_GETITEMRECT";
3821 case 0x1200 + 8: return "HDM_SETIMAGELIST";
3822 case 0x1200 + 9: return "HDM_GETIMAGELIST";
3823 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
3824 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
3825 case 0x1200 + 17: return "HDM_GETORDERARRAY";
3826 case 0x1200 + 18: return "HDM_SETORDERARRAY";
3827 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
c085e333 3828
2d0a075d 3829 // tab control
42e69d6b
VZ
3830 case 0x1300 + 2: return "TCM_GETIMAGELIST";
3831 case 0x1300 + 3: return "TCM_SETIMAGELIST";
3832 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
3833 case 0x1300 + 5: return "TCM_GETITEMA";
3834 case 0x1300 + 60: return "TCM_GETITEMW";
3835 case 0x1300 + 6: return "TCM_SETITEMA";
3836 case 0x1300 + 61: return "TCM_SETITEMW";
3837 case 0x1300 + 7: return "TCM_INSERTITEMA";
3838 case 0x1300 + 62: return "TCM_INSERTITEMW";
3839 case 0x1300 + 8: return "TCM_DELETEITEM";
3840 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
3841 case 0x1300 + 10: return "TCM_GETITEMRECT";
3842 case 0x1300 + 11: return "TCM_GETCURSEL";
3843 case 0x1300 + 12: return "TCM_SETCURSEL";
3844 case 0x1300 + 13: return "TCM_HITTEST";
3845 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
3846 case 0x1300 + 40: return "TCM_ADJUSTRECT";
3847 case 0x1300 + 41: return "TCM_SETITEMSIZE";
3848 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
3849 case 0x1300 + 43: return "TCM_SETPADDING";
3850 case 0x1300 + 44: return "TCM_GETROWCOUNT";
3851 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
3852 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
3853 case 0x1300 + 47: return "TCM_GETCURFOCUS";
3854 case 0x1300 + 48: return "TCM_SETCURFOCUS";
3855 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
3856 case 0x1300 + 50: return "TCM_DESELECTALL";
c085e333 3857
2d0a075d 3858 // toolbar
42e69d6b
VZ
3859 case WM_USER+1: return "TB_ENABLEBUTTON";
3860 case WM_USER+2: return "TB_CHECKBUTTON";
3861 case WM_USER+3: return "TB_PRESSBUTTON";
3862 case WM_USER+4: return "TB_HIDEBUTTON";
3863 case WM_USER+5: return "TB_INDETERMINATE";
3864 case WM_USER+9: return "TB_ISBUTTONENABLED";
3865 case WM_USER+10: return "TB_ISBUTTONCHECKED";
3866 case WM_USER+11: return "TB_ISBUTTONPRESSED";
3867 case WM_USER+12: return "TB_ISBUTTONHIDDEN";
3868 case WM_USER+13: return "TB_ISBUTTONINDETERMINATE";
3869 case WM_USER+17: return "TB_SETSTATE";
3870 case WM_USER+18: return "TB_GETSTATE";
3871 case WM_USER+19: return "TB_ADDBITMAP";
3872 case WM_USER+20: return "TB_ADDBUTTONS";
3873 case WM_USER+21: return "TB_INSERTBUTTON";
3874 case WM_USER+22: return "TB_DELETEBUTTON";
3875 case WM_USER+23: return "TB_GETBUTTON";
3876 case WM_USER+24: return "TB_BUTTONCOUNT";
3877 case WM_USER+25: return "TB_COMMANDTOINDEX";
3878 case WM_USER+26: return "TB_SAVERESTOREA";
3879 case WM_USER+76: return "TB_SAVERESTOREW";
3880 case WM_USER+27: return "TB_CUSTOMIZE";
3881 case WM_USER+28: return "TB_ADDSTRINGA";
3882 case WM_USER+77: return "TB_ADDSTRINGW";
3883 case WM_USER+29: return "TB_GETITEMRECT";
3884 case WM_USER+30: return "TB_BUTTONSTRUCTSIZE";
3885 case WM_USER+31: return "TB_SETBUTTONSIZE";
3886 case WM_USER+32: return "TB_SETBITMAPSIZE";
3887 case WM_USER+33: return "TB_AUTOSIZE";
3888 case WM_USER+35: return "TB_GETTOOLTIPS";
3889 case WM_USER+36: return "TB_SETTOOLTIPS";
3890 case WM_USER+37: return "TB_SETPARENT";
3891 case WM_USER+39: return "TB_SETROWS";
3892 case WM_USER+40: return "TB_GETROWS";
3893 case WM_USER+42: return "TB_SETCMDID";
3894 case WM_USER+43: return "TB_CHANGEBITMAP";
3895 case WM_USER+44: return "TB_GETBITMAP";
3896 case WM_USER+45: return "TB_GETBUTTONTEXTA";
3897 case WM_USER+75: return "TB_GETBUTTONTEXTW";
3898 case WM_USER+46: return "TB_REPLACEBITMAP";
3899 case WM_USER+47: return "TB_SETINDENT";
3900 case WM_USER+48: return "TB_SETIMAGELIST";
3901 case WM_USER+49: return "TB_GETIMAGELIST";
3902 case WM_USER+50: return "TB_LOADIMAGES";
3903 case WM_USER+51: return "TB_GETRECT";
3904 case WM_USER+52: return "TB_SETHOTIMAGELIST";
3905 case WM_USER+53: return "TB_GETHOTIMAGELIST";
3906 case WM_USER+54: return "TB_SETDISABLEDIMAGELIST";
3907 case WM_USER+55: return "TB_GETDISABLEDIMAGELIST";
3908 case WM_USER+56: return "TB_SETSTYLE";
3909 case WM_USER+57: return "TB_GETSTYLE";
3910 case WM_USER+58: return "TB_GETBUTTONSIZE";
3911 case WM_USER+59: return "TB_SETBUTTONWIDTH";
3912 case WM_USER+60: return "TB_SETMAXTEXTROWS";
3913 case WM_USER+61: return "TB_GETTEXTROWS";
3914 case WM_USER+41: return "TB_GETBITMAPFLAGS";
c085e333 3915
a02eb1d2 3916#endif //WIN32
c085e333 3917
42e69d6b
VZ
3918 default:
3919 static char s_szBuf[128];
3920 sprintf(s_szBuf, "<unknown message = %d>", message);
3921 return s_szBuf;
3922 }
47cbd6da 3923}
ea57084d 3924#endif //__WXDEBUG__