]> git.saurik.com Git - wxWidgets.git/blame - src/msw/window.cpp
resizeable dialogs support
[wxWidgets.git] / src / msw / window.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: windows.cpp
3// Purpose: wxWindow
4// Author: Julian Smart
5// Modified by:
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
12#ifdef __GNUG__
13#pragma implementation "window.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
09914df7 20 #pragma hdrstop
2bda0e17
KB
21#endif
22
23#ifndef WX_PRECOMP
3a19e16d
VZ
24 #include "wx/setup.h"
25 #include "wx/menu.h"
26 #include "wx/dc.h"
27 #include "wx/dcclient.h"
28 #include "wx/utils.h"
29 #include "wx/app.h"
30 #include "wx/panel.h"
31 #include "wx/layout.h"
32 #include "wx/dialog.h"
33 #include "wx/frame.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/settings.h"
37 #include "wx/msgdlg.h"
341c92a8
VZ
38
39 #include <stdio.h>
2bda0e17
KB
40#endif
41
47d67540 42#if wxUSE_OWNER_DRAWN
09914df7 43 #include "wx/ownerdrw.h"
2bda0e17
KB
44#endif
45
47d67540 46#if wxUSE_DRAG_AND_DROP
09914df7 47 #include "wx/msw/ole/droptgt.h"
2bda0e17
KB
48#endif
49
50#include "wx/menuitem.h"
47cbd6da 51#include "wx/log.h"
3a19e16d
VZ
52#include "wx/tooltip.h"
53
2bda0e17
KB
54#include "wx/msw/private.h"
55
56#include <string.h>
57
58#ifndef __GNUWIN32__
3a19e16d
VZ
59 #include <shellapi.h>
60 #include <mmsystem.h>
2bda0e17
KB
61#endif
62
63#ifdef __WIN32__
3a19e16d 64 #include <windowsx.h>
2bda0e17
KB
65#endif
66
acbd13a3 67#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
3a19e16d 68#include <commctrl.h>
acbd13a3 69#endif
3a19e16d 70
57c208c5 71#ifndef __TWIN32__
3a19e16d
VZ
72 #ifdef __GNUWIN32__
73 #include <wx/msw/gnuwin32/extra.h>
74 #endif
57c208c5 75#endif
2bda0e17 76
3a19e16d 77// all these are defined in <windows.h>
2bda0e17
KB
78#ifdef GetCharWidth
79#undef GetCharWidth
80#endif
81
82#ifdef FindWindow
83#undef FindWindow
84#endif
85
86#ifdef GetClassName
87#undef GetClassName
88#endif
89
90#ifdef GetClassInfo
91#undef GetClassInfo
92#endif
93
b2aef89b 94#ifdef __WXDEBUG__
09914df7 95 const char *wxGetMessageName(int message);
ea57084d 96#endif //__WXDEBUG__
47cbd6da 97
f54f3bff 98#define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
2bda0e17
KB
99
100wxMenu *wxCurrentPopupMenu = NULL;
cde9f08e 101extern wxList WXDLLEXPORT wxPendingDelete;
2bda0e17
KB
102
103void wxRemoveHandleAssociation(wxWindow *win);
104void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
105wxWindow *wxFindWinFromHandle(WXHWND hWnd);
106
107#if !USE_SHARED_LIBRARY
3a19e16d 108 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
cf65ad8d 109#endif
2bda0e17
KB
110
111BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
cf65ad8d
VZ
112 EVT_CHAR(wxWindow::OnChar)
113 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
114 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
115 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
116 EVT_IDLE(wxWindow::OnIdle)
2bda0e17
KB
117END_EVENT_TABLE()
118
2bda0e17 119// Find an item given the MS Windows id
debe6624 120wxWindow *wxWindow::FindItem(int id) const
2bda0e17 121{
c0ed460c
JS
122// if (!GetChildren())
123// return NULL;
124 wxNode *current = GetChildren().First();
2d0a075d
JS
125 while (current)
126 {
127 wxWindow *childWin = (wxWindow *)current->Data();
2bda0e17 128
2d0a075d
JS
129 wxWindow *wnd = childWin->FindItem(id) ;
130 if (wnd)
131 return wnd ;
2bda0e17 132
2d0a075d
JS
133 if (childWin->IsKindOf(CLASSINFO(wxControl)))
134 {
135 wxControl *item = (wxControl *)childWin;
ce3ed50d 136 if (item->GetId() == id)
2d0a075d
JS
137 return item;
138 else
139 {
140 // In case it's a 'virtual' control (e.g. radiobox)
141 if (item->GetSubcontrols().Member((wxObject *)id))
142 return item;
143 }
144 }
145 current = current->Next();
2bda0e17 146 }
2d0a075d 147 return NULL;
2bda0e17
KB
148}
149
150// Find an item given the MS Windows handle
debe6624 151wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const
2bda0e17 152{
c0ed460c
JS
153// if (!GetChildren())
154// return NULL;
155 wxNode *current = GetChildren().First();
2d0a075d 156 while (current)
2bda0e17 157 {
2d0a075d
JS
158 wxObject *obj = (wxObject *)current->Data() ;
159 // Do a recursive search.
160 wxWindow *parent = (wxWindow *)obj ;
161 wxWindow *wnd = parent->FindItemByHWND(hWnd) ;
162 if (wnd)
163 return wnd ;
164
165 if ((!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl)))
166 {
167 wxWindow *item = (wxWindow *)current->Data();
168 if ((HWND)(item->GetHWND()) == (HWND) hWnd)
169 return item;
170 else
171 {
172 if ( item->ContainsHWND(hWnd) )
173 return item;
174 }
175 }
176 current = current->Next();
2bda0e17 177 }
2d0a075d 178 return NULL;
2bda0e17
KB
179}
180
181// Default command handler
debe6624 182bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
2bda0e17 183{
2d0a075d 184 return FALSE;
2bda0e17
KB
185}
186
fd3f686c 187bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
3a19e16d 188 WXLPARAM lParam,
fd3f686c 189 WXLPARAM* WXUNUSED(result))
2bda0e17 190{
acbd13a3 191#ifdef __WIN95__
3a19e16d
VZ
192 NMHDR* hdr = (NMHDR *)lParam;
193 if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
194 {
195 TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
196 ttt->lpszText = (char *)m_tooltip->GetTip().c_str();
197
198 // processed
199 return TRUE;
200 }
acbd13a3 201#endif
3a19e16d 202
2d0a075d 203 return FALSE;
2bda0e17
KB
204}
205
debe6624 206void wxWindow::PreDelete(WXHDC WXUNUSED(dc))
2bda0e17
KB
207{
208}
209
210WXHWND wxWindow::GetHWND(void) const
211{
2d0a075d 212 return (WXHWND) m_hWnd;
2bda0e17
KB
213}
214
215void wxWindow::SetHWND(WXHWND hWnd)
216{
2d0a075d 217 m_hWnd = hWnd;
2bda0e17
KB
218}
219
fd3f686c
VZ
220// ----------------------------------------------------------------------------
221// constructors and such
222// ----------------------------------------------------------------------------
223
224void wxWindow::Init()
2bda0e17 225{
2d0a075d
JS
226 // Generic
227 m_windowId = 0;
228 m_isShown = TRUE;
229 m_windowStyle = 0;
230 m_windowParent = NULL;
231 m_windowEventHandler = this;
2d0a075d
JS
232 m_windowCursor = *wxSTANDARD_CURSOR;
233 m_children = new wxList;
234 m_doubleClickAllowed = 0 ;
235 m_winCaptured = FALSE;
236 m_constraints = NULL;
237 m_constraintsInvolvedIn = NULL;
238 m_windowSizer = NULL;
239 m_sizerParent = NULL;
240 m_autoLayout = FALSE;
241 m_windowValidator = NULL;
242
243 // MSW-specific
244 m_hWnd = 0;
245 m_winEnabled = TRUE;
fd3f686c
VZ
246 m_caretWidth = m_caretHeight = 0;
247 m_caretEnabled =
2d0a075d
JS
248 m_caretShown = FALSE;
249 m_inOnSize = FALSE;
fd3f686c
VZ
250 m_minSizeX =
251 m_minSizeY =
252 m_maxSizeX =
2d0a075d 253 m_maxSizeY = -1;
fd3f686c 254
2d0a075d
JS
255 m_isBeingDeleted = FALSE;
256 m_oldWndProc = 0;
2bda0e17 257#ifndef __WIN32__
2d0a075d 258 m_globalHandle = 0;
2bda0e17 259#endif
2d0a075d 260 m_useCtl3D = FALSE;
fd3f686c 261 m_mouseInWindow = FALSE;
2bda0e17 262
fd3f686c 263 m_windowParent = NULL;
2d0a075d 264 m_defaultItem = NULL;
2bda0e17 265
2d0a075d 266 wxSystemSettings settings;
2bda0e17 267
2d0a075d 268 m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
2d0a075d 269 m_foregroundColour = *wxBLACK;
2bda0e17 270
2d0a075d
JS
271 // wxWnd
272 m_lastMsg = 0;
273 m_lastWParam = 0;
274 m_lastLParam = 0;
2d0a075d 275 m_hMenu = 0;
2bda0e17 276
2d0a075d
JS
277 m_xThumbSize = 0;
278 m_yThumbSize = 0;
279 m_backgroundTransparent = FALSE;
2bda0e17 280
2d0a075d
JS
281 m_lastXPos = (float)-1.0;
282 m_lastYPos = (float)-1.0;
283 m_lastEvent = -1;
284 m_returnCode = 0;
2bda0e17 285
47d67540 286#if wxUSE_DRAG_AND_DROP
2d0a075d 287 m_pDropTarget = NULL;
2bda0e17 288#endif
3a19e16d
VZ
289
290 m_tooltip = NULL;
2bda0e17
KB
291}
292
fd3f686c
VZ
293wxWindow::wxWindow()
294{
295 Init();
296}
297
2bda0e17 298// Destructor
fd3f686c 299wxWindow::~wxWindow()
2bda0e17 300{
2d0a075d 301 m_isBeingDeleted = TRUE;
2bda0e17 302
3a19e16d
VZ
303 // first of all, delete the things on which nothing else depends
304
305 wxDELETE(m_tooltip);
306
2d0a075d
JS
307 // JACS - if behaviour is odd, restore this
308 // to the start of ~wxWindow. Vadim has changed
309 // it to nearer the end. Unsure of side-effects
310 // e.g. when deleting associated global data.
311 // Restore old Window proc, if required
312 // UnsubclassWin();
2bda0e17 313
2d0a075d
JS
314 // Have to delete constraints/sizer FIRST otherwise
315 // sizers may try to look at deleted windows as they
316 // delete themselves.
47d67540 317#if wxUSE_CONSTRAINTS
2d0a075d 318 DeleteRelatedConstraints();
3a19e16d 319
2d0a075d
JS
320 if (m_constraints)
321 {
322 // This removes any dangling pointers to this window
323 // in other windows' constraintsInvolvedIn lists.
324 UnsetConstraints(m_constraints);
325 delete m_constraints;
326 m_constraints = NULL;
327 }
3a19e16d
VZ
328
329 wxDELETE(m_windowSizer);
330
2d0a075d
JS
331 // If this is a child of a sizer, remove self from parent
332 if (m_sizerParent)
333 m_sizerParent->RemoveChild((wxWindow *)this);
2bda0e17 334#endif
c085e333 335
2d0a075d
JS
336 // wxWnd
337 MSWDetachWindowMenu();
2bda0e17 338
2d0a075d
JS
339 if (m_windowParent)
340 m_windowParent->RemoveChild(this);
2bda0e17 341
2d0a075d 342 DestroyChildren();
2bda0e17 343
2d0a075d
JS
344 if (m_hWnd)
345 ::DestroyWindow((HWND)m_hWnd);
195896c7 346
2d0a075d
JS
347 wxRemoveHandleAssociation(this);
348 m_hWnd = 0;
2bda0e17 349#ifndef __WIN32__
2d0a075d
JS
350 if (m_globalHandle)
351 {
352 GlobalFree((HGLOBAL) m_globalHandle);
353 m_globalHandle = 0;
354 }
2bda0e17 355#endif
c085e333 356
2d0a075d
JS
357 delete m_children;
358 m_children = NULL;
2bda0e17 359
2d0a075d
JS
360 // Just in case the window has been Closed, but
361 // we're then deleting immediately: don't leave
362 // dangling pointers.
363 wxPendingDelete.DeleteObject(this);
2bda0e17 364
2d0a075d
JS
365 // Just in case we've loaded a top-level window via
366 // wxWindow::LoadNativeDialog but we weren't a dialog
367 // class
368 wxTopLevelWindows.DeleteObject(this);
2bda0e17 369
2d0a075d
JS
370 if ( m_windowValidator )
371 delete m_windowValidator;
2bda0e17 372
c085e333 373 // Restore old Window proc, if required
2d0a075d
JS
374 // and remove hWnd <-> wxWindow association
375 UnsubclassWin();
2bda0e17
KB
376}
377
378// Destroy the window (delayed, if a managed window)
fd3f686c 379bool wxWindow::Destroy()
2bda0e17
KB
380{
381 delete this;
382 return TRUE;
383}
384
385extern char wxCanvasClassName[];
386
fd3f686c 387// real construction (Init() must have been called before!)
debe6624 388bool wxWindow::Create(wxWindow *parent, wxWindowID id,
2d0a075d
JS
389 const wxPoint& pos,
390 const wxSize& size,
391 long style,
392 const wxString& name)
393{
fd3f686c 394 wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" );
2bda0e17 395
fd3f686c 396 parent->AddChild(this);
2bda0e17 397
2d0a075d 398 SetName(name);
2bda0e17 399
2d0a075d
JS
400 if ( id == -1 )
401 m_windowId = (int)NewControlId();
402 else
403 m_windowId = id;
2bda0e17 404
2d0a075d
JS
405 int x = pos.x;
406 int y = pos.y;
407 int width = size.x;
408 int height = size.y;
2bda0e17 409
386af6a2
JS
410 // To be consistent with wxGTK
411 if (width == -1)
412 width = 20;
413 if (height == -1)
414 height = 20;
415
2d0a075d 416 wxSystemSettings settings;
2bda0e17 417
2d0a075d 418 m_windowStyle = style;
2bda0e17 419
2d0a075d
JS
420 DWORD msflags = 0;
421 if (style & wxBORDER)
422 msflags |= WS_BORDER;
423 if (style & wxTHICK_FRAME)
424 msflags |= WS_THICKFRAME;
1c089c47 425
2d0a075d
JS
426 msflags |= WS_CHILD | WS_VISIBLE;
427 if (style & wxCLIP_CHILDREN)
428 msflags |= WS_CLIPCHILDREN;
2bda0e17 429
2d0a075d
JS
430 bool want3D;
431 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
2bda0e17 432
2d0a075d
JS
433 // Even with extended styles, need to combine with WS_BORDER
434 // for them to look right.
435 if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
436 (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
437 msflags |= WS_BORDER;
2bda0e17 438
2d0a075d 439 MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL,
fd3f686c 440 x, y, width, height, msflags, NULL, exStyle);
2bda0e17 441
2d0a075d 442 return TRUE;
2bda0e17
KB
443}
444
fd3f686c 445void wxWindow::SetFocus()
2bda0e17 446{
2d0a075d
JS
447 HWND hWnd = (HWND) GetHWND();
448 if (hWnd)
449 ::SetFocus(hWnd);
2bda0e17
KB
450}
451
debe6624 452void wxWindow::Enable(bool enable)
2bda0e17 453{
2d0a075d
JS
454 m_winEnabled = enable;
455 HWND hWnd = (HWND) GetHWND();
456 if (hWnd)
457 ::EnableWindow(hWnd, (BOOL)enable);
2bda0e17
KB
458}
459
fd3f686c 460void wxWindow::CaptureMouse()
2bda0e17 461{
2d0a075d
JS
462 HWND hWnd = (HWND) GetHWND();
463 if (hWnd && !m_winCaptured)
464 {
465 SetCapture(hWnd);
466 m_winCaptured = TRUE;
467 }
2bda0e17
KB
468}
469
fd3f686c 470void wxWindow::ReleaseMouse()
2bda0e17 471{
2d0a075d
JS
472 if (m_winCaptured)
473 {
474 ReleaseCapture();
475 m_winCaptured = FALSE;
476 }
2bda0e17
KB
477}
478
088a95f5
JS
479void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel)
480{
481 m_acceleratorTable = accel;
482}
483
484
2bda0e17
KB
485// Push/pop event handler (i.e. allow a chain of event handlers
486// be searched)
487void wxWindow::PushEventHandler(wxEvtHandler *handler)
488{
2d0a075d
JS
489 handler->SetNextHandler(GetEventHandler());
490 SetEventHandler(handler);
2bda0e17
KB
491}
492
493wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
494{
2d0a075d 495 if ( GetEventHandler() )
564b2609 496 {
2d0a075d
JS
497 wxEvtHandler *handlerA = GetEventHandler();
498 wxEvtHandler *handlerB = handlerA->GetNextHandler();
499 handlerA->SetNextHandler(NULL);
500 SetEventHandler(handlerB);
501 if ( deleteHandler )
502 {
503 delete handlerA;
504 return NULL;
505 }
506 else
507 return handlerA;
564b2609
VZ
508 }
509 else
2d0a075d 510 return NULL;
2bda0e17
KB
511}
512
47d67540 513#if wxUSE_DRAG_AND_DROP
2bda0e17
KB
514
515void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
516{
2d0a075d
JS
517 if ( m_pDropTarget != 0 ) {
518 m_pDropTarget->Revoke(m_hWnd);
519 delete m_pDropTarget;
520 }
195896c7 521
2d0a075d
JS
522 m_pDropTarget = pDropTarget;
523 if ( m_pDropTarget != 0 )
524 m_pDropTarget->Register(m_hWnd);
2bda0e17
KB
525}
526
3a19e16d
VZ
527#endif // wxUSE_DRAG_AND_DROP
528
2bda0e17
KB
529
530//old style file-manager drag&drop support
531// I think we should retain the old-style
532// DragAcceptFiles in parallel with SetDropTarget.
533// JACS
debe6624 534void wxWindow::DragAcceptFiles(bool accept)
2bda0e17 535{
2d0a075d
JS
536 HWND hWnd = (HWND) GetHWND();
537 if (hWnd)
538 ::DragAcceptFiles(hWnd, (BOOL)accept);
2bda0e17
KB
539}
540
3a19e16d
VZ
541// ----------------------------------------------------------------------------
542// tooltips
543// ----------------------------------------------------------------------------
544
545void wxWindow::SetToolTip(const wxString &tip)
546{
547 SetToolTip(new wxToolTip(tip));
548}
549
550void wxWindow::SetToolTip(wxToolTip *tooltip)
551{
552 if ( m_tooltip )
553 delete m_tooltip;
554
555 m_tooltip = tooltip;
556 m_tooltip->SetWindow(this);
557}
558
2bda0e17
KB
559// Get total size
560void wxWindow::GetSize(int *x, int *y) const
561{
2d0a075d
JS
562 HWND hWnd = (HWND) GetHWND();
563 RECT rect;
564 GetWindowRect(hWnd, &rect);
565 *x = rect.right - rect.left;
566 *y = rect.bottom - rect.top;
2bda0e17
KB
567}
568
569void wxWindow::GetPosition(int *x, int *y) const
570{
2d0a075d
JS
571 HWND hWnd = (HWND) GetHWND();
572 HWND hParentWnd = 0;
573 if (GetParent())
574 hParentWnd = (HWND) GetParent()->GetHWND();
81d66cf3 575
2d0a075d
JS
576 RECT rect;
577 GetWindowRect(hWnd, &rect);
578
579 // Since we now have the absolute screen coords,
580 // if there's a parent we must subtract its top left corner
581 POINT point;
582 point.x = rect.left;
583 point.y = rect.top;
584 if (hParentWnd)
585 {
586 ::ScreenToClient(hParentWnd, &point);
587 }
588
589 // We may be faking the client origin.
590 // So a window that's really at (0, 30) may appear
591 // (to wxWin apps) to be at (0, 0).
592 if (GetParent())
593 {
594 wxPoint pt(GetParent()->GetClientAreaOrigin());
595 point.x -= pt.x;
596 point.y -= pt.y;
597 }
598 *x = point.x;
599 *y = point.y;
2bda0e17
KB
600}
601
602void wxWindow::ScreenToClient(int *x, int *y) const
603{
2d0a075d
JS
604 HWND hWnd = (HWND) GetHWND();
605 POINT pt;
606 pt.x = *x;
607 pt.y = *y;
2d0a075d 608
87d1e11f 609 ::ScreenToClient(hWnd, &pt);
0757d27c 610
2d0a075d
JS
611 *x = pt.x;
612 *y = pt.y;
2bda0e17
KB
613}
614
615void wxWindow::ClientToScreen(int *x, int *y) const
616{
2d0a075d
JS
617 HWND hWnd = (HWND) GetHWND();
618 POINT pt;
619 pt.x = *x;
620 pt.y = *y;
621
2d0a075d 622 ::ClientToScreen(hWnd, &pt);
2bda0e17 623
2d0a075d
JS
624 *x = pt.x;
625 *y = pt.y;
2bda0e17
KB
626}
627
628void wxWindow::SetCursor(const wxCursor& cursor)
629{
2d0a075d
JS
630 m_windowCursor = cursor;
631 if (m_windowCursor.Ok())
632 {
633 HWND hWnd = (HWND) GetHWND();
2bda0e17 634
2d0a075d
JS
635 // Change the cursor NOW if we're within the correct window
636 POINT point;
637 ::GetCursorPos(&point);
2bda0e17 638
2d0a075d
JS
639 RECT rect;
640 ::GetWindowRect(hWnd, &rect);
2bda0e17 641
2d0a075d
JS
642 if (::PtInRect(&rect, point) && !wxIsBusy())
643 ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
644 }
2bda0e17 645
2d0a075d
JS
646 // This will cause big reentrancy problems if wxFlushEvents is implemented.
647 // wxFlushEvents();
648 // return old_cursor;
2bda0e17
KB
649}
650
651
652// Get size *available for subwindows* i.e. excluding menu bar etc.
2bda0e17
KB
653void wxWindow::GetClientSize(int *x, int *y) const
654{
2d0a075d
JS
655 HWND hWnd = (HWND) GetHWND();
656 RECT rect;
657 GetClientRect(hWnd, &rect);
658 *x = rect.right;
659 *y = rect.bottom;
2bda0e17
KB
660}
661
debe6624 662void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
2bda0e17 663{
2d0a075d
JS
664 int currentX, currentY;
665 GetPosition(&currentX, &currentY);
72fd19a1
JS
666 int currentW,currentH;
667 GetSize(&currentW, &currentH);
668
669 if (x == currentX && y == currentY && width == currentW && height == currentH)
670 return;
671
2d0a075d
JS
672 int actualWidth = width;
673 int actualHeight = height;
674 int actualX = x;
675 int actualY = y;
676 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
677 actualX = currentX;
678 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
679 actualY = currentY;
680
681 AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
682
2d0a075d
JS
683 if (width == -1)
684 actualWidth = currentW ;
685 if (height == -1)
686 actualHeight = currentH ;
81d66cf3 687
2d0a075d
JS
688 HWND hWnd = (HWND) GetHWND();
689 if (hWnd)
690 MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE);
2bda0e17
KB
691}
692
debe6624 693void wxWindow::SetClientSize(int width, int height)
2bda0e17 694{
2d0a075d
JS
695 wxWindow *parent = GetParent();
696 HWND hWnd = (HWND) GetHWND();
697 HWND hParentWnd = (HWND) (HWND) parent->GetHWND();
2bda0e17 698
2d0a075d
JS
699 RECT rect;
700 GetClientRect(hWnd, &rect);
2bda0e17 701
2d0a075d
JS
702 RECT rect2;
703 GetWindowRect(hWnd, &rect2);
2bda0e17 704
2d0a075d
JS
705 // Find the difference between the entire window (title bar and all)
706 // and the client area; add this to the new client size to move the
707 // window
708 int actual_width = rect2.right - rect2.left - rect.right + width;
709 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
2bda0e17 710
2d0a075d
JS
711 // If there's a parent, must subtract the parent's top left corner
712 // since MoveWindow moves relative to the parent
2bda0e17 713
2d0a075d
JS
714 POINT point;
715 point.x = rect2.left;
716 point.y = rect2.top;
717 if (parent)
718 {
719 ::ScreenToClient(hParentWnd, &point);
720 }
2bda0e17 721
2d0a075d 722 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
debe6624 723
2d0a075d
JS
724 wxSizeEvent event(wxSize(width, height), m_windowId);
725 event.SetEventObject(this);
726 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
727}
728
81d66cf3
JS
729// For implementation purposes - sometimes decorations make the client area
730// smaller
731wxPoint wxWindow::GetClientAreaOrigin() const
732{
733 return wxPoint(0, 0);
734}
735
736// Makes an adjustment to the window position (for example, a frame that has
737// a toolbar that it manages itself).
738void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags)
739{
740 if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
741 {
742 wxPoint pt(GetParent()->GetClientAreaOrigin());
743 x += pt.x; y += pt.y;
744 }
745}
746
debe6624 747bool wxWindow::Show(bool show)
2bda0e17 748{
2d0a075d
JS
749 HWND hWnd = (HWND) GetHWND();
750 int cshow;
751 if (show)
752 cshow = SW_SHOW;
753 else
754 cshow = SW_HIDE;
755 ShowWindow(hWnd, (BOOL)cshow);
756 if (show)
757 {
758 BringWindowToTop(hWnd);
759 // Next line causes a crash on NT, apparently.
760 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
761 }
762 return TRUE;
2bda0e17
KB
763}
764
765bool wxWindow::IsShown(void) const
766{
2d0a075d 767 return (::IsWindowVisible((HWND) GetHWND()) != 0);
2bda0e17
KB
768}
769
770int wxWindow::GetCharHeight(void) const
771{
2d0a075d
JS
772 TEXTMETRIC lpTextMetric;
773 HWND hWnd = (HWND) GetHWND();
774 HDC dc = ::GetDC(hWnd);
2bda0e17 775
2d0a075d
JS
776 GetTextMetrics(dc, &lpTextMetric);
777 ::ReleaseDC(hWnd, dc);
2bda0e17 778
2d0a075d 779 return lpTextMetric.tmHeight;
2bda0e17
KB
780}
781
782int wxWindow::GetCharWidth(void) const
783{
2d0a075d
JS
784 TEXTMETRIC lpTextMetric;
785 HWND hWnd = (HWND) GetHWND();
786 HDC dc = ::GetDC(hWnd);
2bda0e17 787
2d0a075d
JS
788 GetTextMetrics(dc, &lpTextMetric);
789 ::ReleaseDC(hWnd, dc);
2bda0e17 790
2d0a075d 791 return lpTextMetric.tmAveCharWidth;
2bda0e17
KB
792}
793
794void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
2d0a075d 795 int *descent, int *externalLeading, const wxFont *theFont, bool) const
2bda0e17 796{
2d0a075d
JS
797 wxFont *fontToUse = (wxFont *)theFont;
798 if (!fontToUse)
799 fontToUse = (wxFont *) & m_windowFont;
2bda0e17 800
2d0a075d
JS
801 HWND hWnd = (HWND) GetHWND();
802 HDC dc = ::GetDC(hWnd);
2bda0e17 803
c085e333 804 HFONT fnt = 0;
2d0a075d
JS
805 HFONT was = 0;
806 if (fontToUse && fontToUse->Ok())
807 {
fd3f686c
VZ
808 fnt = (HFONT)fontToUse->GetResourceHandle();
809 if ( fnt )
2d0a075d
JS
810 was = (HFONT) SelectObject(dc,fnt) ;
811 }
2bda0e17 812
2d0a075d
JS
813 SIZE sizeRect;
814 TEXTMETRIC tm;
815 GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect);
816 GetTextMetrics(dc, &tm);
2bda0e17 817
c085e333 818 if (fontToUse && fnt && was)
2d0a075d 819 SelectObject(dc,was) ;
2bda0e17 820
2d0a075d 821 ReleaseDC(hWnd, dc);
2bda0e17 822
2d0a075d
JS
823 *x = sizeRect.cx;
824 *y = sizeRect.cy;
825 if (descent) *descent = tm.tmDescent;
826 if (externalLeading) *externalLeading = tm.tmExternalLeading;
2bda0e17 827
2d0a075d
JS
828 // if (fontToUse)
829 // fontToUse->ReleaseResource();
2bda0e17
KB
830}
831
16e93305 832void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
2bda0e17 833{
2d0a075d
JS
834 HWND hWnd = (HWND) GetHWND();
835 if (hWnd)
2bda0e17 836 {
2d0a075d
JS
837 if (rect)
838 {
839 RECT mswRect;
840 mswRect.left = rect->x;
841 mswRect.top = rect->y;
842 mswRect.right = rect->x + rect->width;
843 mswRect.bottom = rect->y + rect->height;
844
845 ::InvalidateRect(hWnd, &mswRect, eraseBack);
846 }
847 else
848 ::InvalidateRect(hWnd, NULL, eraseBack);
2bda0e17 849 }
2bda0e17
KB
850}
851
a02eb1d2
VZ
852bool wxWindow::ProcessEvent(wxEvent& event)
853{
2d0a075d
JS
854 // we save here the information about the last message because it might be
855 // overwritten if the event handler sends any messages to our window (case
856 // in point: wxNotebook::OnSize) - and then if we call Default() later
857 // (which is done quite often if the message is not processed) it will use
858 // incorrect values for m_lastXXX variables
859 WXUINT lastMsg = m_lastMsg;
860 WXWPARAM lastWParam = m_lastWParam;
861 WXLPARAM lastLParam = m_lastLParam;
a02eb1d2 862
2d0a075d
JS
863 // call the base version
864 bool bProcessed = wxEvtHandler::ProcessEvent(event);
a02eb1d2 865
2d0a075d
JS
866 // restore
867 m_lastMsg = lastMsg;
868 m_lastWParam = lastWParam;
869 m_lastLParam = lastLParam;
a02eb1d2 870
2d0a075d 871 return bProcessed;
a02eb1d2
VZ
872}
873
2bda0e17
KB
874// Hook for new window just as it's being created,
875// when the window isn't yet associated with the handle
876wxWindow *wxWndHook = NULL;
877
1c089c47 878// Main window proc
2bda0e17
KB
879LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
880{
2d0a075d 881 wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
2bda0e17 882
2d0a075d
JS
883 if (!wnd && wxWndHook)
884 {
885 wxAssociateWinWithHandle(hWnd, wxWndHook);
886 wnd = wxWndHook;
887 wxWndHook = NULL;
888 wnd->m_hWnd = (WXHWND) hWnd;
889 }
ea57084d 890
341c92a8 891 // Stop right here if we don't have a valid handle in our wxWindow object.
2d0a075d 892 if (wnd && !wnd->m_hWnd) {
2d0a075d
JS
893 wnd->m_hWnd = (WXHWND) hWnd;
894 long res = wnd->MSWDefWindowProc(message, wParam, lParam );
895 wnd->m_hWnd = 0;
896 return res;
897 }
2bda0e17 898
2d0a075d
JS
899 if (wnd) {
900 wnd->m_lastMsg = message;
901 wnd->m_lastWParam = wParam;
902 wnd->m_lastLParam = lParam;
903 }
904 if (wnd)
905 return wnd->MSWWindowProc(message, wParam, lParam);
906 else
907 return DefWindowProc( hWnd, message, wParam, lParam );
2bda0e17
KB
908}
909
910// Should probably have a test for 'genuine' NT
911#if defined(__WIN32__)
09914df7 912 #define DIMENSION_TYPE short
2bda0e17 913#else
09914df7 914 #define DIMENSION_TYPE int
2bda0e17
KB
915#endif
916
917// Main Windows 3 window proc
918long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
919{
2d0a075d 920 wxASSERT( m_lastMsg == message &&
09914df7 921 m_lastWParam == wParam && m_lastLParam == lParam );
5de76427 922
2d0a075d 923#ifdef __WXDEBUG__
a02eb1d2 924 wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
3a19e16d 925 wxGetMessageName(message), wParam, lParam);
ea57084d 926#endif // __WXDEBUG__
c085e333 927
2d0a075d 928 HWND hWnd = (HWND)m_hWnd;
2bda0e17 929
2d0a075d
JS
930 switch (message)
931 {
932 case WM_ACTIVATE:
2bda0e17
KB
933 {
934#ifdef __WIN32__
935 WORD state = LOWORD(wParam);
936 WORD minimized = HIWORD(wParam);
937 HWND hwnd = (HWND)lParam;
938#else
939 WORD state = (WORD)wParam;
940 WORD minimized = LOWORD(lParam);
941 HWND hwnd = (HWND)HIWORD(lParam);
942#endif
943 MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd);
944 return 0;
945 break;
946 }
2d0a075d 947 case WM_SETFOCUS:
2bda0e17
KB
948 {
949 HWND hwnd = (HWND)wParam;
2d0a075d 950 // return OnSetFocus(hwnd);
2bda0e17
KB
951
952 if (MSWOnSetFocus((WXHWND) hwnd))
2d0a075d 953 return 0;
2bda0e17
KB
954 else return MSWDefWindowProc(message, wParam, lParam );
955 break;
956 }
2d0a075d 957 case WM_KILLFOCUS:
2bda0e17
KB
958 {
959 HWND hwnd = (HWND)lParam;
2d0a075d 960 // return OnKillFocus(hwnd);
2bda0e17 961 if (MSWOnKillFocus((WXHWND) hwnd))
2d0a075d 962 return 0;
2bda0e17 963 else
2d0a075d 964 return MSWDefWindowProc(message, wParam, lParam );
2bda0e17
KB
965 break;
966 }
2d0a075d 967 case WM_CREATE:
47cbd6da 968 {
2d0a075d
JS
969 MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam);
970 return 0;
971 break;
47cbd6da 972 }
2d0a075d 973 case WM_SHOWWINDOW:
47cbd6da 974 {
2d0a075d
JS
975 MSWOnShow((wParam != 0), (int) lParam);
976 break;
47cbd6da 977 }
2d0a075d 978 case WM_PAINT:
47cbd6da 979 {
2d0a075d
JS
980 if (MSWOnPaint())
981 return 0;
982 else return MSWDefWindowProc(message, wParam, lParam );
983 break;
2bda0e17 984 }
2d0a075d 985 case WM_QUERYDRAGICON:
47cbd6da 986 {
fd3f686c
VZ
987 HICON hIcon = (HICON)MSWOnQueryDragIcon();
988 if ( hIcon )
2d0a075d 989 return (long)hIcon;
fd3f686c
VZ
990 else
991 return MSWDefWindowProc(message, wParam, lParam );
2d0a075d 992 break;
2bda0e17 993 }
c085e333 994
2d0a075d 995 case WM_SIZE:
2bda0e17 996 {
2d0a075d
JS
997 int width = LOWORD(lParam);
998 int height = HIWORD(lParam);
999 MSWOnSize(width, height, wParam);
1000 break;
2bda0e17 1001 }
c085e333 1002
2d0a075d
JS
1003 case WM_MOVE:
1004 {
568cb543 1005 wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)),
2d0a075d 1006 m_windowId);
568cb543
VZ
1007 event.SetEventObject(this);
1008 if ( !GetEventHandler()->ProcessEvent(event) )
2d0a075d
JS
1009 Default();
1010 }
1011 break;
568cb543 1012
2d0a075d 1013 case WM_WINDOWPOSCHANGING:
2bda0e17 1014 {
2d0a075d
JS
1015 MSWOnWindowPosChanging((void *)lParam);
1016 break;
2bda0e17 1017 }
c085e333 1018
2d0a075d 1019 case WM_RBUTTONDOWN:
2bda0e17
KB
1020 {
1021 int x = (DIMENSION_TYPE) LOWORD(lParam);
1022 int y = (DIMENSION_TYPE) HIWORD(lParam);
1023 MSWOnRButtonDown(x, y, wParam);
1024 break;
1025 }
2d0a075d 1026 case WM_RBUTTONUP:
2bda0e17
KB
1027 {
1028 int x = (DIMENSION_TYPE) LOWORD(lParam);
1029 int y = (DIMENSION_TYPE) HIWORD(lParam);
1030 MSWOnRButtonUp(x, y, wParam);
1031 break;
1032 }
2d0a075d 1033 case WM_RBUTTONDBLCLK:
2bda0e17
KB
1034 {
1035 int x = (DIMENSION_TYPE) LOWORD(lParam);
1036 int y = (DIMENSION_TYPE) HIWORD(lParam);
1037 MSWOnRButtonDClick(x, y, wParam);
1038 break;
1039 }
2d0a075d 1040 case WM_MBUTTONDOWN:
2bda0e17
KB
1041 {
1042 int x = (DIMENSION_TYPE) LOWORD(lParam);
1043 int y = (DIMENSION_TYPE) HIWORD(lParam);
1044 MSWOnMButtonDown(x, y, wParam);
1045 break;
1046 }
2d0a075d 1047 case WM_MBUTTONUP:
2bda0e17
KB
1048 {
1049 int x = (DIMENSION_TYPE) LOWORD(lParam);
1050 int y = (DIMENSION_TYPE) HIWORD(lParam);
1051 MSWOnMButtonUp(x, y, wParam);
1052 break;
1053 }
2d0a075d 1054 case WM_MBUTTONDBLCLK:
2bda0e17
KB
1055 {
1056 int x = (DIMENSION_TYPE) LOWORD(lParam);
1057 int y = (DIMENSION_TYPE) HIWORD(lParam);
1058 MSWOnMButtonDClick(x, y, wParam);
1059 break;
1060 }
2d0a075d 1061 case WM_LBUTTONDOWN:
2bda0e17
KB
1062 {
1063 int x = (DIMENSION_TYPE) LOWORD(lParam);
1064 int y = (DIMENSION_TYPE) HIWORD(lParam);
1065 MSWOnLButtonDown(x, y, wParam);
1066 break;
1067 }
2d0a075d 1068 case WM_LBUTTONUP:
2bda0e17
KB
1069 {
1070 int x = (DIMENSION_TYPE) LOWORD(lParam);
1071 int y = (DIMENSION_TYPE) HIWORD(lParam);
1072 MSWOnLButtonUp(x, y, wParam);
1073 break;
1074 }
2d0a075d 1075 case WM_LBUTTONDBLCLK:
2bda0e17
KB
1076 {
1077 int x = (DIMENSION_TYPE) LOWORD(lParam);
1078 int y = (DIMENSION_TYPE) HIWORD(lParam);
1079 MSWOnLButtonDClick(x, y, wParam);
1080 break;
1081 }
2d0a075d 1082 case WM_MOUSEMOVE:
2bda0e17
KB
1083 {
1084 int x = (DIMENSION_TYPE) LOWORD(lParam);
1085 int y = (DIMENSION_TYPE) HIWORD(lParam);
1086 MSWOnMouseMove(x, y, wParam);
1087 break;
1088 }
2d0a075d 1089 case MM_JOY1BUTTONDOWN:
2bda0e17
KB
1090 {
1091 int x = LOWORD(lParam);
1092 int y = HIWORD(lParam);
1093 MSWOnJoyDown(wxJOYSTICK1, x, y, wParam);
1094 break;
1095 }
2d0a075d 1096 case MM_JOY2BUTTONDOWN:
2bda0e17
KB
1097 {
1098 int x = LOWORD(lParam);
1099 int y = HIWORD(lParam);
1100 MSWOnJoyDown(wxJOYSTICK2, x, y, wParam);
1101 break;
1102 }
2d0a075d 1103 case MM_JOY1BUTTONUP:
2bda0e17
KB
1104 {
1105 int x = LOWORD(lParam);
1106 int y = HIWORD(lParam);
1107 MSWOnJoyUp(wxJOYSTICK1, x, y, wParam);
1108 break;
1109 }
2d0a075d 1110 case MM_JOY2BUTTONUP:
2bda0e17
KB
1111 {
1112 int x = LOWORD(lParam);
1113 int y = HIWORD(lParam);
1114 MSWOnJoyUp(wxJOYSTICK2, x, y, wParam);
1115 break;
1116 }
2d0a075d 1117 case MM_JOY1MOVE:
2bda0e17
KB
1118 {
1119 int x = LOWORD(lParam);
1120 int y = HIWORD(lParam);
1121 MSWOnJoyMove(wxJOYSTICK1, x, y, wParam);
1122 break;
1123 }
2d0a075d 1124 case MM_JOY2MOVE:
2bda0e17
KB
1125 {
1126 int x = LOWORD(lParam);
1127 int y = HIWORD(lParam);
1128 MSWOnJoyMove(wxJOYSTICK2, x, y, wParam);
1129 break;
1130 }
2d0a075d 1131 case MM_JOY1ZMOVE:
2bda0e17
KB
1132 {
1133 int z = LOWORD(lParam);
1134 MSWOnJoyZMove(wxJOYSTICK1, z, wParam);
1135 break;
1136 }
2d0a075d 1137 case MM_JOY2ZMOVE:
2bda0e17
KB
1138 {
1139 int z = LOWORD(lParam);
1140 MSWOnJoyZMove(wxJOYSTICK2, z, wParam);
1141 break;
1142 }
2d0a075d 1143 case WM_DESTROY:
2bda0e17 1144 {
2d0a075d
JS
1145 if (MSWOnDestroy())
1146 return 0;
1147 else return MSWDefWindowProc(message, wParam, lParam );
1148 break;
2bda0e17 1149 }
2d0a075d 1150 case WM_SYSCOMMAND:
2bda0e17
KB
1151 {
1152 return MSWOnSysCommand(wParam, lParam);
1153 break;
1154 }
2d0a075d 1155 case WM_COMMAND:
47cbd6da 1156 {
2bda0e17
KB
1157#ifdef __WIN32__
1158 WORD id = LOWORD(wParam);
1159 HWND hwnd = (HWND)lParam;
1160 WORD cmd = HIWORD(wParam);
1161#else
1162 WORD id = (WORD)wParam;
1163 HWND hwnd = (HWND)LOWORD(lParam) ;
1164 WORD cmd = HIWORD(lParam);
1165#endif
1166 if (!MSWOnCommand(id, cmd, (WXHWND) hwnd))
2d0a075d 1167 return MSWDefWindowProc(message, wParam, lParam );
2bda0e17 1168 break;
47cbd6da 1169 }
2bda0e17 1170#if defined(__WIN95__)
2d0a075d 1171 case WM_NOTIFY:
47cbd6da 1172 {
fd3f686c
VZ
1173 // for some messages (TVN_ITEMEXPANDING for example), the return
1174 // value of WM_NOTIFY handler is important, so don't just return 0
1175 // if we processed the message
1176 return MSWOnNotify(wParam, lParam);
2bda0e17
KB
1177 }
1178#endif
2d0a075d 1179 case WM_MENUSELECT:
2bda0e17
KB
1180 {
1181#ifdef __WIN32__
1182 WORD flags = HIWORD(wParam);
1183 HMENU sysmenu = (HMENU)lParam;
1184#else
1185 WORD flags = LOWORD(lParam);
1186 HMENU sysmenu = (HMENU)HIWORD(lParam);
1187#endif
1188 MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu);
1189 break;
1190 }
2d0a075d 1191 case WM_INITMENUPOPUP:
2bda0e17
KB
1192 {
1193 MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0));
1194 break;
1195 }
2d0a075d 1196 case WM_DRAWITEM:
2bda0e17 1197 {
2d0a075d
JS
1198 return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam);
1199 break;
2bda0e17 1200 }
2d0a075d 1201 case WM_MEASUREITEM:
2bda0e17 1202 {
2d0a075d
JS
1203 return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
1204 break;
2bda0e17 1205 }
c085e333 1206
2d0a075d 1207 case WM_KEYDOWN:
4ce81a75 1208 MSWOnKeyDown((WORD) wParam, lParam);
2d0a075d
JS
1209 // we consider these message "not interesting"
1210 if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
1211 return Default();
1212
341c92a8
VZ
1213 // Avoid duplicate messages to OnChar for these special keys
1214 switch ( wParam )
2d0a075d 1215 {
341c92a8
VZ
1216 case VK_ESCAPE:
1217 case VK_SPACE:
1218 case VK_RETURN:
1219 case VK_BACK:
1220 case VK_TAB:
1221 case VK_LEFT:
1222 case VK_RIGHT:
1223 case VK_DOWN:
1224 case VK_UP:
1225 if ( ::GetKeyState(VK_CONTROL) & 0x100 )
1226 MSWOnChar((WORD)wParam, lParam);
1227 break;
1228
1229 default:
1230 MSWOnChar((WORD)wParam, lParam);
1231 if ( ::GetKeyState(VK_CONTROL) & 0x100 )
1232 return Default();
1233 break;
2d0a075d 1234 }
341c92a8 1235
2d0a075d 1236 break;
47cbd6da 1237
4ce81a75
JS
1238 case WM_KEYUP:
1239 {
1240 MSWOnKeyUp((WORD) wParam, lParam);
1241 break;
1242 }
2d0a075d
JS
1243 case WM_CHAR: // Always an ASCII character
1244 {
47cbd6da
VZ
1245 MSWOnChar((WORD)wParam, lParam, TRUE);
1246 break;
2d0a075d 1247 }
f54f3bff 1248
2d0a075d 1249 case WM_HSCROLL:
2bda0e17
KB
1250 {
1251#ifdef __WIN32__
1252 WORD code = LOWORD(wParam);
1253 WORD pos = HIWORD(wParam);
1254 HWND control = (HWND)lParam;
1255#else
1256 WORD code = (WORD)wParam;
1257 WORD pos = LOWORD(lParam);
1258 HWND control = (HWND)HIWORD(lParam);
1259#endif
1260 MSWOnHScroll(code, pos, (WXHWND) control);
1261 break;
1262 }
2d0a075d 1263 case WM_VSCROLL:
2bda0e17
KB
1264 {
1265#ifdef __WIN32__
1266 WORD code = LOWORD(wParam);
1267 WORD pos = HIWORD(wParam);
1268 HWND control = (HWND)lParam;
1269#else
1270 WORD code = (WORD)wParam;
1271 WORD pos = LOWORD(lParam);
1272 HWND control = (HWND)HIWORD(lParam);
1273#endif
1274 MSWOnVScroll(code, pos, (WXHWND) control);
1275 break;
1276 }
1277#ifdef __WIN32__
2d0a075d 1278 case WM_CTLCOLORBTN:
47cbd6da 1279 {
2d0a075d
JS
1280 int nCtlColor = CTLCOLOR_BTN;
1281 HWND control = (HWND)lParam;
1282 HDC pDC = (HDC)wParam;
1283 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1284 message, wParam, lParam);
1285 break;
47cbd6da 1286 }
2d0a075d 1287 case WM_CTLCOLORDLG:
47cbd6da 1288 {
2d0a075d
JS
1289 int nCtlColor = CTLCOLOR_DLG;
1290 HWND control = (HWND)lParam;
1291 HDC pDC = (HDC)wParam;
1292 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1293 message, wParam, lParam);\
1294 break;
47cbd6da 1295 }
2d0a075d 1296 case WM_CTLCOLORLISTBOX:
47cbd6da 1297 {
2d0a075d
JS
1298 int nCtlColor = CTLCOLOR_LISTBOX;
1299 HWND control = (HWND)lParam;
1300 HDC pDC = (HDC)wParam;
1301 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1302 message, wParam, lParam);
1303 break;
47cbd6da 1304 }
2d0a075d 1305 case WM_CTLCOLORMSGBOX:
47cbd6da 1306 {
2d0a075d
JS
1307 int nCtlColor = CTLCOLOR_MSGBOX;
1308 HWND control = (HWND)lParam;
1309 HDC pDC = (HDC)wParam;
1310 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1311 message, wParam, lParam);
1312 break;
47cbd6da 1313 }
2d0a075d 1314 case WM_CTLCOLORSCROLLBAR:
47cbd6da 1315 {
2d0a075d
JS
1316 int nCtlColor = CTLCOLOR_SCROLLBAR;
1317 HWND control = (HWND)lParam;
1318 HDC pDC = (HDC)wParam;
1319 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1320 message, wParam, lParam);
1321 break;
47cbd6da 1322 }
2d0a075d 1323 case WM_CTLCOLORSTATIC:
47cbd6da 1324 {
2d0a075d
JS
1325 int nCtlColor = CTLCOLOR_STATIC;
1326 HWND control = (HWND)lParam;
1327 HDC pDC = (HDC)wParam;
1328 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1329 message, wParam, lParam);
1330 break;
47cbd6da 1331 }
2d0a075d 1332 case WM_CTLCOLOREDIT:
47cbd6da 1333 {
2d0a075d
JS
1334 int nCtlColor = CTLCOLOR_EDIT;
1335 HWND control = (HWND)lParam;
1336 HDC pDC = (HDC)wParam;
1337 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1338 message, wParam, lParam);
1339 break;
47cbd6da 1340 }
2bda0e17 1341#else
2d0a075d 1342 case WM_CTLCOLOR:
2bda0e17 1343 {
2d0a075d
JS
1344 HWND control = (HWND)LOWORD(lParam);
1345 int nCtlColor = (int)HIWORD(lParam);
1346 HDC pDC = (HDC)wParam;
1347 return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor,
1348 message, wParam, lParam);
1349 break;
2bda0e17
KB
1350 }
1351#endif
2d0a075d 1352 case WM_SYSCOLORCHANGE:
2bda0e17 1353 {
2d0a075d
JS
1354 // Return value of 0 means, we processed it.
1355 if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0)
1356 return 0;
1357 else
1358 return MSWDefWindowProc(message, wParam, lParam );
1359 break;
2bda0e17 1360 }
2d0a075d 1361 case WM_PALETTECHANGED:
f7bd2698
JS
1362 {
1363 return MSWOnPaletteChanged((WXHWND) (HWND) wParam);
1364 break;
1365 }
2d0a075d 1366 case WM_QUERYNEWPALETTE:
f7bd2698
JS
1367 {
1368 return MSWOnQueryNewPalette();
1369 break;
1370 }
2d0a075d 1371 case WM_ERASEBKGND:
2bda0e17 1372 {
2d0a075d
JS
1373 // Prevents flicker when dragging
1374 if (IsIconic(hWnd)) return 1;
2bda0e17 1375
2d0a075d
JS
1376 if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam))
1377 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1378 else return 1;
1379 break;
2bda0e17 1380 }
2d0a075d 1381 case WM_MDIACTIVATE:
2bda0e17
KB
1382 {
1383#ifdef __WIN32__
1384 HWND hWndActivate = GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam,lParam);
1385 HWND hWndDeactivate = GET_WM_MDIACTIVATE_HWNDDEACT(wParam,lParam);
1386 BOOL activate = GET_WM_MDIACTIVATE_FACTIVATE(hWnd,wParam,lParam);
1387 return MSWOnMDIActivate((long) activate, (WXHWND) hWndActivate, (WXHWND) hWndDeactivate);
1388#else
1389 return MSWOnMDIActivate((BOOL)wParam, (HWND)LOWORD(lParam),
2d0a075d 1390 (HWND)HIWORD(lParam));
2bda0e17
KB
1391#endif
1392 }
2d0a075d 1393 case WM_DROPFILES:
2bda0e17
KB
1394 {
1395 MSWOnDropFiles(wParam);
1396 break;
47cbd6da 1397 }
2d0a075d 1398 case WM_INITDIALOG:
2bda0e17
KB
1399 {
1400 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1401 break;
47cbd6da 1402 }
2d0a075d 1403 case WM_QUERYENDSESSION:
2bda0e17 1404 {
47cbd6da 1405 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
2d0a075d 1406 // return MSWOnClose();
387a3b02
JS
1407
1408 return MSWOnQueryEndSession(lParam);
1409 break;
1410 }
2d0a075d 1411 case WM_ENDSESSION:
387a3b02
JS
1412 {
1413 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1414 MSWOnEndSession((wParam != 0), lParam);
1415 return 0L;
2bda0e17
KB
1416 break;
1417 }
2d0a075d 1418 case WM_CLOSE:
2bda0e17
KB
1419 {
1420 if (MSWOnClose())
2d0a075d 1421 return 0L;
2bda0e17 1422 else
2d0a075d 1423 return 1L;
2bda0e17
KB
1424 break;
1425 }
c085e333 1426
2d0a075d 1427 case WM_GETMINMAXINFO:
2bda0e17 1428 {
2d0a075d
JS
1429 MINMAXINFO *info = (MINMAXINFO *)lParam;
1430 if (m_minSizeX != -1)
1431 info->ptMinTrackSize.x = (int)m_minSizeX;
1432 if (m_minSizeY != -1)
1433 info->ptMinTrackSize.y = (int)m_minSizeY;
1434 if (m_maxSizeX != -1)
1435 info->ptMaxTrackSize.x = (int)m_maxSizeX;
1436 if (m_maxSizeY != -1)
1437 info->ptMaxTrackSize.y = (int)m_maxSizeY;
1438 return MSWDefWindowProc(message, wParam, lParam );
1439 break;
2bda0e17 1440 }
c085e333 1441
2d0a075d
JS
1442 case WM_GETDLGCODE:
1443 return MSWGetDlgCode();
2bda0e17 1444
2d0a075d
JS
1445 default:
1446 return MSWDefWindowProc(message, wParam, lParam );
2bda0e17 1447 }
341c92a8 1448
2bda0e17
KB
1449 return 0; // Success: we processed this command.
1450}
1451
1452// Dialog window proc
1453LONG APIENTRY _EXPORT
2d0a075d 1454wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
2bda0e17 1455{
2d0a075d 1456 return 0;
2bda0e17
KB
1457}
1458
1459wxList *wxWinHandleList = NULL;
1460wxWindow *wxFindWinFromHandle(WXHWND hWnd)
1461{
2d0a075d
JS
1462 wxNode *node = wxWinHandleList->Find((long)hWnd);
1463 if (!node)
1464 return NULL;
1465 return (wxWindow *)node->Data();
2bda0e17
KB
1466}
1467
1468void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
1469{
2d0a075d
JS
1470 // adding NULL hWnd is (first) surely a result of an error and
1471 // (secondly) breaks menu command processing
57c208c5 1472 wxCHECK_RET( hWnd != (HWND) NULL, "attempt to add a NULL hWnd to window list" );
195896c7 1473
2d0a075d
JS
1474 if ( !wxWinHandleList->Find((long)hWnd) )
1475 wxWinHandleList->Append((long)hWnd, win);
2bda0e17
KB
1476}
1477
1478void wxRemoveHandleAssociation(wxWindow *win)
1479{
2d0a075d 1480 wxWinHandleList->DeleteObject(win);
2bda0e17
KB
1481}
1482
1483// Default destroyer - override if you destroy it in some other way
1484// (e.g. with MDI child windows)
fd3f686c 1485void wxWindow::MSWDestroyWindow()
2bda0e17 1486{
2bda0e17
KB
1487}
1488
debe6624 1489void wxWindow::MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title,
2d0a075d
JS
1490 int x, int y, int width, int height,
1491 WXDWORD style, const char *dialog_template, WXDWORD extendedStyle)
1492{
1493 bool is_dialog = (dialog_template != NULL);
1494 int x1 = CW_USEDEFAULT;
1495 int y1 = 0;
1496 int width1 = CW_USEDEFAULT;
1497 int height1 = 100;
1498
1499 // Find parent's size, if it exists, to set up a possible default
1500 // panel size the size of the parent window
1501 RECT parent_rect;
1502 if (parent)
1503 {
1504 // Was GetWindowRect: JACS 5/5/95
1505 ::GetClientRect((HWND) parent->GetHWND(), &parent_rect);
2bda0e17 1506
2d0a075d
JS
1507 width1 = parent_rect.right - parent_rect.left;
1508 height1 = parent_rect.bottom - parent_rect.top;
1509 }
2bda0e17 1510
2d0a075d
JS
1511 if (x > -1) x1 = x;
1512 if (y > -1) y1 = y;
1513 if (width > -1) width1 = width;
1514 if (height > -1) height1 = height;
2bda0e17 1515
2d0a075d
JS
1516 HWND hParent = NULL;
1517 if (parent)
1518 hParent = (HWND) parent->GetHWND();
2bda0e17 1519
2d0a075d 1520 wxWndHook = this;
2bda0e17 1521
2d0a075d
JS
1522 if (is_dialog)
1523 {
1524 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1525 // other compilers???
1526 // VZ: it's always needed for Win16 and never for Win32
2bda0e17 1527#ifdef __WIN32__
2d0a075d
JS
1528 m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
1529 (DLGPROC)wxDlgProc);
2bda0e17 1530#else
f60d0f94
JS
1531 // N.B.: if we _don't_ use this form,
1532 // then with VC++ 1.5, it crashes horribly.
1533#if 1
1534 m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
1535 (DLGPROC)wxDlgProc);
1536#else
1537 // Crashes when we use this.
2d0a075d 1538 DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance());
2bda0e17 1539
2d0a075d
JS
1540 m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
1541 (DLGPROC)dlgproc);
f60d0f94 1542#endif
2bda0e17 1543#endif
c085e333 1544
2d0a075d
JS
1545 if (m_hWnd == 0)
1546 MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1547 "wxWindows Error", MB_ICONEXCLAMATION | MB_OK);
1548 else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE);
1549 }
1550 else
1551 {
1552 int controlId = 0;
1553 if (style & WS_CHILD)
1554 controlId = id;
1555 if (!title)
1556 title = "";
1557
1558 m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, wclass,
1559 title,
1560 style,
1561 x1, y1,
1562 width1, height1,
1563 hParent, (HMENU)controlId, wxGetInstance(),
1564 NULL);
1565
1566 if ( !m_hWnd ) {
1567 wxLogError("Can't create window of class %s!\n"
1568 "Possible Windows 3.x compatibility problem?", wclass);
1569 }
2bda0e17 1570 }
a02eb1d2 1571
2d0a075d
JS
1572 wxWndHook = NULL;
1573 wxWinHandleList->Append((long)m_hWnd, this);
2bda0e17
KB
1574}
1575
1576void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs))
1577{
1578}
1579
fd3f686c 1580bool wxWindow::MSWOnClose()
2bda0e17 1581{
2d0a075d 1582 return FALSE;
2bda0e17
KB
1583}
1584
3572173c
JS
1585// Some compilers don't define this
1586#ifndef ENDSESSION_LOGOFF
1587#define ENDSESSION_LOGOFF 0x80000000
1588#endif
1589
387a3b02
JS
1590// Return TRUE to end session, FALSE to veto end session.
1591bool wxWindow::MSWOnQueryEndSession(long logOff)
1592{
1593 wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1);
1594 event.SetEventObject(wxTheApp);
1595 event.SetCanVeto(TRUE);
1596 event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
1597 if ((this == wxTheApp->GetTopWindow()) && // Only send once
2d0a075d 1598 wxTheApp->ProcessEvent(event) && event.GetVeto())
387a3b02
JS
1599 {
1600 return FALSE; // Veto!
1601 }
1602 else
1603 {
1604 return TRUE; // Don't veto
1605 }
1606}
1607
1608bool wxWindow::MSWOnEndSession(bool endSession, long logOff)
1609{
1610 wxCloseEvent event(wxEVT_END_SESSION, -1);
1611 event.SetEventObject(wxTheApp);
1612 event.SetCanVeto(FALSE);
1613 event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) );
1614 if (endSession && // No need to send if the session isn't ending
1615 (this == wxTheApp->GetTopWindow()) && // Only send once
2d0a075d 1616 wxTheApp->ProcessEvent(event))
387a3b02
JS
1617 {
1618 }
1619 return TRUE;
1620}
1621
fd3f686c 1622bool wxWindow::MSWOnDestroy()
2bda0e17 1623{
2d0a075d
JS
1624 // delete our drop target if we've got one
1625#if wxUSE_DRAG_AND_DROP
195896c7 1626 if ( m_pDropTarget != NULL ) {
2d0a075d 1627 m_pDropTarget->Revoke(m_hWnd);
2bda0e17 1628
2d0a075d
JS
1629 delete m_pDropTarget;
1630 m_pDropTarget = NULL;
2bda0e17 1631 }
2d0a075d 1632#endif
c085e333 1633
2d0a075d 1634 return TRUE;
2bda0e17
KB
1635}
1636
1637// Deal with child commands from buttons etc.
1638
fd3f686c 1639long wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam)
2bda0e17
KB
1640{
1641#if defined(__WIN95__)
1642 // Find a child window to send the notification to, e.g. a toolbar.
1643 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1644 // handle of the toolbar; it's probably the handle of the tooltip
1645 // window (anyway, it's parent is also the toolbar's parent).
1646 // So, since we don't know which hWnd or wxWindow originated the
1647 // WM_NOTIFY, we'll need to go through all the children of this window
1648 // trying out MSWNotify.
2d0a075d
JS
1649 // This won't work now, though, because any number of controls
1650 // could respond to the same generic messages :-(
2bda0e17 1651
2d0a075d
JS
1652 /* This doesn't work for toolbars, but try for other controls first.
1653 */
2bda0e17
KB
1654 NMHDR *hdr = (NMHDR *)lParam;
1655 HWND hWnd = (HWND)hdr->hwndFrom;
1656 wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd);
c085e333 1657
fd3f686c
VZ
1658 WXLPARAM result = 0;
1659
2d0a075d 1660 if ( win )
fd3f686c 1661 {
cf65ad8d
VZ
1662 if ( win->MSWNotify(wParam, lParam, &result) )
1663 return result;
fd3f686c 1664 }
2d0a075d
JS
1665 else
1666 {
564b2609 1667 // Rely on MSWNotify to check whether the message
2d0a075d 1668 // belongs to the window or not
c0ed460c 1669 wxNode *node = GetChildren().First();
564b2609
VZ
1670 while (node)
1671 {
1672 wxWindow *child = (wxWindow *)node->Data();
fd3f686c 1673 if ( child->MSWNotify(wParam, lParam, &result) )
cf65ad8d 1674 return result;
2d0a075d 1675 node = node->Next();
564b2609 1676 }
2bda0e17 1677
cf65ad8d
VZ
1678 // finally try this window too (catches toolbar case)
1679 if ( MSWNotify(wParam, lParam, &result) )
1680 return result;
1681 }
fd3f686c 1682#endif // Win95
c085e333 1683
cf65ad8d 1684 // not processed
2d0a075d 1685 return FALSE;
2bda0e17
KB
1686}
1687
debe6624 1688void wxWindow::MSWOnMenuHighlight(WXWORD WXUNUSED(item), WXWORD WXUNUSED(flags), WXHMENU WXUNUSED(sysmenu))
2bda0e17 1689{
2bda0e17
KB
1690}
1691
debe6624 1692void wxWindow::MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem)
2bda0e17 1693{
2bda0e17
KB
1694}
1695
debe6624 1696bool wxWindow::MSWOnActivate(int state, bool WXUNUSED(minimized), WXHWND WXUNUSED(activate))
2bda0e17 1697{
2d0a075d
JS
1698 wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)),
1699 m_windowId);
1700 event.SetEventObject(this);
1701 GetEventHandler()->ProcessEvent(event);
1702 return 0;
2bda0e17
KB
1703}
1704
debe6624 1705bool wxWindow::MSWOnSetFocus(WXHWND WXUNUSED(hwnd))
2bda0e17 1706{
2bda0e17
KB
1707 // Deal with caret
1708 if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0))
1709 {
2d0a075d
JS
1710 ::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight);
1711 if (m_caretShown)
1712 ::ShowCaret((HWND) GetHWND());
2bda0e17 1713 }
c085e333 1714
341c92a8
VZ
1715 // panel wants to track the window which was the last to have focus in it
1716 wxWindow *parent = GetParent();
1717 if ( parent && parent->IsKindOf(CLASSINFO(wxPanel)) )
1718 {
1719 ((wxPanel *)parent)->SetLastFocus(this);
1720 }
1721
2d0a075d
JS
1722 wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
1723 event.SetEventObject(this);
1724 if (!GetEventHandler()->ProcessEvent(event))
1725 Default();
1726 return TRUE;
2bda0e17
KB
1727}
1728
debe6624 1729bool wxWindow::MSWOnKillFocus(WXHWND WXUNUSED(hwnd))
2bda0e17 1730{
2bda0e17
KB
1731 // Deal with caret
1732 if (m_caretEnabled)
1733 {
2d0a075d 1734 ::DestroyCaret();
2bda0e17 1735 }
c085e333 1736
2d0a075d
JS
1737 wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
1738 event.SetEventObject(this);
1739 if (!GetEventHandler()->ProcessEvent(event))
1740 Default();
1741 return TRUE;
2bda0e17
KB
1742}
1743
debe6624 1744void wxWindow::MSWOnDropFiles(WXWPARAM wParam)
2bda0e17 1745{
c085e333 1746
2d0a075d
JS
1747 HDROP hFilesInfo = (HDROP) wParam;
1748 POINT dropPoint;
1749 DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint);
1750
1751 // Get the total number of files dropped
1752 WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo,
1753 (UINT)-1,
1754 (LPSTR)0,
1755 (UINT)0);
1756
1757 wxString *files = new wxString[gwFilesDropped];
1758 int wIndex;
1759 for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++)
1760 {
1761 DragQueryFile (hFilesInfo, wIndex, (LPSTR) wxBuffer, 1000);
1762 files[wIndex] = wxBuffer;
1763 }
1764 DragFinish (hFilesInfo);
2bda0e17 1765
2d0a075d
JS
1766 wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files);
1767 event.m_eventObject = this;
1768 event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y;
2bda0e17 1769
2d0a075d
JS
1770 if (!GetEventHandler()->ProcessEvent(event))
1771 Default();
2bda0e17 1772
2d0a075d 1773 delete[] files;
2bda0e17
KB
1774}
1775
debe6624 1776bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct)
2bda0e17 1777{
47d67540 1778#if wxUSE_OWNER_DRAWN
2bda0e17 1779 if ( id == 0 ) { // is it a menu item?
2d0a075d
JS
1780 DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct;
1781 wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData);
1782 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
1783
1784 // prepare to call OnDrawItem()
1785 wxDC dc;
1786 dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE);
1787 wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top,
1788 pDrawStruct->rcItem.right - pDrawStruct->rcItem.left,
1789 pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top);
1790 return pMenuItem->OnDrawItem(
1791 dc, rect,
1792 (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction,
1793 (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState
1794 );
2bda0e17
KB
1795 }
1796#endif // owner-drawn menus
c085e333 1797
2d0a075d 1798 wxWindow *item = FindItem(id);
47d67540 1799#if wxUSE_DYNAMIC_CLASSES
2d0a075d
JS
1800 if (item && item->IsKindOf(CLASSINFO(wxControl)))
1801 {
1802 return ((wxControl *)item)->MSWOnDraw(itemStruct);
1803 }
1804 else
2bda0e17 1805#endif
2d0a075d 1806 return FALSE;
2bda0e17
KB
1807}
1808
debe6624 1809bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct)
2bda0e17 1810{
47d67540 1811#if wxUSE_OWNER_DRAWN
2bda0e17 1812 if ( id == 0 ) { // is it a menu item?
2d0a075d
JS
1813 MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct;
1814 wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
1815 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2bda0e17 1816
c085e333 1817 return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth,
2d0a075d 1818 &pMeasureStruct->itemHeight);
2bda0e17
KB
1819 }
1820#endif // owner-drawn menus
c085e333 1821
2d0a075d 1822 wxWindow *item = FindItem(id);
47d67540 1823#if wxUSE_DYNAMIC_CLASSES
2d0a075d
JS
1824 if (item && item->IsKindOf(CLASSINFO(wxControl)))
1825 {
1826 return ((wxControl *)item)->MSWOnMeasure(itemStruct);
1827 }
1828 else
2bda0e17 1829#endif
2d0a075d 1830 return FALSE;
2bda0e17
KB
1831}
1832
debe6624 1833WXHBRUSH wxWindow::MSWOnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
2d0a075d 1834 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
2bda0e17 1835{
2d0a075d
JS
1836 if (nCtlColor == CTLCOLOR_DLG)
1837 {
1838 return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
1839 }
2bda0e17 1840
2d0a075d 1841 wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE);
2bda0e17 1842
2d0a075d 1843 WXHBRUSH hBrush = 0;
2bda0e17 1844
2d0a075d
JS
1845 if ( item )
1846 hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
2bda0e17 1847
2d0a075d
JS
1848 // I think that even for dialogs, we may need to call DefWindowProc (?)
1849 // Or maybe just rely on the usual default behaviour.
1850 if ( !hBrush )
1851 hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
2bda0e17 1852
2d0a075d 1853 return hBrush ;
2bda0e17
KB
1854}
1855
1856// Define for each class of dialog and control
debe6624 1857WXHBRUSH wxWindow::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
2d0a075d 1858 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
2bda0e17
KB
1859{
1860 return (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam);
1861}
1862
debe6624 1863bool wxWindow::MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
2bda0e17 1864{
2d0a075d
JS
1865 wxSysColourChangedEvent event;
1866 event.SetEventObject(this);
2bda0e17 1867
2d0a075d
JS
1868 // Check if app handles this.
1869 if (GetEventHandler()->ProcessEvent(event))
1870 return 0;
2bda0e17 1871
2d0a075d
JS
1872 // We didn't process it
1873 return 1;
2bda0e17
KB
1874}
1875
f7bd2698
JS
1876long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange)
1877{
1878 wxPaletteChangedEvent event(GetId());
1879 event.SetEventObject(this);
1880 event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
1881 GetEventHandler()->ProcessEvent(event);
1882 return 0;
1883}
1884
1885long wxWindow::MSWOnQueryNewPalette()
1886{
1887 wxQueryNewPaletteEvent event(GetId());
1888 event.SetEventObject(this);
1889 if (!GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized())
1890 {
1891 return (long) FALSE;
1892 }
1893 else
1894 return (long) TRUE;
1895}
1896
2bda0e17
KB
1897// Responds to colour changes: passes event on to children.
1898void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
1899{
c0ed460c 1900 wxNode *node = GetChildren().First();
2bda0e17
KB
1901 while ( node )
1902 {
1903 // Only propagate to non-top-level windows
1904 wxWindow *win = (wxWindow *)node->Data();
1905 if ( win->GetParent() )
1906 {
1907 wxSysColourChangedEvent event2;
1908 event.m_eventObject = win;
1909 win->GetEventHandler()->ProcessEvent(event2);
1910 }
c085e333 1911
2bda0e17
KB
1912 node = node->Next();
1913 }
1914}
1915
1916long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
1917{
2d0a075d
JS
1918 if ( m_oldWndProc )
1919 return ::CallWindowProc(CASTWNDPROC m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
1920 else
1921 return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam);
2bda0e17
KB
1922}
1923
1924long wxWindow::Default()
1925{
46851318
JS
1926 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1927 if (m_lastMsg == 0)
1c089c47 1928 return 0;
c085e333 1929
2d0a075d
JS
1930#ifdef __WXDEBUG__
1931 wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.",
1932 wxGetMessageName(m_lastMsg));
ea57084d 1933#endif // __WXDEBUG__
c085e333 1934
46851318 1935 return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
2bda0e17
KB
1936}
1937
1938bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
1939{
2d0a075d
JS
1940 if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) {
1941 // intercept dialog navigation keys
1942 MSG *msg = (MSG *)pMsg;
1943 bool bProcess = TRUE;
1944 if ( msg->message != WM_KEYDOWN )
1945 bProcess = FALSE;
47cbd6da 1946
341c92a8 1947 if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN )
2d0a075d 1948 bProcess = FALSE;
47cbd6da 1949
341c92a8
VZ
1950 if ( bProcess )
1951 {
1952 bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0;
47cbd6da 1953
341c92a8
VZ
1954 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1955 // don't process it if it's the case (except for Ctrl-Tab/Enter
1956 // combinations which are always processed)
1957 LONG lDlgCode = 0;
1958 if ( !bCtrlDown )
1959 {
1960 lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
1961 }
1962
1963 bool bForward = TRUE,
1964 bWindowChange = FALSE;
47cbd6da 1965
341c92a8
VZ
1966 switch ( msg->wParam )
1967 {
fd3f686c 1968 case VK_TAB:
3a19e16d 1969 if ( lDlgCode & DLGC_WANTTAB ) {
fd3f686c 1970 bProcess = FALSE;
3a19e16d
VZ
1971 }
1972 else {
1973 // Ctrl-Tab cycles thru notebook pages
1974 bWindowChange = bCtrlDown;
fd3f686c 1975 bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
3a19e16d 1976 }
fd3f686c 1977 break;
47cbd6da 1978
fd3f686c
VZ
1979 case VK_UP:
1980 case VK_LEFT:
1981 if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown )
1982 bProcess = FALSE;
1983 else
1984 bForward = FALSE;
1985 break;
47cbd6da 1986
fd3f686c
VZ
1987 case VK_DOWN:
1988 case VK_RIGHT:
1989 if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown )
1990 bProcess = FALSE;
1991 break;
47cbd6da 1992
3a19e16d 1993 case VK_RETURN:
341c92a8
VZ
1994 {
1995 if ( lDlgCode & DLGC_WANTMESSAGE )
5fb9fcfc
VZ
1996 {
1997 // control wants to process Enter itself, don't
1998 // call IsDialogMessage() which would interpret
1999 // it
2000 return FALSE;
2001 }
341c92a8
VZ
2002
2003 wxButton *btnDefault = GetDefaultItem();
2004 if ( btnDefault && !bCtrlDown )
2005 {
2006 // if there is a default button, Enter should
2007 // press it
2008 (void)::SendMessage((HWND)btnDefault->GetHWND(),
2009 BM_CLICK, 0, 0);
2010 return TRUE;
2011 }
2012 // else: but if there is not it makes sense to make it
2013 // work like a TAB - and that's what we do.
2014 // Note that Ctrl-Enter always works this way.
3a19e16d 2015 }
341c92a8 2016 break;
3a19e16d 2017
fd3f686c
VZ
2018 default:
2019 bProcess = FALSE;
2d0a075d 2020 }
47cbd6da 2021
341c92a8
VZ
2022 if ( bProcess )
2023 {
2024 wxNavigationKeyEvent event;
2025 event.SetDirection(bForward);
2026 event.SetWindowChange(bWindowChange);
2027 event.SetEventObject(this);
47cbd6da 2028
341c92a8
VZ
2029 if ( GetEventHandler()->ProcessEvent(event) )
2030 return TRUE;
2031 }
2d0a075d 2032 }
47cbd6da 2033
341c92a8
VZ
2034 if ( ::IsDialogMessage((HWND)GetHWND(), msg) )
2035 return TRUE;
2d0a075d 2036 }
3a19e16d 2037#if wxUSE_TOOLTIPS
341c92a8
VZ
2038 if ( m_tooltip )
2039 {
3a19e16d
VZ
2040 // relay mouse move events to the tooltip control
2041 MSG *msg = (MSG *)pMsg;
2042 if ( msg->message == WM_MOUSEMOVE )
2043 m_tooltip->RelayEvent(pMsg);
2044 }
2045#endif // wxUSE_TOOLTIPS
47cbd6da 2046
2d0a075d 2047 return FALSE;
2bda0e17
KB
2048}
2049
088a95f5 2050bool wxWindow::MSWTranslateMessage(WXMSG* pMsg)
57a7b7c1 2051{
088a95f5 2052 if (m_acceleratorTable.Ok() &&
2d0a075d 2053 ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg))
088a95f5
JS
2054 return TRUE;
2055 else
2056 return FALSE;
57a7b7c1
JS
2057}
2058
debe6624 2059long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate), WXHWND WXUNUSED(deactivate))
2bda0e17 2060{
2d0a075d 2061 return 1;
2bda0e17
KB
2062}
2063
fd3f686c 2064void wxWindow::MSWDetachWindowMenu()
2bda0e17 2065{
2d0a075d 2066 if (m_hMenu)
2bda0e17 2067 {
2d0a075d
JS
2068 int N = GetMenuItemCount((HMENU) m_hMenu);
2069 int i;
2070 for (i = 0; i < N; i++)
2071 {
2072 char buf[100];
2073 int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION);
2074 if ((chars > 0) && (strcmp(buf, "&Window") == 0))
2075 {
2076 RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION);
2077 break;
2078 }
2079 }
2bda0e17 2080 }
2bda0e17
KB
2081}
2082
fd3f686c 2083bool wxWindow::MSWOnPaint()
2bda0e17 2084{
81d66cf3 2085#ifdef __WIN32__
2d0a075d
JS
2086 HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2087 ::GetUpdateRgn((HWND) GetHWND(), hRegion, FALSE);
81d66cf3 2088
2d0a075d 2089 m_updateRegion = wxRegion((WXHRGN) hRegion);
81d66cf3 2090#else
2d0a075d
JS
2091 RECT updateRect;
2092 ::GetUpdateRect((HWND) GetHWND(), & updateRect, FALSE);
81d66cf3 2093
2d0a075d
JS
2094 m_updateRegion = wxRegion(updateRect.left, updateRect.top,
2095 updateRect.right - updateRect.left, updateRect.bottom - updateRect.top);
81d66cf3 2096#endif
c085e333 2097
2d0a075d
JS
2098 wxPaintEvent event(m_windowId);
2099 event.SetEventObject(this);
2100 if (!GetEventHandler()->ProcessEvent(event))
2101 Default();
2102 return TRUE;
2bda0e17
KB
2103}
2104
debe6624 2105void wxWindow::MSWOnSize(int w, int h, WXUINT WXUNUSED(flag))
2bda0e17 2106{
2d0a075d
JS
2107 if (m_inOnSize)
2108 return;
2109
2d0a075d
JS
2110 if (!m_hWnd)
2111 return;
2bda0e17 2112
2d0a075d 2113 m_inOnSize = TRUE;
2bda0e17 2114
2d0a075d
JS
2115 wxSizeEvent event(wxSize(w, h), m_windowId);
2116 event.SetEventObject(this);
2117 if (!GetEventHandler()->ProcessEvent(event))
2118 Default();
2bda0e17 2119
2d0a075d 2120 m_inOnSize = FALSE;
2bda0e17
KB
2121}
2122
2123void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos))
2124{
2125 Default();
2126}
2127
2128// Deal with child commands from buttons etc.
34138703 2129bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
2bda0e17 2130{
2d0a075d
JS
2131 if (wxCurrentPopupMenu)
2132 {
2133 wxMenu *popupMenu = wxCurrentPopupMenu;
2134 wxCurrentPopupMenu = NULL;
2135 bool succ = popupMenu->MSWCommand(cmd, id);
2136 return succ;
2137 }
c085e333 2138
2d0a075d
JS
2139 wxWindow *item = FindItem(id);
2140 if (item)
2141 {
2142 bool value = item->MSWCommand(cmd, id);
2d0a075d
JS
2143 return value;
2144 }
2145 else
2146 {
2147 wxWindow *win = wxFindWinFromHandle(control);
2148 if (win)
2149 return win->MSWCommand(cmd, id);
2150 }
2151 return FALSE;
2bda0e17
KB
2152}
2153
2154long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam)
2155{
2156 switch (wParam)
2157 {
2d0a075d 2158 case SC_MAXIMIZE:
2bda0e17
KB
2159 {
2160 wxMaximizeEvent event(m_windowId);
2161 event.SetEventObject(this);
2162 if (!GetEventHandler()->ProcessEvent(event))
2163 return Default();
2164 else
2165 return 0;
2166 break;
2167 }
2d0a075d 2168 case SC_MINIMIZE:
2bda0e17
KB
2169 {
2170 wxIconizeEvent event(m_windowId);
2171 event.SetEventObject(this);
2172 if (!GetEventHandler()->ProcessEvent(event))
2173 return Default();
2174 else
2175 return 0;
2176 break;
2177 }
2d0a075d
JS
2178 default:
2179 return Default();
2bda0e17
KB
2180 }
2181 return 0;
2182}
2183
debe6624 2184void wxWindow::MSWOnLButtonDown(int x, int y, WXUINT flags)
2bda0e17 2185{
2d0a075d 2186 wxMouseEvent event(wxEVT_LEFT_DOWN);
2bda0e17 2187
2d0a075d
JS
2188 event.m_x = x; event.m_y = y;
2189 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2190 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2191 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2192 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2193 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2194 event.SetTimestamp(wxApp::sm_lastMessageTime);
2195 event.m_eventObject = this;
2bda0e17 2196
f5419957 2197 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DOWN;
debe6624 2198
2d0a075d
JS
2199 if (!GetEventHandler()->ProcessEvent(event))
2200 Default();
2bda0e17
KB
2201}
2202
debe6624 2203void wxWindow::MSWOnLButtonUp(int x, int y, WXUINT flags)
2bda0e17 2204{
2d0a075d 2205 wxMouseEvent event(wxEVT_LEFT_UP);
2bda0e17 2206
2d0a075d
JS
2207 event.m_x = x; event.m_y = y;
2208 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2209 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2210 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2211 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2212 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2213 event.SetTimestamp(wxApp::sm_lastMessageTime);
2214 event.m_eventObject = this;
2bda0e17 2215
2d0a075d 2216 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_UP;
2bda0e17 2217
2d0a075d
JS
2218 if (!GetEventHandler()->ProcessEvent(event))
2219 Default();
2bda0e17
KB
2220}
2221
debe6624 2222void wxWindow::MSWOnLButtonDClick(int x, int y, WXUINT flags)
2bda0e17 2223{
2d0a075d 2224 wxMouseEvent event(wxEVT_LEFT_DCLICK);
2bda0e17 2225
2d0a075d
JS
2226 event.m_x = x; event.m_y = y;
2227 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2228 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2229 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2230 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2231 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2232 event.SetTimestamp(wxApp::sm_lastMessageTime);
2233 event.m_eventObject = this;
2bda0e17 2234
2d0a075d 2235 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DCLICK;
2bda0e17 2236
2d0a075d
JS
2237 if (!GetEventHandler()->ProcessEvent(event))
2238 Default();
2bda0e17
KB
2239}
2240
debe6624 2241void wxWindow::MSWOnMButtonDown(int x, int y, WXUINT flags)
2bda0e17 2242{
2d0a075d 2243 wxMouseEvent event(wxEVT_MIDDLE_DOWN);
2bda0e17 2244
2d0a075d
JS
2245 event.m_x = x; event.m_y = y;
2246 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2247 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2248 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2249 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2250 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2251 event.SetTimestamp(wxApp::sm_lastMessageTime);
2252 event.m_eventObject = this;
2bda0e17 2253
2d0a075d 2254 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DOWN;
debe6624 2255
2d0a075d
JS
2256 if (!GetEventHandler()->ProcessEvent(event))
2257 Default();
2bda0e17
KB
2258}
2259
debe6624 2260void wxWindow::MSWOnMButtonUp(int x, int y, WXUINT flags)
2bda0e17 2261{
2d0a075d 2262 wxMouseEvent event(wxEVT_MIDDLE_UP);
2bda0e17 2263
2d0a075d
JS
2264 event.m_x = x; event.m_y = y;
2265 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2266 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2267 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2268 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2269 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2270 event.SetTimestamp(wxApp::sm_lastMessageTime);
2271 event.m_eventObject = this;
2bda0e17 2272
2d0a075d 2273 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_UP;
debe6624 2274
2d0a075d
JS
2275 if (!GetEventHandler()->ProcessEvent(event))
2276 Default();
2bda0e17
KB
2277}
2278
debe6624 2279void wxWindow::MSWOnMButtonDClick(int x, int y, WXUINT flags)
2bda0e17 2280{
2d0a075d 2281 wxMouseEvent event(wxEVT_MIDDLE_DCLICK);
2bda0e17 2282
2d0a075d
JS
2283 event.m_x = x; event.m_y = y;
2284 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2285 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2286 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2287 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2288 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2289 event.SetTimestamp(wxApp::sm_lastMessageTime);
2290 event.m_eventObject = this;
2bda0e17 2291
2d0a075d 2292 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DCLICK;
debe6624 2293
2d0a075d
JS
2294 if (!GetEventHandler()->ProcessEvent(event))
2295 Default();
2bda0e17
KB
2296}
2297
debe6624 2298void wxWindow::MSWOnRButtonDown(int x, int y, WXUINT flags)
2bda0e17 2299{
2d0a075d 2300 wxMouseEvent event(wxEVT_RIGHT_DOWN);
2bda0e17 2301
2d0a075d
JS
2302 event.m_x = x; event.m_y = y;
2303 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2304 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2305 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2306 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2307 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2308 event.SetTimestamp(wxApp::sm_lastMessageTime);
2309 event.m_eventObject = this;
2bda0e17 2310
2d0a075d 2311 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DOWN;
debe6624 2312
2d0a075d
JS
2313 if (!GetEventHandler()->ProcessEvent(event))
2314 Default();
2bda0e17
KB
2315}
2316
debe6624 2317void wxWindow::MSWOnRButtonUp(int x, int y, WXUINT flags)
2bda0e17 2318{
2d0a075d 2319 wxMouseEvent event(wxEVT_RIGHT_UP);
2bda0e17 2320
2d0a075d
JS
2321 event.m_x = x; event.m_y = y;
2322 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2323 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2324 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2325 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2326 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2327 event.m_eventObject = this;
2328 event.SetTimestamp(wxApp::sm_lastMessageTime);
2bda0e17 2329
2d0a075d 2330 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_UP;
debe6624 2331
2d0a075d
JS
2332 if (!GetEventHandler()->ProcessEvent(event))
2333 Default();
2bda0e17
KB
2334}
2335
debe6624 2336void wxWindow::MSWOnRButtonDClick(int x, int y, WXUINT flags)
2bda0e17 2337{
2d0a075d 2338 wxMouseEvent event(wxEVT_RIGHT_DCLICK);
2bda0e17 2339
2d0a075d
JS
2340 event.m_x = x; event.m_y = y;
2341 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2342 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2343 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2344 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2345 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2346 event.SetTimestamp(wxApp::sm_lastMessageTime);
2347 event.m_eventObject = this;
2bda0e17 2348
2d0a075d 2349 m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DCLICK;
debe6624 2350
2d0a075d
JS
2351 if (!GetEventHandler()->ProcessEvent(event))
2352 Default();
2bda0e17
KB
2353}
2354
debe6624 2355void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags)
2bda0e17 2356{
2d0a075d
JS
2357 // 'normal' move event...
2358 // Set cursor, but only if we're not in 'busy' mode
2bda0e17 2359
2d0a075d
JS
2360 // Trouble with this is that it sets the cursor for controls too :-(
2361 if (m_windowCursor.Ok() && !wxIsBusy())
2362 ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR());
2bda0e17 2363
2d0a075d
JS
2364 if (!m_mouseInWindow)
2365 {
2366 // Generate an ENTER event
2367 m_mouseInWindow = TRUE;
2368 MSWOnMouseEnter(x, y, flags);
2369 }
2bda0e17 2370
2d0a075d 2371 wxMouseEvent event(wxEVT_MOTION);
debe6624 2372
2d0a075d
JS
2373 event.m_x = x; event.m_y = y;
2374 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2375 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2376 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2377 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2378 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2379 event.SetTimestamp(wxApp::sm_lastMessageTime);
2380 event.m_eventObject = this;
2381
2382 // Window gets a click down message followed by a mouse move
2383 // message even if position isn't changed! We want to discard
2384 // the trailing move event if x and y are the same.
2385 if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN ||
2386 m_lastEvent == wxEVT_MIDDLE_DOWN) &&
2387 (m_lastXPos == event.m_x && m_lastYPos == event.m_y))
2388 {
2389 m_lastXPos = event.m_x; m_lastYPos = event.m_y;
2390 m_lastEvent = wxEVT_MOTION;
2391 return;
2392 }
2393
2394 m_lastEvent = wxEVT_MOTION;
2395 m_lastXPos = event.m_x; m_lastYPos = event.m_y;
2396
2397 if (!GetEventHandler()->ProcessEvent(event))
2398 Default();
2bda0e17 2399}
2bda0e17 2400
debe6624 2401void wxWindow::MSWOnMouseEnter(int x, int y, WXUINT flags)
2bda0e17 2402{
2d0a075d 2403 wxMouseEvent event(wxEVT_ENTER_WINDOW);
2bda0e17 2404
2d0a075d
JS
2405 event.m_x = x; event.m_y = y;
2406 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2407 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2408 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2409 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2410 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2411 event.SetTimestamp(wxApp::sm_lastMessageTime);
2412 event.m_eventObject = this;
2bda0e17 2413
2d0a075d
JS
2414 m_lastEvent = wxEVT_ENTER_WINDOW;
2415 m_lastXPos = event.m_x; m_lastYPos = event.m_y;
2416 // No message - ensure we don't try to call the default behaviour accidentally.
2417 m_lastMsg = 0;
2418 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2419}
2420
debe6624 2421void wxWindow::MSWOnMouseLeave(int x, int y, WXUINT flags)
2bda0e17 2422{
2d0a075d 2423 wxMouseEvent event(wxEVT_LEAVE_WINDOW);
2bda0e17 2424
2d0a075d
JS
2425 event.m_x = x; event.m_y = y;
2426 event.m_shiftDown = ((flags & MK_SHIFT) != 0);
2427 event.m_controlDown = ((flags & MK_CONTROL) != 0);
2428 event.m_leftDown = ((flags & MK_LBUTTON) != 0);
2429 event.m_middleDown = ((flags & MK_MBUTTON) != 0);
2430 event.m_rightDown = ((flags & MK_RBUTTON) != 0);
2431 event.SetTimestamp(wxApp::sm_lastMessageTime);
2432 event.m_eventObject = this;
2bda0e17 2433
2d0a075d
JS
2434 m_lastEvent = wxEVT_LEAVE_WINDOW;
2435 m_lastXPos = event.m_x; m_lastYPos = event.m_y;
2436 // No message - ensure we don't try to call the default behaviour accidentally.
2437 m_lastMsg = 0;
2438 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2439}
2440
debe6624 2441void wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2bda0e17 2442{
2d0a075d
JS
2443 int id;
2444 bool tempControlDown = FALSE;
2445 if (isASCII)
2bda0e17 2446 {
2d0a075d
JS
2447 // If 1 -> 26, translate to CTRL plus a letter.
2448 id = wParam;
2449 if ((id > 0) && (id < 27))
2bda0e17 2450 {
2d0a075d
JS
2451 switch (id)
2452 {
2453 case 13:
2454 {
2455 id = WXK_RETURN;
2456 break;
2457 }
2458 case 8:
2459 {
2460 id = WXK_BACK;
2461 break;
2462 }
2463 case 9:
2464 {
2465 id = WXK_TAB;
2466 break;
2467 }
2468 default:
2469 {
2470 tempControlDown = TRUE;
2471 id = id + 96;
2472 }
2473 }
2bda0e17 2474 }
2bda0e17 2475 }
2d0a075d
JS
2476 else if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
2477 // it's ASCII and will be processed here only when called from
2478 // WM_CHAR (i.e. when isASCII = TRUE)
2479 id = -1;
2480 }
2bda0e17 2481
2d0a075d
JS
2482 if (id != -1)
2483 {
2484 wxKeyEvent event(wxEVT_CHAR);
2485 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
2486 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
2487 if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
2488 event.m_altDown = TRUE;
2489
2490 event.m_eventObject = this;
2491 event.m_keyCode = id;
2492 event.SetTimestamp(wxApp::sm_lastMessageTime);
2493
2494 POINT pt ;
2495 GetCursorPos(&pt) ;
2496 RECT rect ;
2497 GetWindowRect((HWND) GetHWND(),&rect) ;
2498 pt.x -= rect.left ;
2499 pt.y -= rect.top ;
2500
2501 event.m_x = pt.x; event.m_y = pt.y;
2502
2503 if (!GetEventHandler()->ProcessEvent(event))
2504 Default();
2505 }
2bda0e17
KB
2506}
2507
4ce81a75
JS
2508void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2509{
2510 int id;
2511
2512 if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
2513 id = wParam;
2514 }
2515
2516 if (id != -1)
2517 {
2518 wxKeyEvent event(wxEVT_KEY_DOWN);
2519 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
2520 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
2521 if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
2522 event.m_altDown = TRUE;
2523
2524 event.m_eventObject = this;
2525 event.m_keyCode = id;
2526 event.SetTimestamp(wxApp::sm_lastMessageTime);
2527
2528 POINT pt ;
2529 GetCursorPos(&pt) ;
2530 RECT rect ;
2531 GetWindowRect((HWND) GetHWND(),&rect) ;
2532 pt.x -= rect.left ;
2533 pt.y -= rect.top ;
2534
2535 event.m_x = pt.x; event.m_y = pt.y;
2536
2537 if (!GetEventHandler()->ProcessEvent(event))
2538 Default();
2539 }
2540}
2541
2542void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII)
2543{
2544 int id;
2545
2546 if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
2547 id = wParam;
2548 }
2549
2550 if (id != -1)
2551 {
2552 wxKeyEvent event(wxEVT_KEY_UP);
2553 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
2554 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
2555 if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
2556 event.m_altDown = TRUE;
2557
2558 event.m_eventObject = this;
2559 event.m_keyCode = id;
2560 event.SetTimestamp(wxApp::sm_lastMessageTime);
2561
2562 POINT pt ;
2563 GetCursorPos(&pt) ;
2564 RECT rect ;
2565 GetWindowRect((HWND) GetHWND(),&rect) ;
2566 pt.x -= rect.left ;
2567 pt.y -= rect.top ;
2568
2569 event.m_x = pt.x; event.m_y = pt.y;
2570
2571 if (!GetEventHandler()->ProcessEvent(event))
2572 Default();
2573 }
2574}
2575
debe6624 2576void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags)
2bda0e17
KB
2577{
2578 int buttons = 0;
2579 int change = 0;
2580 if (flags & JOY_BUTTON1CHG)
2581 change = wxJOY_BUTTON1;
2582 if (flags & JOY_BUTTON2CHG)
2583 change = wxJOY_BUTTON2;
2584 if (flags & JOY_BUTTON3CHG)
2585 change = wxJOY_BUTTON3;
2586 if (flags & JOY_BUTTON4CHG)
2587 change = wxJOY_BUTTON4;
c085e333 2588
2bda0e17
KB
2589 if (flags & JOY_BUTTON1)
2590 buttons |= wxJOY_BUTTON1;
2591 if (flags & JOY_BUTTON2)
2592 buttons |= wxJOY_BUTTON2;
2593 if (flags & JOY_BUTTON3)
2594 buttons |= wxJOY_BUTTON3;
2595 if (flags & JOY_BUTTON4)
2596 buttons |= wxJOY_BUTTON4;
c085e333 2597
2bda0e17
KB
2598 wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change);
2599 event.SetPosition(wxPoint(x, y));
2600 event.SetEventObject(this);
c085e333 2601
2bda0e17
KB
2602 GetEventHandler()->ProcessEvent(event);
2603}
2604
debe6624 2605void wxWindow::MSWOnJoyUp(int joystick, int x, int y, WXUINT flags)
2bda0e17
KB
2606{
2607 int buttons = 0;
2608 int change = 0;
2609 if (flags & JOY_BUTTON1CHG)
2610 change = wxJOY_BUTTON1;
2611 if (flags & JOY_BUTTON2CHG)
2612 change = wxJOY_BUTTON2;
2613 if (flags & JOY_BUTTON3CHG)
2614 change = wxJOY_BUTTON3;
2615 if (flags & JOY_BUTTON4CHG)
2616 change = wxJOY_BUTTON4;
c085e333 2617
2bda0e17
KB
2618 if (flags & JOY_BUTTON1)
2619 buttons |= wxJOY_BUTTON1;
2620 if (flags & JOY_BUTTON2)
2621 buttons |= wxJOY_BUTTON2;
2622 if (flags & JOY_BUTTON3)
2623 buttons |= wxJOY_BUTTON3;
2624 if (flags & JOY_BUTTON4)
2625 buttons |= wxJOY_BUTTON4;
c085e333 2626
2bda0e17
KB
2627 wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change);
2628 event.SetPosition(wxPoint(x, y));
2629 event.SetEventObject(this);
c085e333 2630
2bda0e17
KB
2631 GetEventHandler()->ProcessEvent(event);
2632}
2633
debe6624 2634void wxWindow::MSWOnJoyMove(int joystick, int x, int y, WXUINT flags)
2bda0e17
KB
2635{
2636 int buttons = 0;
2637 if (flags & JOY_BUTTON1)
2638 buttons |= wxJOY_BUTTON1;
2639 if (flags & JOY_BUTTON2)
2640 buttons |= wxJOY_BUTTON2;
2641 if (flags & JOY_BUTTON3)
2642 buttons |= wxJOY_BUTTON3;
2643 if (flags & JOY_BUTTON4)
2644 buttons |= wxJOY_BUTTON4;
c085e333 2645
2bda0e17
KB
2646 wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0);
2647 event.SetPosition(wxPoint(x, y));
2648 event.SetEventObject(this);
c085e333 2649
2bda0e17
KB
2650 GetEventHandler()->ProcessEvent(event);
2651}
2652
debe6624 2653void wxWindow::MSWOnJoyZMove(int joystick, int z, WXUINT flags)
2bda0e17
KB
2654{
2655 int buttons = 0;
2656 if (flags & JOY_BUTTON1)
2657 buttons |= wxJOY_BUTTON1;
2658 if (flags & JOY_BUTTON2)
2659 buttons |= wxJOY_BUTTON2;
2660 if (flags & JOY_BUTTON3)
2661 buttons |= wxJOY_BUTTON3;
2662 if (flags & JOY_BUTTON4)
2663 buttons |= wxJOY_BUTTON4;
c085e333 2664
2bda0e17
KB
2665 wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0);
2666 event.SetZPosition(z);
2667 event.SetEventObject(this);
c085e333 2668
2bda0e17
KB
2669 GetEventHandler()->ProcessEvent(event);
2670}
2671
debe6624 2672void wxWindow::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control)
2bda0e17 2673{
2d0a075d 2674 if (control)
564b2609 2675 {
2d0a075d
JS
2676 wxWindow *child = wxFindWinFromHandle(control);
2677 if ( child )
2678 child->MSWOnVScroll(wParam, pos, control);
2679 return;
564b2609 2680 }
2bda0e17 2681
564b2609
VZ
2682 wxScrollEvent event;
2683 event.SetPosition(pos);
2d0a075d 2684 event.SetOrientation(wxVERTICAL);
564b2609 2685 event.m_eventObject = this;
2d0a075d 2686
564b2609
VZ
2687 switch ( wParam )
2688 {
2d0a075d 2689 case SB_TOP:
564b2609
VZ
2690 event.m_eventType = wxEVT_SCROLL_TOP;
2691 break;
2d0a075d
JS
2692
2693 case SB_BOTTOM:
564b2609
VZ
2694 event.m_eventType = wxEVT_SCROLL_BOTTOM;
2695 break;
2d0a075d
JS
2696
2697 case SB_LINEUP:
564b2609
VZ
2698 event.m_eventType = wxEVT_SCROLL_LINEUP;
2699 break;
2d0a075d
JS
2700
2701 case SB_LINEDOWN:
564b2609
VZ
2702 event.m_eventType = wxEVT_SCROLL_LINEDOWN;
2703 break;
2d0a075d
JS
2704
2705 case SB_PAGEUP:
564b2609
VZ
2706 event.m_eventType = wxEVT_SCROLL_PAGEUP;
2707 break;
2d0a075d
JS
2708
2709 case SB_PAGEDOWN:
564b2609
VZ
2710 event.m_eventType = wxEVT_SCROLL_PAGEDOWN;
2711 break;
2d0a075d
JS
2712
2713 case SB_THUMBTRACK:
2714 case SB_THUMBPOSITION:
564b2609
VZ
2715 event.m_eventType = wxEVT_SCROLL_THUMBTRACK;
2716 break;
2d0a075d
JS
2717
2718 default:
564b2609 2719 return;
2d0a075d 2720 break;
564b2609 2721 }
c085e333 2722
2d0a075d
JS
2723 if (!GetEventHandler()->ProcessEvent(event))
2724 Default();
2725}
2726
2727void wxWindow::MSWOnHScroll( WXWORD wParam, WXWORD pos, WXHWND control)
2728{
2729 if (control)
2730 {
2731 wxWindow *child = wxFindWinFromHandle(control);
2732 if ( child ) {
2733 child->MSWOnHScroll(wParam, pos, control);
2734
2735 return;
2736 }
2737 }
2738 else {
2739 wxScrollEvent event;
2740 event.SetPosition(pos);
2741 event.SetOrientation(wxHORIZONTAL);
2742 event.m_eventObject = this;
2743
2744 switch ( wParam )
2745 {
2746 case SB_TOP:
2747 event.m_eventType = wxEVT_SCROLL_TOP;
2748 break;
2749
2750 case SB_BOTTOM:
2751 event.m_eventType = wxEVT_SCROLL_BOTTOM;
2752 break;
2753
2754 case SB_LINEUP:
2755 event.m_eventType = wxEVT_SCROLL_LINEUP;
2756 break;
2bda0e17 2757
2d0a075d
JS
2758 case SB_LINEDOWN:
2759 event.m_eventType = wxEVT_SCROLL_LINEDOWN;
2760 break;
2761
2762 case SB_PAGEUP:
2763 event.m_eventType = wxEVT_SCROLL_PAGEUP;
2764 break;
2765
2766 case SB_PAGEDOWN:
2767 event.m_eventType = wxEVT_SCROLL_PAGEDOWN;
2768 break;
2769
2770 case SB_THUMBTRACK:
2771 case SB_THUMBPOSITION:
2772 event.m_eventType = wxEVT_SCROLL_THUMBTRACK;
2773 break;
2774
2775 default:
2776 return;
2777 }
2bda0e17 2778
2d0a075d
JS
2779 if ( GetEventHandler()->ProcessEvent(event) )
2780 return;
2781 }
2782
2783 // call the default WM_HSCROLL handler: it's non trivial in some common
2784 // controls (up-down control for example)
2785 Default();
2bda0e17
KB
2786}
2787
2788void wxWindow::MSWOnShow(bool show, int status)
2789{
2d0a075d
JS
2790 wxShowEvent event(GetId(), show);
2791 event.m_eventObject = this;
2792 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2793}
2794
2795bool wxWindow::MSWOnInitDialog(WXHWND WXUNUSED(hWndFocus))
2796{
2d0a075d
JS
2797 wxInitDialogEvent event(GetId());
2798 event.m_eventObject = this;
2799 GetEventHandler()->ProcessEvent(event);
2800 return TRUE;
2bda0e17
KB
2801}
2802
fd3f686c 2803void wxWindow::InitDialog()
2bda0e17 2804{
2d0a075d
JS
2805 wxInitDialogEvent event(GetId());
2806 event.SetEventObject( this );
2807 GetEventHandler()->ProcessEvent(event);
2bda0e17
KB
2808}
2809
2810// Default init dialog behaviour is to transfer data to window
2811void wxWindow::OnInitDialog(wxInitDialogEvent& event)
2812{
2d0a075d 2813 TransferDataToWindow();
2bda0e17
KB
2814}
2815
2816void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
2817{
2d0a075d
JS
2818 TEXTMETRIC tm;
2819 HDC dc = ::GetDC((HWND) wnd);
2820 HFONT fnt =0;
2821 HFONT was = 0;
2822 if (the_font)
2823 {
2d0a075d
JS
2824 // the_font->UseResource();
2825 // the_font->RealizeResource();
fd3f686c
VZ
2826 fnt = (HFONT)the_font->GetResourceHandle();
2827 if ( fnt )
2d0a075d
JS
2828 was = (HFONT) SelectObject(dc,fnt) ;
2829 }
2830 GetTextMetrics(dc, &tm);
2831 if (the_font && fnt && was)
2832 {
2d0a075d
JS
2833 SelectObject(dc,was) ;
2834 }
2835 ReleaseDC((HWND)wnd, dc);
2836 *x = tm.tmAveCharWidth;
2837 *y = tm.tmHeight + tm.tmExternalLeading;
2bda0e17 2838
2d0a075d
JS
2839 // if (the_font)
2840 // the_font->ReleaseResource();
2bda0e17
KB
2841}
2842
2843// Returns 0 if was a normal ASCII value, not a special key. This indicates that
2844// the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2845int wxCharCodeMSWToWX(int keySym)
2846{
2d0a075d
JS
2847 int id = 0;
2848 switch (keySym)
2849 {
2850 case VK_CANCEL: id = WXK_CANCEL; break;
2851 case VK_BACK: id = WXK_BACK; break;
2852 case VK_TAB: id = WXK_TAB; break;
564b2609
VZ
2853 case VK_CLEAR: id = WXK_CLEAR; break;
2854 case VK_RETURN: id = WXK_RETURN; break;
2855 case VK_SHIFT: id = WXK_SHIFT; break;
2d0a075d 2856 case VK_CONTROL: id = WXK_CONTROL; break;
564b2609
VZ
2857 case VK_MENU : id = WXK_MENU; break;
2858 case VK_PAUSE: id = WXK_PAUSE; break;
2859 case VK_SPACE: id = WXK_SPACE; break;
2860 case VK_ESCAPE: id = WXK_ESCAPE; break;
2861 case VK_PRIOR: id = WXK_PRIOR; break;
2862 case VK_NEXT : id = WXK_NEXT; break;
2863 case VK_END: id = WXK_END; break;
2864 case VK_HOME : id = WXK_HOME; break;
2865 case VK_LEFT : id = WXK_LEFT; break;
2d0a075d 2866 case VK_UP: id = WXK_UP; break;
564b2609
VZ
2867 case VK_RIGHT: id = WXK_RIGHT; break;
2868 case VK_DOWN : id = WXK_DOWN; break;
2869 case VK_SELECT: id = WXK_SELECT; break;
2870 case VK_PRINT: id = WXK_PRINT; break;
2d0a075d 2871 case VK_EXECUTE: id = WXK_EXECUTE; break;
564b2609
VZ
2872 case VK_INSERT: id = WXK_INSERT; break;
2873 case VK_DELETE: id = WXK_DELETE; break;
2874 case VK_HELP : id = WXK_HELP; break;
2d0a075d
JS
2875 case VK_NUMPAD0: id = WXK_NUMPAD0; break;
2876 case VK_NUMPAD1: id = WXK_NUMPAD1; break;
2877 case VK_NUMPAD2: id = WXK_NUMPAD2; break;
2878 case VK_NUMPAD3: id = WXK_NUMPAD3; break;
2879 case VK_NUMPAD4: id = WXK_NUMPAD4; break;
2880 case VK_NUMPAD5: id = WXK_NUMPAD5; break;
2881 case VK_NUMPAD6: id = WXK_NUMPAD6; break;
2882 case VK_NUMPAD7: id = WXK_NUMPAD7; break;
2883 case VK_NUMPAD8: id = WXK_NUMPAD8; break;
2884 case VK_NUMPAD9: id = WXK_NUMPAD9; break;
2885 case VK_MULTIPLY: id = WXK_MULTIPLY; break;
564b2609 2886 case VK_ADD: id = WXK_ADD; break;
2d0a075d
JS
2887 case VK_SUBTRACT: id = WXK_SUBTRACT; break;
2888 case VK_DECIMAL: id = WXK_DECIMAL; break;
564b2609 2889 case VK_DIVIDE: id = WXK_DIVIDE; break;
2d0a075d
JS
2890 case VK_F1: id = WXK_F1; break;
2891 case VK_F2: id = WXK_F2; break;
2892 case VK_F3: id = WXK_F3; break;
2893 case VK_F4: id = WXK_F4; break;
2894 case VK_F5: id = WXK_F5; break;
2895 case VK_F6: id = WXK_F6; break;
2896 case VK_F7: id = WXK_F7; break;
2897 case VK_F8: id = WXK_F8; break;
2898 case VK_F9: id = WXK_F9; break;
564b2609
VZ
2899 case VK_F10: id = WXK_F10; break;
2900 case VK_F11: id = WXK_F11; break;
2901 case VK_F12: id = WXK_F12; break;
2902 case VK_F13: id = WXK_F13; break;
2903 case VK_F14: id = WXK_F14; break;
2904 case VK_F15: id = WXK_F15; break;
2905 case VK_F16: id = WXK_F16; break;
2906 case VK_F17: id = WXK_F17; break;
2907 case VK_F18: id = WXK_F18; break;
2908 case VK_F19: id = WXK_F19; break;
2909 case VK_F20: id = WXK_F20; break;
2910 case VK_F21: id = WXK_F21; break;
2911 case VK_F22: id = WXK_F22; break;
2912 case VK_F23: id = WXK_F23; break;
2913 case VK_F24: id = WXK_F24; break;
2d0a075d 2914 case VK_NUMLOCK: id = WXK_NUMLOCK; break;
564b2609 2915 case VK_SCROLL: id = WXK_SCROLL; break;
2bda0e17 2916 default:
2d0a075d
JS
2917 {
2918 return 0;
2919 }
2bda0e17 2920 }
2d0a075d 2921 return id;
2bda0e17
KB
2922}
2923
2924int wxCharCodeWXToMSW(int id, bool *isVirtual)
2925{
2d0a075d
JS
2926 *isVirtual = TRUE;
2927 int keySym = 0;
2928 switch (id)
2929 {
2930 case WXK_CANCEL: keySym = VK_CANCEL; break;
564b2609
VZ
2931 case WXK_CLEAR: keySym = VK_CLEAR; break;
2932 case WXK_SHIFT: keySym = VK_SHIFT; break;
2d0a075d 2933 case WXK_CONTROL: keySym = VK_CONTROL; break;
564b2609
VZ
2934 case WXK_MENU : keySym = VK_MENU; break;
2935 case WXK_PAUSE: keySym = VK_PAUSE; break;
2936 case WXK_PRIOR: keySym = VK_PRIOR; break;
2937 case WXK_NEXT : keySym = VK_NEXT; break;
2938 case WXK_END: keySym = VK_END; break;
2939 case WXK_HOME : keySym = VK_HOME; break;
2940 case WXK_LEFT : keySym = VK_LEFT; break;
2941 case WXK_UP: keySym = VK_UP; break;
2942 case WXK_RIGHT: keySym = VK_RIGHT; break;
2943 case WXK_DOWN : keySym = VK_DOWN; break;
2d0a075d 2944 case WXK_SELECT: keySym = VK_SELECT; break;
564b2609 2945 case WXK_PRINT: keySym = VK_PRINT; break;
2d0a075d
JS
2946 case WXK_EXECUTE: keySym = VK_EXECUTE; break;
2947 case WXK_INSERT: keySym = VK_INSERT; break;
2948 case WXK_DELETE: keySym = VK_DELETE; break;
564b2609 2949 case WXK_HELP : keySym = VK_HELP; break;
2d0a075d
JS
2950 case WXK_NUMPAD0: keySym = VK_NUMPAD0; break;
2951 case WXK_NUMPAD1: keySym = VK_NUMPAD1; break;
2952 case WXK_NUMPAD2: keySym = VK_NUMPAD2; break;
2953 case WXK_NUMPAD3: keySym = VK_NUMPAD3; break;
2954 case WXK_NUMPAD4: keySym = VK_NUMPAD4; break;
2955 case WXK_NUMPAD5: keySym = VK_NUMPAD5; break;
2956 case WXK_NUMPAD6: keySym = VK_NUMPAD6; break;
2957 case WXK_NUMPAD7: keySym = VK_NUMPAD7; break;
2958 case WXK_NUMPAD8: keySym = VK_NUMPAD8; break;
2959 case WXK_NUMPAD9: keySym = VK_NUMPAD9; break;
2960 case WXK_MULTIPLY: keySym = VK_MULTIPLY; break;
564b2609 2961 case WXK_ADD: keySym = VK_ADD; break;
2d0a075d
JS
2962 case WXK_SUBTRACT: keySym = VK_SUBTRACT; break;
2963 case WXK_DECIMAL: keySym = VK_DECIMAL; break;
2964 case WXK_DIVIDE: keySym = VK_DIVIDE; break;
564b2609
VZ
2965 case WXK_F1: keySym = VK_F1; break;
2966 case WXK_F2: keySym = VK_F2; break;
2967 case WXK_F3: keySym = VK_F3; break;
2968 case WXK_F4: keySym = VK_F4; break;
2969 case WXK_F5: keySym = VK_F5; break;
2970 case WXK_F6: keySym = VK_F6; break;
2971 case WXK_F7: keySym = VK_F7; break;
2972 case WXK_F8: keySym = VK_F8; break;
2973 case WXK_F9: keySym = VK_F9; break;
2974 case WXK_F10: keySym = VK_F10; break;
2975 case WXK_F11: keySym = VK_F11; break;
2976 case WXK_F12: keySym = VK_F12; break;
2977 case WXK_F13: keySym = VK_F13; break;
2978 case WXK_F14: keySym = VK_F14; break;
2979 case WXK_F15: keySym = VK_F15; break;
2980 case WXK_F16: keySym = VK_F16; break;
2981 case WXK_F17: keySym = VK_F17; break;
2982 case WXK_F18: keySym = VK_F18; break;
2983 case WXK_F19: keySym = VK_F19; break;
2984 case WXK_F20: keySym = VK_F20; break;
2985 case WXK_F21: keySym = VK_F21; break;
2986 case WXK_F22: keySym = VK_F22; break;
2987 case WXK_F23: keySym = VK_F23; break;
2988 case WXK_F24: keySym = VK_F24; break;
2d0a075d
JS
2989 case WXK_NUMLOCK: keySym = VK_NUMLOCK; break;
2990 case WXK_SCROLL: keySym = VK_SCROLL; break;
2bda0e17 2991 default:
2d0a075d
JS
2992 {
2993 *isVirtual = FALSE;
2994 keySym = id;
2995 break;
2996 }
2bda0e17 2997 }
2d0a075d 2998 return keySym;
2bda0e17
KB
2999}
3000
3001// Caret manipulation
debe6624 3002void wxWindow::CreateCaret(int w, int h)
2bda0e17 3003{
2d0a075d
JS
3004 m_caretWidth = w;
3005 m_caretHeight = h;
3006 m_caretEnabled = TRUE;
2bda0e17
KB
3007}
3008
3009void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
3010{
2d0a075d 3011 // Not implemented
2bda0e17
KB
3012}
3013
debe6624 3014void wxWindow::ShowCaret(bool show)
2bda0e17 3015{
2d0a075d
JS
3016 if (m_caretEnabled)
3017 {
3018 if (show)
3019 ::ShowCaret((HWND) GetHWND());
3020 else
3021 ::HideCaret((HWND) GetHWND());
3022 m_caretShown = show;
3023 }
2bda0e17
KB
3024}
3025
fd3f686c 3026void wxWindow::DestroyCaret()
2bda0e17 3027{
2d0a075d 3028 m_caretEnabled = FALSE;
2bda0e17
KB
3029}
3030
debe6624 3031void wxWindow::SetCaretPos(int x, int y)
2bda0e17 3032{
2d0a075d 3033 ::SetCaretPos(x, y);
2bda0e17
KB
3034}
3035
3036void wxWindow::GetCaretPos(int *x, int *y) const
3037{
2d0a075d
JS
3038 POINT point;
3039 ::GetCaretPos(&point);
3040 *x = point.x;
3041 *y = point.y;
2bda0e17
KB
3042}
3043
fd3f686c 3044wxWindow *wxGetActiveWindow()
2bda0e17 3045{
2d0a075d
JS
3046 HWND hWnd = GetActiveWindow();
3047 if (hWnd != 0)
3048 {
3049 return wxFindWinFromHandle((WXHWND) hWnd);
3050 }
3051 return NULL;
2bda0e17
KB
3052}
3053
3054// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3055// in active frames and dialogs, regardless of where the focus is.
3056static HHOOK wxTheKeyboardHook = 0;
3057static FARPROC wxTheKeyboardHookProc = 0;
3058int APIENTRY _EXPORT
2d0a075d 3059wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
2bda0e17
KB
3060
3061void wxSetKeyboardHook(bool doIt)
3062{
2d0a075d
JS
3063 if (doIt)
3064 {
3065 wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
3066 wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
57c208c5 3067#if defined(__WIN32__) && !defined(__TWIN32__)
2d0a075d
JS
3068 GetCurrentThreadId());
3069 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2bda0e17 3070#else
2d0a075d 3071 GetCurrentTask());
2bda0e17 3072#endif
2d0a075d
JS
3073 }
3074 else
3075 {
3076 UnhookWindowsHookEx(wxTheKeyboardHook);
3077 FreeProcInstance(wxTheKeyboardHookProc);
3078 }
2bda0e17
KB
3079}
3080
3081int APIENTRY _EXPORT
2d0a075d 3082wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
2bda0e17 3083{
2d0a075d
JS
3084 DWORD hiWord = HIWORD(lParam);
3085 if (nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0))
2bda0e17 3086 {
2d0a075d
JS
3087 int id;
3088 if ((id = wxCharCodeMSWToWX(wParam)) != 0)
564b2609 3089 {
2d0a075d
JS
3090 wxKeyEvent event(wxEVT_CHAR_HOOK);
3091 if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
3092 event.m_altDown = TRUE;
3093
3094 event.m_eventObject = NULL;
3095 event.m_keyCode = id;
3096 /* begin Albert's fix for control and shift key 26.5 */
3097 event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
3098 event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
3099 /* end Albert's fix for control and shift key 26.5 */
3100 event.SetTimestamp(wxApp::sm_lastMessageTime);
3101
3102 wxWindow *win = wxGetActiveWindow();
3103 if (win)
3104 {
3105 if (win->GetEventHandler()->ProcessEvent(event))
3106 return 1;
3107 }
3108 else
3109 {
3110 if ( wxTheApp && wxTheApp->ProcessEvent(event) )
3111 return 1;
3112 }
564b2609 3113 }
2bda0e17 3114 }
2d0a075d 3115 return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam);
2bda0e17
KB
3116}
3117
debe6624 3118void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH))
2bda0e17 3119{
2d0a075d
JS
3120 m_minSizeX = minW;
3121 m_minSizeY = minH;
3122 m_maxSizeX = maxW;
3123 m_maxSizeY = maxH;
2bda0e17
KB
3124}
3125
debe6624 3126void wxWindow::Centre(int direction)
2bda0e17 3127{
2d0a075d 3128 int x, y, width, height, panel_width, panel_height, new_x, new_y;
2bda0e17 3129
2d0a075d
JS
3130 wxWindow *father = (wxWindow *)GetParent();
3131 if (!father)
3132 return;
2bda0e17 3133
2d0a075d
JS
3134 father->GetClientSize(&panel_width, &panel_height);
3135 GetSize(&width, &height);
3136 GetPosition(&x, &y);
2bda0e17 3137
2d0a075d
JS
3138 new_x = -1;
3139 new_y = -1;
2bda0e17 3140
2d0a075d
JS
3141 if (direction & wxHORIZONTAL)
3142 new_x = (int)((panel_width - width)/2);
2bda0e17 3143
2d0a075d
JS
3144 if (direction & wxVERTICAL)
3145 new_y = (int)((panel_height - height)/2);
2bda0e17 3146
2d0a075d 3147 SetSize(new_x, new_y, -1, -1);
2bda0e17
KB
3148
3149}
3150
debe6624 3151void wxWindow::WarpPointer (int x_pos, int y_pos)
2bda0e17 3152{
5de76427
JS
3153 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3154 // pixel coordinates, relatives to the canvas -- So, we first need to
3155 // substract origin of the window, then convert to screen position
c085e333 3156
5de76427
JS
3157 int x = x_pos; int y = y_pos;
3158 RECT rect;
3159 GetWindowRect ((HWND) GetHWND(), &rect);
c085e333 3160
5de76427
JS
3161 x += rect.left;
3162 y += rect.top;
c085e333 3163
5de76427 3164 SetCursorPos (x, y);
2bda0e17
KB
3165}
3166
3167void wxWindow::MSWDeviceToLogical (float *x, float *y) const
3168{
2bda0e17
KB
3169}
3170
debe6624 3171bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC)
2bda0e17
KB
3172{
3173 wxDC dc ;
c085e333 3174
564b2609
VZ
3175 dc.SetHDC(pDC);
3176 dc.SetWindow(this);
3177 dc.BeginDrawing();
c085e333 3178
2bda0e17
KB
3179 wxEraseEvent event(m_windowId, &dc);
3180 event.m_eventObject = this;
3181 if (!GetEventHandler()->ProcessEvent(event))
3182 {
564b2609
VZ
3183 dc.EndDrawing();
3184 dc.SelectOldObjects(pDC);
2bda0e17
KB
3185 return FALSE;
3186 }
3187 else
3188 {
564b2609
VZ
3189 dc.EndDrawing();
3190 dc.SelectOldObjects(pDC);
2bda0e17 3191 }
c085e333 3192
2bda0e17
KB
3193 dc.SetHDC((WXHDC) NULL);
3194 return TRUE;
3195}
3196
3197void wxWindow::OnEraseBackground(wxEraseEvent& event)
3198{
ce3ed50d
JS
3199 if (!GetHWND())
3200 return;
3201
2d0a075d
JS
3202 RECT rect;
3203 ::GetClientRect((HWND) GetHWND(), &rect);
2bda0e17 3204
ce3ed50d
JS
3205 COLORREF ref = PALETTERGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()) ;
3206 HBRUSH hBrush = ::CreateSolidBrush(ref);
2d0a075d 3207 int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
2bda0e17 3208
2d0a075d
JS
3209 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3210 ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
3211 ::DeleteObject(hBrush);
3212 ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
3213 /*
3214 // Less efficient version (and doesn't account for scrolling)
3215 int w, h;
3216 GetClientSize(& w, & h);
3217 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3218 event.GetDC()->SetBrush(brush);
3219 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3220
3221 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3222 */
2bda0e17
KB
3223}
3224
3225#if WXWIN_COMPATIBILITY
debe6624 3226void wxWindow::SetScrollRange(int orient, int range, bool refresh)
2bda0e17
KB
3227{
3228#if defined(__WIN95__)
c085e333 3229
2d0a075d 3230 int range1 = range;
2bda0e17 3231
2d0a075d
JS
3232 // Try to adjust the range to cope with page size > 1
3233 // - a Windows API quirk
3234 int pageSize = GetScrollPage(orient);
3235 if ( pageSize > 1 && range > 0)
3236 {
3237 range1 += (pageSize - 1);
3238 }
2bda0e17 3239
2d0a075d
JS
3240 SCROLLINFO info;
3241 int dir;
2bda0e17 3242
2d0a075d
JS
3243 if (orient == wxHORIZONTAL) {
3244 dir = SB_HORZ;
3245 } else {
3246 dir = SB_VERT;
3247 }
2bda0e17 3248
2d0a075d
JS
3249 info.cbSize = sizeof(SCROLLINFO);
3250 info.nPage = pageSize; // Have to set this, or scrollbar goes awry
3251 info.nMin = 0;
3252 info.nMax = range1;
3253 info.nPos = 0;
3254 info.fMask = SIF_RANGE | SIF_PAGE;
2bda0e17 3255
2d0a075d
JS
3256 HWND hWnd = (HWND) GetHWND();
3257 if (hWnd)
3258 ::SetScrollInfo(hWnd, dir, &info, refresh);
2bda0e17 3259#else
2d0a075d
JS
3260 int wOrient ;
3261 if (orient == wxHORIZONTAL)
3262 wOrient = SB_HORZ;
3263 else
3264 wOrient = SB_VERT;
3265
3266 HWND hWnd = (HWND) GetHWND();
3267 if (hWnd)
3268 ::SetScrollRange(hWnd, wOrient, 0, range, refresh);
2bda0e17
KB
3269#endif
3270}
3271
debe6624 3272void wxWindow::SetScrollPage(int orient, int page, bool refresh)
2bda0e17
KB
3273{
3274#if defined(__WIN95__)
2d0a075d
JS
3275 SCROLLINFO info;
3276 int dir;
3277
3278 if (orient == wxHORIZONTAL) {
3279 dir = SB_HORZ;
3280 m_xThumbSize = page;
3281 } else {
3282 dir = SB_VERT;
3283 m_yThumbSize = page;
3284 }
2bda0e17 3285
2d0a075d
JS
3286 info.cbSize = sizeof(SCROLLINFO);
3287 info.nPage = page;
3288 info.nMin = 0;
3289 info.fMask = SIF_PAGE ;
2bda0e17 3290
2d0a075d
JS
3291 HWND hWnd = (HWND) GetHWND();
3292 if (hWnd)
3293 ::SetScrollInfo(hWnd, dir, &info, refresh);
2bda0e17 3294#else
2d0a075d
JS
3295 if (orient == wxHORIZONTAL)
3296 m_xThumbSize = page;
3297 else
3298 m_yThumbSize = page;
2bda0e17
KB
3299#endif
3300}
3301
debe6624 3302int wxWindow::OldGetScrollRange(int orient) const
2bda0e17 3303{
2d0a075d
JS
3304 int wOrient ;
3305 if (orient == wxHORIZONTAL)
3306 wOrient = SB_HORZ;
3307 else
3308 wOrient = SB_VERT;
2bda0e17
KB
3309
3310#if __WATCOMC__ && defined(__WINDOWS_386__)
2d0a075d 3311 short minPos, maxPos;
2bda0e17 3312#else
2d0a075d 3313 int minPos, maxPos;
2bda0e17 3314#endif
2d0a075d
JS
3315 HWND hWnd = (HWND) GetHWND();
3316 if (hWnd)
2bda0e17 3317 {
2d0a075d
JS
3318 ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
3319#if defined(__WIN95__)
3320 // Try to adjust the range to cope with page size > 1
3321 // - a Windows API quirk
3322 int pageSize = GetScrollPage(orient);
3323 if ( pageSize > 1 )
3324 {
3325 maxPos -= (pageSize - 1);
3326 }
2bda0e17 3327#endif
2d0a075d
JS
3328 return maxPos;
3329 }
3330 else
3331 return 0;
2bda0e17
KB
3332}
3333
debe6624 3334int wxWindow::GetScrollPage(int orient) const
2bda0e17 3335{
2d0a075d
JS
3336 if (orient == wxHORIZONTAL)
3337 return m_xThumbSize;
3338 else
3339 return m_yThumbSize;
2bda0e17
KB
3340}
3341#endif
3342
debe6624 3343int wxWindow::GetScrollPos(int orient) const
2bda0e17 3344{
2d0a075d
JS
3345 int wOrient ;
3346 if (orient == wxHORIZONTAL)
3347 wOrient = SB_HORZ;
3348 else
3349 wOrient = SB_VERT;
3350 HWND hWnd = (HWND) GetHWND();
3351 if (hWnd)
3352 {
3353 return ::GetScrollPos(hWnd, wOrient);
3354 }
3355 else
3356 return 0;
2bda0e17
KB
3357}
3358
3359// This now returns the whole range, not just the number
3360// of positions that we can scroll.
debe6624 3361int wxWindow::GetScrollRange(int orient) const
2bda0e17 3362{
2d0a075d
JS
3363 int wOrient ;
3364 if (orient == wxHORIZONTAL)
3365 wOrient = SB_HORZ;
3366 else
3367 wOrient = SB_VERT;
2bda0e17
KB
3368
3369#if __WATCOMC__ && defined(__WINDOWS_386__)
2d0a075d 3370 short minPos, maxPos;
2bda0e17 3371#else
2d0a075d 3372 int minPos, maxPos;
2bda0e17 3373#endif
2d0a075d
JS
3374 HWND hWnd = (HWND) GetHWND();
3375 if (hWnd)
2bda0e17 3376 {
2d0a075d
JS
3377 ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos);
3378#if defined(__WIN95__)
3379 // Try to adjust the range to cope with page size > 1
3380 // - a Windows API quirk
ca5e9f67 3381 int pageSize = GetScrollThumb(orient);
2d0a075d
JS
3382 if ( pageSize > 1 )
3383 {
3384 maxPos -= (pageSize - 1);
3385 }
3386 // October 10th: new range concept.
3387 maxPos += pageSize;
2bda0e17 3388#endif
c085e333 3389
2d0a075d
JS
3390 return maxPos;
3391 }
3392 else
3393 return 0;
2bda0e17
KB
3394}
3395
debe6624 3396int wxWindow::GetScrollThumb(int orient) const
2bda0e17 3397{
2d0a075d
JS
3398 if (orient == wxHORIZONTAL)
3399 return m_xThumbSize;
3400 else
3401 return m_yThumbSize;
2bda0e17
KB
3402}
3403
debe6624 3404void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
2bda0e17
KB
3405{
3406#if defined(__WIN95__)
2d0a075d
JS
3407 SCROLLINFO info;
3408 int dir;
2bda0e17 3409
2d0a075d
JS
3410 if (orient == wxHORIZONTAL) {
3411 dir = SB_HORZ;
3412 } else {
3413 dir = SB_VERT;
3414 }
2bda0e17 3415
2d0a075d
JS
3416 info.cbSize = sizeof(SCROLLINFO);
3417 info.nPage = 0;
3418 info.nMin = 0;
3419 info.nPos = pos;
3420 info.fMask = SIF_POS ;
2bda0e17 3421
2d0a075d
JS
3422 HWND hWnd = (HWND) GetHWND();
3423 if (hWnd)
3424 ::SetScrollInfo(hWnd, dir, &info, refresh);
2bda0e17 3425#else
2d0a075d
JS
3426 int wOrient ;
3427 if (orient == wxHORIZONTAL)
3428 wOrient = SB_HORZ;
3429 else
3430 wOrient = SB_VERT;
3431
3432 HWND hWnd = (HWND) GetHWND();
3433 if (hWnd)
3434 ::SetScrollPos(hWnd, wOrient, pos, refresh);
2bda0e17
KB
3435#endif
3436}
3437
3438// New function that will replace some of the above.
debe6624 3439void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
2d0a075d 3440 int range, bool refresh)
2bda0e17
KB
3441{
3442/*
2d0a075d 3443SetScrollPage(orient, thumbVisible, FALSE);
2bda0e17 3444
2d0a075d
JS
3445 int oldRange = range - thumbVisible ;
3446 SetScrollRange(orient, oldRange, FALSE);
c085e333 3447
2bda0e17 3448 SetScrollPos(orient, pos, refresh);
2d0a075d 3449 */
2bda0e17 3450#if defined(__WIN95__)
2d0a075d 3451 int oldRange = range - thumbVisible ;
2bda0e17 3452
2d0a075d 3453 int range1 = oldRange;
2bda0e17 3454
2d0a075d
JS
3455 // Try to adjust the range to cope with page size > 1
3456 // - a Windows API quirk
3457 int pageSize = thumbVisible;
3458 if ( pageSize > 1 && range > 0)
3459 {
3460 range1 += (pageSize - 1);
3461 }
2bda0e17 3462
2d0a075d
JS
3463 SCROLLINFO info;
3464 int dir;
2bda0e17 3465
2d0a075d
JS
3466 if (orient == wxHORIZONTAL) {
3467 dir = SB_HORZ;
3468 } else {
3469 dir = SB_VERT;
3470 }
2bda0e17 3471
2d0a075d
JS
3472 info.cbSize = sizeof(SCROLLINFO);
3473 info.nPage = pageSize; // Have to set this, or scrollbar goes awry
3474 info.nMin = 0;
3475 info.nMax = range1;
3476 info.nPos = pos;
3477 info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
2bda0e17 3478
2d0a075d
JS
3479 HWND hWnd = (HWND) GetHWND();
3480 if (hWnd)
3481 ::SetScrollInfo(hWnd, dir, &info, refresh);
2bda0e17 3482#else
2d0a075d
JS
3483 int wOrient ;
3484 if (orient == wxHORIZONTAL)
3485 wOrient = SB_HORZ;
3486 else
3487 wOrient = SB_VERT;
3488
3489 HWND hWnd = (HWND) GetHWND();
3490 if (hWnd)
3491 {
3492 ::SetScrollRange(hWnd, wOrient, 0, range, FALSE);
3493 ::SetScrollPos(hWnd, wOrient, pos, refresh);
3494 }
2bda0e17 3495#endif
2d0a075d
JS
3496 if (orient == wxHORIZONTAL) {
3497 m_xThumbSize = thumbVisible;
3498 } else {
3499 m_yThumbSize = thumbVisible;
3500 }
2bda0e17
KB
3501}
3502
16e93305 3503void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
2bda0e17 3504{
564b2609
VZ
3505 RECT rect2;
3506 if ( rect )
3507 {
3508 rect2.left = rect->x;
3509 rect2.top = rect->y;
3510 rect2.right = rect->x + rect->width;
3511 rect2.bottom = rect->y + rect->height;
3512 }
c085e333 3513
564b2609
VZ
3514 if ( rect )
3515 ::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL);
3516 else
3517 ::ScrollWindow((HWND) GetHWND(), dx, dy, NULL, NULL);
2bda0e17
KB
3518}
3519
2bda0e17
KB
3520void wxWindow::SetFont(const wxFont& font)
3521{
2d0a075d 3522 m_windowFont = font;
2bda0e17 3523
2d0a075d
JS
3524 if (!m_windowFont.Ok())
3525 return;
2bda0e17 3526
2d0a075d
JS
3527 HWND hWnd = (HWND) GetHWND();
3528 if (hWnd != 0)
3529 {
3530 if (m_windowFont.GetResourceHandle())
3531 SendMessage(hWnd, WM_SETFONT,
3532 (WPARAM)m_windowFont.GetResourceHandle(),TRUE);
3533 }
2bda0e17
KB
3534}
3535
3536void wxWindow::SubclassWin(WXHWND hWnd)
3537{
2d0a075d 3538 wxASSERT_MSG( !m_oldWndProc, "subclassing window twice?" );
a02eb1d2 3539
2d0a075d 3540 wxAssociateWinWithHandle((HWND)hWnd, this);
2bda0e17 3541
2d0a075d
JS
3542 m_oldWndProc = (WXFARPROC) GetWindowLong((HWND) hWnd, GWL_WNDPROC);
3543 SetWindowLong((HWND) hWnd, GWL_WNDPROC, (LONG) wxWndProc);
2bda0e17
KB
3544}
3545
fd3f686c 3546void wxWindow::UnsubclassWin()
2bda0e17 3547{
564b2609 3548 wxRemoveHandleAssociation(this);
c085e333 3549
2d0a075d
JS
3550 // Restore old Window proc
3551 if ((HWND) GetHWND())
564b2609 3552 {
2d0a075d
JS
3553 FARPROC farProc = (FARPROC) GetWindowLong((HWND) GetHWND(), GWL_WNDPROC);
3554 if ((m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc))
3555 {
3556 SetWindowLong((HWND) GetHWND(), GWL_WNDPROC, (LONG) m_oldWndProc);
3557 m_oldWndProc = 0;
3558 }
564b2609 3559 }
2bda0e17
KB
3560}
3561
3562// Make a Windows extended style from the given wxWindows window style
3563WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders)
3564{
564b2609
VZ
3565 WXDWORD exStyle = 0;
3566 if ( style & wxTRANSPARENT_WINDOW )
3567 exStyle |= WS_EX_TRANSPARENT ;
c085e333 3568
2d0a075d
JS
3569 if ( !eliminateBorders )
3570 {
3571 if ( style & wxSUNKEN_BORDER )
3572 exStyle |= WS_EX_CLIENTEDGE ;
3573 if ( style & wxDOUBLE_BORDER )
3574 exStyle |= WS_EX_DLGMODALFRAME ;
2bda0e17 3575#if defined(__WIN95__)
2d0a075d
JS
3576 if ( style & wxRAISED_BORDER )
3577 exStyle |= WS_EX_WINDOWEDGE ;
3578 if ( style & wxSTATIC_BORDER )
3579 exStyle |= WS_EX_STATICEDGE ;
2bda0e17 3580#endif
2d0a075d
JS
3581 }
3582 return exStyle;
2bda0e17
KB
3583}
3584
3585// Determines whether native 3D effects or CTL3D should be used,
3586// applying a default border style if required, and returning an extended
3587// style to pass to CreateWindowEx.
3588WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D)
3589{
2d0a075d
JS
3590 // If matches certain criteria, then assume no 3D effects
3591 // unless specifically requested (dealt with in MakeExtendedStyle)
3592 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) )
3593 {
3594 *want3D = FALSE;
3595 return MakeExtendedStyle(m_windowStyle, FALSE);
3596 }
2bda0e17 3597
2d0a075d
JS
3598 // Determine whether we should be using 3D effects or not.
3599 bool nativeBorder = FALSE; // by default, we don't want a Win95 effect
2bda0e17 3600
2d0a075d
JS
3601 // 1) App can specify global 3D effects
3602 *want3D = wxTheApp->GetAuto3D();
2bda0e17 3603
2d0a075d
JS
3604 // 2) If the parent is being drawn with user colours, or simple border specified,
3605 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3606 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER))
3607 *want3D = FALSE;
2bda0e17 3608
2d0a075d
JS
3609 // 3) Control can override this global setting by defining
3610 // a border style, e.g. wxSUNKEN_BORDER
3611 if (m_windowStyle & wxSUNKEN_BORDER )
3612 *want3D = TRUE;
2bda0e17 3613
2d0a075d
JS
3614 // 4) If it's a special border, CTL3D can't cope so we want a native border
3615 if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
3616 (m_windowStyle & wxSTATIC_BORDER) )
3617 {
3618 *want3D = TRUE;
3619 nativeBorder = TRUE;
3620 }
2bda0e17 3621
2d0a075d
JS
3622 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3623 // effects from extended style
1f112209 3624#if wxUSE_CTL3D
2d0a075d
JS
3625 if ( *want3D )
3626 nativeBorder = FALSE;
2bda0e17 3627#endif
c085e333 3628
2d0a075d 3629 DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder);
2bda0e17 3630
2d0a075d
JS
3631 // If we want 3D, but haven't specified a border here,
3632 // apply the default border style specified.
3633 // TODO what about non-Win95 WIN32? Does it have borders?
1f112209 3634#if defined(__WIN95__) && !wxUSE_CTL3D
2d0a075d 3635 if (defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
2bda0e17 3636 (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) ))
2d0a075d 3637 exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ;
2bda0e17 3638#endif
c085e333 3639
2d0a075d 3640 return exStyle;
2bda0e17
KB
3641}
3642
2bda0e17
KB
3643void wxWindow::OnChar(wxKeyEvent& event)
3644{
47cbd6da
VZ
3645 bool isVirtual;
3646 int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
c085e333 3647
47cbd6da
VZ
3648 if ( id == -1 )
3649 id= m_lastWParam;
c085e333 3650
2bda0e17 3651 if ( !event.ControlDown() )
47cbd6da 3652 (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
2bda0e17
KB
3653}
3654
2bda0e17
KB
3655bool wxWindow::IsEnabled(void) const
3656{
564b2609 3657 return (::IsWindowEnabled((HWND) GetHWND()) != 0);
2bda0e17
KB
3658}
3659
3660// Dialog support: override these and call
3661// base class members to add functionality
3662// that can't be done using validators.
3663// NOTE: these functions assume that controls
3664// are direct children of this window, not grandchildren
3665// or other levels of descendant.
3666
3667// Transfer values to controls. If returns FALSE,
3668// it's an application error (pops up a dialog)
fd3f686c 3669bool wxWindow::TransferDataToWindow()
2bda0e17 3670{
c0ed460c 3671 wxNode *node = GetChildren().First();
564b2609
VZ
3672 while ( node )
3673 {
3674 wxWindow *child = (wxWindow *)node->Data();
3675 if ( child->GetValidator() && /* child->GetValidator()->Ok() && */
2d0a075d 3676 !child->GetValidator()->TransferToWindow() )
564b2609 3677 {
341c92a8 3678 wxLogError(_("Could not transfer data to window"));
564b2609
VZ
3679 return FALSE;
3680 }
c085e333 3681
564b2609
VZ
3682 node = node->Next();
3683 }
3684 return TRUE;
2bda0e17
KB
3685}
3686
3687// Transfer values from controls. If returns FALSE,
3688// validation failed: don't quit
fd3f686c 3689bool wxWindow::TransferDataFromWindow()
2bda0e17 3690{
c0ed460c 3691 wxNode *node = GetChildren().First();
564b2609
VZ
3692 while ( node )
3693 {
3694 wxWindow *child = (wxWindow *)node->Data();
3695 if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() )
3696 {
3697 return FALSE;
3698 }
c085e333 3699
564b2609
VZ
3700 node = node->Next();
3701 }
3702 return TRUE;
2bda0e17
KB
3703}
3704
fd3f686c 3705bool wxWindow::Validate()
2bda0e17 3706{
c0ed460c 3707 wxNode *node = GetChildren().First();
564b2609
VZ
3708 while ( node )
3709 {
3710 wxWindow *child = (wxWindow *)node->Data();
3711 if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) )
3712 {
3713 return FALSE;
3714 }
c085e333 3715
564b2609
VZ
3716 node = node->Next();
3717 }
3718 return TRUE;
2bda0e17
KB
3719}
3720
3721// Get the window with the focus
fd3f686c 3722wxWindow *wxWindow::FindFocus()
2bda0e17
KB
3723{
3724 HWND hWnd = ::GetFocus();
3725 if ( hWnd )
3726 {
3727 return wxFindWinFromHandle((WXHWND) hWnd);
3728 }
3729 return NULL;
3730}
3731
3732void wxWindow::AddChild(wxWindow *child)
3733{
c0ed460c 3734 GetChildren().Append(child);
2d0a075d 3735 child->m_windowParent = this;
2bda0e17
KB
3736}
3737
3738void wxWindow::RemoveChild(wxWindow *child)
3739{
c0ed460c
JS
3740// if (GetChildren())
3741 GetChildren().DeleteObject(child);
2d0a075d 3742 child->m_windowParent = NULL;
2bda0e17
KB
3743}
3744
fd3f686c 3745void wxWindow::DestroyChildren()
2bda0e17 3746{
2d0a075d 3747 wxNode *node;
c0ed460c 3748 while ((node = GetChildren().First()) != (wxNode *)NULL) {
2d0a075d
JS
3749 wxWindow *child;
3750 if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
3751 delete child;
c0ed460c 3752 if ( GetChildren().Member(child) )
2d0a075d
JS
3753 delete node;
3754 }
3755 } /* while */
2bda0e17
KB
3756}
3757
debe6624 3758void wxWindow::MakeModal(bool modal)
2bda0e17 3759{
2d0a075d
JS
3760 // Disable all other windows
3761 if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
2bda0e17 3762 {
2d0a075d
JS
3763 wxNode *node = wxTopLevelWindows.First();
3764 while (node)
3765 {
3766 wxWindow *win = (wxWindow *)node->Data();
3767 if (win != this)
3768 win->Enable(!modal);
2bda0e17 3769
2d0a075d
JS
3770 node = node->Next();
3771 }
2bda0e17 3772 }
2bda0e17
KB
3773}
3774
3775// If nothing defined for this, try the parent.
3776// E.g. we may be a button loaded from a resource, with no callback function
3777// defined.
3778void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
3779{
2d0a075d
JS
3780 if (GetEventHandler()->ProcessEvent(event) )
3781 return;
3782 if (m_windowParent)
3783 m_windowParent->GetEventHandler()->OnCommand(win, event);
2bda0e17
KB
3784}
3785
3786void wxWindow::SetConstraints(wxLayoutConstraints *c)
3787{
2d0a075d
JS
3788 if (m_constraints)
3789 {
3790 UnsetConstraints(m_constraints);
3791 delete m_constraints;
3792 }
3793 m_constraints = c;
3794 if (m_constraints)
3795 {
3796 // Make sure other windows know they're part of a 'meaningful relationship'
3797 if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
3798 m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3799 if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
3800 m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3801 if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
3802 m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3803 if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
3804 m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3805 if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
3806 m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3807 if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
3808 m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3809 if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
3810 m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3811 if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
3812 m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
3813 }
2bda0e17
KB
3814}
3815
3816// This removes any dangling pointers to this window
3817// in other windows' constraintsInvolvedIn lists.
3818void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
3819{
2d0a075d
JS
3820 if (c)
3821 {
3822 if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
3823 c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3824 if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
3825 c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3826 if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
3827 c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3828 if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
3829 c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3830 if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
3831 c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3832 if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
3833 c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3834 if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
3835 c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3836 if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
3837 c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
3838 }
2bda0e17
KB
3839}
3840
3841// Back-pointer to other windows we're involved with, so if we delete
3842// this window, we must delete any constraints we're involved with.
3843void wxWindow::AddConstraintReference(wxWindow *otherWin)
3844{
2d0a075d
JS
3845 if (!m_constraintsInvolvedIn)
3846 m_constraintsInvolvedIn = new wxList;
3847 if (!m_constraintsInvolvedIn->Member(otherWin))
3848 m_constraintsInvolvedIn->Append(otherWin);
2bda0e17
KB
3849}
3850
3851// REMOVE back-pointer to other windows we're involved with.
3852void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
3853{
2d0a075d
JS
3854 if (m_constraintsInvolvedIn)
3855 m_constraintsInvolvedIn->DeleteObject(otherWin);
2bda0e17
KB
3856}
3857
3858// Reset any constraints that mention this window
fd3f686c 3859void wxWindow::DeleteRelatedConstraints()
2bda0e17 3860{
2d0a075d 3861 if (m_constraintsInvolvedIn)
2bda0e17 3862 {
2d0a075d
JS
3863 wxNode *node = m_constraintsInvolvedIn->First();
3864 while (node)
3865 {
3866 wxWindow *win = (wxWindow *)node->Data();
3867 wxNode *next = node->Next();
3868 wxLayoutConstraints *constr = win->GetConstraints();
3869
3870 // Reset any constraints involving this window
3871 if (constr)
3872 {
3873 constr->left.ResetIfWin((wxWindow *)this);
3874 constr->top.ResetIfWin((wxWindow *)this);
3875 constr->right.ResetIfWin((wxWindow *)this);
3876 constr->bottom.ResetIfWin((wxWindow *)this);
3877 constr->width.ResetIfWin((wxWindow *)this);
3878 constr->height.ResetIfWin((wxWindow *)this);
3879 constr->centreX.ResetIfWin((wxWindow *)this);
3880 constr->centreY.ResetIfWin((wxWindow *)this);
3881 }
3882 delete node;
3883 node = next;
3884 }
3885 delete m_constraintsInvolvedIn;
3886 m_constraintsInvolvedIn = NULL;
2bda0e17 3887 }
2bda0e17
KB
3888}
3889
3890void wxWindow::SetSizer(wxSizer *sizer)
3891{
2d0a075d
JS
3892 m_windowSizer = sizer;
3893 if (sizer)
3894 sizer->SetSizerParent((wxWindow *)this);
2bda0e17
KB
3895}
3896
3897/*
2d0a075d
JS
3898* New version
3899*/
2bda0e17 3900
fd3f686c 3901bool wxWindow::Layout()
2bda0e17 3902{
2d0a075d
JS
3903 if (GetConstraints())
3904 {
3905 int w, h;
3906 GetClientSize(&w, &h);
3907 GetConstraints()->width.SetValue(w);
3908 GetConstraints()->height.SetValue(h);
3909 }
3910
3911 // If top level (one sizer), evaluate the sizer's constraints.
3912 if (GetSizer())
3913 {
3914 int noChanges;
3915 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3916 GetSizer()->LayoutPhase1(&noChanges);
3917 GetSizer()->LayoutPhase2(&noChanges);
3918 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3919 return TRUE;
3920 }
3921 else
3922 {
3923 // Otherwise, evaluate child constraints
3924 ResetConstraints(); // Mark all constraints as unevaluated
3925 DoPhase(1); // Just one phase need if no sizers involved
3926 DoPhase(2);
3927 SetConstraintSizes(); // Recursively set the real window sizes
3928 }
2bda0e17 3929 return TRUE;
2bda0e17
KB
3930}
3931
3932
3933// Do a phase of evaluating constraints:
3934// the default behaviour. wxSizers may do a similar
3935// thing, but also impose their own 'constraints'
3936// and order the evaluation differently.
3937bool wxWindow::LayoutPhase1(int *noChanges)
3938{
2d0a075d
JS
3939 wxLayoutConstraints *constr = GetConstraints();
3940 if (constr)
3941 {
3942 return constr->SatisfyConstraints((wxWindow *)this, noChanges);
3943 }
3944 else
3945 return TRUE;
2bda0e17
KB
3946}
3947
3948bool wxWindow::LayoutPhase2(int *noChanges)
3949{
2d0a075d
JS
3950 *noChanges = 0;
3951
3952 // Layout children
3953 DoPhase(1);
3954 DoPhase(2);
3955 return TRUE;
2bda0e17
KB
3956}
3957
3958// Do a phase of evaluating child constraints
debe6624 3959bool wxWindow::DoPhase(int phase)
2bda0e17 3960{
2d0a075d
JS
3961 int noIterations = 0;
3962 int maxIterations = 500;
3963 int noChanges = 1;
3964 int noFailures = 0;
3965 wxList succeeded;
3966 while ((noChanges > 0) && (noIterations < maxIterations))
2bda0e17 3967 {
2d0a075d
JS
3968 noChanges = 0;
3969 noFailures = 0;
c0ed460c 3970 wxNode *node = GetChildren().First();
2d0a075d 3971 while (node)
2bda0e17 3972 {
2d0a075d
JS
3973 wxWindow *child = (wxWindow *)node->Data();
3974 if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
2bda0e17 3975 {
2d0a075d
JS
3976 wxLayoutConstraints *constr = child->GetConstraints();
3977 if (constr)
3978 {
3979 if (succeeded.Member(child))
3980 {
3981 }
3982 else
3983 {
3984 int tempNoChanges = 0;
3985 bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
3986 noChanges += tempNoChanges;
3987 if (success)
3988 {
3989 succeeded.Append(child);
3990 }
3991 }
3992 }
2bda0e17 3993 }
2d0a075d 3994 node = node->Next();
2bda0e17 3995 }
2d0a075d 3996 noIterations ++;
2bda0e17 3997 }
2d0a075d 3998 return TRUE;
2bda0e17
KB
3999}
4000
fd3f686c 4001void wxWindow::ResetConstraints()
2bda0e17 4002{
2d0a075d
JS
4003 wxLayoutConstraints *constr = GetConstraints();
4004 if (constr)
4005 {
4006 constr->left.SetDone(FALSE);
4007 constr->top.SetDone(FALSE);
4008 constr->right.SetDone(FALSE);
4009 constr->bottom.SetDone(FALSE);
4010 constr->width.SetDone(FALSE);
4011 constr->height.SetDone(FALSE);
4012 constr->centreX.SetDone(FALSE);
4013 constr->centreY.SetDone(FALSE);
4014 }
c0ed460c 4015 wxNode *node = GetChildren().First();
2d0a075d
JS
4016 while (node)
4017 {
4018 wxWindow *win = (wxWindow *)node->Data();
4019 if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
4020 win->ResetConstraints();
4021 node = node->Next();
4022 }
2bda0e17
KB
4023}
4024
4025// Need to distinguish between setting the 'fake' size for
4026// windows and sizers, and setting the real values.
debe6624 4027void wxWindow::SetConstraintSizes(bool recurse)
2bda0e17 4028{
2d0a075d
JS
4029 wxLayoutConstraints *constr = GetConstraints();
4030 if (constr && constr->left.GetDone() && constr->right.GetDone() &&
4031 constr->width.GetDone() && constr->height.GetDone())
2bda0e17 4032 {
2d0a075d
JS
4033 int x = constr->left.GetValue();
4034 int y = constr->top.GetValue();
4035 int w = constr->width.GetValue();
4036 int h = constr->height.GetValue();
4037
4038 // If we don't want to resize this window, just move it...
4039 if ((constr->width.GetRelationship() != wxAsIs) ||
4040 (constr->height.GetRelationship() != wxAsIs))
4041 {
4042 // Calls Layout() recursively. AAAGH. How can we stop that.
4043 // Simply take Layout() out of non-top level OnSizes.
4044 SizerSetSize(x, y, w, h);
4045 }
4046 else
4047 {
4048 SizerMove(x, y);
4049 }
2bda0e17 4050 }
2d0a075d 4051 else if (constr)
2bda0e17 4052 {
2d0a075d 4053 char *windowClass = this->GetClassInfo()->GetClassName();
2bda0e17 4054
2d0a075d
JS
4055 wxString winName;
4056 if (GetName() == "")
4057 winName = "unnamed";
4058 else
4059 winName = GetName();
341c92a8
VZ
4060 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4061 (const char *)windowClass, (const char *)winName);
2d0a075d 4062 if (!constr->left.GetDone())
341c92a8 4063 wxLogDebug(" unsatisfied 'left' constraint.");
2d0a075d 4064 if (!constr->right.GetDone())
341c92a8 4065 wxLogDebug(" unsatisfied 'right' constraint.");
2d0a075d 4066 if (!constr->width.GetDone())
341c92a8 4067 wxLogDebug(" unsatisfied 'width' constraint.");
2d0a075d 4068 if (!constr->height.GetDone())
341c92a8
VZ
4069 wxLogDebug(" unsatisfied 'height' constraint.");
4070 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
2d0a075d 4071 }
2bda0e17 4072
2d0a075d 4073 if (recurse)
2bda0e17 4074 {
c0ed460c 4075 wxNode *node = GetChildren().First();
2d0a075d
JS
4076 while (node)
4077 {
4078 wxWindow *win = (wxWindow *)node->Data();
4079 if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
4080 win->SetConstraintSizes();
4081 node = node->Next();
4082 }
2bda0e17 4083 }
2bda0e17
KB
4084}
4085
4086// This assumes that all sizers are 'on' the same
4087// window, i.e. the parent of this window.
4088void wxWindow::TransformSizerToActual(int *x, int *y) const
4089{
2d0a075d
JS
4090 if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
4091 m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
4092 return;
4093
4094 int xp, yp;
4095 m_sizerParent->GetPosition(&xp, &yp);
4096 m_sizerParent->TransformSizerToActual(&xp, &yp);
4097 *x += xp;
4098 *y += yp;
2bda0e17
KB
4099}
4100
debe6624 4101void wxWindow::SizerSetSize(int x, int y, int w, int h)
2bda0e17 4102{
564b2609
VZ
4103 int xx = x;
4104 int yy = y;
2d0a075d
JS
4105 TransformSizerToActual(&xx, &yy);
4106 SetSize(xx, yy, w, h);
2bda0e17
KB
4107}
4108
debe6624 4109void wxWindow::SizerMove(int x, int y)
2bda0e17 4110{
564b2609
VZ
4111 int xx = x;
4112 int yy = y;
2d0a075d
JS
4113 TransformSizerToActual(&xx, &yy);
4114 Move(xx, yy);
2bda0e17
KB
4115}
4116
4117// Only set the size/position of the constraint (if any)
debe6624 4118void wxWindow::SetSizeConstraint(int x, int y, int w, int h)
2bda0e17 4119{
2d0a075d
JS
4120 wxLayoutConstraints *constr = GetConstraints();
4121 if (constr)
2bda0e17 4122 {
2d0a075d
JS
4123 if (x != -1)
4124 {
4125 constr->left.SetValue(x);
4126 constr->left.SetDone(TRUE);
4127 }
4128 if (y != -1)
4129 {
4130 constr->top.SetValue(y);
4131 constr->top.SetDone(TRUE);
4132 }
4133 if (w != -1)
4134 {
4135 constr->width.SetValue(w);
4136 constr->width.SetDone(TRUE);
4137 }
4138 if (h != -1)
4139 {
4140 constr->height.SetValue(h);
4141 constr->height.SetDone(TRUE);
4142 }
2bda0e17 4143 }
2bda0e17
KB
4144}
4145
debe6624 4146void wxWindow::MoveConstraint(int x, int y)
2bda0e17 4147{
2d0a075d
JS
4148 wxLayoutConstraints *constr = GetConstraints();
4149 if (constr)
2bda0e17 4150 {
2d0a075d
JS
4151 if (x != -1)
4152 {
4153 constr->left.SetValue(x);
4154 constr->left.SetDone(TRUE);
4155 }
4156 if (y != -1)
4157 {
4158 constr->top.SetValue(y);
4159 constr->top.SetDone(TRUE);
4160 }
2bda0e17 4161 }
2bda0e17
KB
4162}
4163
4164void wxWindow::GetSizeConstraint(int *w, int *h) const
4165{
2d0a075d
JS
4166 wxLayoutConstraints *constr = GetConstraints();
4167 if (constr)
4168 {
4169 *w = constr->width.GetValue();
4170 *h = constr->height.GetValue();
4171 }
4172 else
4173 GetSize(w, h);
2bda0e17
KB
4174}
4175
4176void wxWindow::GetClientSizeConstraint(int *w, int *h) const
4177{
2d0a075d
JS
4178 wxLayoutConstraints *constr = GetConstraints();
4179 if (constr)
4180 {
4181 *w = constr->width.GetValue();
4182 *h = constr->height.GetValue();
4183 }
4184 else
4185 GetClientSize(w, h);
2bda0e17
KB
4186}
4187
4188void wxWindow::GetPositionConstraint(int *x, int *y) const
4189{
2d0a075d
JS
4190 wxLayoutConstraints *constr = GetConstraints();
4191 if (constr)
4192 {
4193 *x = constr->left.GetValue();
4194 *y = constr->top.GetValue();
4195 }
4196 else
4197 GetPosition(x, y);
2bda0e17
KB
4198}
4199
debe6624 4200bool wxWindow::Close(bool force)
2bda0e17 4201{
2d0a075d
JS
4202 wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
4203 event.SetEventObject(this);
e3065973 4204#if WXWIN_COMPATIBILITY
2d0a075d 4205 event.SetForce(force);
e3065973 4206#endif
2d0a075d 4207 event.SetCanVeto(!force);
2bda0e17 4208
2d0a075d 4209 return (GetEventHandler()->ProcessEvent(event) && !event.GetVeto());
2bda0e17
KB
4210}
4211
debe6624 4212wxObject* wxWindow::GetChild(int number) const
2bda0e17 4213{
2d0a075d 4214 // Return a pointer to the Nth object in the Panel
c0ed460c
JS
4215// if (!GetChildren())
4216// return(NULL) ;
4217 wxNode *node = GetChildren().First();
2d0a075d
JS
4218 int n = number;
4219 while (node && n--)
4220 node = node->Next() ;
4221 if (node)
4222 {
4223 wxObject *obj = (wxObject *)node->Data();
4224 return(obj) ;
4225 }
4226 else
4227 return NULL ;
2bda0e17
KB
4228}
4229
4230void wxWindow::OnDefaultAction(wxControl *initiatingItem)
4231{
debe6624 4232/* This is obsolete now; if we wish to intercept listbox double-clicks,
2d0a075d
JS
4233* we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4234* event.
debe6624
JS
4235
4236 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
2bda0e17 4237 {
2d0a075d
JS
4238 wxListBox *lbox = (wxListBox *)initiatingItem;
4239 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4240 event.m_commandInt = -1;
4241 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
2bda0e17 4242 {
2d0a075d
JS
4243 event.m_commandString = copystring(lbox->GetStringSelection());
4244 event.m_commandInt = lbox->GetSelection();
4245 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
2bda0e17 4246 }
2d0a075d 4247 event.m_eventObject = lbox;
c085e333 4248
2d0a075d 4249 lbox->ProcessCommand(event);
c085e333 4250
2d0a075d
JS
4251 if (event.m_commandString)
4252 delete[] event.m_commandString;
4253 return;
4254 }
4255
4256 wxButton *but = GetDefaultItem();
4257 if (but)
4258 {
4259 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4260 event.SetEventObject(but);
4261 but->Command(event);
4262 }
4263 */
2bda0e17
KB
4264}
4265
fd3f686c 4266void wxWindow::Clear()
2bda0e17 4267{
564b2609 4268 wxClientDC dc(this);
2bda0e17
KB
4269 wxBrush brush(GetBackgroundColour(), wxSOLID);
4270 dc.SetBackground(brush);
4271 dc.Clear();
4272}
4273
4274// Fits the panel around the items
fd3f686c 4275void wxWindow::Fit()
2bda0e17 4276{
564b2609
VZ
4277 int maxX = 0;
4278 int maxY = 0;
c0ed460c 4279 wxNode *node = GetChildren().First();
564b2609
VZ
4280 while ( node )
4281 {
4282 wxWindow *win = (wxWindow *)node->Data();
4283 int wx, wy, ww, wh;
4284 win->GetPosition(&wx, &wy);
4285 win->GetSize(&ww, &wh);
4286 if ( wx + ww > maxX )
4287 maxX = wx + ww;
4288 if ( wy + wh > maxY )
4289 maxY = wy + wh;
c085e333 4290
564b2609
VZ
4291 node = node->Next();
4292 }
4293 SetClientSize(maxX + 5, maxY + 5);
2bda0e17
KB
4294}
4295
4296void wxWindow::SetValidator(const wxValidator& validator)
4297{
564b2609
VZ
4298 if ( m_windowValidator )
4299 delete m_windowValidator;
4300 m_windowValidator = validator.Clone();
c085e333 4301
564b2609
VZ
4302 if ( m_windowValidator )
4303 m_windowValidator->SetWindow(this) ;
2bda0e17
KB
4304}
4305
4306// Find a window by id or name
debe6624 4307wxWindow *wxWindow::FindWindow(long id)
2bda0e17 4308{
564b2609
VZ
4309 if ( GetId() == id)
4310 return this;
c085e333 4311
c0ed460c 4312 wxNode *node = GetChildren().First();
564b2609
VZ
4313 while ( node )
4314 {
4315 wxWindow *child = (wxWindow *)node->Data();
4316 wxWindow *found = child->FindWindow(id);
4317 if ( found )
4318 return found;
4319 node = node->Next();
4320 }
4321 return NULL;
2bda0e17
KB
4322}
4323
4324wxWindow *wxWindow::FindWindow(const wxString& name)
4325{
564b2609
VZ
4326 if ( GetName() == name)
4327 return this;
c085e333 4328
c0ed460c 4329 wxNode *node = GetChildren().First();
564b2609
VZ
4330 while ( node )
4331 {
4332 wxWindow *child = (wxWindow *)node->Data();
4333 wxWindow *found = child->FindWindow(name);
4334 if ( found )
4335 return found;
4336 node = node->Next();
4337 }
4338 return NULL;
2bda0e17
KB
4339}
4340
4341/* TODO
4342// Default input behaviour for a scrolling canvas should be to scroll
4343// according to the cursor keys pressed
4344void wxWindow::OnChar(wxKeyEvent& event)
4345{
2d0a075d
JS
4346int x_page = 0;
4347int y_page = 0;
4348int start_x = 0;
4349int start_y = 0;
4350// Bugfix Begin
4351int v_width = 0;
4352int v_height = 0;
4353int y_pages = 0;
4354// Bugfix End
2bda0e17
KB
4355
4356 GetScrollUnitsPerPage(&x_page, &y_page);
4357 // Bugfix Begin
4358 GetVirtualSize(&v_width,&v_height);
4359 // Bugfix End
4360 ViewStart(&start_x, &start_y);
4361 // Bugfix begin
4362 if (vert_units)
2d0a075d 4363 y_pages = (int)(v_height/vert_units) - y_page;
c085e333 4364
2d0a075d
JS
4365 #ifdef __WXMSW__
4366 int y = 0;
4367 #else
4368 int y = y_page-1;
4369 #endif
4370 // Bugfix End
4371 switch (event.keyCode)
4372 {
4373 case WXK_PRIOR:
4374 {
4375 // BugFix Begin
4376 if (y_page > 0)
4377 {
4378 if (start_y - y_page > 0)
4379 Scroll(start_x, start_y - y_page);
4380 else
4381 Scroll(start_x, 0);
4382 }
4383 // Bugfix End
4384 break;
4385 }
4386 case WXK_NEXT:
4387 {
4388 // Bugfix Begin
4389 if ((y_page > 0) && (start_y <= y_pages-y-1))
4390 {
4391 if (y_pages + y < start_y + y_page)
4392 Scroll(start_x, y_pages + y);
4393 else
4394 Scroll(start_x, start_y + y_page);
4395 }
4396 // Bugfix End
4397 break;
4398 }
4399 case WXK_UP:
4400 {
4401 if ((y_page > 0) && (start_y >= 1))
4402 Scroll(start_x, start_y - 1);
4403 break;
4404 }
4405 case WXK_DOWN:
4406 {
4407 // Bugfix Begin
4408 if ((y_page > 0) && (start_y <= y_pages-y-1))
4409 // Bugfix End
4410 {
4411 Scroll(start_x, start_y + 1);
4412 }
4413 break;
4414 }
4415 case WXK_LEFT:
4416 {
4417 if ((x_page > 0) && (start_x >= 1))
4418 Scroll(start_x - 1, start_y);
4419 break;
4420 }
4421 case WXK_RIGHT:
4422 {
4423 if (x_page > 0)
4424 Scroll(start_x + 1, start_y);
4425 break;
4426 }
4427 case WXK_HOME:
4428 {
4429 Scroll(0, 0);
4430 break;
4431 }
4432 // This is new
4433 case WXK_END:
4434 {
4435 Scroll(start_x, y_pages+y);
4436 break;
4437 }
4438 // end
4439 }
4440 }
2bda0e17
KB
4441*/
4442
4443// Setup background and foreground colours correctly
fd3f686c 4444void wxWindow::SetupColours()
2bda0e17 4445{
564b2609
VZ
4446 if (GetParent())
4447 SetBackgroundColour(GetParent()->GetBackgroundColour());
2bda0e17
KB
4448}
4449
2bda0e17
KB
4450void wxWindow::OnIdle(wxIdleEvent& event)
4451{
43d811ea
JS
4452 // Check if we need to send a LEAVE event
4453 if (m_mouseInWindow)
4454 {
4455 POINT pt;
4456 ::GetCursorPos(&pt);
4457 if (::WindowFromPoint(pt) != (HWND) GetHWND())
4458 {
4459 // Generate a LEAVE event
4460 m_mouseInWindow = FALSE;
c085e333 4461
2d524929 4462 int state = 0;
567da5c6
JS
4463 if (::GetKeyState(VK_SHIFT) != 0)
4464 state |= MK_SHIFT;
4465 if (::GetKeyState(VK_CONTROL) != 0)
4466 state |= MK_CONTROL;
c085e333 4467
567da5c6
JS
4468 // Unfortunately the mouse button and keyboard state may have changed
4469 // by the time the OnIdle function is called, so 'state' may be
4470 // meaningless.
c085e333 4471
567da5c6 4472 MSWOnMouseLeave(pt.x, pt.y, state);
43d811ea
JS
4473 }
4474 }
564b2609 4475 UpdateWindowUI();
2bda0e17
KB
4476}
4477
4478// Raise the window to the top of the Z order
fd3f686c 4479void wxWindow::Raise()
2bda0e17
KB
4480{
4481 ::BringWindowToTop((HWND) GetHWND());
4482}
4483
4484// Lower the window to the bottom of the Z order
fd3f686c 4485void wxWindow::Lower()
2bda0e17
KB
4486{
4487 ::SetWindowPos((HWND) GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
4488}
4489
47cbd6da
VZ
4490long wxWindow::MSWGetDlgCode()
4491{
2d0a075d
JS
4492 // default: just forward to def window proc (the msg has no parameters)
4493 return MSWDefWindowProc(WM_GETDLGCODE, 0, 0);
47cbd6da
VZ
4494}
4495
4496bool wxWindow::AcceptsFocus() const
4497{
3a19e16d 4498 // invisible and disabled controls don't need focus
2d0a075d 4499 return IsShown() && IsEnabled();
47cbd6da
VZ
4500}
4501
81d66cf3
JS
4502// Update region access
4503wxRegion wxWindow::GetUpdateRegion() const
4504{
4505 return m_updateRegion;
4506}
4507
4508bool wxWindow::IsExposed(int x, int y, int w, int h) const
4509{
4510 return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion);
4511}
4512
4513bool wxWindow::IsExposed(const wxPoint& pt) const
4514{
4515 return (m_updateRegion.Contains(pt) != wxOutRegion);
4516}
4517
4518bool wxWindow::IsExposed(const wxRect& rect) const
4519{
4520 return (m_updateRegion.Contains(rect) != wxOutRegion);
4521}
4522
4fabb575
JS
4523// Set this window to be the child of 'parent'.
4524bool wxWindow::Reparent(wxWindow *parent)
4525{
4526 if (parent == GetParent())
4527 return TRUE;
4528
4529 // Unlink this window from the existing parent.
4530 if (GetParent())
4531 {
4532 GetParent()->RemoveChild(this);
4533 }
4534 else
4535 wxTopLevelWindows.DeleteObject(this);
4536
4537 HWND hWndParent = 0;
4538 HWND hWndChild = (HWND) GetHWND();
4539 if (parent != (wxWindow*) NULL)
4540 {
4541 parent->AddChild(this);
4542 hWndParent = (HWND) parent->GetHWND();
4543 }
4544 else
4545 wxTopLevelWindows.Append(this);
4546
4547 ::SetParent(hWndChild, hWndParent);
4548
4549 return TRUE;
4550}
4551
b2aef89b 4552#ifdef __WXDEBUG__
f449ef69 4553const char *wxGetMessageName(int message)
47cbd6da 4554{
2d0a075d 4555 switch ( message ) {
47cbd6da
VZ
4556 case 0x0000: return "WM_NULL";
4557 case 0x0001: return "WM_CREATE";
4558 case 0x0002: return "WM_DESTROY";
4559 case 0x0003: return "WM_MOVE";
4560 case 0x0005: return "WM_SIZE";
4561 case 0x0006: return "WM_ACTIVATE";
4562 case 0x0007: return "WM_SETFOCUS";
4563 case 0x0008: return "WM_KILLFOCUS";
4564 case 0x000A: return "WM_ENABLE";
4565 case 0x000B: return "WM_SETREDRAW";
4566 case 0x000C: return "WM_SETTEXT";
4567 case 0x000D: return "WM_GETTEXT";
4568 case 0x000E: return "WM_GETTEXTLENGTH";
4569 case 0x000F: return "WM_PAINT";
4570 case 0x0010: return "WM_CLOSE";
4571 case 0x0011: return "WM_QUERYENDSESSION";
4572 case 0x0012: return "WM_QUIT";
4573 case 0x0013: return "WM_QUERYOPEN";
4574 case 0x0014: return "WM_ERASEBKGND";
4575 case 0x0015: return "WM_SYSCOLORCHANGE";
4576 case 0x0016: return "WM_ENDSESSION";
4577 case 0x0017: return "WM_SYSTEMERROR";
4578 case 0x0018: return "WM_SHOWWINDOW";
4579 case 0x0019: return "WM_CTLCOLOR";
4580 case 0x001A: return "WM_WININICHANGE";
4581 case 0x001B: return "WM_DEVMODECHANGE";
4582 case 0x001C: return "WM_ACTIVATEAPP";
4583 case 0x001D: return "WM_FONTCHANGE";
4584 case 0x001E: return "WM_TIMECHANGE";
4585 case 0x001F: return "WM_CANCELMODE";
4586 case 0x0020: return "WM_SETCURSOR";
4587 case 0x0021: return "WM_MOUSEACTIVATE";
4588 case 0x0022: return "WM_CHILDACTIVATE";
4589 case 0x0023: return "WM_QUEUESYNC";
4590 case 0x0024: return "WM_GETMINMAXINFO";
4591 case 0x0026: return "WM_PAINTICON";
4592 case 0x0027: return "WM_ICONERASEBKGND";
4593 case 0x0028: return "WM_NEXTDLGCTL";
4594 case 0x002A: return "WM_SPOOLERSTATUS";
4595 case 0x002B: return "WM_DRAWITEM";
4596 case 0x002C: return "WM_MEASUREITEM";
4597 case 0x002D: return "WM_DELETEITEM";
4598 case 0x002E: return "WM_VKEYTOITEM";
4599 case 0x002F: return "WM_CHARTOITEM";
4600 case 0x0030: return "WM_SETFONT";
4601 case 0x0031: return "WM_GETFONT";
4602 case 0x0037: return "WM_QUERYDRAGICON";
4603 case 0x0039: return "WM_COMPAREITEM";
4604 case 0x0041: return "WM_COMPACTING";
4605 case 0x0044: return "WM_COMMNOTIFY";
4606 case 0x0046: return "WM_WINDOWPOSCHANGING";
4607 case 0x0047: return "WM_WINDOWPOSCHANGED";
4608 case 0x0048: return "WM_POWER";
c085e333 4609
a02eb1d2
VZ
4610#ifdef __WIN32__
4611 case 0x004A: return "WM_COPYDATA";
4612 case 0x004B: return "WM_CANCELJOURNAL";
4613 case 0x004E: return "WM_NOTIFY";
4614 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4615 case 0x0051: return "WM_INPUTLANGCHANGE";
4616 case 0x0052: return "WM_TCARD";
4617 case 0x0053: return "WM_HELP";
4618 case 0x0054: return "WM_USERCHANGED";
4619 case 0x0055: return "WM_NOTIFYFORMAT";
4620 case 0x007B: return "WM_CONTEXTMENU";
4621 case 0x007C: return "WM_STYLECHANGING";
4622 case 0x007D: return "WM_STYLECHANGED";
4623 case 0x007E: return "WM_DISPLAYCHANGE";
4624 case 0x007F: return "WM_GETICON";
4625 case 0x0080: return "WM_SETICON";
4626#endif //WIN32
c085e333 4627
47cbd6da
VZ
4628 case 0x0081: return "WM_NCCREATE";
4629 case 0x0082: return "WM_NCDESTROY";
4630 case 0x0083: return "WM_NCCALCSIZE";
4631 case 0x0084: return "WM_NCHITTEST";
4632 case 0x0085: return "WM_NCPAINT";
4633 case 0x0086: return "WM_NCACTIVATE";
4634 case 0x0087: return "WM_GETDLGCODE";
4635 case 0x00A0: return "WM_NCMOUSEMOVE";
4636 case 0x00A1: return "WM_NCLBUTTONDOWN";
4637 case 0x00A2: return "WM_NCLBUTTONUP";
4638 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4639 case 0x00A4: return "WM_NCRBUTTONDOWN";
4640 case 0x00A5: return "WM_NCRBUTTONUP";
4641 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4642 case 0x00A7: return "WM_NCMBUTTONDOWN";
4643 case 0x00A8: return "WM_NCMBUTTONUP";
4644 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4645 case 0x0100: return "WM_KEYDOWN";
4646 case 0x0101: return "WM_KEYUP";
4647 case 0x0102: return "WM_CHAR";
4648 case 0x0103: return "WM_DEADCHAR";
4649 case 0x0104: return "WM_SYSKEYDOWN";
4650 case 0x0105: return "WM_SYSKEYUP";
4651 case 0x0106: return "WM_SYSCHAR";
4652 case 0x0107: return "WM_SYSDEADCHAR";
4653 case 0x0108: return "WM_KEYLAST";
c085e333 4654
a02eb1d2
VZ
4655#ifdef __WIN32__
4656 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4657 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4658 case 0x010F: return "WM_IME_COMPOSITION";
4659#endif //WIN32
c085e333 4660
47cbd6da
VZ
4661 case 0x0110: return "WM_INITDIALOG";
4662 case 0x0111: return "WM_COMMAND";
4663 case 0x0112: return "WM_SYSCOMMAND";
4664 case 0x0113: return "WM_TIMER";
4665 case 0x0114: return "WM_HSCROLL";
4666 case 0x0115: return "WM_VSCROLL";
4667 case 0x0116: return "WM_INITMENU";
4668 case 0x0117: return "WM_INITMENUPOPUP";
4669 case 0x011F: return "WM_MENUSELECT";
4670 case 0x0120: return "WM_MENUCHAR";
4671 case 0x0121: return "WM_ENTERIDLE";
4672 case 0x0200: return "WM_MOUSEMOVE";
4673 case 0x0201: return "WM_LBUTTONDOWN";
4674 case 0x0202: return "WM_LBUTTONUP";
4675 case 0x0203: return "WM_LBUTTONDBLCLK";
4676 case 0x0204: return "WM_RBUTTONDOWN";
4677 case 0x0205: return "WM_RBUTTONUP";
4678 case 0x0206: return "WM_RBUTTONDBLCLK";
4679 case 0x0207: return "WM_MBUTTONDOWN";
4680 case 0x0208: return "WM_MBUTTONUP";
4681 case 0x0209: return "WM_MBUTTONDBLCLK";
4682 case 0x0210: return "WM_PARENTNOTIFY";
a02eb1d2
VZ
4683 case 0x0211: return "WM_ENTERMENULOOP";
4684 case 0x0212: return "WM_EXITMENULOOP";
c085e333 4685
a02eb1d2
VZ
4686#ifdef __WIN32__
4687 case 0x0213: return "WM_NEXTMENU";
4688 case 0x0214: return "WM_SIZING";
4689 case 0x0215: return "WM_CAPTURECHANGED";
4690 case 0x0216: return "WM_MOVING";
4691 case 0x0218: return "WM_POWERBROADCAST";
4692 case 0x0219: return "WM_DEVICECHANGE";
4693#endif //WIN32
c085e333 4694
47cbd6da
VZ
4695 case 0x0220: return "WM_MDICREATE";
4696 case 0x0221: return "WM_MDIDESTROY";
4697 case 0x0222: return "WM_MDIACTIVATE";
4698 case 0x0223: return "WM_MDIRESTORE";
4699 case 0x0224: return "WM_MDINEXT";
4700 case 0x0225: return "WM_MDIMAXIMIZE";
4701 case 0x0226: return "WM_MDITILE";
4702 case 0x0227: return "WM_MDICASCADE";
4703 case 0x0228: return "WM_MDIICONARRANGE";
4704 case 0x0229: return "WM_MDIGETACTIVE";
4705 case 0x0230: return "WM_MDISETMENU";
4706 case 0x0233: return "WM_DROPFILES";
c085e333 4707
a02eb1d2
VZ
4708#ifdef __WIN32__
4709 case 0x0281: return "WM_IME_SETCONTEXT";
4710 case 0x0282: return "WM_IME_NOTIFY";
4711 case 0x0283: return "WM_IME_CONTROL";
4712 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4713 case 0x0285: return "WM_IME_SELECT";
4714 case 0x0286: return "WM_IME_CHAR";
4715 case 0x0290: return "WM_IME_KEYDOWN";
4716 case 0x0291: return "WM_IME_KEYUP";
4717#endif //WIN32
c085e333 4718
47cbd6da
VZ
4719 case 0x0300: return "WM_CUT";
4720 case 0x0301: return "WM_COPY";
4721 case 0x0302: return "WM_PASTE";
4722 case 0x0303: return "WM_CLEAR";
4723 case 0x0304: return "WM_UNDO";
4724 case 0x0305: return "WM_RENDERFORMAT";
4725 case 0x0306: return "WM_RENDERALLFORMATS";
4726 case 0x0307: return "WM_DESTROYCLIPBOARD";
4727 case 0x0308: return "WM_DRAWCLIPBOARD";
4728 case 0x0309: return "WM_PAINTCLIPBOARD";
4729 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4730 case 0x030B: return "WM_SIZECLIPBOARD";
4731 case 0x030C: return "WM_ASKCBFORMATNAME";
4732 case 0x030D: return "WM_CHANGECBCHAIN";
4733 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4734 case 0x030F: return "WM_QUERYNEWPALETTE";
4735 case 0x0310: return "WM_PALETTEISCHANGING";
4736 case 0x0311: return "WM_PALETTECHANGED";
c085e333 4737
a02eb1d2 4738#ifdef __WIN32__
2d0a075d
JS
4739 // common controls messages - although they're not strictly speaking
4740 // standard, it's nice to decode them nevertheless
a02eb1d2 4741
2d0a075d 4742 // listview
a02eb1d2
VZ
4743 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4744 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4745 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4746 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4747 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4748 case 0x1000 + 5: return "LVM_GETITEMA";
4749 case 0x1000 + 75: return "LVM_GETITEMW";
4750 case 0x1000 + 6: return "LVM_SETITEMA";
4751 case 0x1000 + 76: return "LVM_SETITEMW";
4752 case 0x1000 + 7: return "LVM_INSERTITEMA";
4753 case 0x1000 + 77: return "LVM_INSERTITEMW";
4754 case 0x1000 + 8: return "LVM_DELETEITEM";
4755 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4756 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4757 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4758 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4759 case 0x1000 + 13: return "LVM_FINDITEMA";
4760 case 0x1000 + 83: return "LVM_FINDITEMW";
4761 case 0x1000 + 14: return "LVM_GETITEMRECT";
4762 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4763 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4764 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4765 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4766 case 0x1000 + 18: return "LVM_HITTEST";
4767 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4768 case 0x1000 + 20: return "LVM_SCROLL";
4769 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4770 case 0x1000 + 22: return "LVM_ARRANGE";
4771 case 0x1000 + 23: return "LVM_EDITLABELA";
4772 case 0x1000 + 118: return "LVM_EDITLABELW";
4773 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4774 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4775 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4776 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4777 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4778 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4779 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4780 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4781 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4782 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4783 case 0x1000 + 31: return "LVM_GETHEADER";
4784 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4785 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4786 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4787 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4788 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4789 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4790 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4791 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4792 case 0x1000 + 41: return "LVM_GETORIGIN";
4793 case 0x1000 + 42: return "LVM_UPDATE";
4794 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4795 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4796 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4797 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4798 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4799 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4800 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4801 case 0x1000 + 48: return "LVM_SORTITEMS";
4802 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4803 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4804 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4805 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4806 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4807 case 0x1000 + 53: return "LVM_SETICONSPACING";
4808 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4809 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4810 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4811 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4812 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4813 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4814 case 0x1000 + 60: return "LVM_SETHOTITEM";
4815 case 0x1000 + 61: return "LVM_GETHOTITEM";
4816 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4817 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4818 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4819 case 0x1000 + 65: return "LVM_SETWORKAREA";
c085e333 4820
2d0a075d 4821 // tree view
a02eb1d2
VZ
4822 case 0x1100 + 0: return "TVM_INSERTITEMA";
4823 case 0x1100 + 50: return "TVM_INSERTITEMW";
4824 case 0x1100 + 1: return "TVM_DELETEITEM";
4825 case 0x1100 + 2: return "TVM_EXPAND";
4826 case 0x1100 + 4: return "TVM_GETITEMRECT";
4827 case 0x1100 + 5: return "TVM_GETCOUNT";
4828 case 0x1100 + 6: return "TVM_GETINDENT";
4829 case 0x1100 + 7: return "TVM_SETINDENT";
4830 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4831 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4832 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4833 case 0x1100 + 11: return "TVM_SELECTITEM";
4834 case 0x1100 + 12: return "TVM_GETITEMA";
4835 case 0x1100 + 62: return "TVM_GETITEMW";
4836 case 0x1100 + 13: return "TVM_SETITEMA";
4837 case 0x1100 + 63: return "TVM_SETITEMW";
4838 case 0x1100 + 14: return "TVM_EDITLABELA";
4839 case 0x1100 + 65: return "TVM_EDITLABELW";
4840 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4841 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4842 case 0x1100 + 17: return "TVM_HITTEST";
4843 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4844 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4845 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4846 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4847 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4848 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4849 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4850 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4851 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
c085e333 4852
2d0a075d 4853 // header
a02eb1d2
VZ
4854 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4855 case 0x1200 + 1: return "HDM_INSERTITEMA";
4856 case 0x1200 + 10: return "HDM_INSERTITEMW";
4857 case 0x1200 + 2: return "HDM_DELETEITEM";
4858 case 0x1200 + 3: return "HDM_GETITEMA";
4859 case 0x1200 + 11: return "HDM_GETITEMW";
4860 case 0x1200 + 4: return "HDM_SETITEMA";
4861 case 0x1200 + 12: return "HDM_SETITEMW";
4862 case 0x1200 + 5: return "HDM_LAYOUT";
4863 case 0x1200 + 6: return "HDM_HITTEST";
4864 case 0x1200 + 7: return "HDM_GETITEMRECT";
4865 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4866 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4867 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4868 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4869 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4870 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4871 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
c085e333 4872
2d0a075d 4873 // tab control
a02eb1d2
VZ
4874 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4875 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4876 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4877 case 0x1300 + 5: return "TCM_GETITEMA";
4878 case 0x1300 + 60: return "TCM_GETITEMW";
4879 case 0x1300 + 6: return "TCM_SETITEMA";
4880 case 0x1300 + 61: return "TCM_SETITEMW";
4881 case 0x1300 + 7: return "TCM_INSERTITEMA";
4882 case 0x1300 + 62: return "TCM_INSERTITEMW";
4883 case 0x1300 + 8: return "TCM_DELETEITEM";
4884 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4885 case 0x1300 + 10: return "TCM_GETITEMRECT";
4886 case 0x1300 + 11: return "TCM_GETCURSEL";
4887 case 0x1300 + 12: return "TCM_SETCURSEL";
4888 case 0x1300 + 13: return "TCM_HITTEST";
4889 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4890 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4891 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4892 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4893 case 0x1300 + 43: return "TCM_SETPADDING";
4894 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4895 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4896 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4897 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4898 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4899 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4900 case 0x1300 + 50: return "TCM_DESELECTALL";
c085e333 4901
2d0a075d 4902 // toolbar
a02eb1d2
VZ
4903 case WM_USER+1: return "TB_ENABLEBUTTON";
4904 case WM_USER+2: return "TB_CHECKBUTTON";
4905 case WM_USER+3: return "TB_PRESSBUTTON";
4906 case WM_USER+4: return "TB_HIDEBUTTON";
4907 case WM_USER+5: return "TB_INDETERMINATE";
4908 case WM_USER+9: return "TB_ISBUTTONENABLED";
4909 case WM_USER+10: return "TB_ISBUTTONCHECKED";
4910 case WM_USER+11: return "TB_ISBUTTONPRESSED";
4911 case WM_USER+12: return "TB_ISBUTTONHIDDEN";
4912 case WM_USER+13: return "TB_ISBUTTONINDETERMINATE";
4913 case WM_USER+17: return "TB_SETSTATE";
4914 case WM_USER+18: return "TB_GETSTATE";
4915 case WM_USER+19: return "TB_ADDBITMAP";
4916 case WM_USER+20: return "TB_ADDBUTTONS";
4917 case WM_USER+21: return "TB_INSERTBUTTON";
4918 case WM_USER+22: return "TB_DELETEBUTTON";
4919 case WM_USER+23: return "TB_GETBUTTON";
4920 case WM_USER+24: return "TB_BUTTONCOUNT";
4921 case WM_USER+25: return "TB_COMMANDTOINDEX";
4922 case WM_USER+26: return "TB_SAVERESTOREA";
4923 case WM_USER+76: return "TB_SAVERESTOREW";
4924 case WM_USER+27: return "TB_CUSTOMIZE";
4925 case WM_USER+28: return "TB_ADDSTRINGA";
4926 case WM_USER+77: return "TB_ADDSTRINGW";
4927 case WM_USER+29: return "TB_GETITEMRECT";
4928 case WM_USER+30: return "TB_BUTTONSTRUCTSIZE";
4929 case WM_USER+31: return "TB_SETBUTTONSIZE";
4930 case WM_USER+32: return "TB_SETBITMAPSIZE";
4931 case WM_USER+33: return "TB_AUTOSIZE";
4932 case WM_USER+35: return "TB_GETTOOLTIPS";
4933 case WM_USER+36: return "TB_SETTOOLTIPS";
4934 case WM_USER+37: return "TB_SETPARENT";
4935 case WM_USER+39: return "TB_SETROWS";
4936 case WM_USER+40: return "TB_GETROWS";
4937 case WM_USER+42: return "TB_SETCMDID";
4938 case WM_USER+43: return "TB_CHANGEBITMAP";
4939 case WM_USER+44: return "TB_GETBITMAP";
4940 case WM_USER+45: return "TB_GETBUTTONTEXTA";
4941 case WM_USER+75: return "TB_GETBUTTONTEXTW";
4942 case WM_USER+46: return "TB_REPLACEBITMAP";
4943 case WM_USER+47: return "TB_SETINDENT";
4944 case WM_USER+48: return "TB_SETIMAGELIST";
4945 case WM_USER+49: return "TB_GETIMAGELIST";
4946 case WM_USER+50: return "TB_LOADIMAGES";
4947 case WM_USER+51: return "TB_GETRECT";
4948 case WM_USER+52: return "TB_SETHOTIMAGELIST";
4949 case WM_USER+53: return "TB_GETHOTIMAGELIST";
4950 case WM_USER+54: return "TB_SETDISABLEDIMAGELIST";
4951 case WM_USER+55: return "TB_GETDISABLEDIMAGELIST";
4952 case WM_USER+56: return "TB_SETSTYLE";
4953 case WM_USER+57: return "TB_GETSTYLE";
4954 case WM_USER+58: return "TB_GETBUTTONSIZE";
4955 case WM_USER+59: return "TB_SETBUTTONWIDTH";
4956 case WM_USER+60: return "TB_SETMAXTEXTROWS";
4957 case WM_USER+61: return "TB_GETTEXTROWS";
4958 case WM_USER+41: return "TB_GETBITMAPFLAGS";
c085e333 4959
a02eb1d2 4960#endif //WIN32
c085e333 4961
47cbd6da 4962 default:
2d0a075d
JS
4963 static char s_szBuf[128];
4964 sprintf(s_szBuf, "<unknown message = %d>", message);
4965 return s_szBuf;
47cbd6da
VZ
4966 }
4967}
ea57084d 4968#endif //__WXDEBUG__