]> git.saurik.com Git - wxWidgets.git/blob - src/os2/window.cpp
fb4a8cb4b76170b4d97b9d86cbac11ab51021379
[wxWidgets.git] / src / os2 / window.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windows.cpp
3 // Purpose: wxWindow
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/12/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 //
13 // For compilers that support precompilation, includes "wx.h".
14 //
15 #include "wx/wxprec.h"
16
17 #ifndef WX_PRECOMP
18 #define INCL_DOS
19 #define INCL_PM
20 #include <os2.h>
21 #include "wx/window.h"
22 #include "wx/accel.h"
23 #include "wx/setup.h"
24 #include "wx/menu.h"
25 #include "wx/dc.h"
26 #include "wx/dcclient.h"
27 #include "wx/utils.h"
28 #include "wx/app.h"
29 #include "wx/panel.h"
30 #include "wx/layout.h"
31 #include "wx/dialog.h"
32 #include "wx/frame.h"
33 #include "wx/listbox.h"
34 #include "wx/button.h"
35 #include "wx/msgdlg.h"
36
37 #include <stdio.h>
38 #endif
39
40 #if wxUSE_OWNER_DRAWN
41 #include "wx/ownerdrw.h"
42 #endif
43
44 #if wxUSE_DRAG_AND_DROP
45 #include "wx/dnd.h"
46 #endif
47
48 #include "wx/menuitem.h"
49 #include "wx/log.h"
50
51 #include "wx/os2/private.h"
52
53 #if wxUSE_TOOLTIPS
54 #include "wx/tooltip.h"
55 #endif
56
57 #if wxUSE_CARET
58 #include "wx/caret.h"
59 #endif // wxUSE_CARET
60
61 #include "wx/intl.h"
62 #include "wx/log.h"
63
64
65 #include "wx/textctrl.h"
66
67 #include <string.h>
68
69 //
70 // Place compiler, OS specific includes here
71 //
72
73 //
74 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
75 //
76 #ifndef GET_X_LPARAM
77 //
78 // SHORT1FROMMP -- LOWORD
79 //
80 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
81 //
82 // SHORT2FROMMP -- HIWORD
83 //
84 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
85 #endif // GET_X_LPARAM
86
87 #ifndef CW_USEDEFAULT
88 # define CW_USEDEFAULT ((int)0x80000000)
89 #endif
90
91 // ---------------------------------------------------------------------------
92 // global variables
93 // ---------------------------------------------------------------------------
94
95 //
96 // The last Windows message we got (MT-UNSAFE)
97 //
98 QMSG s_currentMsg;
99
100 wxMenu* wxCurrentPopupMenu = NULL;
101 extern wxList WXDLLEXPORT wxPendingDelete;
102 #if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
103 extern wxChar wxCanvasClassName[];
104 #endif
105 wxList* wxWinHandleList = NULL;
106
107 // ---------------------------------------------------------------------------
108 // private functions
109 // ---------------------------------------------------------------------------
110
111 //
112 // the window proc for all our windows; most gui's have something similar
113 //
114 MRESULT EXPENTRY wxWndProc( HWND hWnd
115 ,ULONG message
116 ,MPARAM mp1
117 ,MPARAM mp2
118 );
119
120 #ifdef __WXDEBUG__
121 const char *wxGetMessageName(int message);
122 #endif //__WXDEBUG__
123
124 void wxRemoveHandleAssociation(wxWindow* pWin);
125 void wxAssociateWinWithHandle( HWND hWnd
126 ,wxWindow* pWin
127 );
128 wxWindow* wxFindWinFromHandle(WXHWND hWnd);
129
130 //
131 // This magical function is used to translate VK_APPS key presses to right
132 // mouse clicks
133 //
134 static void TranslateKbdEventToMouse( wxWindow* pWin
135 ,int* pX
136 ,int* pY
137 ,MPARAM* pFlags
138 );
139
140 //
141 // get the current state of SHIFT/CTRL keys
142 //
143 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
144 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
145 // ---------------------------------------------------------------------------
146 // event tables
147 // ---------------------------------------------------------------------------
148
149 IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
150
151 BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
152 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
153 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
154 EVT_INIT_DIALOG(wxWindow::OnInitDialog)
155 EVT_IDLE(wxWindow::OnIdle)
156 EVT_SET_FOCUS(wxWindow::OnSetFocus)
157 END_EVENT_TABLE()
158
159 // ===========================================================================
160 // implementation
161 // ===========================================================================
162
163 //
164 // Find an item given the PM Window id
165 //
166 wxWindow* wxWindow::FindItem(
167 long lId
168 ) const
169 {
170 wxControl* pItem = wxDynamicCast( this
171 ,wxControl
172 );
173
174 if (pItem)
175 {
176 //
177 // I it we or one of our "internal" children?
178 //
179 if (pItem->GetId() == lId ||
180 (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND))
181 {
182 return pItem;
183 }
184 }
185
186 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
187
188 while (pCurrent)
189 {
190 wxWindow* pChildWin = pCurrent->GetData();
191 wxWindow* pWnd = pChildWin->FindItem(lId);
192
193 if (pWnd)
194 return pWnd;
195
196 pCurrent = pCurrent->GetNext();
197 }
198 return(NULL);
199 } // end of wxWindow::FindItem
200
201 //
202 // Find an item given the PM Window handle
203 //
204 wxWindow* wxWindow::FindItemByHWND(
205 WXHWND hWnd
206 , bool bControlOnly
207 ) const
208 {
209 wxWindowList::Node* pCurrent = GetChildren().GetFirst();
210
211 while (pCurrent)
212 {
213 wxWindow* pParent = pCurrent->GetData();
214
215 //
216 // Do a recursive search.
217 //
218 wxWindow* pWnd = pParent->FindItemByHWND(hWnd);
219
220 if (pWnd)
221 return(pWnd);
222
223 if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
224 {
225 wxWindow* pItem = pCurrent->GetData();
226
227 if (pItem->GetHWND() == hWnd)
228 return(pItem);
229 else
230 {
231 if (pItem->ContainsHWND(hWnd))
232 return(pItem);
233 }
234 }
235 pCurrent = pCurrent->GetNext();
236 }
237 return(NULL);
238 } // end of wxWindow::FindItemByHWND
239
240 //
241 // Default command handler
242 //
243 bool wxWindow::OS2Command(
244 WXUINT WXUNUSED(uParam)
245 , WXWORD WXUNUSED(uId)
246 )
247 {
248 return(FALSE);
249 }
250
251 // ----------------------------------------------------------------------------
252 // constructors and such
253 // ----------------------------------------------------------------------------
254
255 void wxWindow::Init()
256 {
257 //
258 // Generic
259 //
260 InitBase();
261
262 //
263 // PM specific
264 //
265 m_bDoubleClickAllowed = 0;
266 m_bWinCaptured = FALSE;
267
268 m_isBeingDeleted = FALSE;
269 m_fnOldWndProc = 0;
270 m_bUseCtl3D = FALSE;
271 m_bMouseInWindow = FALSE;
272
273 //
274 // wxWnd
275 //
276 m_hMenu = 0L;
277 m_hWnd = 0L;
278 m_hWndScrollBar = 0L;
279
280 //
281 // Pass WM_GETDLGCODE to DefWindowProc()
282 m_lDlgCode = 0;
283
284 m_nXThumbSize = 0;
285 m_nYThumbSize = 0;
286 m_bBackgroundTransparent = FALSE;
287
288 //
289 // As all windows are created with WS_VISIBLE style...
290 //
291 m_isShown = TRUE;
292
293 #if wxUSE_MOUSEEVENT_HACK
294 m_lLastMouseX =
295 m_lLastMouseY = -1;
296 m_nLastMouseEvent = -1;
297 #endif // wxUSE_MOUSEEVENT_HACK
298 } // wxWindow::Init
299
300 //
301 // Destructor
302 //
303 wxWindow::~wxWindow()
304 {
305 m_isBeingDeleted = TRUE;
306
307 OS2DetachWindowMenu();
308 if (m_parent)
309 m_parent->RemoveChild(this);
310 DestroyChildren();
311
312 if (m_hWnd)
313 {
314 if(!::WinDestroyWindow(GetHWND()))
315 wxLogLastError(wxT("DestroyWindow"));
316 //
317 // remove hWnd <-> wxWindow association
318 //
319 wxRemoveHandleAssociation(this);
320 }
321 } // end of wxWindow::~wxWindow
322
323 bool wxWindow::Create(
324 wxWindow* pParent
325 , wxWindowID vId
326 , const wxPoint& rPos
327 , const wxSize& rSize
328 , long lStyle
329 , const wxString& rName
330 )
331 {
332 HWND hParent = NULLHANDLE;
333 wxPoint vPos = rPos; // The OS/2 position
334
335 wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
336
337 if ( !CreateBase( pParent
338 ,vId
339 ,rPos
340 ,rSize
341 ,lStyle
342 ,wxDefaultValidator
343 ,rName
344 ))
345 return(FALSE);
346
347 if (pParent)
348 {
349 pParent->AddChild(this);
350 hParent = GetWinHwnd(pParent);
351 //
352 // OS2 uses normal coordinates, no bassackwards Windows ones
353 //
354 vPos.y = pParent->GetSize().y - (vPos.y + rSize.y);
355 }
356 else
357 {
358 RECTL vRect;
359
360 ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
361 hParent = HWND_DESKTOP;
362 vPos.y = vRect.yTop - (vPos.y + rSize.y);
363 }
364
365 ULONG ulCreateFlags = 0L;
366
367
368 //
369 // Most wxSTYLES are really PM Class specific styles and will be
370 // set in those class create procs. PM's basic windows styles are
371 // very limited.
372 //
373 ulCreateFlags |= WS_VISIBLE;
374
375
376 if ( lStyle & wxCLIP_SIBLINGS )
377 ulCreateFlags |= WS_CLIPSIBLINGS;
378
379 if (lStyle & wxCLIP_CHILDREN )
380 ulCreateFlags |= WS_CLIPCHILDREN;
381
382 //
383 // Empty stuff for now since PM has no custome 3D effects
384 // Doesn't mean someone cannot make some up though
385 //
386 bool bWant3D;
387 WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
388
389 //
390 // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
391 // and no presentation parameters
392 //
393 OS2Create( hParent
394 ,(PSZ)wxCanvasClassName
395 ,rName.c_str()
396 ,ulCreateFlags
397 ,vPos.x
398 ,vPos.y
399 ,WidthDefault(rSize.x)
400 ,HeightDefault(rSize.y)
401 ,NULLHANDLE
402 ,NULLHANDLE
403 ,m_windowId
404 );
405
406 return(TRUE);
407 } // end of wxWindow::Create
408
409 // ---------------------------------------------------------------------------
410 // basic operations
411 // ---------------------------------------------------------------------------
412
413 void wxWindow::SetFocus()
414 {
415 HWND hWnd = GetHwnd();
416
417 if (hWnd)
418 ::WinSetFocus(HWND_DESKTOP, hWnd);
419 } // end of wxWindow::SetFocus
420
421 wxWindow* wxWindowBase::FindFocus()
422 {
423 HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
424
425 if (hWnd)
426 {
427 return wxFindWinFromHandle((WXHWND)hWnd);
428 }
429 return NULL;
430 } // wxWindowBase::FindFocus
431
432 bool wxWindow::Enable(
433 bool bEnable
434 )
435 {
436 if (!wxWindowBase::Enable(bEnable))
437 return(FALSE);
438
439 HWND hWnd = GetHwnd();
440
441 if ( hWnd )
442 ::WinEnableWindow(hWnd, (BOOL)bEnable);
443
444 wxWindowList::Node* pNode = GetChildren().GetFirst();
445
446 while (pNode)
447 {
448 wxWindow* pChild = pNode->GetData();
449
450 pChild->Enable(bEnable);
451 pNode = pNode->GetNext();
452 }
453 return(TRUE);
454 } // end of wxWindow::Enable
455
456 bool wxWindow::Show(
457 bool bShow
458 )
459 {
460 if (!wxWindowBase::Show(bShow))
461 return(FALSE);
462
463 HWND hWnd = GetHwnd();
464
465 ::WinShowWindow(hWnd, bShow);
466
467 if (bShow)
468 {
469 ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
470 }
471 return(TRUE);
472 } // end of wxWindow::Show
473
474 void wxWindow::Raise()
475 {
476 ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
477 } // end of wxWindow::Raise
478
479 void wxWindow::Lower()
480 {
481 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
482 } // end of wxWindow::Lower
483
484 void wxWindow::SetTitle(
485 const wxString& rTitle
486 )
487 {
488 ::WinSetWindowText(GetHwnd(), rTitle.c_str());
489 } // end of wxWindow::SetTitle
490
491 wxString wxWindow::GetTitle() const
492 {
493 return wxGetWindowText(GetHWND());
494 } // end of wxWindow::GetTitle
495
496 void wxWindow::CaptureMouse()
497 {
498 HWND hWnd = GetHwnd();
499
500 if (hWnd && !m_bWinCaptured)
501 {
502 ::WinSetCapture(HWND_DESKTOP, hWnd);
503 m_bWinCaptured = TRUE;
504 }
505 } // end of wxWindow::GetTitle
506
507 void wxWindow::ReleaseMouse()
508 {
509 if (m_bWinCaptured)
510 {
511 ::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
512 m_bWinCaptured = FALSE;
513 }
514 } // end of wxWindow::ReleaseMouse
515
516 bool wxWindow::SetFont(
517 const wxFont& rFont
518 )
519 {
520 if (!wxWindowBase::SetFont(rFont))
521 {
522 // nothing to do
523 return(FALSE);
524 }
525
526 HWND hWnd = GetHwnd();
527
528 if (hWnd != 0)
529 {
530 wxChar zFont[128];
531
532 sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
533 return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont));
534 }
535 return(TRUE);
536 }
537
538 bool wxWindow::SetCursor(
539 const wxCursor& rCursor
540 ) // check if base implementation is OK
541 {
542 if ( !wxWindowBase::SetCursor(rCursor))
543 {
544 // no change
545 return FALSE;
546 }
547
548 wxASSERT_MSG( m_cursor.Ok(),
549 wxT("cursor must be valid after call to the base version"));
550
551 HWND hWnd = GetHwnd();
552 POINTL vPoint;
553 RECTL vRect;
554 HPS hPS;
555 HRGN hRGN;
556
557 hPS = ::WinGetPS(hWnd);
558
559 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
560 ::WinQueryWindowRect(hWnd, &vRect);
561
562 hRGN = ::GpiCreateRegion(hPS, 1L, &vRect);
563
564 if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy())
565 {
566 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
567 }
568 return TRUE;
569 } // end of wxWindow::SetCursor
570
571 void wxWindow::WarpPointer(
572 int nXPos
573 , int nYPos
574 )
575 {
576 int nX = nXPos;
577 int nY = nYPos;
578 RECTL vRect;
579
580 ::WinQueryWindowRect(GetHwnd(), &vRect);
581 nX += vRect.xLeft;
582 nY += vRect.yBottom;
583
584 ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY));
585 } // end of wxWindow::WarpPointer
586
587 #if WXWIN_COMPATIBILITY
588 void wxWindow::OS2DeviceToLogical (float *x, float *y) const
589 {
590 }
591 #endif // WXWIN_COMPATIBILITY
592
593 // ---------------------------------------------------------------------------
594 // scrolling stuff
595 // ---------------------------------------------------------------------------
596
597 #if WXWIN_COMPATIBILITY
598 void wxWindow::SetScrollRange(
599 int nOrient
600 , int nRange
601 , bool bRefresh
602 )
603 {
604 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange));
605 } // end of wxWindow::SetScrollRange
606
607 void wxWindow::SetScrollPage(
608 int nOrient
609 , int nPage
610 , bool bRefresh
611 )
612 {
613 if ( orient == wxHORIZONTAL )
614 m_xThumbSize = page;
615 else
616 m_yThumbSize = page;
617 }
618
619 int wxWindow::OldGetScrollRange(
620 int nOrient
621 ) const
622 {
623 MRESULT mRc;
624 HWND hWnd = GetHwnd();
625
626 if (hWnd)
627 {
628 mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L);
629 return(SHORT2FROMMR(mRc));
630 }
631 return 0;
632 } // end of wxWindow::OldGetScrollRange
633
634 int wxWindow::GetScrollPage(
635 int nOrient
636 ) const
637 {
638 if (nOrient == wxHORIZONTAL)
639 return m_nXThumbSize;
640 else
641 return m_nYThumbSize;
642 } // end of wxWindow::GetScrollPage
643 #endif // WXWIN_COMPATIBILITY
644
645 int wxWindow::GetScrollPos(
646 int nOrient
647 ) const
648 {
649 return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
650 } // end of wxWindow::GetScrollPos
651
652 int wxWindow::GetScrollRange(
653 int nOrient
654 ) const
655 {
656 MRESULT mr;
657
658 mr = ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE, (MPARAM)NULL, (MPARAM)NULL);
659 return((int)SHORT2FROMMR(mr));
660 } // end of wxWindow::GetScrollRange
661
662 int wxWindow::GetScrollThumb(
663 int nOrient
664 ) const
665 {
666 WNDPARAMS vWndParams;
667 PSBCDATA pSbcd;
668
669 ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS, (MPARAM)&vWndParams, (MPARAM)NULL);
670 pSbcd = (PSBCDATA)vWndParams.pCtlData;
671 return((int)pSbcd->posThumb);
672 } // end of wxWindow::GetScrollThumb
673
674 void wxWindow::SetScrollPos(
675 int nOrient
676 , int nPos
677 , bool bRefresh
678 )
679 {
680 ::WinSendMsg(GetHwnd(), SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
681 } // end of wxWindow::SetScrollPos(
682
683 void wxWindow::SetScrollbar(
684 int nOrient
685 , int nPos
686 , int nThumbVisible
687 , int nRange
688 , bool bRefresh
689 )
690 {
691 int nOldRange = nRange - nThumbVisible;
692 int nRange1 = nOldRange;
693 int nPageSize = nThumbVisible;
694 SBCDATA vInfo;
695 HWND hWnd = GetHwnd();
696 ULONG ulStyle = WS_VISIBLE;
697 RECTL vRect;
698
699 ::WinQueryWindowRect(hWnd, &vRect);
700 if (nPageSize > 1 && nRange > 0)
701 {
702 nRange1 += (nPageSize - 1);
703 }
704
705 vInfo.cb = sizeof(SBCDATA);
706 vInfo.posFirst = 0;
707 vInfo.posLast = (SHORT)nRange1;
708 vInfo.posThumb = nPos;
709
710 if (nOrient == wxHORIZONTAL )
711 {
712 ulStyle |= SBS_HORZ;
713 if (m_hWndScrollBar == 0L)
714 {
715 m_hWndScrollBar = ::WinCreateWindow( hWnd
716 ,WC_SCROLLBAR
717 ,(PSZ)NULL
718 ,ulStyle
719 ,vRect.xLeft
720 ,vRect.yBottom
721 ,vRect.xRight - vRect.xLeft
722 ,20
723 ,hWnd
724 ,HWND_TOP
725 ,-1
726 ,&vInfo
727 ,NULL
728 );
729 }
730 else
731 {
732 ::WinSendMsg(m_hWndScrollBar, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1));
733 }
734 }
735 else
736 {
737 ulStyle |= SBS_VERT;
738 if (m_hWndScrollBar == 0L)
739 {
740 m_hWndScrollBar = ::WinCreateWindow( hWnd
741 ,WC_SCROLLBAR
742 ,(PSZ)NULL
743 ,ulStyle
744 ,vRect.xRight - 20
745 ,vRect.yBottom
746 ,20
747 ,vRect.yTop - vRect.yBottom
748 ,hWnd
749 ,HWND_TOP
750 ,-1
751 ,&vInfo
752 ,NULL
753 );
754 }
755 else
756 {
757 ::WinSendMsg(m_hWndScrollBar, SBM_SETSCROLLBAR, (MPARAM)nPos, MPFROM2SHORT(0, (SHORT)nRange1));
758 }
759 m_nYThumbSize = nThumbVisible;
760 }
761 } // end of wxWindow::SetScrollbar
762
763 void wxWindow::ScrollWindow(
764 int nDx
765 , int nDy
766 , const wxRect* pRect
767 )
768 {
769 RECTL vRect2;
770
771 if (pRect)
772 {
773 vRect2.xLeft = pRect->x;
774 vRect2.yTop = pRect->y;
775 vRect2.xRight = pRect->x + pRect->width;
776 vRect2.yBottom = pRect->y + pRect->height;
777 }
778
779 if (pRect)
780 ::WinScrollWindow(GetHwnd(), (LONG)nDx, (LONG)nDy, &vRect2, NULL, NULLHANDLE, NULL, 0L);
781 else
782 ::WinScrollWindow(GetHwnd(), nDx, nDy, NULL, NULL, NULLHANDLE, NULL, 0L);
783 } // end of wxWindow::ScrollWindow
784
785 // ---------------------------------------------------------------------------
786 // subclassing
787 // ---------------------------------------------------------------------------
788
789 void wxWindow::SubclassWin(
790 WXHWND hWnd
791 )
792 {
793 HWND hwnd = (HWND)hWnd;
794
795 wxASSERT_MSG( !m_fnOldWndProc, wxT("subclassing window twice?") );
796 wxCHECK_RET(::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in SubclassWin") );
797 m_fnOldWndProc = (WXFARPROC) ::WinSubclassWindow(hwnd, (PFNWP)wxWndProc);
798 } // end of wxWindow::SubclassWin
799
800 void wxWindow::UnsubclassWin()
801 {
802 //
803 // Restore old Window proc
804 //
805 HWND hwnd = GetHWND();
806
807 if (m_hWnd)
808 {
809 wxCHECK_RET( ::WinIsWindow(vHabmain, hwnd), wxT("invalid HWND in UnsubclassWin") );
810
811 PFNWP fnProc = (PFNWP)::WinQueryWindowPtr(hwnd, QWP_PFNWP);
812
813 if ( (m_fnOldWndProc != 0) && (fnProc != (PFNWP) m_fnOldWndProc))
814 {
815 WinSubclassWindow(hwnd, (PFNWP)m_fnOldWndProc);
816 m_fnOldWndProc = 0;
817 }
818 }
819 } // end of wxWindow::UnsubclassWin
820
821 //
822 // Make a Windows extended style from the given wxWindows window style
823 //
824 WXDWORD wxWindow::MakeExtendedStyle(
825 long lStyle
826 , bool bEliminateBorders
827 )
828 {
829 //
830 // PM does not support extended style
831 //
832 WXDWORD exStyle = 0;
833 return exStyle;
834 } // end of wxWindow::MakeExtendedStyle
835
836 //
837 // Determines whether native 3D effects or CTL3D should be used,
838 // applying a default border style if required, and returning an extended
839 // style to pass to CreateWindowEx.
840 //
841 WXDWORD wxWindow::Determine3DEffects(
842 WXDWORD dwDefaultBorderStyle
843 , bool* pbWant3D
844 ) const
845 {
846 WXDWORD dwStyle = 0L;
847
848 //
849 // Native PM does not have any specialize 3D effects like WIN32 does
850 //
851 *pbWant3D = FALSE;
852 return dwStyle;
853 } // end of wxWindow::Determine3DEffects
854
855 #if WXWIN_COMPATIBILITY
856 void wxWindow::OnCommand(
857 wxWindow& rWin
858 , wxCommandEvent& rEvent
859 )
860 {
861 if (GetEventHandler()->ProcessEvent(rEvent))
862 return;
863 if (m_parent)
864 m_parent->GetEventHandler()->OnCommand( rWin
865 ,rEvent
866 );
867 } // end of wxWindow::OnCommand
868
869 wxObject* wxWindow::GetChild(
870 int nNumber
871 ) const
872 {
873 //
874 // Return a pointer to the Nth object in the Panel
875 //
876 wxNode* pNode = GetChildren().First();
877 int n = nNumber;
878
879 while (pNode && n--)
880 pNode = pNode->Next();
881 if (pNode)
882 {
883 wxObject* pObj = (wxObject*)pNode->Data();
884 return(pObj);
885 }
886 else
887 return NULL;
888 } // end of wxWindow::GetChild
889
890 #endif // WXWIN_COMPATIBILITY
891
892 //
893 // Setup background and foreground colours correctly
894 //
895 void wxWindow::SetupColours()
896 {
897 if ( GetParent() )
898 SetBackgroundColour(GetParent()->GetBackgroundColour());
899 } // end of wxWindow::SetupColours
900
901 void wxWindow::OnIdle(
902 wxIdleEvent& rEvent
903 )
904 {
905 //
906 // Check if we need to send a LEAVE event
907 //
908 if (m_bMouseInWindow)
909 {
910 POINTL vPoint;
911
912 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
913 if (::WinWindowFromPoint(HWND_DESKTOP, &vPoint, FALSE) != (HWND)GetHwnd())
914 {
915 //
916 // Generate a LEAVE event
917 //
918 m_bMouseInWindow = FALSE;
919
920 //
921 // Unfortunately the mouse button and keyboard state may have changed
922 // by the time the OnIdle function is called, so 'state' may be
923 // meaningless.
924 //
925 int nState = 0;
926
927 if (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) != 0)
928 nState |= VK_SHIFT;
929 if (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) != 0);
930 nState |= VK_CTRL;
931
932 wxMouseEvent rEvent(wxEVT_LEAVE_WINDOW);
933
934 InitMouseEvent( rEvent
935 ,vPoint.x
936 ,vPoint.y
937 ,nState
938 );
939 (void)GetEventHandler()->ProcessEvent(rEvent);
940 }
941 }
942 UpdateWindowUI();
943 } // end of wxWindow::OnIdle
944
945 //
946 // Set this window to be the child of 'parent'.
947 //
948 bool wxWindow::Reparent(
949 wxWindow* pParent
950 )
951 {
952 if (!wxWindowBase::Reparent(pParent))
953 return FALSE;
954
955 HWND hWndChild = GetHwnd();
956 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
957
958 ::WinSetParent(hWndChild, hWndParent, TRUE);
959 return TRUE;
960 } // end of wxWindow::Reparent
961
962 void wxWindow::Clear()
963 {
964 wxClientDC vDc(this);
965 wxBrush vBrush( GetBackgroundColour()
966 ,wxSOLID
967 );
968
969 vDc.SetBackground(vBrush);
970 vDc.Clear();
971 } // end of wxWindow::Clear
972
973 void wxWindow::Refresh(
974 bool bEraseBack
975 , const wxRect* pRect
976 )
977 {
978 HWND hWnd = GetHwnd();
979
980 if (hWnd)
981 {
982 if (pRect)
983 {
984 RECTL vOs2Rect;
985
986 vOs2Rect.xLeft = pRect->x;
987 vOs2Rect.yTop = pRect->y;
988 vOs2Rect.xRight = pRect->x + pRect->width;
989 vOs2Rect.yBottom = pRect->y + pRect->height;
990
991 ::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
992 }
993 else
994 ::WinInvalidateRect(hWnd, NULL, bEraseBack);
995 }
996 } // end of wxWindow::Refresh
997
998 // ---------------------------------------------------------------------------
999 // drag and drop
1000 // ---------------------------------------------------------------------------
1001
1002 #if wxUSE_DRAG_AND_DROP
1003 void wxWindow::SetDropTarget(
1004 wxDropTarget* pDropTarget
1005 )
1006 {
1007 if (m_dropTarget != 0)
1008 {
1009 m_dropTarget->Revoke(m_hWnd);
1010 delete m_dropTarget;
1011 }
1012 m_dropTarget = pDropTarget;
1013 if (m_dropTarget != 0)
1014 m_dropTarget->Register(m_hWnd);
1015 } // end of wxWindow::SetDropTarget
1016 #endif
1017
1018 //
1019 // old style file-manager drag&drop support: we retain the old-style
1020 // DragAcceptFiles in parallel with SetDropTarget.
1021 //
1022 void wxWindow::DragAcceptFiles(
1023 bool bAccept
1024 )
1025 {
1026 HWND hWnd = GetHwnd();
1027
1028 if (hWnd && bAccept)
1029 ::DrgAcceptDroppedFiles(hWnd, NULL, NULL, DO_COPY, 0L);
1030 } // end of wxWindow::DragAcceptFiles
1031
1032 // ----------------------------------------------------------------------------
1033 // tooltips
1034 // ----------------------------------------------------------------------------
1035
1036 #if wxUSE_TOOLTIPS
1037
1038 void wxWindow::DoSetToolTip(
1039 wxToolTip* pTooltip
1040 )
1041 {
1042 wxWindowBase::DoSetToolTip(pTooltip);
1043
1044 if (m_tooltip)
1045 m_tooltip->SetWindow(this);
1046 } // end of wxWindow::DoSetToolTip
1047
1048 #endif // wxUSE_TOOLTIPS
1049
1050 // ---------------------------------------------------------------------------
1051 // moving and resizing
1052 // ---------------------------------------------------------------------------
1053
1054 // Get total size
1055 void wxWindow::DoGetSize(
1056 int* pWidth
1057 , int* pHeight
1058 ) const
1059 {
1060 HWND hWnd = GetHwnd();
1061 RECTL vRect;
1062
1063 ::WinQueryWindowRect(hWnd, &vRect);
1064
1065 if (pWidth)
1066 *pWidth = vRect.xRight - vRect.xLeft;
1067 if (pHeight )
1068 // OS/2 PM is backwards from windows
1069 *pHeight = vRect.yTop - vRect.yBottom;
1070 } // end of wxWindow::DoGetSize
1071
1072 void wxWindow::DoGetPosition(
1073 int* pX
1074 , int* pY
1075 ) const
1076 {
1077 HWND hWnd = GetHwnd();
1078 RECT vRect;
1079 POINTL vPoint;
1080
1081 ::WinQueryWindowRect(hWnd, &vRect);
1082
1083 vPoint.x = vRect.xLeft;
1084 vPoint.y = vRect.yBottom;
1085
1086 //
1087 // We do the adjustments with respect to the parent only for the "real"
1088 // children, not for the dialogs/frames
1089 //
1090 if (!IsTopLevel())
1091 {
1092 HWND hParentWnd = 0;
1093 wxWindow* pParent = GetParent();
1094
1095 if (pParent)
1096 hParentWnd = GetWinHwnd(pParent);
1097
1098 //
1099 // Since we now have the absolute screen coords, if there's a parent we
1100 // must subtract its bottom left corner
1101 //
1102 if (hParentWnd)
1103 {
1104 RECTL vRect2;
1105
1106 ::WinQueryWindowRect(hParentWnd, &vRect2);
1107 vPoint.x -= vRect.xLeft;
1108 vPoint.y -= vRect.yBottom;
1109 }
1110
1111 //
1112 // We may be faking the client origin. So a window that's really at (0,
1113 // 30) may appear (to wxWin apps) to be at (0, 0).
1114 //
1115 wxPoint vPt(pParent->GetClientAreaOrigin());
1116
1117 vPoint.x -= vPt.x;
1118 vPoint.y -= vPt.y;
1119 }
1120
1121 if (pX)
1122 *pX = vPoint.x;
1123 if (pY)
1124 *pY = vPoint.y;
1125 } // end of wxWindow::DoGetPosition
1126
1127 void wxWindow::DoScreenToClient(
1128 int* pX
1129 , int* pY
1130 ) const
1131 {
1132 HWND hWnd = GetHwnd();
1133 SWP vSwp;
1134
1135 ::WinQueryWindowPos(hWnd, &vSwp);
1136
1137 if (pX)
1138 *pX -= vSwp.x;
1139 if (pY)
1140 *pY -= vSwp.y;
1141 } // end of wxWindow::DoScreenToClient
1142
1143 void wxWindow::DoClientToScreen(
1144 int* pX
1145 , int* pY
1146 ) const
1147 {
1148 HWND hWnd = GetHwnd();
1149 SWP vSwp;
1150
1151 ::WinQueryWindowPos(hWnd, &vSwp);
1152
1153 if (pX)
1154 *pX += vSwp.x;
1155 if (pY)
1156 *pY += vSwp.y;
1157 } // end of wxWindow::DoClientToScreen
1158
1159 //
1160 // Get size *available for subwindows* i.e. excluding menu bar etc.
1161 // Must be a frame type window
1162 //
1163 void wxWindow::DoGetClientSize(
1164 int* pWidth
1165 , int* pHeight
1166 ) const
1167 {
1168 HWND hWnd = GetHwnd();
1169 HWND hWndClient;
1170 RECTL vRect;
1171
1172 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1173 if( hWndClient == NULLHANDLE)
1174 ::WinQueryWindowRect(GetHwnd(), &vRect);
1175 else
1176 ::WinQueryWindowRect(hWndClient, &vRect);
1177
1178 if (pWidth)
1179 *pWidth = vRect.xRight;
1180 if (pHeight)
1181 *pHeight = vRect.yTop;
1182 } // end of wxWindow::DoGetClientSize
1183
1184 void wxWindow::DoMoveWindow(
1185 int nX
1186 , int nY
1187 , int nWidth
1188 , int nHeight
1189 )
1190 {
1191 if ( !::WinSetWindowPos( GetHwnd()
1192 ,HWND_TOP
1193 ,(LONG)nX
1194 ,(LONG)nY
1195 ,(LONG)nWidth
1196 ,(LONG)nHeight
1197 ,SWP_SIZE | SWP_MOVE
1198 ))
1199 {
1200 wxLogLastError("MoveWindow");
1201 }
1202 } // end of wxWindow::DoMoveWindow
1203
1204 //
1205 // Set the size of the window: if the dimensions are positive, just use them,
1206 // but if any of them is equal to -1, it means that we must find the value for
1207 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1208 // which case -1 is a valid value for x and y)
1209 //
1210 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1211 // the width/height to best suit our contents, otherwise we reuse the current
1212 // width/height
1213 //
1214 void wxWindow::DoSetSize(
1215 int nX
1216 , int nY
1217 , int nWidth
1218 , int nHeight
1219 , int nSizeFlags
1220 )
1221 {
1222 //
1223 // Get the current size and position...
1224 //
1225 int nCurrentX;
1226 int nCurrentY;
1227 int nCurrentWidth;
1228 int nCurrentHeight;
1229 wxSize vSize(-1, -1);
1230
1231 GetPosition( &nCurrentX
1232 ,&nCurrentY
1233 );
1234 GetSize( &nCurrentWidth
1235 ,&nCurrentHeight
1236 );
1237
1238 //
1239 // ... and don't do anything (avoiding flicker) if it's already ok
1240 //
1241 if ( nX == nCurrentX &&
1242 nY == nCurrentY &&
1243 nWidth == nCurrentWidth &&
1244 nHeight == nCurrentHeight
1245 )
1246 {
1247 return;
1248 }
1249
1250 if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1251 nX = nCurrentX;
1252 if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
1253 nY = nCurrentY;
1254
1255 AdjustForParentClientOrigin( nX
1256 ,nY
1257 ,nSizeFlags
1258 );
1259
1260 if (nWidth == -1)
1261 {
1262 if (nSizeFlags & wxSIZE_AUTO_WIDTH)
1263 {
1264 vSize = DoGetBestSize();
1265 nWidth = vSize.x;
1266 }
1267 else
1268 {
1269 //
1270 // Just take the current one
1271 //
1272 nWidth = nCurrentWidth;
1273 }
1274 }
1275
1276 if (nHeight == -1)
1277 {
1278 if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
1279 {
1280 if (vSize.x == -1)
1281 {
1282 vSize = DoGetBestSize();
1283 }
1284 nHeight = vSize.y;
1285 }
1286 else
1287 {
1288 // just take the current one
1289 nHeight = nCurrentHeight;
1290 }
1291 }
1292
1293 DoMoveWindow( nX
1294 ,nY
1295 ,nWidth
1296 ,nHeight
1297 );
1298 } // end of wxWindow::DoSetSize
1299
1300 void wxWindow::DoSetClientSize(
1301 int nWidth
1302 , int nHeight
1303 )
1304 {
1305 wxWindow* pParent = GetParent();
1306 HWND hWnd = GetHwnd();
1307 HWND hParentWnd = (HWND)0;
1308 HWND hClientWnd = (HWND)0;
1309 RECTL vRect;
1310 RECT vRect2;
1311 RECT vRect3;
1312
1313 hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1314 ::WinQueryWindowRect(hClientWnd, &vRect2);
1315
1316 if (pParent)
1317 hParentWnd = (HWND) pParent->GetHWND();
1318
1319 ::WinQueryWindowRect(hWnd, &vRect);
1320 ::WinQueryWindowRect(hParentWnd, &vRect3);
1321 //
1322 // Find the difference between the entire window (title bar and all)
1323 // and the client area; add this to the new client size to move the
1324 // window. OS/2 is backward from windows on height
1325 //
1326 int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
1327 int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
1328
1329 //
1330 // If there's a parent, must subtract the parent's bottom left corner
1331 // since MoveWindow moves relative to the parent
1332 //
1333 POINTL vPoint;
1334
1335 vPoint.x = vRect2.xLeft;
1336 vPoint.y = vRect2.yBottom;
1337 if (pParent)
1338 {
1339 vPoint.x -= vRect3.xLeft;
1340 vPoint.y -= vRect3.yBottom;
1341 }
1342
1343 DoMoveWindow( vPoint.x
1344 ,vPoint.y
1345 ,nActualWidth
1346 ,nActualHeight
1347 );
1348
1349 wxSizeEvent vEvent( wxSize( nWidth
1350 ,nHeight
1351 )
1352 ,m_windowId
1353 );
1354
1355 vEvent.SetEventObject(this);
1356 GetEventHandler()->ProcessEvent(vEvent);
1357 } // end of wxWindow::DoSetClientSize
1358
1359 wxPoint wxWindow::GetClientAreaOrigin() const
1360 {
1361 return wxPoint(0, 0);
1362 } // end of wxWindow::GetClientAreaOrigin
1363
1364 void wxWindow::AdjustForParentClientOrigin(
1365 int& rX
1366 , int& rY
1367 , int nSizeFlags
1368 )
1369 {
1370 //
1371 // Don't do it for the dialogs/frames - they float independently of their
1372 // parent
1373 //
1374 if (!IsTopLevel())
1375 {
1376 wxWindow* pParent = GetParent();
1377
1378 if (!(nSizeFlags & wxSIZE_NO_ADJUSTMENTS) && pParent)
1379 {
1380 wxPoint vPoint(pParent->GetClientAreaOrigin());
1381 rX += vPoint.x;
1382 rY += vPoint.y;
1383 }
1384 }
1385 } // end of wxWindow::AdjustForParentClientOrigin
1386
1387 // ---------------------------------------------------------------------------
1388 // text metrics
1389 // ---------------------------------------------------------------------------
1390
1391 int wxWindow::GetCharHeight() const
1392 {
1393 HPS hPs;
1394 FONTMETRICS vFontMetrics;
1395 BOOL bRc;
1396
1397 hPs = ::WinGetPS(GetHwnd());
1398
1399 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1400 {
1401 ::WinReleasePS(hPs);
1402 return (0);
1403 }
1404 ::WinReleasePS(hPs);
1405 return(vFontMetrics.lMaxAscender + vFontMetrics.lMaxDescender);
1406 } // end of wxWindow::GetCharHeight
1407
1408 int wxWindow::GetCharWidth() const
1409 {
1410 HPS hPs;
1411 FONTMETRICS vFontMetrics;
1412
1413 hPs = ::WinGetPS(GetHwnd());
1414
1415 if(!GpiQueryFontMetrics(hPs, sizeof(FONTMETRICS), &vFontMetrics))
1416 {
1417 ::WinReleasePS(hPs);
1418 return (0);
1419 }
1420 ::WinReleasePS(hPs);
1421 return(vFontMetrics.lAveCharWidth);
1422 } // end of wxWindow::GetCharWidth
1423
1424 void wxWindow::GetTextExtent(
1425 const wxString& rString
1426 , int* pX
1427 , int* pY
1428 , int* pDescent
1429 , int* pExternalLeading
1430 , const wxFont* pTheFont
1431 ) const
1432 {
1433 const wxFont* pFontToUse = pTheFont;
1434 HPS hPs;
1435
1436 hPs = ::WinGetPS(GetHwnd());
1437 /*
1438 // TODO: Will have to play with fonts later
1439
1440 if (!pFontToUse)
1441 pFontToUse = &m_font;
1442
1443 HFONT hFnt = 0;
1444 HFONT hFfontOld = 0;
1445
1446 if (pFontToUse && pFontToUse->Ok())
1447 {
1448 ::GpiCreateLog
1449 hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
1450 if (hFnt)
1451 hFontOld = (HFONT)SelectObject(dc,fnt);
1452 }
1453
1454 SIZE sizeRect;
1455 TEXTMETRIC tm;
1456 GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
1457 GetTextMetrics(dc, &tm);
1458
1459 if ( fontToUse && fnt && hfontOld )
1460 SelectObject(dc, hfontOld);
1461
1462 ReleaseDC(hWnd, dc);
1463
1464 if ( x )
1465 *x = sizeRect.cx;
1466 if ( y )
1467 *y = sizeRect.cy;
1468 if ( descent )
1469 *descent = tm.tmDescent;
1470 if ( externalLeading )
1471 *externalLeading = tm.tmExternalLeading;
1472 */
1473 ::WinReleasePS(hPs);
1474 }
1475
1476 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1477 // ---------------------------------------------------------------------------
1478 // Caret manipulation
1479 // ---------------------------------------------------------------------------
1480
1481 void wxWindow::CreateCaret(
1482 int nWidth
1483 , int nHeight
1484 )
1485 {
1486 SetCaret(new wxCaret( this
1487 ,nWidth
1488 ,nHeight
1489 ));
1490 } // end of wxWindow::CreateCaret
1491
1492 void wxWindow::CreateCaret(
1493 const wxBitmap* pBitmap
1494 )
1495 {
1496 wxFAIL_MSG("not implemented");
1497 } // end of wxWindow::CreateCaret
1498
1499 void wxWindow::ShowCaret(
1500 bool bShow
1501 )
1502 {
1503 wxCHECK_RET( m_caret, "no caret to show" );
1504
1505 m_caret->Show(bShow);
1506 } // end of wxWindow::ShowCaret
1507
1508 void wxWindow::DestroyCaret()
1509 {
1510 SetCaret(NULL);
1511 } // end of wxWindow::DestroyCaret
1512
1513 void wxWindow::SetCaretPos(
1514 int nX
1515 , int nY)
1516 {
1517 wxCHECK_RET( m_caret, "no caret to move" );
1518
1519 m_caret->Move( nX
1520 ,nY
1521 );
1522 } // end of wxWindow::SetCaretPos
1523
1524 void wxWindow::GetCaretPos(
1525 int* pX
1526 , int* pY
1527 ) const
1528 {
1529 wxCHECK_RET( m_caret, "no caret to get position of" );
1530
1531 m_caret->GetPosition( pX
1532 ,pY
1533 );
1534 } // end of wxWindow::GetCaretPos
1535
1536 #endif //wxUSE_CARET
1537
1538 // ---------------------------------------------------------------------------
1539 // popup menu
1540 // ---------------------------------------------------------------------------
1541
1542 bool wxWindow::DoPopupMenu(
1543 wxMenu* pMenu
1544 , int nX
1545 , int nY
1546 )
1547 {
1548 HWND hWnd = GetHwnd();
1549 HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
1550 HWND hMenu = GetHmenuOf(pMenu);
1551
1552 pMenu->SetInvokingWindow(this);
1553 pMenu->UpdateUI();
1554
1555 DoClientToScreen( &nX
1556 ,&nY
1557 );
1558 wxCurrentPopupMenu = pMenu;
1559
1560 ::WinPopupMenu( hWndParent
1561 ,hWnd
1562 ,hMenu
1563 ,nX
1564 ,nY
1565 ,0L
1566 ,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
1567 );
1568 wxYield();
1569 wxCurrentPopupMenu = NULL;
1570
1571 pMenu->SetInvokingWindow(NULL);
1572 return TRUE;
1573 } // end of wxWindow::DoPopupMenu
1574
1575 // ===========================================================================
1576 // pre/post message processing
1577 // ===========================================================================
1578
1579 MRESULT wxWindow::OS2DefWindowProc(
1580 WXUINT uMsg
1581 , WXWPARAM wParam
1582 , WXLPARAM lParam
1583 )
1584 {
1585 if (m_fnOldWndProc)
1586 return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
1587 else
1588 return ::WinDefWindowProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
1589 } // end of wxWindow::OS2DefWindowProc
1590
1591 bool wxWindow::OS2ProcessMessage(
1592 WXMSG* pMsg
1593 )
1594 {
1595 QMSG* pQMsg = (QMSG*)pMsg;
1596
1597 if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL))
1598 {
1599 //
1600 // Intercept dialog navigation keys
1601 //
1602 bool bProcess = TRUE;
1603 USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
1604
1605 if (uKeyFlags & KC_KEYUP)
1606 bProcess = FALSE;
1607
1608 if (uKeyFlags & KC_ALT)
1609 bProcess = FALSE;
1610
1611 if (!(uKeyFlags & KC_VIRTUALKEY))
1612 bProcess = FALSE;
1613
1614 if (bProcess)
1615 {
1616 bool bCtrlDown = IsCtrlDown();
1617 bool bShiftDown = IsShiftDown();
1618
1619 //
1620 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1621 // don't process it if it's the case (except for Ctrl-Tab/Enter
1622 // combinations which are always processed)
1623 //
1624 ULONG ulDlgCode = 0;
1625
1626 if (!bCtrlDown)
1627 {
1628 ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0);
1629 }
1630
1631 bool bForward = TRUE;
1632 bool bWindowChange = FALSE;
1633
1634 switch (SHORT2FROMMP(pQMsg->mp2))
1635 {
1636 //
1637 // Going to make certain assumptions about specific types of controls
1638 // here, so we may have to alter some things later if they prove invalid
1639 //
1640 case VK_TAB:
1641 //
1642 // Shift tabl will always be a nav-key but tabs may be wanted
1643 //
1644 if (!bShiftDown)
1645 {
1646 bProcess = FALSE;
1647 }
1648 else
1649 {
1650 //
1651 // Entry Fields want tabs for themselve usually
1652 //
1653 switch (ulDlgCode)
1654 {
1655 case DLGC_ENTRYFIELD:
1656 case DLGC_MLE:
1657 bProcess = TRUE;
1658 break;
1659
1660 default:
1661 bProcess = FALSE;
1662 }
1663
1664 //
1665 // Ctrl-Tab cycles thru notebook pages
1666 //
1667 bWindowChange = bCtrlDown;
1668 bForward = !bShiftDown;
1669 }
1670 break;
1671
1672 case VK_UP:
1673 case VK_LEFT:
1674 if (bCtrlDown)
1675 bProcess = FALSE;
1676 else
1677 bForward = FALSE;
1678 break;
1679
1680 case VK_DOWN:
1681 case VK_RIGHT:
1682 if (bCtrlDown)
1683 bProcess = FALSE;
1684 break;
1685
1686 case VK_ENTER:
1687 {
1688 if (bCtrlDown)
1689 {
1690 //
1691 // ctrl-enter is not processed
1692 //
1693 return FALSE;
1694 }
1695 else if (ulDlgCode & DLGC_BUTTON)
1696 {
1697 //
1698 // buttons want process Enter themselevs
1699 //
1700 bProcess = FALSE;
1701 }
1702 else
1703 {
1704 wxPanel* pPanel = wxDynamicCast(this, wxPanel);
1705 wxButton* pBtn = NULL;
1706
1707 if (pPanel)
1708 {
1709 //
1710 // Panel may have a default button which should
1711 // be activated by Enter
1712 //
1713 pBtn = pPanel->GetDefaultItem();
1714 }
1715
1716 if (pBtn && pBtn->IsEnabled())
1717 {
1718 //
1719 // If we do have a default button, do press it
1720 //
1721 pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
1722 return TRUE;
1723 }
1724 // else: but if it does not it makes sense to make
1725 // it work like a TAB - and that's what we do.
1726 // Note that Ctrl-Enter always works this way.
1727 }
1728 }
1729 break;
1730
1731 default:
1732 bProcess = FALSE;
1733 }
1734
1735 if (bProcess)
1736 {
1737 wxNavigationKeyEvent vEvent;
1738
1739 vEvent.SetDirection(bForward);
1740 vEvent.SetWindowChange(bWindowChange);
1741 vEvent.SetEventObject(this);
1742
1743 if (GetEventHandler()->ProcessEvent(vEvent))
1744 {
1745 wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton);
1746
1747 if (pBtn)
1748 {
1749 //
1750 // The button which has focus should be default
1751 //
1752 pBtn->SetDefault();
1753 }
1754 return TRUE;
1755 }
1756 }
1757 }
1758 //
1759 // Let Dialogs process
1760 //
1761 if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
1762 return TRUE;
1763 }
1764
1765 #if wxUSE_TOOLTIPS
1766 if ( m_tooltip )
1767 {
1768 // relay mouse move events to the tooltip control
1769 QMSG* pQMsg = (QMSG*)pMsg;
1770
1771 if (pQMsg->msg == WM_MOUSEMOVE )
1772 m_tooltip->RelayEvent(pMsg);
1773 }
1774 #endif // wxUSE_TOOLTIPS
1775
1776 return FALSE;
1777 } // end of wxWindow::OS2ProcessMessage
1778
1779 bool wxWindow::OS2TranslateMessage(
1780 WXMSG* pMsg
1781 )
1782 {
1783 #if wxUSE_ACCEL
1784 return m_acceleratorTable.Translate(m_hWnd, pMsg);
1785 #else
1786 return FALSE;
1787 #endif //wxUSE_ACCEL
1788 } // end of wxWindow::OS2TranslateMessage
1789
1790 // ---------------------------------------------------------------------------
1791 // message params unpackers
1792 // ---------------------------------------------------------------------------
1793
1794 void wxWindow::UnpackCommand(
1795 WXWPARAM wParam
1796 , WXLPARAM lParam
1797 , WORD* pId
1798 , WXHWND* phWnd
1799 , WORD* pCmd
1800 )
1801 {
1802 *pId = LOWORD(wParam);
1803 *phWnd = NULL; // or may be GetHWND() ?
1804 *pCmd = LOWORD(lParam);
1805 } // end of wxWindow::UnpackCommand
1806
1807 void wxWindow::UnpackActivate(
1808 WXWPARAM wParam
1809 , WXLPARAM lParam
1810 , WXWORD* pState
1811 , WXHWND* phWnd
1812 )
1813 {
1814 *pState = LOWORD(wParam);
1815 *phWnd = (WXHWND)lParam;
1816 } // end of wxWindow::UnpackActivate
1817
1818 void wxWindow::UnpackScroll(
1819 WXWPARAM wParam
1820 , WXLPARAM lParam
1821 , WXWORD* pCode
1822 , WXWORD* pPos
1823 , WXHWND* phWnd
1824 )
1825 {
1826 *pCode = LOWORD(wParam);
1827 *pPos = HIWORD(wParam);
1828 *phWnd = (WXHWND)lParam;
1829 } // end of wxWindow::UnpackScroll
1830
1831 void wxWindow::UnpackMenuSelect(
1832 WXWPARAM wParam
1833 , WXLPARAM lParam
1834 , WXWORD* pItem
1835 , WXWORD* pFlags
1836 , WXHMENU* phMenu
1837 )
1838 {
1839 *pItem = (WXWORD)LOWORD(wParam);
1840 *pFlags = HIWORD(wParam);
1841 *phMenu = (WXHMENU)lParam;
1842 } // end of wxWindow::UnpackMenuSelect
1843
1844 // ---------------------------------------------------------------------------
1845 // Main wxWindows window proc and the window proc for wxWindow
1846 // ---------------------------------------------------------------------------
1847
1848 //
1849 // Hook for new window just as it's being created, when the window isn't yet
1850 // associated with the handle
1851 //
1852 wxWindow* wxWndHook = NULL;
1853
1854 //
1855 // Main window proc
1856 //
1857 MRESULT EXPENTRY wxWndProc(
1858 HWND hWnd
1859 , ULONG ulMsg
1860 , MPARAM wParam
1861 , MPARAM lParam
1862 )
1863 {
1864 //
1865 // Trace all ulMsgs - useful for the debugging
1866 //
1867 #ifdef __WXDEBUG__
1868 wxLogTrace(wxTraceMessages, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1869 wxGetMessageName(ulMsg), wParam, lParam);
1870 #endif // __WXDEBUG__
1871
1872 wxWindow* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
1873
1874 //
1875 // When we get the first message for the HWND we just created, we associate
1876 // it with wxWindow stored in wxWndHook
1877 //
1878 if (!pWnd && wxWndHook)
1879 {
1880 wxAssociateWinWithHandle(hWnd, wxWndHook);
1881 pWnd = wxWndHook;
1882 wxWndHook = NULL;
1883 pWnd->SetHWND((WXHWND)hWnd);
1884 }
1885
1886 MRESULT rc = (MRESULT)0;
1887
1888
1889 //
1890 // Stop right here if we don't have a valid handle in our wxWindow object.
1891 //
1892 if (pWnd && !pWnd->GetHWND())
1893 {
1894 pWnd->SetHWND((WXHWND) hWnd);
1895 rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
1896 pWnd->SetHWND(0);
1897 }
1898 else
1899 {
1900 if (pWnd)
1901 rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
1902 else
1903 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
1904 }
1905
1906 return rc;
1907 } // end of wxWndProc
1908
1909 //
1910 // We will add (or delete) messages we need to handle at this default
1911 // level as we go
1912 //
1913 MRESULT wxWindow::OS2WindowProc(
1914 WXUINT uMsg
1915 , WXWPARAM wParam
1916 , WXLPARAM lParam
1917 )
1918 {
1919 //
1920 // Did we process the uMsg?
1921 //
1922 bool bProcessed = FALSE;
1923 bool bAllow;
1924 MRESULT mResult;
1925 WXHICON hIcon;
1926 WXHBRUSH hBrush;
1927
1928 //
1929 // For most messages we should return 0 when we do process the message
1930 //
1931 mResult = (MRESULT)0;
1932
1933 switch (uMsg)
1934 {
1935 case WM_CREATE:
1936 {
1937 bool bMayCreate;
1938
1939 bProcessed = HandleCreate( (WXLPCREATESTRUCT)lParam
1940 ,&bMayCreate
1941 );
1942 if (bProcessed)
1943 {
1944 //
1945 // Return 0 to bAllow window creation
1946 //
1947 mResult = (MRESULT)(bMayCreate ? 0 : -1);
1948 }
1949 }
1950 break;
1951
1952 case WM_DESTROY:
1953 HandleDestroy();
1954 bProcessed = TRUE;
1955 break;
1956
1957 case WM_MOVE:
1958 bProcessed = HandleMove( LOWORD(lParam)
1959 ,HIWORD(lParam)
1960 );
1961 break;
1962
1963 case WM_SIZE:
1964 bProcessed = HandleSize( LOWORD(lParam)
1965 ,HIWORD(lParam)
1966 ,(WXUINT)wParam
1967 );
1968 break;
1969
1970 case WM_ACTIVATE:
1971 {
1972 WXWORD wState;
1973 WXHWND hWnd;
1974
1975 UnpackActivate( wParam
1976 ,lParam
1977 ,&wState
1978 ,&hWnd
1979 );
1980
1981 bProcessed = HandleActivate( wState
1982 ,(WXHWND)hWnd
1983 );
1984 bProcessed = FALSE;
1985 }
1986 break;
1987
1988 case WM_SETFOCUS:
1989 if (SHORT1FROMMP((MPARAM)lParam) == TRUE)
1990 bProcessed = HandleSetFocus((WXHWND)(HWND)wParam);
1991 else
1992 bProcessed = HandleKillFocus((WXHWND)(HWND)wParam);
1993 break;
1994
1995 case WM_PAINT:
1996 bProcessed = HandlePaint();
1997 break;
1998
1999 case WM_CLOSE:
2000 //
2001 // Don't let the DefWindowProc() destroy our window - we'll do it
2002 // ourselves in ~wxWindow
2003 //
2004 bProcessed = TRUE;
2005 mResult = (MRESULT)TRUE;
2006 break;
2007
2008 case WM_SHOW:
2009 bProcessed = HandleShow(wParam != 0, (int)lParam);
2010 break;
2011
2012 //
2013 // Under OS2 PM Joysticks are treated just like mouse events
2014 // The "Motion" events will be prevelent in joysticks
2015 //
2016 case WM_MOUSEMOVE:
2017 case WM_BUTTON1DOWN:
2018 case WM_BUTTON1UP:
2019 case WM_BUTTON1DBLCLK:
2020 case WM_BUTTON1MOTIONEND:
2021 case WM_BUTTON1MOTIONSTART:
2022 case WM_BUTTON2DOWN:
2023 case WM_BUTTON2UP:
2024 case WM_BUTTON2DBLCLK:
2025 case WM_BUTTON2MOTIONEND:
2026 case WM_BUTTON2MOTIONSTART:
2027 case WM_BUTTON3DOWN:
2028 case WM_BUTTON3UP:
2029 case WM_BUTTON3DBLCLK:
2030 case WM_BUTTON3MOTIONEND:
2031 case WM_BUTTON3MOTIONSTART:
2032 {
2033 short x = LOWORD(lParam);
2034 short y = HIWORD(lParam);
2035
2036 bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam);
2037 }
2038 break;
2039 case WM_SYSCOMMAND:
2040 bProcessed = HandleSysCommand(wParam, lParam);
2041 break;
2042
2043 case WM_COMMAND:
2044 {
2045 WORD id, cmd;
2046 WXHWND hwnd;
2047 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
2048
2049 bProcessed = HandleCommand(id, cmd, hwnd);
2050 }
2051 break;
2052
2053 //
2054 // For these messages we must return TRUE if process the message
2055 //
2056 case WM_DRAWITEM:
2057 case WM_MEASUREITEM:
2058 {
2059 int nIdCtrl = (UINT)wParam;
2060
2061 if ( uMsg == WM_DRAWITEM )
2062 {
2063 bProcessed = OS2OnDrawItem(nIdCtrl,
2064 (WXDRAWITEMSTRUCT *)lParam);
2065 }
2066 else
2067 {
2068 bProcessed = OS2OnMeasureItem(nIdCtrl,
2069 (WXMEASUREITEMSTRUCT *)lParam);
2070 }
2071
2072 if ( bProcessed )
2073 mResult = (MRESULT)TRUE;
2074 }
2075 break;
2076
2077 case WM_QUERYDLGCODE:
2078 if ( m_lDlgCode )
2079 {
2080 mResult = (MRESULT)m_lDlgCode;
2081 bProcessed = TRUE;
2082 }
2083 //
2084 //else: get the dlg code from the DefWindowProc()
2085 //
2086 break;
2087
2088 //
2089 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2090 // and key-down events are obtained from the WM_CHAR params.
2091 //
2092 case WM_CHAR:
2093 {
2094 USHORT uKeyFlags = SHORT1FROMMP((MPARAM)wParam);
2095
2096 if (uKeyFlags & KC_KEYUP)
2097 {
2098 bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
2099 break;
2100 }
2101 else // keydown event
2102 {
2103 //
2104 // If this has been processed by an event handler,
2105 // return 0 now (we've handled it). DON't RETURN
2106 // we still need to process further
2107 //
2108 HandleKeyDown((WXDWORD)wParam, lParam);
2109 if (uKeyFlags & KC_VIRTUALKEY)
2110 {
2111 USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
2112
2113 //
2114 // We consider these message "not interesting" to OnChar
2115 //
2116 if (uVk == VK_SHIFT || uVk == VK_CTRL )
2117 {
2118 bProcessed = TRUE;
2119 break;
2120 }
2121 switch(uVk)
2122 {
2123 //
2124 // Avoid duplicate messages to OnChar for these ASCII keys: they
2125 // will be translated by TranslateMessage() and received in WM_CHAR
2126 case VK_ESC:
2127 case VK_SPACE:
2128 case VK_ENTER:
2129 case VK_BACKSPACE:
2130 case VK_TAB:
2131 // But set processed to FALSE, not TRUE to still pass them to
2132 // the control's default window proc - otherwise built-in
2133 // keyboard handling won't work
2134 bProcessed = FALSE;
2135 break;
2136
2137 case VK_LEFT:
2138 case VK_RIGHT:
2139 case VK_DOWN:
2140 case VK_UP:
2141 default:
2142 bProcessed = HandleChar((WXDWORD)wParam, lParam);
2143 }
2144 break;
2145 }
2146 else // WM_CHAR -- Always an ASCII character
2147 {
2148 bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
2149 break;
2150 }
2151 }
2152 }
2153
2154 case WM_HSCROLL:
2155 case WM_VSCROLL:
2156 {
2157 WXWORD wCode;
2158 WXWORD wPos;
2159 WXHWND hWnd;
2160 UnpackScroll( wParam
2161 ,lParam
2162 ,&wCode
2163 ,&wPos
2164 ,&hWnd
2165 );
2166
2167 bProcessed = OS2OnScroll( uMsg == WM_HSCROLL ? wxHORIZONTAL
2168 : wxVERTICAL
2169 ,wCode
2170 ,wPos
2171 ,hWnd
2172 );
2173 }
2174 break;
2175
2176 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2177 case WM_CTLCOLORCHANGE:
2178 {
2179 bProcessed = HandleCtlColor(&hBrush);
2180 }
2181 break;
2182 #endif
2183 case WM_ERASEBACKGROUND:
2184 //
2185 // Returning TRUE to requestw PM to paint the window background
2186 // in SYSCLR_WINDOW. We don't really want that
2187 //
2188 bProcessed = HandleEraseBkgnd((WXHDC)(HPS)wParam);
2189 mResult = (MRESULT)(FALSE);
2190 break;
2191
2192 //
2193 // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
2194 // things such as colors and fonts and such
2195 //
2196 case WM_QUERYWINDOWPARAMS:
2197 {
2198 PWNDPARAMS pWndParams = (PWNDPARAMS)wParam;
2199
2200 bProcessed = HandleWindowParams( pWndParams
2201 ,lParam
2202 );
2203 }
2204 break;
2205
2206 // the return value for this message is ignored
2207 case WM_SYSCOLORCHANGE:
2208 bProcessed = HandleSysColorChange();
2209 break;
2210
2211 case WM_REALIZEPALETTE:
2212 bProcessed = HandlePaletteChanged();
2213 break;
2214
2215 case WM_PRESPARAMCHANGED:
2216 bProcessed = HandlePresParamChanged(wParam);
2217 break;
2218
2219
2220 // move all drag and drops to wxDrg
2221 case WM_ENDDRAG:
2222 bProcessed = HandleEndDrag(wParam);
2223 break;
2224
2225 case WM_INITDLG:
2226 bProcessed = HandleInitDialog((WXHWND)(HWND)wParam);
2227
2228 if ( bProcessed )
2229 {
2230 // we never set focus from here
2231 mResult = FALSE;
2232 }
2233 break;
2234
2235 // wxFrame specific message
2236 case WM_MINMAXFRAME:
2237 bProcessed = HandleGetMinMaxInfo((PSWP)wParam);
2238 break;
2239
2240 case WM_SYSVALUECHANGED:
2241 // TODO: do something
2242 mResult = (MRESULT)TRUE;
2243 break;
2244
2245 //
2246 // Comparable to WM_SETPOINTER for windows, only for just controls
2247 //
2248 case WM_CONTROLPOINTER:
2249 bProcessed = HandleSetCursor( SHORT1FROMMP(wParam) // Control ID
2250 ,(HWND)lParam // Cursor Handle
2251 );
2252 if (bProcessed )
2253 {
2254 //
2255 // Returning TRUE stops the DefWindowProc() from further
2256 // processing this message - exactly what we need because we've
2257 // just set the cursor.
2258 //
2259 mResult = (MRESULT)TRUE;
2260 }
2261 break;
2262 }
2263 if (!bProcessed)
2264 {
2265 #ifdef __WXDEBUG__
2266 wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
2267 wxGetMessageName(uMsg));
2268 #endif // __WXDEBUG__
2269 if (IsKindOf(CLASSINFO(wxFrame)))
2270 mResult = ::WinDefWindowProc(m_hWnd, uMsg, wParam, lParam);
2271 else
2272 mResult = OS2DefWindowProc(uMsg, wParam, lParam);
2273 }
2274 return mResult;
2275 } // end of wxWindow::OS2WindowProc
2276
2277 //
2278 // Dialog window proc
2279 //
2280 MRESULT wxDlgProc(
2281 HWND hWnd
2282 , UINT uMsg
2283 , MPARAM wParam
2284 , MPARAM lParam)
2285 {
2286 if (uMsg == WM_INITDLG)
2287 {
2288 //
2289 // For this message, returning TRUE tells system to set focus to the
2290 // first control in the dialog box
2291 //
2292 return (MRESULT)TRUE;
2293 }
2294 else
2295 {
2296 //
2297 // For all the other ones, FALSE means that we didn't process the
2298 // message
2299 //
2300 return (MRESULT)0;
2301 }
2302 } // end of wxDlgProc
2303
2304 wxWindow* wxFindWinFromHandle(
2305 WXHWND hWnd
2306 )
2307 {
2308 wxNode* pNode = wxWinHandleList->Find((long)hWnd);
2309
2310 if (!pNode)
2311 return NULL;
2312 return (wxWindow *)pNode->Data();
2313 } // end of wxFindWinFromHandle
2314
2315 void wxAssociateWinWithHandle(
2316 HWND hWnd
2317 , wxWindow* pWin
2318 )
2319 {
2320 //
2321 // Adding NULL hWnd is (first) surely a result of an error and
2322 // (secondly) breaks menu command processing
2323 //
2324 wxCHECK_RET( hWnd != (HWND)NULL,
2325 wxT("attempt to add a NULL hWnd to window list ignored") );
2326
2327
2328 wxWindow* pOldWin = wxFindWinFromHandle((WXHWND) hWnd);
2329
2330 if (pOldWin && (pOldWin != pWin))
2331 {
2332 wxString str(pWin->GetClassInfo()->GetClassName());
2333 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2334 ,(int)hWnd
2335 ,(const char*)str
2336 );
2337 }
2338 else if (!pOldWin)
2339 {
2340 wxWinHandleList->Append( (long)hWnd
2341 ,pWin
2342 );
2343 }
2344 } // end of wxAssociateWinWithHandle
2345
2346 void wxRemoveHandleAssociation(
2347 wxWindow* pWin
2348 )
2349 {
2350 wxWinHandleList->DeleteObject(pWin);
2351 } // end of wxRemoveHandleAssociation
2352
2353 //
2354 // Default destroyer - override if you destroy it in some other way
2355 // (e.g. with MDI child windows)
2356 //
2357 void wxWindow::OS2DestroyWindow()
2358 {
2359 }
2360
2361 void wxWindow::OS2DetachWindowMenu()
2362 {
2363 if (m_hMenu)
2364 {
2365 HMENU hMenu = (HMENU)m_hMenu;
2366
2367 int nN = (int)::WinSendMsg(hMenu, MM_QUERYITEMCOUNT, 0, 0);
2368 int i;
2369
2370 for (i = 0; i < nN; i++)
2371 {
2372 wxChar zBuf[100];
2373 int nChars = (int)::WinSendMsg( hMenu
2374 ,MM_QUERYITEMTEXT
2375 ,MPFROM2SHORT(i, nN)
2376 ,zBuf
2377 );
2378 if (!nChars)
2379 {
2380 wxLogLastError(wxT("GetMenuString"));
2381 continue;
2382 }
2383
2384 if (wxStrcmp(zBuf, wxT("&Window")) == 0)
2385 {
2386 ::WinSendMsg(hMenu, MM_DELETEITEM, MPFROM2SHORT(i, TRUE), 0);
2387 break;
2388 }
2389 }
2390 }
2391 } // end of wxWindow::OS2DetachWindowMenu
2392
2393 bool wxWindow::OS2Create(
2394 WXHWND hParent
2395 , PSZ zClass
2396 , const wxChar* zTitle
2397 , WXDWORD dwStyle
2398 , long lX
2399 , long lY
2400 , long lWidth
2401 , long lHeight
2402 , WXHWND hOwner
2403 , WXHWND hZOrder
2404 , unsigned long ulId
2405 , void* pCtlData
2406 , void* pPresParams
2407 )
2408 {
2409 ERRORID vError;
2410 wxString sError;
2411 long lX1 = 0L;
2412 long lY1 = 0L;
2413 long lWidth1 = 20L;
2414 long lHeight1 = 20L;
2415 int nControlId = 0;
2416 int nNeedsubclass = 0;
2417 PCSZ pszClass = zClass;
2418
2419 //
2420 // Find parent's size, if it exists, to set up a possible default
2421 // panel size the size of the parent window
2422 //
2423 RECTL vParentRect;
2424 HWND hWndClient;
2425
2426 if (lX > -1L)
2427 lX1 = lX;
2428 if (lY > -1L)
2429 lY1 = lY;
2430 if (lWidth > -1L)
2431 lWidth1 = lWidth;
2432 if (lHeight > -1L)
2433 lHeight1 = lHeight;
2434
2435 wxWndHook = this;
2436
2437 //
2438 // check to see if the new window is a standard control
2439 //
2440 if ((ULONG)zClass == (ULONG)WC_BUTTON ||
2441 (ULONG)zClass == (ULONG)WC_COMBOBOX ||
2442 (ULONG)zClass == (ULONG)WC_CONTAINER ||
2443 (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
2444 (ULONG)zClass == (ULONG)WC_FRAME ||
2445 (ULONG)zClass == (ULONG)WC_LISTBOX ||
2446 (ULONG)zClass == (ULONG)WC_MENU ||
2447 (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
2448 (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
2449 (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
2450 (ULONG)zClass == (ULONG)WC_STATIC ||
2451 (ULONG)zClass == (ULONG)WC_TITLEBAR ||
2452 (ULONG)zClass == (ULONG)WC_VALUESET
2453 )
2454 {
2455 nControlId = ulId;
2456 }
2457 else
2458 {
2459 // no standard controls
2460 if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
2461 {
2462 pszClass = WC_FRAME;
2463 nNeedsubclass = 1;
2464 }
2465 else
2466 {
2467 nControlId = ulId;
2468 if(nControlId < 0)
2469 nControlId = FID_CLIENT;
2470 }
2471 }
2472
2473 //
2474 // We will either have a registered class via string name or a standard PM Class via a long
2475 //
2476 m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
2477 ,zClass
2478 ,(PSZ)zTitle ? zTitle : wxT("")
2479 ,(ULONG)dwStyle
2480 ,(LONG)lX1
2481 ,(LONG)lY1
2482 ,(LONG)lWidth
2483 ,(LONG)lHeight
2484 ,hOwner
2485 ,HWND_TOP
2486 ,(ULONG)nControlId
2487 ,pCtlData
2488 ,pPresParams
2489 );
2490 if (!m_hWnd)
2491 {
2492 vError = ::WinGetLastError(vHabmain);
2493 sError = wxPMErrorToStr(vError);
2494 wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
2495 return FALSE;
2496 }
2497 ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
2498 wxWndHook = NULL;
2499
2500 #ifdef __WXDEBUG__
2501 wxNode* pNode = wxWinHandleList->Member(this);
2502
2503 if (pNode)
2504 {
2505 HWND hWnd = (HWND)pNode->GetKeyInteger();
2506
2507 if (hWnd != (HWND)m_hWnd)
2508
2509 {
2510 wxLogError("A second HWND association is being added for the same window!");
2511 }
2512 }
2513 #endif
2514 wxAssociateWinWithHandle((HWND)m_hWnd
2515 ,this
2516 );
2517 //
2518 // Now need to subclass window.
2519 //
2520 if(!nNeedsubclass)
2521 {
2522 wxAssociateWinWithHandle((HWND)m_hWnd,this);
2523 }
2524 else
2525 {
2526 SubclassWin(GetHWND());
2527 }
2528 return TRUE;
2529 } // end of wxWindow::OS2Create
2530
2531 // ===========================================================================
2532 // OS2 PM message handlers
2533 // ===========================================================================
2534
2535 // ---------------------------------------------------------------------------
2536 // window creation/destruction
2537 // ---------------------------------------------------------------------------
2538
2539 bool wxWindow::HandleCreate(
2540 WXLPCREATESTRUCT vCs
2541 , bool* pbMayCreate
2542 )
2543 {
2544 wxWindowCreateEvent vEvent(this);
2545
2546 (void)GetEventHandler()->ProcessEvent(vEvent);
2547 *pbMayCreate = TRUE;
2548 return TRUE;
2549 } // end of wxWindow::HandleCreate
2550
2551 bool wxWindow::HandleDestroy()
2552 {
2553 wxWindowDestroyEvent vEvent(this);
2554
2555 (void)GetEventHandler()->ProcessEvent(vEvent);
2556
2557 //
2558 // Delete our drop target if we've got one
2559 //
2560 #if wxUSE_DRAG_AND_DROP
2561 if (m_dropTarget != NULL)
2562 {
2563 m_dropTarget->Revoke(m_hWnd);
2564 delete m_dropTarget;
2565 m_dropTarget = NULL;
2566 }
2567 #endif // wxUSE_DRAG_AND_DROP
2568
2569 //
2570 // WM_DESTROY handled
2571 //
2572 return TRUE;
2573 } // end of wxWindow::HandleDestroy
2574
2575 // ---------------------------------------------------------------------------
2576 // activation/focus
2577 // ---------------------------------------------------------------------------
2578 void wxWindow::OnSetFocus(
2579 wxFocusEvent& rEvent
2580 )
2581 {
2582 //
2583 // Panel wants to track the window which was the last to have focus in it,
2584 // so we want to set ourselves as the window which last had focus
2585 //
2586 // Notice that it's also important to do it upwards the tree becaus
2587 // otherwise when the top level panel gets focus, it won't set it back to
2588 // us, but to some other sibling
2589 //
2590 wxWindow* pWin = this;
2591
2592 while (pWin)
2593 {
2594 wxWindow* pParent = pWin->GetParent();
2595 wxPanel* pPanel = wxDynamicCast( pParent
2596 ,wxPanel
2597 );
2598 if (pPanel)
2599 {
2600 pPanel->SetLastFocus(pWin);
2601 }
2602 pWin = pParent;
2603 }
2604
2605 wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
2606 GetClassInfo()->GetClassName(), GetHandle());
2607
2608 rEvent.Skip();
2609 } // end of wxWindow::OnSetFocus
2610
2611 bool wxWindow::HandleActivate(
2612 int nState
2613 , WXHWND WXUNUSED(hActivate)
2614 )
2615 {
2616 wxActivateEvent vEvent( wxEVT_ACTIVATE
2617 ,(bool)nState
2618 ,m_windowId
2619 );
2620 vEvent.SetEventObject(this);
2621 return GetEventHandler()->ProcessEvent(vEvent);
2622 } // end of wxWindow::HandleActivate
2623
2624 bool wxWindow::HandleSetFocus(
2625 WXHWND WXUNUSED(hWnd)
2626 )
2627 {
2628 #if wxUSE_CARET
2629 //
2630 // Deal with caret
2631 //
2632 if (m_caret)
2633 {
2634 m_caret->OnSetFocus();
2635 }
2636 #endif // wxUSE_CARET
2637
2638 //
2639 // Panel wants to track the window which was the last to have focus in it
2640 //
2641 wxPanel* pPanel = wxDynamicCast( GetParent()
2642 ,wxPanel
2643 );
2644 if (pPanel)
2645 {
2646 pPanel->SetLastFocus(this);
2647 }
2648
2649 wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
2650
2651 vEvent.SetEventObject(this);
2652 return GetEventHandler()->ProcessEvent(vEvent);
2653 } // end of wxWindow::HandleSetFocus
2654
2655 bool wxWindow::HandleKillFocus(
2656 WXHWND WXUNUSED(hWnd)
2657 )
2658 {
2659 #if wxUSE_CARET
2660 //
2661 // Deal with caret
2662 //
2663 if (m_caret)
2664 {
2665 m_caret->OnKillFocus();
2666 }
2667 #endif // wxUSE_CARET
2668
2669 wxFocusEvent vEvent( wxEVT_KILL_FOCUS
2670 ,m_windowId
2671 );
2672
2673 vEvent.SetEventObject(this);
2674 return GetEventHandler()->ProcessEvent(vEvent);
2675 } // end of wxWindow::HandleKillFocus
2676
2677 // ---------------------------------------------------------------------------
2678 // miscellaneous
2679 // ---------------------------------------------------------------------------
2680
2681 bool wxWindow::HandleShow(
2682 bool bShow
2683 , int nStatus
2684 )
2685 {
2686 wxShowEvent vEvent( GetId()
2687 ,bShow
2688 );
2689
2690 vEvent.m_eventObject = this;
2691 return GetEventHandler()->ProcessEvent(vEvent);
2692 } // end of wxWindow::HandleShow
2693
2694 bool wxWindow::HandleInitDialog(
2695 WXHWND WXUNUSED(hWndFocus)
2696 )
2697 {
2698 wxInitDialogEvent vEvent(GetId());
2699
2700 vEvent.m_eventObject = this;
2701 return GetEventHandler()->ProcessEvent(vEvent);
2702 } // end of wxWindow::HandleInitDialog
2703
2704 bool wxWindow::HandleEndDrag(WXWPARAM wParam)
2705 {
2706 // TODO: We'll handle drag and drop later
2707 return FALSE;
2708 }
2709
2710 bool wxWindow::HandleSetCursor(
2711 USHORT vId
2712 , WXHWND hPointer
2713 )
2714 {
2715 //
2716 // Under OS/2 PM this allows the pointer to be changed
2717 // as it passes over a control
2718 //
2719 ::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer);
2720 return TRUE;
2721 } // end of wxWindow::HandleSetCursor
2722
2723 // ---------------------------------------------------------------------------
2724 // owner drawn stuff
2725 // ---------------------------------------------------------------------------
2726 bool wxWindow::OS2OnDrawItem(
2727 int vId
2728 , WXDRAWITEMSTRUCT* pItemStruct
2729 )
2730 {
2731 wxDC vDc;
2732
2733 #if wxUSE_OWNER_DRAWN
2734 //
2735 // Is it a menu item?
2736 //
2737 if (vId == 0)
2738 {
2739 ERRORID vError;
2740 wxString sError;
2741 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
2742 wxFrame* pFrame = (wxFrame*)this;
2743 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
2744 HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps);
2745 wxRect vRect( pMeasureStruct->rclItem.xLeft
2746 ,pMeasureStruct->rclItem.yBottom
2747 ,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft
2748 ,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom
2749 );
2750 vDc.SetHDC( hDC
2751 ,FALSE
2752 );
2753 vDc.SetHPS(pMeasureStruct->hps);
2754 //
2755 // Load the wxWindows Pallete and set to RGB mode
2756 //
2757 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
2758 ,0L
2759 ,LCOLF_CONSECRGB
2760 ,0L
2761 ,(LONG)wxTheColourDatabase->m_nSize
2762 ,(PLONG)wxTheColourDatabase->m_palTable
2763 ))
2764 {
2765 vError = ::WinGetLastError(vHabmain);
2766 sError = wxPMErrorToStr(vError);
2767 wxLogError("Unable to set current color table. Error: %s\n", sError);
2768 }
2769 //
2770 // Set the color table to RGB mode
2771 //
2772 if (!::GpiCreateLogColorTable( pMeasureStruct->hps
2773 ,0L
2774 ,LCOLF_RGB
2775 ,0L
2776 ,0L
2777 ,NULL
2778 ))
2779 {
2780 vError = ::WinGetLastError(vHabmain);
2781 sError = wxPMErrorToStr(vError);
2782 wxLogError("Unable to set current color table. Error: %s\n", sError);
2783 }
2784
2785 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2786
2787
2788 int eAction = 0;
2789 int eStatus = 0;
2790
2791 if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld)
2792 {
2793 //
2794 // Entire Item needs to be redrawn (either it has reappeared from
2795 // behind another window or is being displayed for the first time
2796 //
2797 eAction = wxOwnerDrawn::wxODDrawAll;
2798
2799 if (pMeasureStruct->fsAttribute & MIA_HILITED)
2800 {
2801 //
2802 // If it is currently selected we let the system handle it
2803 //
2804 eStatus |= wxOwnerDrawn::wxODSelected;
2805 }
2806 if (pMeasureStruct->fsAttribute & MIA_CHECKED)
2807 {
2808 //
2809 // If it is currently checked we draw our own
2810 //
2811 eStatus |= wxOwnerDrawn::wxODChecked;
2812 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_CHECKED;
2813 }
2814 if (pMeasureStruct->fsAttribute & MIA_DISABLED)
2815 {
2816 //
2817 // If it is currently disabled we let the system handle it
2818 //
2819 eStatus |= wxOwnerDrawn::wxODDisabled;
2820 }
2821 //
2822 // Don't really care about framed (indicationg focus) or NoDismiss
2823 //
2824 }
2825 else
2826 {
2827 if (pMeasureStruct->fsAttribute & MIA_HILITED)
2828 {
2829 eAction = wxOwnerDrawn::wxODDrawAll;
2830 eStatus |= wxOwnerDrawn::wxODSelected;
2831 //
2832 // Keep the system from trying to highlight with its bogus colors
2833 //
2834 pMeasureStruct->fsAttributeOld = pMeasureStruct->fsAttribute &= ~MIA_HILITED;
2835 }
2836 else if (!(pMeasureStruct->fsAttribute & MIA_HILITED))
2837 {
2838 eAction = wxOwnerDrawn::wxODDrawAll;
2839 eStatus = 0;
2840 //
2841 // Keep the system from trying to highlight with its bogus colors
2842 //
2843 pMeasureStruct->fsAttribute = pMeasureStruct->fsAttributeOld &= ~MIA_HILITED;
2844 }
2845 else
2846 {
2847 //
2848 // For now we don't care about anything else
2849 // just ignore the entire message!
2850 //
2851 return TRUE;
2852 }
2853 }
2854 //
2855 // Now redraw the item
2856 //
2857 return(pMenuItem->OnDrawItem( vDc
2858 ,vRect
2859 ,(wxOwnerDrawn::wxODAction)eAction
2860 ,(wxOwnerDrawn::wxODStatus)eStatus
2861 ));
2862 //
2863 // leave the fsAttribute and fsOldAttribute unchanged. If different,
2864 // the system will do the highlight or fraeming or disabling for us,
2865 // otherwise, we'd have to do it ourselves.
2866 //
2867 }
2868
2869 wxWindow* pItem = FindItem(vId);
2870
2871 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
2872 {
2873 return ((wxControl *)pItem)->OS2OnDraw(pItemStruct);
2874 }
2875 #endif
2876 return FALSE;
2877 } // end of wxWindow::OS2OnDrawItem
2878
2879 bool wxWindow::OS2OnMeasureItem(
2880 int lId
2881 , WXMEASUREITEMSTRUCT* pItemStruct
2882 )
2883 {
2884 //
2885 // Is it a menu item?
2886 //
2887 if (lId == 65536) // I really don't like this...has to be a better indicator
2888 {
2889 if (IsKindOf(CLASSINFO(wxFrame))) // we'll assume if Frame then a menu
2890 {
2891 size_t nWidth;
2892 size_t nHeight;
2893 POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct;
2894 wxFrame* pFrame = (wxFrame*)this;
2895 wxMenuItem* pMenuItem = pFrame->GetMenuBar()->FindItem(pMeasureStruct->idItem, pMeasureStruct->hItem);
2896
2897 wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
2898 nWidth = 0L;
2899 nHeight = 0L;
2900 if (pMenuItem->OnMeasureItem( &nWidth
2901 ,&nHeight
2902 ))
2903 {
2904 pMeasureStruct->rclItem.xRight = nWidth;
2905 pMeasureStruct->rclItem.xLeft = 0L;
2906 pMeasureStruct->rclItem.yTop = nHeight;
2907 pMeasureStruct->rclItem.yBottom = 0L;
2908 return TRUE;
2909 }
2910 return FALSE;
2911 }
2912 }
2913 wxWindow* pItem = FindItem(lId);
2914
2915 if (pItem && pItem->IsKindOf(CLASSINFO(wxControl)))
2916 {
2917 return ((wxControl *)pItem)->OS2OnMeasure(pItemStruct);
2918 }
2919 return FALSE;
2920 }
2921
2922 // ---------------------------------------------------------------------------
2923 // colours and palettes
2924 // ---------------------------------------------------------------------------
2925
2926 bool wxWindow::HandleSysColorChange()
2927 {
2928 wxSysColourChangedEvent vEvent;
2929
2930 vEvent.SetEventObject(this);
2931 return GetEventHandler()->ProcessEvent(vEvent);
2932 } // end of wxWindow::HandleSysColorChange
2933
2934 bool wxWindow::HandleCtlColor(
2935 WXHBRUSH* phBrush
2936 )
2937 {
2938 //
2939 // Not much provided with message. So not sure I can do anything with it
2940 //
2941 return TRUE;
2942 } // end of wxWindow::HandleCtlColor
2943
2944 bool wxWindow::HandleWindowParams(
2945 PWNDPARAMS pWndParams
2946 , WXLPARAM lParam
2947 )
2948 {
2949 // TODO: I'll do something here, just not sure what yet
2950 return TRUE;
2951 }
2952
2953 // Define for each class of dialog and control
2954 WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC,
2955 WXHWND hWnd,
2956 WXUINT nCtlColor,
2957 WXUINT message,
2958 WXWPARAM wParam,
2959 WXLPARAM lParam)
2960 {
2961 return (WXHBRUSH)0;
2962 }
2963
2964 bool wxWindow::HandlePaletteChanged()
2965 {
2966 // need to set this to something first
2967 WXHWND hWndPalChange = NULLHANDLE;
2968
2969 wxPaletteChangedEvent vEvent(GetId());
2970
2971 vEvent.SetEventObject(this);
2972 vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
2973
2974 return GetEventHandler()->ProcessEvent(vEvent);
2975 } // end of wxWindow::HandlePaletteChanged
2976
2977 bool wxWindow::HandlePresParamChanged(
2978 WXWPARAM wParam
2979 )
2980 {
2981 //
2982 // TODO: Once again I'll do something here when I need it
2983 //
2984 //wxQueryNewPaletteEvent event(GetId());
2985 //event.SetEventObject(this);
2986 // if the background is erased
2987 // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
2988
2989 return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
2990 }
2991
2992 //
2993 // Responds to colour changes: passes event on to children.
2994 //
2995 void wxWindow::OnSysColourChanged(
2996 wxSysColourChangedEvent& rEvent
2997 )
2998 {
2999 wxNode* pNode = GetChildren().First();
3000
3001 while (pNode)
3002 {
3003 //
3004 // Only propagate to non-top-level windows
3005 //
3006 wxWindow* pWin = (wxWindow *)pNode->Data();
3007
3008 if (pWin->GetParent())
3009 {
3010 wxSysColourChangedEvent vEvent;
3011
3012 rEvent.m_eventObject = pWin;
3013 pWin->GetEventHandler()->ProcessEvent(vEvent);
3014 }
3015 pNode = pNode->Next();
3016 }
3017 } // end of wxWindow::OnSysColourChanged
3018
3019 // ---------------------------------------------------------------------------
3020 // painting
3021 // ---------------------------------------------------------------------------
3022
3023 bool wxWindow::HandlePaint()
3024 {
3025 HRGN hRgn = NULLHANDLE;
3026 wxPaintEvent vEvent;
3027 HPS hPS;
3028 RECTL vRect;
3029
3030 if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL)
3031 {
3032 wxLogLastError("CreateRectRgn");
3033 return FALSE;
3034 }
3035
3036 m_updateRegion = wxRegion(hRgn);
3037 vEvent.SetEventObject(this);
3038 if (!GetEventHandler()->ProcessEvent(vEvent))
3039 {
3040 HPS hPS;
3041
3042 hPS = ::WinBeginPaint( GetHwnd()
3043 ,NULLHANDLE
3044 ,&vRect
3045 );
3046 if(hPS)
3047 {
3048 ::GpiCreateLogColorTable( hPS
3049 ,0L
3050 ,LCOLF_CONSECRGB
3051 ,0L
3052 ,(LONG)wxTheColourDatabase->m_nSize
3053 ,(PLONG)wxTheColourDatabase->m_palTable
3054 );
3055 ::GpiCreateLogColorTable( hPS
3056 ,0L
3057 ,LCOLF_RGB
3058 ,0L
3059 ,0L
3060 ,NULL
3061 );
3062
3063 ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
3064 ::WinEndPaint(hPS);
3065 }
3066 }
3067 return (GetEventHandler()->ProcessEvent(vEvent));
3068 } // end of wxWindow::HandlePaint
3069
3070 bool wxWindow::HandleEraseBkgnd(
3071 WXHDC hDC
3072 )
3073 {
3074 SWP vSwp;
3075
3076 ::WinQueryWindowPos(GetHwnd(), &vSwp);
3077 if (vSwp.fl & SWP_MINIMIZE)
3078 return TRUE;
3079
3080 wxDC vDC;
3081
3082 vDC.m_hPS = (HPS)hDC; // this is really a PS
3083 vDC.SetWindow(this);
3084 vDC.BeginDrawing();
3085
3086 wxEraseEvent vEvent(m_windowId, &vDC);
3087
3088 vEvent.SetEventObject(this);
3089
3090 bool rc = GetEventHandler()->ProcessEvent(vEvent);
3091
3092 vDC.EndDrawing();
3093 vDC.m_hPS = NULLHANDLE;
3094 return TRUE;
3095 } // end of wxWindow::HandleEraseBkgnd
3096
3097 void wxWindow::OnEraseBackground(
3098 wxEraseEvent& rEvent
3099 )
3100 {
3101 RECTL vRect;
3102 HPS hPS = rEvent.m_dc->m_hPS;
3103
3104 ::WinQueryWindowRect(GetHwnd(), &vRect);
3105 ::WinFillRect(hPS, &vRect, m_backgroundColour.GetPixel());
3106 } // end of wxWindow::OnEraseBackground
3107
3108 // ---------------------------------------------------------------------------
3109 // moving and resizing
3110 // ---------------------------------------------------------------------------
3111
3112 bool wxWindow::HandleMinimize()
3113 {
3114 wxIconizeEvent vEvent(m_windowId);
3115
3116 vEvent.SetEventObject(this);
3117 return GetEventHandler()->ProcessEvent(vEvent);
3118 } // end of wxWindow::HandleMinimize
3119
3120 bool wxWindow::HandleMaximize()
3121 {
3122 wxMaximizeEvent vEvent(m_windowId);
3123
3124 vEvent.SetEventObject(this);
3125 return GetEventHandler()->ProcessEvent(vEvent);
3126 } // end of wxWindow::HandleMaximize
3127
3128 bool wxWindow::HandleMove(
3129 int nX
3130 , int nY
3131 )
3132 {
3133 wxMoveEvent vEvent( wxPoint( nX
3134 ,nY
3135 )
3136 ,m_windowId
3137 );
3138
3139 vEvent.SetEventObject(this);
3140 return GetEventHandler()->ProcessEvent(vEvent);
3141 } // end of wxWindow::HandleMove
3142
3143 bool wxWindow::HandleSize(
3144 int nWidth
3145 , int nHeight
3146 , WXUINT WXUNUSED(nFlag)
3147 )
3148 {
3149 wxSizeEvent vEvent( wxSize( nWidth
3150 ,nHeight
3151 )
3152 ,m_windowId
3153 );
3154
3155 vEvent.SetEventObject(this);
3156 return GetEventHandler()->ProcessEvent(vEvent);
3157 } // end of wxWindow::HandleSize
3158
3159 bool wxWindow::HandleGetMinMaxInfo(
3160 PSWP pSwp
3161 )
3162 {
3163 bool bRc = FALSE;
3164 POINTL vPoint;
3165
3166 switch(pSwp->fl)
3167 {
3168 case SWP_MAXIMIZE:
3169 ::WinGetMaxPosition(GetHwnd(), pSwp);
3170 m_maxWidth = pSwp->cx;
3171 m_maxHeight = pSwp->cy;
3172 break;
3173
3174 case SWP_MINIMIZE:
3175 ::WinGetMinPosition(GetHwnd(), pSwp, &vPoint);
3176 m_minWidth = pSwp->cx;
3177 m_minHeight = pSwp->cy;
3178 break;
3179
3180 default:
3181 return FALSE;
3182 }
3183 return TRUE;
3184 } // end of wxWindow::HandleGetMinMaxInfo
3185
3186 // ---------------------------------------------------------------------------
3187 // command messages
3188 // ---------------------------------------------------------------------------
3189 bool wxWindow::HandleCommand(
3190 WXWORD wId
3191 , WXWORD wCmd
3192 , WXHWND hControl
3193 )
3194 {
3195 if (wxCurrentPopupMenu)
3196 {
3197 wxMenu* pPopupMenu = wxCurrentPopupMenu;
3198
3199 wxCurrentPopupMenu = NULL;
3200 return pPopupMenu->OS2Command(wCmd, wId);
3201 }
3202
3203 wxWindow* pWin = FindItem(wId);
3204
3205 if (!pWin)
3206 {
3207 pWin = wxFindWinFromHandle(hControl);
3208 }
3209
3210 if (pWin)
3211 return pWin->OS2Command( wCmd
3212 ,wId
3213 );
3214 return FALSE;
3215 } // end of wxWindow::HandleCommand
3216
3217 bool wxWindow::HandleSysCommand(
3218 WXWPARAM wParam
3219 , WXLPARAM lParam
3220 )
3221 {
3222 //
3223 // 4 bits are reserved
3224 //
3225 switch (SHORT1FROMMP(wParam))
3226 {
3227 case SC_MAXIMIZE:
3228 return HandleMaximize();
3229
3230 case SC_MINIMIZE:
3231 return HandleMinimize();
3232 }
3233 return FALSE;
3234 } // end of wxWindow::HandleSysCommand
3235
3236 // ---------------------------------------------------------------------------
3237 // mouse events
3238 // ---------------------------------------------------------------------------
3239
3240 void wxWindow::InitMouseEvent(
3241 wxMouseEvent& rEvent
3242 , int nX
3243 , int nY
3244 , WXUINT uFlags
3245 )
3246 {
3247 rEvent.m_x = nX;
3248 rEvent.m_y = nY;
3249 rEvent.m_shiftDown = ((uFlags & VK_SHIFT) != 0);
3250 rEvent.m_controlDown = ((uFlags & VK_CTRL) != 0);
3251 rEvent.m_leftDown = ((uFlags & VK_BUTTON1) != 0);
3252 rEvent.m_middleDown = ((uFlags & VK_BUTTON3) != 0);
3253 rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0);
3254 rEvent.SetTimestamp(s_currentMsg.time);
3255 rEvent.m_eventObject = this;
3256
3257 #if wxUSE_MOUSEEVENT_HACK
3258 m_lastMouseX = nX;
3259 m_lastMouseY = nY;
3260 m_lastMouseEvent = rEvent.GetEventType();
3261 #endif // wxUSE_MOUSEEVENT_HACK
3262 } // end of wxWindow::InitMouseEvent
3263
3264 bool wxWindow::HandleMouseEvent(
3265 WXUINT uMsg
3266 , int nX
3267 , int nY
3268 , WXUINT uFlags
3269 )
3270 {
3271 //
3272 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3273 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3274 // from the message id and take the value in the table to get wxWin event
3275 // id
3276 //
3277 static const wxEventType eventsMouse[] =
3278 {
3279 wxEVT_MOTION,
3280 wxEVT_LEFT_DOWN,
3281 wxEVT_LEFT_UP,
3282 wxEVT_LEFT_DCLICK,
3283 wxEVT_RIGHT_DOWN,
3284 wxEVT_RIGHT_UP,
3285 wxEVT_RIGHT_DCLICK,
3286 wxEVT_MIDDLE_DOWN,
3287 wxEVT_MIDDLE_UP,
3288 wxEVT_MIDDLE_DCLICK
3289 };
3290
3291 wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]);
3292
3293 InitMouseEvent( vEvent
3294 ,nX
3295 ,nY
3296 ,uFlags
3297 );
3298
3299 return GetEventHandler()->ProcessEvent(vEvent);
3300 } // end of wxWindow::HandleMouseEvent
3301
3302 bool wxWindow::HandleMouseMove(
3303 int nX
3304 , int nY
3305 , WXUINT uFlags
3306 )
3307 {
3308 if (!m_bMouseInWindow)
3309 {
3310 //
3311 // Generate an ENTER event
3312 //
3313 m_bMouseInWindow = TRUE;
3314
3315 wxMouseEvent vEvent(wxEVT_ENTER_WINDOW);
3316
3317 InitMouseEvent( vEvent
3318 ,nX
3319 ,nY
3320 ,uFlags
3321 );
3322
3323 (void)GetEventHandler()->ProcessEvent(vEvent);
3324 }
3325 return HandleMouseEvent( WM_MOUSEMOVE
3326 ,nX
3327 ,nY
3328 ,uFlags
3329 );
3330 } // end of wxWindow::HandleMouseMove
3331
3332 // ---------------------------------------------------------------------------
3333 // keyboard handling
3334 // ---------------------------------------------------------------------------
3335
3336 //
3337 // Create the key event of the given type for the given key - used by
3338 // HandleChar and HandleKeyDown/Up
3339 //
3340 wxKeyEvent wxWindow::CreateKeyEvent(
3341 wxEventType eType
3342 , int nId
3343 , WXLPARAM lParam
3344 ) const
3345 {
3346 wxKeyEvent vEvent(eType);
3347
3348 vEvent.SetId(GetId());
3349 vEvent.m_shiftDown = IsShiftDown();
3350 vEvent.m_controlDown = IsCtrlDown();
3351 vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT;
3352
3353 vEvent.m_eventObject = (wxWindow *)this; // const_cast
3354 vEvent.m_keyCode = nId;
3355 vEvent.SetTimestamp(s_currentMsg.time);
3356
3357 //
3358 // Translate the position to client coords
3359 //
3360 POINTL vPoint;
3361 RECTL vRect;
3362
3363 ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
3364 ::WinQueryWindowRect( GetHwnd()
3365 ,&vRect
3366 );
3367
3368 vPoint.x -= vRect.xLeft;
3369 vPoint.y -= vRect.yBottom;
3370
3371 vEvent.m_x = vPoint.x;
3372 vEvent.m_y = vPoint.y;
3373
3374 return vEvent;
3375 } // end of wxWindow::CreateKeyEvent
3376
3377 //
3378 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3379 // WM_KEYDOWN one
3380 //
3381 bool wxWindow::HandleChar(
3382 WXWORD wParam
3383 , WXLPARAM lParam
3384 , bool isASCII
3385 )
3386 {
3387 bool bCtrlDown = FALSE;
3388 int vId;
3389
3390 if (isASCII)
3391 {
3392 //
3393 // If 1 -> 26, translate to CTRL plus a letter.
3394 //
3395 vId = wParam;
3396 if ((vId > 0) && (vId < 27))
3397 {
3398 switch (vId)
3399 {
3400 case 13:
3401 vId = WXK_RETURN;
3402 break;
3403
3404 case 8:
3405 vId = WXK_BACK;
3406 break;
3407
3408 case 9:
3409 vId = WXK_TAB;
3410 break;
3411
3412 default:
3413 bCtrlDown = TRUE;
3414 vId = vId + 96;
3415 }
3416 }
3417 }
3418 else if ( (vId = wxCharCodeOS2ToWX(wParam)) == 0)
3419 {
3420 //
3421 // It's ASCII and will be processed here only when called from
3422 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3423 //
3424 vId = -1;
3425 }
3426
3427 if (vId != -1)
3428 {
3429 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR
3430 ,vId
3431 ,lParam
3432 ));
3433
3434 if (bCtrlDown)
3435 {
3436 vEvent.m_controlDown = TRUE;
3437 }
3438
3439 if (GetEventHandler()->ProcessEvent(vEvent))
3440 return TRUE;
3441 }
3442 return FALSE;
3443 }
3444
3445 bool wxWindow::HandleKeyDown(
3446 WXWORD wParam
3447 , WXLPARAM lParam
3448 )
3449 {
3450 int nId = wxCharCodeOS2ToWX(wParam);
3451
3452 if (!nId)
3453 {
3454 //
3455 // Normal ASCII char
3456 //
3457 nId = wParam;
3458 }
3459
3460 if (nId != -1)
3461 {
3462 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3463 ,nId
3464 ,lParam
3465 ));
3466
3467 if (GetEventHandler()->ProcessEvent(vEvent))
3468 {
3469 return TRUE;
3470 }
3471 }
3472 return FALSE;
3473 } // end of wxWindow::HandleKeyDown
3474
3475 bool wxWindow::HandleKeyUp(
3476 WXWORD wParam
3477 , WXLPARAM lParam
3478 )
3479 {
3480 int nId = wxCharCodeOS2ToWX(wParam);
3481
3482 if (!nId)
3483 {
3484 //
3485 // Normal ASCII char
3486 //
3487 nId = wParam;
3488 }
3489
3490 if (nId != -1)
3491 {
3492 wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP
3493 ,nId
3494 ,lParam
3495 ));
3496
3497 if (GetEventHandler()->ProcessEvent(vEvent))
3498 return TRUE;
3499 }
3500 return FALSE;
3501 } // end of wxWindow::HandleKeyUp
3502
3503 // ---------------------------------------------------------------------------
3504 // joystick
3505 // ---------------------------------------------------------------------------
3506
3507 // ---------------------------------------------------------------------------
3508 // scrolling
3509 // ---------------------------------------------------------------------------
3510
3511 bool wxWindow::OS2OnScroll(
3512 int nOrientation
3513 , WXWORD wParam
3514 , WXWORD wPos
3515 , WXHWND hControl
3516 )
3517 {
3518 if (hControl)
3519 {
3520 wxWindow* pChild = wxFindWinFromHandle(hControl);
3521
3522 if (pChild )
3523 return pChild->OS2OnScroll( nOrientation
3524 ,wParam
3525 ,wPos
3526 ,hControl
3527 );
3528 }
3529
3530 wxScrollWinEvent vEvent;
3531
3532 vEvent.SetPosition(wPos);
3533 vEvent.SetOrientation(nOrientation);
3534 vEvent.m_eventObject = this;
3535
3536 switch (wParam)
3537 {
3538 case SB_LINEUP:
3539 vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
3540 break;
3541
3542 case SB_LINEDOWN:
3543 vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
3544 break;
3545
3546 case SB_PAGEUP:
3547 vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
3548 break;
3549
3550 case SB_PAGEDOWN:
3551 vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
3552 break;
3553
3554 case SB_SLIDERPOSITION:
3555 vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
3556 break;
3557
3558 case SB_SLIDERTRACK:
3559 vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
3560 break;
3561
3562 default:
3563 return FALSE;
3564 }
3565 return GetEventHandler()->ProcessEvent(vEvent);
3566 } // end of wxWindow::OS2OnScroll
3567
3568 // ===========================================================================
3569 // global functions
3570 // ===========================================================================
3571
3572 void wxGetCharSize(
3573 WXHWND hWnd
3574 , int* pX
3575 , int* pY
3576 ,wxFont* pTheFont
3577 )
3578 {
3579 // TODO: we'll do this later
3580 } // end of wxGetCharSize
3581
3582 //
3583 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
3584 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3585 //
3586 int wxCharCodeOS2ToWX(
3587 int nKeySym
3588 )
3589 {
3590 int nId = 0;
3591
3592 switch (nKeySym)
3593 {
3594 case VK_BACKTAB: nId = WXK_BACK; break;
3595 case VK_TAB: nId = WXK_TAB; break;
3596 case VK_CLEAR: nId = WXK_CLEAR; break;
3597 case VK_ENTER: nId = WXK_RETURN; break;
3598 case VK_SHIFT: nId = WXK_SHIFT; break;
3599 case VK_CTRL: nId = WXK_CONTROL; break;
3600 case VK_PAUSE: nId = WXK_PAUSE; break;
3601 case VK_SPACE: nId = WXK_SPACE; break;
3602 case VK_ESC: nId = WXK_ESCAPE; break;
3603 case VK_END: nId = WXK_END; break;
3604 case VK_HOME : nId = WXK_HOME; break;
3605 case VK_LEFT : nId = WXK_LEFT; break;
3606 case VK_UP: nId = WXK_UP; break;
3607 case VK_RIGHT: nId = WXK_RIGHT; break;
3608 case VK_DOWN : nId = WXK_DOWN; break;
3609 case VK_PRINTSCRN: nId = WXK_PRINT; break;
3610 case VK_INSERT: nId = WXK_INSERT; break;
3611 case VK_DELETE: nId = WXK_DELETE; break;
3612 case VK_F1: nId = WXK_F1; break;
3613 case VK_F2: nId = WXK_F2; break;
3614 case VK_F3: nId = WXK_F3; break;
3615 case VK_F4: nId = WXK_F4; break;
3616 case VK_F5: nId = WXK_F5; break;
3617 case VK_F6: nId = WXK_F6; break;
3618 case VK_F7: nId = WXK_F7; break;
3619 case VK_F8: nId = WXK_F8; break;
3620 case VK_F9: nId = WXK_F9; break;
3621 case VK_F10: nId = WXK_F10; break;
3622 case VK_F11: nId = WXK_F11; break;
3623 case VK_F12: nId = WXK_F12; break;
3624 case VK_F13: nId = WXK_F13; break;
3625 case VK_F14: nId = WXK_F14; break;
3626 case VK_F15: nId = WXK_F15; break;
3627 case VK_F16: nId = WXK_F16; break;
3628 case VK_F17: nId = WXK_F17; break;
3629 case VK_F18: nId = WXK_F18; break;
3630 case VK_F19: nId = WXK_F19; break;
3631 case VK_F20: nId = WXK_F20; break;
3632 case VK_F21: nId = WXK_F21; break;
3633 case VK_F22: nId = WXK_F22; break;
3634 case VK_F23: nId = WXK_F23; break;
3635 case VK_F24: nId = WXK_F24; break;
3636 case VK_NUMLOCK: nId = WXK_NUMLOCK; break;
3637 case VK_SCRLLOCK: nId = WXK_SCROLL; break;
3638 default:
3639 {
3640 return 0;
3641 }
3642 }
3643 return nId;
3644 } // end of wxCharCodeOS2ToWX
3645
3646 int wxCharCodeWXToOS2(
3647 int nId
3648 , bool* bIsVirtual
3649 )
3650 {
3651 int nKeySym = 0;
3652
3653 *bIsVirtual = TRUE;
3654 switch (nId)
3655 {
3656 case WXK_CLEAR: nKeySym = VK_CLEAR; break;
3657 case WXK_SHIFT: nKeySym = VK_SHIFT; break;
3658 case WXK_CONTROL: nKeySym = VK_CTRL; break;
3659 case WXK_PAUSE: nKeySym = VK_PAUSE; break;
3660 case WXK_END: nKeySym = VK_END; break;
3661 case WXK_HOME : nKeySym = VK_HOME; break;
3662 case WXK_LEFT : nKeySym = VK_LEFT; break;
3663 case WXK_UP: nKeySym = VK_UP; break;
3664 case WXK_RIGHT: nKeySym = VK_RIGHT; break;
3665 case WXK_DOWN : nKeySym = VK_DOWN; break;
3666 case WXK_PRINT: nKeySym = VK_PRINTSCRN; break;
3667 case WXK_INSERT: nKeySym = VK_INSERT; break;
3668 case WXK_DELETE: nKeySym = VK_DELETE; break;
3669 case WXK_F1: nKeySym = VK_F1; break;
3670 case WXK_F2: nKeySym = VK_F2; break;
3671 case WXK_F3: nKeySym = VK_F3; break;
3672 case WXK_F4: nKeySym = VK_F4; break;
3673 case WXK_F5: nKeySym = VK_F5; break;
3674 case WXK_F6: nKeySym = VK_F6; break;
3675 case WXK_F7: nKeySym = VK_F7; break;
3676 case WXK_F8: nKeySym = VK_F8; break;
3677 case WXK_F9: nKeySym = VK_F9; break;
3678 case WXK_F10: nKeySym = VK_F10; break;
3679 case WXK_F11: nKeySym = VK_F11; break;
3680 case WXK_F12: nKeySym = VK_F12; break;
3681 case WXK_F13: nKeySym = VK_F13; break;
3682 case WXK_F14: nKeySym = VK_F14; break;
3683 case WXK_F15: nKeySym = VK_F15; break;
3684 case WXK_F16: nKeySym = VK_F16; break;
3685 case WXK_F17: nKeySym = VK_F17; break;
3686 case WXK_F18: nKeySym = VK_F18; break;
3687 case WXK_F19: nKeySym = VK_F19; break;
3688 case WXK_F20: nKeySym = VK_F20; break;
3689 case WXK_F21: nKeySym = VK_F21; break;
3690 case WXK_F22: nKeySym = VK_F22; break;
3691 case WXK_F23: nKeySym = VK_F23; break;
3692 case WXK_F24: nKeySym = VK_F24; break;
3693 case WXK_NUMLOCK: nKeySym = VK_NUMLOCK; break;
3694 case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break;
3695 default:
3696 {
3697 *bIsVirtual = FALSE;
3698 nKeySym = nId;
3699 break;
3700 }
3701 }
3702 return nKeySym;
3703 } // end of wxCharCodeWXToOS2
3704
3705 wxWindow* wxGetActiveWindow()
3706 {
3707 HWND hWnd = ::WinQueryActiveWindow(HWND_DESKTOP);
3708
3709 if (hWnd != 0)
3710 {
3711 return wxFindWinFromHandle((WXHWND)hWnd);
3712 }
3713 return NULL;
3714 } // end of wxGetActiveWindow
3715
3716 #ifdef __WXDEBUG__
3717 const char* wxGetMessageName(
3718 int nMessage)
3719 {
3720 switch (nMessage)
3721 {
3722 case 0x0000: return "WM_NULL";
3723 case 0x0001: return "WM_CREATE";
3724 case 0x0002: return "WM_DESTROY";
3725 case 0x0004: return "WM_ENABLE";
3726 case 0x0005: return "WM_SHOW";
3727 case 0x0006: return "WM_MOVE";
3728 case 0x0007: return "WM_SIZE";
3729 case 0x0008: return "WM_ADJUSTWINDOWPOS";
3730 case 0x0009: return "WM_CALCVALIDRECTS";
3731 case 0x000A: return "WM_SETWINDOWPARAMS";
3732 case 0x000B: return "WM_QUERYWINDOWPARAMS";
3733 case 0x000C: return "WM_HITTEST";
3734 case 0x000D: return "WM_ACTIVATE";
3735 case 0x000F: return "WM_SETFOCUS";
3736 case 0x0010: return "WM_SETSELECTION";
3737 case 0x0011: return "WM_PPAINT";
3738 case 0x0012: return "WM_PSETFOCUS";
3739 case 0x0013: return "WM_PSYSCOLORCHANGE";
3740 case 0x0014: return "WM_PSIZE";
3741 case 0x0015: return "WM_PACTIVATE";
3742 case 0x0016: return "WM_PCONTROL";
3743 case 0x0020: return "WM_COMMAND";
3744 case 0x0021: return "WM_SYSCOMMAND";
3745 case 0x0022: return "WM_HELP";
3746 case 0x0023: return "WM_PAINT";
3747 case 0x0024: return "WM_TIMER";
3748 case 0x0025: return "WM_SEM1";
3749 case 0x0026: return "WM_SEM2";
3750 case 0x0027: return "WM_SEM3";
3751 case 0x0028: return "WM_SEM4";
3752 case 0x0029: return "WM_CLOSE";
3753 case 0x002A: return "WM_QUIT";
3754 case 0x002B: return "WM_SYSCOLORCHANGE";
3755 case 0x002D: return "WM_SYSVALUECHANGE";
3756 case 0x002E: return "WM_APPTERMINATENOTIFY";
3757 case 0x002F: return "WM_PRESPARAMCHANGED";
3758 // Control notification messages
3759 case 0x0030: return "WM_CONTROL";
3760 case 0x0031: return "WM_VSCROLL";
3761 case 0x0032: return "WM_HSCROLL";
3762 case 0x0033: return "WM_INITMENU";
3763 case 0x0034: return "WM_MENUSELECT";
3764 case 0x0035: return "WM_MENUSEND";
3765 case 0x0036: return "WM_DRAWITEM";
3766 case 0x0037: return "WM_MEASUREITEM";
3767 case 0x0038: return "WM_CONTROLPOINTER";
3768 case 0x003A: return "WM_QUERYDLGCODE";
3769 case 0x003B: return "WM_INITDLG";
3770 case 0x003C: return "WM_SUBSTITUTESTRING";
3771 case 0x003D: return "WM_MATCHMNEMONIC";
3772 case 0x003E: return "WM_SAVEAPPLICATION";
3773 case 0x0129: return "WM_CTLCOLORCHANGE";
3774 case 0x0130: return "WM_QUERYCTLTYPE";
3775 // Frame messages
3776 case 0x0040: return "WM_FLASHWINDOW";
3777 case 0x0041: return "WM_FORMATFRAME";
3778 case 0x0042: return "WM_UPDATEFRAME";
3779 case 0x0043: return "WM_FOCUSCHANGE";
3780 case 0x0044: return "WM_SETBORDERSIZE";
3781 case 0x0045: return "WM_TRACKFRAME";
3782 case 0x0046: return "WM_MINMAXFRAME";
3783 case 0x0047: return "WM_SETICON";
3784 case 0x0048: return "WM_QUERYICON";
3785 case 0x0049: return "WM_SETACCELTABLE";
3786 case 0x004A: return "WM_QUERYACCELTABLE";
3787 case 0x004B: return "WM_TRANSLATEACCEL";
3788 case 0x004C: return "WM_QUERYTRACKINFO";
3789 case 0x004D: return "WM_QUERYBORDERSIZE";
3790 case 0x004E: return "WM_NEXTMENU";
3791 case 0x004F: return "WM_ERASEBACKGROUND";
3792 case 0x0050: return "WM_QUERYFRAMEINFO";
3793 case 0x0051: return "WM_QUERYFOCUSCHAIN";
3794 case 0x0052: return "WM_OWNERPOSCHANGE";
3795 case 0x0053: return "WM_CACLFRAMERECT";
3796 case 0x0055: return "WM_WINDOWPOSCHANGED";
3797 case 0x0056: return "WM_ADJUSTFRAMEPOS";
3798 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
3799 case 0x005B: return "WM_QUERYHELPINFO";
3800 case 0x005C: return "WM_SETHELPINFO";
3801 case 0x005D: return "WM_ERROR";
3802 case 0x005E: return "WM_REALIZEPALETTE";
3803 // Clipboard messages
3804 case 0x0060: return "WM_RENDERFMT";
3805 case 0x0061: return "WM_RENDERALLFMTS";
3806 case 0x0062: return "WM_DESTROYCLIPBOARD";
3807 case 0x0063: return "WM_PAINTCLIPBOARD";
3808 case 0x0064: return "WM_SIZECLIPBOARD";
3809 case 0x0065: return "WM_HSCROLLCLIPBOARD";
3810 case 0x0066: return "WM_VSCROLLCLIPBOARD";
3811 case 0x0067: return "WM_DRAWCLIPBOARD";
3812 // mouse messages
3813 case 0x0070: return "WM_MOUSEMOVE";
3814 case 0x0071: return "WM_BUTTON1DOWN";
3815 case 0x0072: return "WM_BUTTON1UP";
3816 case 0x0073: return "WM_BUTTON1DBLCLK";
3817 case 0x0074: return "WM_BUTTON2DOWN";
3818 case 0x0075: return "WM_BUTTON2UP";
3819 case 0x0076: return "WM_BUTTON2DBLCLK";
3820 case 0x0077: return "WM_BUTTON3DOWN";
3821 case 0x0078: return "WM_BUTTON3UP";
3822 case 0x0079: return "WM_BUTTON3DBLCLK";
3823 case 0x007D: return "WM_MOUSEMAP";
3824 case 0x007E: return "WM_VRNDISABLED";
3825 case 0x007F: return "WM_VRNENABLED";
3826 case 0x0410: return "WM_CHORD";
3827 case 0x0411: return "WM_BUTTON1MOTIONSTART";
3828 case 0x0412: return "WM_BUTTON1MOTIONEND";
3829 case 0x0413: return "WM_BUTTON1CLICK";
3830 case 0x0414: return "WM_BUTTON2MOTIONSTART";
3831 case 0x0415: return "WM_BUTTON2MOTIONEND";
3832 case 0x0416: return "WM_BUTTON2CLICK";
3833 case 0x0417: return "WM_BUTTON3MOTIONSTART";
3834 case 0x0418: return "WM_BUTTON3MOTIONEND";
3835 case 0x0419: return "WM_BUTTON3CLICK";
3836 case 0x0420: return "WM_BEGINDRAG";
3837 case 0x0421: return "WM_ENDDRAG";
3838 case 0x0422: return "WM_SINGLESELECT";
3839 case 0x0423: return "WM_OPEN";
3840 case 0x0424: return "WM_CONTEXTMENU";
3841 case 0x0425: return "WM_CONTEXTHELP";
3842 case 0x0426: return "WM_TEXTEDIT";
3843 case 0x0427: return "WM_BEGINSELECT";
3844 case 0x0228: return "WM_ENDSELECT";
3845 case 0x0429: return "WM_PICKUP";
3846 case 0x04C0: return "WM_PENFIRST";
3847 case 0x04FF: return "WM_PENLAST";
3848 case 0x0500: return "WM_MMPMFIRST";
3849 case 0x05FF: return "WM_MMPMLAST";
3850 case 0x0600: return "WM_STDDLGFIRST";
3851 case 0x06FF: return "WM_STDDLGLAST";
3852 case 0x0BD0: return "WM_BIDI_FIRST";
3853 case 0x0BFF: return "WM_BIDI_LAST";
3854 // keyboard input
3855 case 0x007A: return "WM_CHAR";
3856 case 0x007B: return "WM_VIOCHAR";
3857 // DDE messages
3858 case 0x00A0: return "WM_DDE_INITIATE";
3859 case 0x00A1: return "WM_DDE_REQUEST";
3860 case 0x00A2: return "WM_DDE_ACK";
3861 case 0x00A3: return "WM_DDE_DATA";
3862 case 0x00A4: return "WM_DDE_ADVISE";
3863 case 0x00A5: return "WM_DDE_UNADVISE";
3864 case 0x00A6: return "WM_DDE_POKE";
3865 case 0x00A7: return "WM_DDE_EXECUTE";
3866 case 0x00A8: return "WM_DDE_TERMINATE";
3867 case 0x00A9: return "WM_DDE_INITIATEACK";
3868 case 0x00AF: return "WM_DDE_LAST";
3869 // Buttons
3870 case 0x0120: return "BM_CLICK";
3871 case 0x0121: return "BM_QUERYCHECKINDEX";
3872 case 0x0122: return "BM_QUERYHILITE";
3873 case 0x0123: return "BM_SETHILITE";
3874 case 0x0124: return "BM_QUERYCHECK";
3875 case 0x0125: return "BM_SETCHECK";
3876 case 0x0126: return "BM_SETDEFAULT";
3877 case 0x0128: return "BM_AUTOSIZE";
3878 // Combo boxes
3879 case 0x029A: return "CBID_LIST";
3880 case 0x029B: return "CBID_EDIT";
3881 case 0x0170: return "CBM_SHOWLIST";
3882 case 0x0171: return "CBM_HILITE";
3883 case 0x0172: return "CBM_ISLISTSHOWING";
3884 // Edit fields
3885 case 0x0140: return "EM_QUERYCHANGED";
3886 case 0x0141: return "EM_QUERYSEL";
3887 case 0x0142: return "EM_SETSEL";
3888 case 0x0143: return "EM_SETTEXTLIMIT";
3889 case 0x0144: return "EM_CUT";
3890 case 0x0145: return "EM_COPY";
3891 case 0x0146: return "EM_CLEAR";
3892 case 0x0147: return "EM_PASTE";
3893 case 0x0148: return "EM_QUERYFIRSTCHAR";
3894 case 0x0149: return "EM_SETFIRSTCHAR";
3895 case 0x014A: return "EM_QUERYREADONLY";
3896 case 0x014B: return "EM_SETREADONLY";
3897 case 0x014C: return "EM_SETINSERTMODE";
3898 // Listboxes
3899 case 0x0160: return "LM_QUERYITEMCOUNT";
3900 case 0x0161: return "LM_INSERTITEM";
3901 case 0x0162: return "LM_SETOPENINDEX";
3902 case 0x0163: return "LM_DELETEITEM";
3903 case 0x0164: return "LM_SELECTITEM";
3904 case 0x0165: return "LM_QUERYSELECTION";
3905 case 0x0166: return "LM_SETITEMTEXT";
3906 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
3907 case 0x0168: return "LM_QUERYITEMTEXT";
3908 case 0x0169: return "LM_SETITEMHANDLE";
3909 case 0x016A: return "LM_QUERYITEMHANDLE";
3910 case 0x016B: return "LM_SEARCHSTRING";
3911 case 0x016C: return "LM_SETITEMHEIGHT";
3912 case 0x016D: return "LM_QUERYTOPINDEX";
3913 case 0x016E: return "LM_DELETEALL";
3914 case 0x016F: return "LM_INSERTMULITEMS";
3915 case 0x0660: return "LM_SETITEMWIDTH";
3916 // Menus
3917 case 0x0180: return "MM_INSERTITEM";
3918 case 0x0181: return "MM_DELETEITEM";
3919 case 0x0182: return "MM_QUERYITEM";
3920 case 0x0183: return "MM_SETITEM";
3921 case 0x0184: return "MM_QUERYITEMCOUNT";
3922 case 0x0185: return "MM_STARTMENUMODE";
3923 case 0x0186: return "MM_ENDMENUMODE";
3924 case 0x0188: return "MM_REMOVEITEM";
3925 case 0x0189: return "MM_SELECTITEM";
3926 case 0x018A: return "MM_QUERYSELITEMID";
3927 case 0x018B: return "MM_QUERYITEMTEXT";
3928 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
3929 case 0x018D: return "MM_SETITEMHANDLE";
3930 case 0x018E: return "MM_SETITEMTEXT";
3931 case 0x018F: return "MM_ITEMPOSITIONFROMID";
3932 case 0x0190: return "MM_ITEMIDFROMPOSITION";
3933 case 0x0191: return "MM_QUERYITEMATTR";
3934 case 0x0192: return "MM_SETITEMATTR";
3935 case 0x0193: return "MM_ISITEMVALID";
3936 case 0x0194: return "MM_QUERYITEMRECT";
3937 case 0x0431: return "MM_QUERYDEFAULTITEMID";
3938 case 0x0432: return "MM_SETDEFAULTITEMID";
3939 // Scrollbars
3940 case 0x01A0: return "SBM_SETSCROLLBAR";
3941 case 0x01A1: return "SBM_SETPOS";
3942 case 0x01A2: return "SBM_QUERYPOS";
3943 case 0x01A3: return "SBM_QUERYRANGE";
3944 case 0x01A6: return "SBM_SETTHUMBSIZE";
3945
3946 // Help messages
3947 case 0x0F00: return "WM_HELPBASE";
3948 case 0x0FFF: return "WM_HELPTOP";
3949 // Beginning of user defined messages
3950 case 0x1000: return "WM_USER";
3951
3952 // wxWindows user defined types
3953
3954 // listview
3955 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
3956 case 0x1000 + 1: return "LVM_SETBKCOLOR";
3957 case 0x1000 + 2: return "LVM_GETIMAGELIST";
3958 case 0x1000 + 3: return "LVM_SETIMAGELIST";
3959 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
3960 case 0x1000 + 5: return "LVM_GETITEMA";
3961 case 0x1000 + 75: return "LVM_GETITEMW";
3962 case 0x1000 + 6: return "LVM_SETITEMA";
3963 case 0x1000 + 76: return "LVM_SETITEMW";
3964 case 0x1000 + 7: return "LVM_INSERTITEMA";
3965 case 0x1000 + 77: return "LVM_INSERTITEMW";
3966 case 0x1000 + 8: return "LVM_DELETEITEM";
3967 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
3968 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
3969 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
3970 case 0x1000 + 12: return "LVM_GETNEXTITEM";
3971 case 0x1000 + 13: return "LVM_FINDITEMA";
3972 case 0x1000 + 83: return "LVM_FINDITEMW";
3973 case 0x1000 + 14: return "LVM_GETITEMRECT";
3974 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
3975 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
3976 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
3977 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
3978 case 0x1000 + 18: return "LVM_HITTEST";
3979 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
3980 case 0x1000 + 20: return "LVM_SCROLL";
3981 case 0x1000 + 21: return "LVM_REDRAWITEMS";
3982 case 0x1000 + 22: return "LVM_ARRANGE";
3983 case 0x1000 + 23: return "LVM_EDITLABELA";
3984 case 0x1000 + 118: return "LVM_EDITLABELW";
3985 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
3986 case 0x1000 + 25: return "LVM_GETCOLUMNA";
3987 case 0x1000 + 95: return "LVM_GETCOLUMNW";
3988 case 0x1000 + 26: return "LVM_SETCOLUMNA";
3989 case 0x1000 + 96: return "LVM_SETCOLUMNW";
3990 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
3991 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
3992 case 0x1000 + 28: return "LVM_DELETECOLUMN";
3993 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
3994 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
3995 case 0x1000 + 31: return "LVM_GETHEADER";
3996 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
3997 case 0x1000 + 34: return "LVM_GETVIEWRECT";
3998 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
3999 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4000 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4001 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4002 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4003 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4004 case 0x1000 + 41: return "LVM_GETORIGIN";
4005 case 0x1000 + 42: return "LVM_UPDATE";
4006 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4007 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4008 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4009 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4010 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4011 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4012 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4013 case 0x1000 + 48: return "LVM_SORTITEMS";
4014 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4015 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4016 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4017 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4018 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4019 case 0x1000 + 53: return "LVM_SETICONSPACING";
4020 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4021 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4022 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4023 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4024 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4025 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4026 case 0x1000 + 60: return "LVM_SETHOTITEM";
4027 case 0x1000 + 61: return "LVM_GETHOTITEM";
4028 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4029 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4030 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4031 case 0x1000 + 65: return "LVM_SETWORKAREA";
4032
4033 // tree view
4034 case 0x1100 + 0: return "TVM_INSERTITEMA";
4035 case 0x1100 + 50: return "TVM_INSERTITEMW";
4036 case 0x1100 + 1: return "TVM_DELETEITEM";
4037 case 0x1100 + 2: return "TVM_EXPAND";
4038 case 0x1100 + 4: return "TVM_GETITEMRECT";
4039 case 0x1100 + 5: return "TVM_GETCOUNT";
4040 case 0x1100 + 6: return "TVM_GETINDENT";
4041 case 0x1100 + 7: return "TVM_SETINDENT";
4042 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4043 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4044 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4045 case 0x1100 + 11: return "TVM_SELECTITEM";
4046 case 0x1100 + 12: return "TVM_GETITEMA";
4047 case 0x1100 + 62: return "TVM_GETITEMW";
4048 case 0x1100 + 13: return "TVM_SETITEMA";
4049 case 0x1100 + 63: return "TVM_SETITEMW";
4050 case 0x1100 + 14: return "TVM_EDITLABELA";
4051 case 0x1100 + 65: return "TVM_EDITLABELW";
4052 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4053 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4054 case 0x1100 + 17: return "TVM_HITTEST";
4055 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4056 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4057 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4058 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4059 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4060 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4061 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4062 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4063 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4064
4065 // header
4066 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4067 case 0x1200 + 1: return "HDM_INSERTITEMA";
4068 case 0x1200 + 10: return "HDM_INSERTITEMW";
4069 case 0x1200 + 2: return "HDM_DELETEITEM";
4070 case 0x1200 + 3: return "HDM_GETITEMA";
4071 case 0x1200 + 11: return "HDM_GETITEMW";
4072 case 0x1200 + 4: return "HDM_SETITEMA";
4073 case 0x1200 + 12: return "HDM_SETITEMW";
4074 case 0x1200 + 5: return "HDM_LAYOUT";
4075 case 0x1200 + 6: return "HDM_HITTEST";
4076 case 0x1200 + 7: return "HDM_GETITEMRECT";
4077 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4078 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4079 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4080 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4081 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4082 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4083 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4084
4085 // tab control
4086 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4087 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4088 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4089 case 0x1300 + 5: return "TCM_GETITEMA";
4090 case 0x1300 + 60: return "TCM_GETITEMW";
4091 case 0x1300 + 6: return "TCM_SETITEMA";
4092 case 0x1300 + 61: return "TCM_SETITEMW";
4093 case 0x1300 + 7: return "TCM_INSERTITEMA";
4094 case 0x1300 + 62: return "TCM_INSERTITEMW";
4095 case 0x1300 + 8: return "TCM_DELETEITEM";
4096 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4097 case 0x1300 + 10: return "TCM_GETITEMRECT";
4098 case 0x1300 + 11: return "TCM_GETCURSEL";
4099 case 0x1300 + 12: return "TCM_SETCURSEL";
4100 case 0x1300 + 13: return "TCM_HITTEST";
4101 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4102 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4103 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4104 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4105 case 0x1300 + 43: return "TCM_SETPADDING";
4106 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4107 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4108 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4109 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4110 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4111 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4112 case 0x1300 + 50: return "TCM_DESELECTALL";
4113
4114 // toolbar
4115 case WM_USER+1000+1: return "TB_ENABLEBUTTON";
4116 case WM_USER+1000+2: return "TB_CHECKBUTTON";
4117 case WM_USER+1000+3: return "TB_PRESSBUTTON";
4118 case WM_USER+1000+4: return "TB_HIDEBUTTON";
4119 case WM_USER+1000+5: return "TB_INDETERMINATE";
4120 case WM_USER+1000+9: return "TB_ISBUTTONENABLED";
4121 case WM_USER+1000+10: return "TB_ISBUTTONCHECKED";
4122 case WM_USER+1000+11: return "TB_ISBUTTONPRESSED";
4123 case WM_USER+1000+12: return "TB_ISBUTTONHIDDEN";
4124 case WM_USER+1000+13: return "TB_ISBUTTONINDETERMINATE";
4125 case WM_USER+1000+17: return "TB_SETSTATE";
4126 case WM_USER+1000+18: return "TB_GETSTATE";
4127 case WM_USER+1000+19: return "TB_ADDBITMAP";
4128 case WM_USER+1000+20: return "TB_ADDBUTTONS";
4129 case WM_USER+1000+21: return "TB_INSERTBUTTON";
4130 case WM_USER+1000+22: return "TB_DELETEBUTTON";
4131 case WM_USER+1000+23: return "TB_GETBUTTON";
4132 case WM_USER+1000+24: return "TB_BUTTONCOUNT";
4133 case WM_USER+1000+25: return "TB_COMMANDTOINDEX";
4134 case WM_USER+1000+26: return "TB_SAVERESTOREA";
4135 case WM_USER+1000+76: return "TB_SAVERESTOREW";
4136 case WM_USER+1000+27: return "TB_CUSTOMIZE";
4137 case WM_USER+1000+28: return "TB_ADDSTRINGA";
4138 case WM_USER+1000+77: return "TB_ADDSTRINGW";
4139 case WM_USER+1000+29: return "TB_GETITEMRECT";
4140 case WM_USER+1000+30: return "TB_BUTTONSTRUCTSIZE";
4141 case WM_USER+1000+31: return "TB_SETBUTTONSIZE";
4142 case WM_USER+1000+32: return "TB_SETBITMAPSIZE";
4143 case WM_USER+1000+33: return "TB_AUTOSIZE";
4144 case WM_USER+1000+35: return "TB_GETTOOLTIPS";
4145 case WM_USER+1000+36: return "TB_SETTOOLTIPS";
4146 case WM_USER+1000+37: return "TB_SETPARENT";
4147 case WM_USER+1000+39: return "TB_SETROWS";
4148 case WM_USER+1000+40: return "TB_GETROWS";
4149 case WM_USER+1000+42: return "TB_SETCMDID";
4150 case WM_USER+1000+43: return "TB_CHANGEBITMAP";
4151 case WM_USER+1000+44: return "TB_GETBITMAP";
4152 case WM_USER+1000+45: return "TB_GETBUTTONTEXTA";
4153 case WM_USER+1000+75: return "TB_GETBUTTONTEXTW";
4154 case WM_USER+1000+46: return "TB_REPLACEBITMAP";
4155 case WM_USER+1000+47: return "TB_SETINDENT";
4156 case WM_USER+1000+48: return "TB_SETIMAGELIST";
4157 case WM_USER+1000+49: return "TB_GETIMAGELIST";
4158 case WM_USER+1000+50: return "TB_LOADIMAGES";
4159 case WM_USER+1000+51: return "TB_GETRECT";
4160 case WM_USER+1000+52: return "TB_SETHOTIMAGELIST";
4161 case WM_USER+1000+53: return "TB_GETHOTIMAGELIST";
4162 case WM_USER+1000+54: return "TB_SETDISABLEDIMAGELIST";
4163 case WM_USER+1000+55: return "TB_GETDISABLEDIMAGELIST";
4164 case WM_USER+1000+56: return "TB_SETSTYLE";
4165 case WM_USER+1000+57: return "TB_GETSTYLE";
4166 case WM_USER+1000+58: return "TB_GETBUTTONSIZE";
4167 case WM_USER+1000+59: return "TB_SETBUTTONWIDTH";
4168 case WM_USER+1000+60: return "TB_SETMAXTEXTROWS";
4169 case WM_USER+1000+61: return "TB_GETTEXTROWS";
4170 case WM_USER+1000+41: return "TB_GETBITMAPFLAGS";
4171
4172 default:
4173 static char s_szBuf[128];
4174 sprintf(s_szBuf, "<unknown message = %d>", nMessage);
4175 return s_szBuf;
4176 }
4177 return NULL;
4178 } // end of wxGetMessageName
4179
4180 #endif // __WXDEBUG__
4181
4182 static void TranslateKbdEventToMouse(
4183 wxWindow* pWin
4184 , int* pX
4185 , int* pY
4186 , ULONG* pFlags
4187 )
4188 {
4189 //
4190 // Construct the key mask
4191 ULONG& fwKeys = *pFlags;
4192
4193 fwKeys = VK_BUTTON2;
4194 if ((::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x100) != 0)
4195 fwKeys |= VK_CTRL;
4196 if ((::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x100) != 0)
4197 fwKeys |= VK_SHIFT;
4198
4199 //
4200 // Simulate right mouse button click
4201 //
4202 POINTL vPoint;
4203
4204 ::WinQueryMsgPos(vHabmain, &vPoint);
4205 *pX = vPoint.x;
4206 *pY = vPoint.y;
4207
4208 pWin->ScreenToClient(pX, pY);
4209 } // end of TranslateKbdEventToMouse
4210
4211 // Find the wxWindow at the current mouse position, returning the mouse
4212 // position.
4213 wxWindow* wxFindWindowAtPointer(
4214 wxPoint& rPt
4215 )
4216 {
4217 return wxFindWindowAtPoint(wxGetMousePosition());
4218 }
4219
4220 wxWindow* wxFindWindowAtPoint(
4221 const wxPoint& rPt
4222 )
4223 {
4224 POINTL vPt2;
4225
4226 vPt2.x = rPt.x;
4227 vPt2.y = rPt.y;
4228
4229 HWND hWndHit = ::WinWindowFromPoint(HWND_DESKTOP, &vPt2, FALSE);
4230 wxWindow* pWin = wxFindWinFromHandle((WXHWND)hWndHit) ;
4231 HWND hWnd = hWndHit;
4232
4233 //
4234 // Try to find a window with a wxWindow associated with it
4235 //
4236 while (!pWin && (hWnd != 0))
4237 {
4238 hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
4239 pWin = wxFindWinFromHandle((WXHWND)hWnd) ;
4240 }
4241 return pWin;
4242 }
4243
4244 // Get the current mouse position.
4245 wxPoint wxGetMousePosition()
4246 {
4247 POINTL vPt;
4248
4249 ::WinQueryPointerPos(HWND_DESKTOP, &vPt);
4250 return wxPoint(vPt.x, vPt.y);
4251 }
4252