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