1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  13 // For compilers that support precompilation, includes "wx.h". 
  15 #include "wx/wxprec.h" 
  21     #include "wx/window.h" 
  26     #include "wx/dcclient.h" 
  30     #include "wx/layout.h" 
  31     #include "wx/dialog.h" 
  33     #include "wx/listbox.h" 
  34     #include "wx/button.h" 
  35     #include "wx/msgdlg.h" 
  36     #include "wx/scrolwin.h" 
  42     #include "wx/ownerdrw.h" 
  45 #if     wxUSE_DRAG_AND_DROP 
  49 #include "wx/menuitem.h" 
  52 #include "wx/os2/private.h" 
  55     #include "wx/tooltip.h" 
  66 #include "wx/textctrl.h" 
  71 // Place compiler, OS specific includes here 
  75 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar 
  79 //  SHORT1FROMMP -- LOWORD 
  81     #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) 
  83 //  SHORT2FROMMP -- HIWORD 
  85     #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) 
  86 #endif // GET_X_LPARAM 
  89 #  define CW_USEDEFAULT    ((int)0x80000000) 
  92 // --------------------------------------------------------------------------- 
  94 // --------------------------------------------------------------------------- 
  97 // The last PM message we got (MT-UNSAFE) 
 101 #if wxUSE_MENUS_NATIVE 
 102 wxMenu
*                   wxCurrentPopupMenu 
= NULL
; 
 103 #endif // wxUSE_MENUS_NATIVE 
 105 wxList
*                   wxWinHandleList 
= NULL
; 
 107 // --------------------------------------------------------------------------- 
 109 // --------------------------------------------------------------------------- 
 112 // the window proc for all our windows; most gui's have something similar 
 114 MRESULT EXPENTRY 
wxWndProc( HWND hWnd
 
 121     const char *wxGetMessageName(int message
); 
 124 void      wxRemoveHandleAssociation(wxWindowOS2
* pWin
); 
 125 void      wxAssociateWinWithHandle( HWND         hWnd
 
 128 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
); 
 131 // This magical function is used to translate VK_APPS key presses to right 
 136 static void TranslateKbdEventToMouse( wxWindow
* pWin
 
 143 // get the current state of SHIFT/CTRL keys 
 145 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; } 
 146 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; } 
 148 static wxWindow
*                    gpWinBeingCreated 
= NULL
; 
 150 // --------------------------------------------------------------------------- 
 152 // --------------------------------------------------------------------------- 
 154 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu() 
 156 #ifdef __WXUNIVERSAL__ 
 157     IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
) 
 159     IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
) 
 160 #endif // __WXUNIVERSAL__/__WXPM__ 
 162 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
) 
 163     EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
) 
 164     EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
) 
 165     EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog
) 
 166     EVT_IDLE(wxWindowOS2::OnIdle
) 
 167     EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
) 
 170 // =========================================================================== 
 172 // =========================================================================== 
 174 // --------------------------------------------------------------------------- 
 175 // wxWindow utility functions 
 176 // --------------------------------------------------------------------------- 
 179 // Find an item given the PM Window id 
 181 wxWindow
* wxWindowOS2::FindItem( 
 186     wxControl
*                      pItem 
= wxDynamicCast(this, wxControl
); 
 191         // I it we or one of our "internal" children? 
 193         if (pItem
->GetId() == lId
 
 194 #ifndef __WXUNIVERSAL__ 
 195             || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
) 
 202 #endif // wxUSE_CONTROLS 
 204     wxWindowList::Node
*             pCurrent 
= GetChildren().GetFirst(); 
 208         wxWindow
*                   pChildWin 
= pCurrent
->GetData(); 
 209         wxWindow
*                   pWnd 
= pChildWin
->FindItem(lId
); 
 214         pCurrent 
= pCurrent
->GetNext(); 
 217 } // end of wxWindowOS2::FindItem 
 220 // Find an item given the PM Window handle 
 222 wxWindow
* wxWindowOS2::FindItemByHWND( 
 227     wxWindowList::Node
*             pCurrent 
= GetChildren().GetFirst(); 
 231         wxWindow
*                   pParent 
= pCurrent
->GetData(); 
 234         // Do a recursive search. 
 236         wxWindow
*                   pWnd 
= pParent
->FindItemByHWND(hWnd
); 
 243             || pParent
->IsKindOf(CLASSINFO(wxControl
)) 
 244 #endif // wxUSE_CONTROLS 
 247             wxWindow
*               pItem 
= pCurrent
->GetData(); 
 249             if (pItem
->GetHWND() == hWnd
) 
 253                 if (pItem
->ContainsHWND(hWnd
)) 
 257         pCurrent 
= pCurrent
->GetNext(); 
 260 } // end of wxWindowOS2::FindItemByHWND 
 263 // Default command handler 
 265 bool wxWindowOS2::OS2Command( 
 266   WXUINT                            
WXUNUSED(uParam
) 
 267 , WXWORD                            
WXUNUSED(uId
) 
 273 // ---------------------------------------------------------------------------- 
 274 // constructors and such 
 275 // ---------------------------------------------------------------------------- 
 277 void wxWindowOS2::Init() 
 287     m_bDoubleClickAllowed 
= 0; 
 288     m_bWinCaptured 
= FALSE
; 
 290     m_isBeingDeleted 
= FALSE
; 
 293     m_bMouseInWindow 
= FALSE
; 
 300     m_hWndScrollBarHorz 
= 0L; 
 301     m_hWndScrollBarVert 
= 0L; 
 304     // Pass WM_GETDLGCODE to DefWindowProc() 
 309     m_bBackgroundTransparent 
= FALSE
; 
 312     // As all windows are created with WS_VISIBLE style... 
 316 #if wxUSE_MOUSEEVENT_HACK 
 319     m_nLastMouseEvent 
= -1; 
 320 #endif // wxUSE_MOUSEEVENT_HACK 
 321 } // wxWindowOS2::Init 
 326 wxWindowOS2::~wxWindowOS2() 
 328     m_isBeingDeleted 
= TRUE
; 
 330     for (wxWindow
* pWin 
= GetParent(); pWin
; pWin 
= pWin
->GetParent()) 
 332         wxFrame
*                    pFrame 
= wxDynamicCast(pWin
, wxFrame
); 
 336             if (pFrame
->GetLastFocus() == this) 
 337                 pFrame
->SetLastFocus((wxWindow
*)NULL
); 
 344         m_parent
->RemoveChild(this); 
 348         if(!::WinDestroyWindow(GetHWND())) 
 349             wxLogLastError(wxT("DestroyWindow")); 
 351         // remove hWnd <-> wxWindow association 
 353         wxRemoveHandleAssociation(this); 
 355 } // end of wxWindowOS2::~wxWindowOS2 
 357 // real construction (Init() must have been called before!) 
 358 bool wxWindowOS2::Create( 
 361 , const wxPoint
&                    rPos
 
 362 , const wxSize
&                     rSize
 
 364 , const wxString
&                   rName
 
 367     HWND                            hParent 
= NULLHANDLE
; 
 368     ULONG                           ulCreateFlags 
= 0; 
 369     WXDWORD                         dwExStyle 
= 0; 
 371     wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent")); 
 373     if ( !CreateBase( pParent
 
 387         pParent
->AddChild(this); 
 388         hParent 
= GetWinHwnd(pParent
); 
 390         if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) || 
 391              pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) 
 393             ulCreateFlags 
|= WS_CLIPSIBLINGS
; 
 397     // Most wxSTYLES are really PM Class specific styles and will be 
 398     // set in those class create procs.  PM's basic windows styles are 
 401     ulCreateFlags 
|=  WS_VISIBLE
; 
 404 #ifdef __WXUNIVERSAL__ 
 405     // no 3d effects, we draw them ourselves 
 407 #else // !wxUniversal 
 408     if (lStyle 
& wxCLIP_SIBLINGS
) 
 409         ulCreateFlags 
|= WS_CLIPSIBLINGS
; 
 411     if (lStyle 
& wxCLIP_CHILDREN 
) 
 412         ulCreateFlags 
|= WS_CLIPCHILDREN
; 
 418     dwExStyle 
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
); 
 423     // Add the simple border style as we'll use this to draw borders 
 425     if (lStyle 
& wxSIMPLE_BORDER
) 
 426         dwExStyle 
|= wxSIMPLE_BORDER
; 
 428     if (lStyle 
& wxPOPUP_WINDOW
) 
 430         // a popup window floats on top of everything 
 432 //        exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW; 
 434         // it is also created hidden as other top level windows 
 435         ulCreateFlags 
&= ~WS_VISIBLE
; 
 440     // Generic OS/2 Windows have no Control Data but other classes 
 441     // that call OS2Create may have some. 
 443     OS2Create( (PSZ
)wxCanvasClassName
 
 448               ,NULL         
// Control Data 
 454 } // end of wxWindowOS2::Create 
 456 // --------------------------------------------------------------------------- 
 458 // --------------------------------------------------------------------------- 
 460 void wxWindowOS2::SetFocus() 
 462     HWND                            hWnd 
= GetHwnd(); 
 463     wxCHECK_RET( hWnd
, _T("can't set focus to invalid window") ); 
 466         ::WinSetFocus(HWND_DESKTOP
, hWnd
); 
 467 } // end of wxWindowOS2::SetFocus 
 469 wxWindow
* wxWindowBase::FindFocus() 
 471     HWND                            hWnd 
= ::WinQueryFocus(HWND_DESKTOP
); 
 475         return wxFindWinFromHandle((WXHWND
)hWnd
); 
 478 } // wxWindowBase::FindFocus 
 480 bool wxWindowOS2::Enable( 
 484     if (!wxWindowBase::Enable(bEnable
)) 
 487     HWND                            hWnd 
= GetHwnd(); 
 490         ::WinEnableWindow(hWnd
, (BOOL
)bEnable
); 
 492     wxWindowList::Node
*             pNode 
= GetChildren().GetFirst(); 
 496         wxWindow
*                   pChild 
= pNode
->GetData(); 
 498         pChild
->Enable(bEnable
); 
 499         pNode 
= pNode
->GetNext(); 
 502 } // end of wxWindowOS2::Enable 
 504 bool wxWindowOS2::Show( 
 508     if (!wxWindowBase::Show(bShow
)) 
 511     HWND                            hWnd 
= GetHwnd(); 
 513     ::WinShowWindow(hWnd
, bShow
); 
 517         ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE 
| SWP_ZORDER
); 
 520 } // end of wxWindowOS2::Show 
 522 void wxWindowOS2::Raise() 
 524     ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER 
| SWP_ACTIVATE
); 
 525 } // end of wxWindowOS2::Raise 
 527 void wxWindowOS2::Lower() 
 529     ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER 
| SWP_DEACTIVATE
); 
 530 } // end of wxWindowOS2::Lower 
 532 void wxWindowOS2::SetTitle( 
 533   const wxString
&                   rTitle
 
 536     ::WinSetWindowText(GetHwnd(), rTitle
.c_str()); 
 537 } // end of wxWindowOS2::SetTitle 
 539 wxString 
wxWindowOS2::GetTitle() const 
 541     return wxGetWindowText(GetHWND()); 
 542 } // end of wxWindowOS2::GetTitle 
 544 void wxWindowOS2::DoCaptureMouse() 
 546     HWND                            hWnd 
= GetHwnd(); 
 548     if (hWnd 
&& !m_bWinCaptured
) 
 550         ::WinSetCapture(HWND_DESKTOP
, hWnd
); 
 551         m_bWinCaptured 
= TRUE
; 
 553 } // end of wxWindowOS2::GetTitle 
 555 void wxWindowOS2::DoReleaseMouse() 
 559         ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
); 
 560         m_bWinCaptured 
= FALSE
; 
 562 } // end of wxWindowOS2::ReleaseMouse 
 564 /* static */ wxWindow
* wxWindowBase::GetCapture() 
 566     HWND hwnd 
= ::WinQueryCapture(HWND_DESKTOP
); 
 567     return hwnd 
? wxFindWinFromHandle((WXHWND
)hwnd
) : (wxWindow 
*)NULL
; 
 568 } // end of wxWindowBase::GetCapture 
 570 bool wxWindowOS2::SetFont( 
 574     if (!wxWindowBase::SetFont(rFont
)) 
 580     HWND                            hWnd 
= GetHwnd(); 
 590         // The fonts available for Presentation Params are just three 
 591         // outline fonts, the rest are available to the GPI, so we must 
 592         // map the families to one of these three 
 594         switch(rFont
.GetFamily()) 
 599                 strcpy(zFacename
,"Times New Roman"); 
 604                 strcpy(zFacename
, "Courier"); 
 610                 strcpy(zFacename
, "Helvetica"); 
 614         switch(rFont
.GetWeight()) 
 623             case wxFONTWEIGHT_MAX
: 
 624                 strcpy(zWeight
, "Bold"); 
 627         switch(rFont
.GetStyle()) 
 631                 strcpy(zStyle
, "Italic"); 
 638         sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), zFacename
); 
 639         if (zWeight
[0] != '\0') 
 642             strcat(zFont
, zWeight
); 
 644         if (zStyle
[0] != '\0') 
 647             strcat(zFont
, zStyle
); 
 649         ::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
) + 1, (PVOID
)zFont
); 
 654 bool wxWindowOS2::SetCursor( 
 655   const wxCursor
&                   rCursor
 
 656 ) // check if base implementation is OK 
 658     if ( !wxWindowBase::SetCursor(rCursor
)) 
 664     if ( m_cursor
.Ok() ) { 
 665         HWND                            hWnd 
= GetHwnd(); 
 669         ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
); 
 670         ::WinQueryWindowRect(hWnd
, &vRect
); 
 672         if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy()) 
 674             ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR()); 
 678 } // end of wxWindowOS2::SetCursor 
 680 void wxWindowOS2::WarpPointer( 
 689     ::WinQueryWindowRect(GetHwnd(), &vRect
); 
 693     ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
)); 
 694 } // end of wxWindowOS2::WarpPointer 
 696 #if WXWIN_COMPATIBILITY 
 697 void wxWindowOS2::OS2DeviceToLogical (float *x
, float *y
) const 
 700 #endif // WXWIN_COMPATIBILITY 
 702 // --------------------------------------------------------------------------- 
 704 // --------------------------------------------------------------------------- 
 706 #if WXWIN_COMPATIBILITY 
 707 void wxWindowOS2::SetScrollRange( 
 713     int                             nRange1 
= nRange
; 
 714     int                             nPageSize 
= GetScrollPage(nOrient
); 
 716     if (nPpageSize 
> 1 && nRange 
> 0) 
 718         nRange1 
+= (nPageSize 
- 1); 
 721     if (nOrient 
== wxHORIZONTAL
) 
 723         ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
)); 
 724         ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0); 
 728         ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
)); 
 729         ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0); 
 731 } // end of wxWindowOS2::SetScrollRange 
 733 void wxWindowOS2::SetScrollPage( 
 739     if (nOrient 
== wxHORIZONTAL 
) 
 740         m_nXThumbSize 
= nPage
; 
 742         m_nYThumbSize 
= nPage
; 
 743 } // end of wxWindowOS2::SetScrollPage 
 745 int wxWindowOS2::OldGetScrollRange( 
 750     HWND                            hWnd 
= GetHwnd(); 
 754         mRc 
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L); 
 755         return(SHORT2FROMMR(mRc
)); 
 758 } // end of wxWindowOS2::OldGetScrollRange 
 760 int  wxWindowOS2::GetScrollPage( 
 764     if (nOrient 
== wxHORIZONTAL
) 
 765         return m_nXThumbSize
; 
 767         return m_nYThumbSize
; 
 768 } // end of wxWindowOS2::GetScrollPage 
 769 #endif // WXWIN_COMPATIBILITY 
 771 int  wxWindowOS2::GetScrollPos( 
 775     if (nOrient 
== wxHORIZONTAL
) 
 776         return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
)); 
 778         return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
)); 
 779 } // end of wxWindowOS2::GetScrollPos 
 781 int wxWindowOS2::GetScrollRange( 
 787     if (nOrient 
== wxHORIZONTAL
) 
 788         mr 
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
); 
 790         mr 
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
); 
 791     return((int)SHORT2FROMMR(mr
)); 
 792 } // end of wxWindowOS2::GetScrollRange 
 794 int wxWindowOS2::GetScrollThumb( 
 798     if (nOrient 
== wxHORIZONTAL 
) 
 799         return m_nXThumbSize
; 
 801         return m_nYThumbSize
; 
 802 } // end of wxWindowOS2::GetScrollThumb 
 804 void wxWindowOS2::SetScrollPos( 
 807 , bool                              WXUNUSED(bRefresh
) 
 810     if (nOrient 
== wxHORIZONTAL 
) 
 811         ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
); 
 813         ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
); 
 814 } // end of wxWindowOS2::SetScrollPos 
 816 void wxWindowOS2::SetScrollbar( 
 821 , bool                              WXUNUSED(bRefresh
) 
 824     int                             nOldRange 
= nRange 
- nThumbVisible
; 
 825     int                             nRange1 
= nOldRange
; 
 826     int                             nPageSize 
= nThumbVisible
; 
 828     HWND                            hWnd 
= GetHwnd(); 
 829     ULONG                           ulStyle 
= WS_VISIBLE 
| WS_SYNCPAINT
; 
 832     ::WinQueryWindowRect(hWnd
, &vRect
); 
 833     if (nPageSize 
> 1 && nRange 
> 0) 
 835         nRange1 
+= (nPageSize 
- 1); 
 838     vInfo
.cb 
= sizeof(SBCDATA
); 
 840     vInfo
.posLast 
= (SHORT
)nRange1
; 
 841     vInfo
.posThumb 
= nPos
; 
 843     if (nOrient 
== wxHORIZONTAL 
) 
 846         if (m_hWndScrollBarHorz 
== 0L) 
 849             // We create the scrollbars with the desktop so that they are not 
 850             // registered as child windows of the window in order that child 
 851             // windows may be scrolled without scrolling the scrollbars themselves! 
 853             m_hWndScrollBarHorz 
= ::WinCreateWindow( hWnd
 
 859                                                     ,vRect
.xRight 
- vRect
.xLeft
 
 873             // Only want to resize the scrollbar if it changes, otherwise 
 874             // we'd probably end up in a recursive loop until we crash the call stack 
 875             // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE 
 876             // generates those events. 
 878             ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect2
); 
 879             if (!(vRect2
.xLeft 
== vRect
.xLeft     
&& 
 880                   vRect2
.xRight 
== vRect
.xRight   
&& 
 881                   vRect2
.yBottom 
== vRect
.yBottom 
&& 
 882                   vRect2
.yTop 
== vRect
.yTop
 
 885                 ::WinSetWindowPos( m_hWndScrollBarHorz
 
 889                                   ,vRect
.xRight 
- vRect
.xLeft
 
 891                                   ,SWP_ACTIVATE 
| SWP_MOVE 
| SWP_SIZE 
| SWP_SHOW
 
 894             ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
)); 
 895             ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0); 
 901         if (m_hWndScrollBarVert 
== 0L) 
 903             m_hWndScrollBarVert 
= ::WinCreateWindow( hWnd
 
 910                                                     ,vRect
.yTop 
- (vRect
.yBottom 
+ 20) 
 923             // Only want to resize the scrollbar if it changes, otherwise 
 924             // we'd probably end up in a recursive loop until we crash the call stack 
 925             // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE 
 926             // generates those events. 
 928             ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect2
); 
 929             if (!(vRect2
.xLeft 
== vRect
.xLeft     
&& 
 930                   vRect2
.xRight 
== vRect
.xRight   
&& 
 931                   vRect2
.yBottom 
== vRect
.yBottom 
&& 
 932                   vRect2
.yTop 
== vRect
.yTop
 
 935                 ::WinSetWindowPos( m_hWndScrollBarVert
 
 940                                   ,vRect
.yTop 
- (vRect
.yBottom 
+ 20) 
 941                                   ,SWP_ACTIVATE 
| SWP_MOVE 
| SWP_SIZE 
| SWP_SHOW
 
 944             ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
)); 
 945             ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0); 
 947         m_nYThumbSize 
= nThumbVisible
; 
 949 } // end of wxWindowOS2::SetScrollbar 
 951 void wxWindowOS2::ScrollWindow( 
 954 , const wxRect
*                     pRect
 
 960     nDy 
*= -1; // flip the sign of Dy as OS/2 is opposite wxWin. 
 963         vRect2
.xLeft   
= pRect
->x
; 
 964         vRect2
.yTop    
= pRect
->y 
+ pRect
->height
; 
 965         vRect2
.xRight  
= pRect
->x 
+ pRect
->width
; 
 966         vRect2
.yBottom 
= pRect
->y
; 
 970         ::WinQueryWindowRect(GetHwnd(), &vRect2
); 
 971         ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect
); 
 972         vRect2
.yBottom 
+= vRect
.yTop 
- vRect
.yBottom
; 
 973         ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect
); 
 974         vRect2
.xRight 
-= vRect
.xRight 
- vRect
.xLeft
; 
 978         ::WinScrollWindow( GetHwnd() 
 988         ::WinScrollWindow( GetHwnd() 
1000     wxWindowList::Node
*             pCurrent 
= GetChildren().GetFirst(); 
1005         wxWindow
*                   pChildWin 
= pCurrent
->GetData(); 
1007         if (pChildWin
->GetHWND() != NULLHANDLE
) 
1009             ::WinQueryWindowPos(pChildWin
->GetHWND(), &vSwp
); 
1010             ::WinQueryWindowRect(pChildWin
->GetHWND(), &vRect
); 
1011             if (pChildWin
->GetHWND() == m_hWndScrollBarVert 
|| 
1012                 pChildWin
->GetHWND() == m_hWndScrollBarHorz
) 
1014                 ::WinSetWindowPos( pChildWin
->GetHWND() 
1020                                   ,SWP_MOVE 
| SWP_SHOW 
| SWP_ZORDER
 
1025                 ::WinSetWindowPos( pChildWin
->GetHWND() 
1031                                   ,SWP_MOVE 
| SWP_ZORDER
 
1033                 ::WinInvalidateRect(pChildWin
->GetHWND(), &vRect
, FALSE
); 
1036         pCurrent 
= pCurrent
->GetNext(); 
1038 } // end of wxWindowOS2::ScrollWindow 
1040 // --------------------------------------------------------------------------- 
1042 // --------------------------------------------------------------------------- 
1044 void wxWindowOS2::SubclassWin( 
1048     HWND                            hwnd 
= (HWND
)hWnd
; 
1050     wxASSERT_MSG( !m_fnOldWndProc
, wxT("subclassing window twice?") ); 
1051     wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") ); 
1052     m_fnOldWndProc 
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
); 
1053 } // end of wxWindowOS2::SubclassWin 
1055 void wxWindowOS2::UnsubclassWin() 
1058     // Restore old Window proc 
1060     HWND                            hwnd 
= GetHWND(); 
1064         wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") ); 
1066         PFNWP                       fnProc 
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
); 
1068         if ( (m_fnOldWndProc 
!= 0) && (fnProc 
!= (PFNWP
) m_fnOldWndProc
)) 
1070             WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
); 
1074 } // end of wxWindowOS2::UnsubclassWin 
1076 bool wxCheckWindowWndProc( 
1078 , WXFARPROC                         fnWndProc
 
1081     static char                     zBuffer
[512]; 
1084     ::WinQueryClassName((HWND
)hWnd
, (LONG
)512, (PCH
)zBuffer
); 
1085     ::WinQueryClassInfo(wxGetInstance(), (PSZ
)zBuffer
, &vCls
); 
1086     return(fnWndProc 
== (WXFARPROC
)vCls
.pfnWindowProc
); 
1087 } // end of WinGuiBase_CheckWindowWndProc 
1090 // Make a Windows extended style from the given wxWindows window style 
1092 WXDWORD 
wxWindowOS2::MakeExtendedStyle( 
1094 , bool                              bEliminateBorders
 
1098    // Simply fill out with wxWindow extended styles.  We'll conjure 
1099    // something up in OS2Create and all window redrawing pieces later 
1101     WXDWORD                         dwStyle 
= 0; 
1103     if (lStyle 
& wxTRANSPARENT_WINDOW 
) 
1104         dwStyle 
|= wxTRANSPARENT_WINDOW
; 
1106     if (!bEliminateBorders
) 
1108         if (lStyle 
& wxSUNKEN_BORDER
) 
1109             dwStyle 
|= wxSUNKEN_BORDER
; 
1110         if (lStyle 
& wxDOUBLE_BORDER
) 
1111             dwStyle 
|= wxDOUBLE_BORDER
; 
1112         if (lStyle 
& wxRAISED_BORDER 
) 
1113             dwStyle 
|= wxRAISED_BORDER
; 
1114         if (lStyle 
& wxSTATIC_BORDER
) 
1115             dwStyle 
|= wxSTATIC_BORDER
; 
1118 } // end of wxWindowOS2::MakeExtendedStyle 
1121 // Determines whether simulated 3D effects or CTL3D should be used, 
1122 // applying a default border style if required, and returning an extended 
1123 // style to pass to OS2Create. 
1125 WXDWORD 
wxWindowOS2::Determine3DEffects( 
1126   WXDWORD                           dwDefaultBorderStyle
 
1130     WXDWORD                         dwStyle 
= 0L; 
1133     // Native PM does not have any specialize 3D effects like WIN32 does, 
1134     // so we have to try and invent them. 
1138     // If matches certain criteria, then assume no 3D effects 
1139     // unless specifically requested (dealt with in MakeExtendedStyle) 
1142         !IsKindOf(CLASSINFO(wxControl
)) || 
1143         (m_windowStyle 
& wxNO_BORDER
) 
1147         return MakeExtendedStyle(m_windowStyle
, FALSE
); 
1151     // 1) App can specify global 3D effects 
1153     *pbWant3D 
= wxTheApp
->GetAuto3D(); 
1156     // 2) If the parent is being drawn with user colours, or simple border 
1157     //    specified, switch effects off. 
1160         (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || 
1161         (m_windowStyle 
& wxSIMPLE_BORDER
) 
1166     // 3) Control can override this global setting by defining 
1167     //    a border style, e.g. wxSUNKEN_BORDER 
1169     if ((m_windowStyle 
& wxDOUBLE_BORDER
) || 
1170         (m_windowStyle 
& wxRAISED_BORDER
) || 
1171         (m_windowStyle 
& wxSTATIC_BORDER
) || 
1172         (m_windowStyle 
& wxSUNKEN_BORDER
) 
1176     dwStyle 
= MakeExtendedStyle( m_windowStyle
 
1181     // If we want 3D, but haven't specified a border here, 
1182     // apply the default border style specified. 
1184     if (dwDefaultBorderStyle 
&& (*pbWant3D
) && 
1185         !((m_windowStyle 
& wxDOUBLE_BORDER
) || 
1186           (m_windowStyle 
& wxRAISED_BORDER
) || 
1187           (m_windowStyle 
& wxSTATIC_BORDER
) || 
1188           (m_windowStyle 
& wxSIMPLE_BORDER
) 
1191         dwStyle 
|= dwDefaultBorderStyle
; 
1193 } // end of wxWindowOS2::Determine3DEffects 
1195 #if WXWIN_COMPATIBILITY 
1196 void wxWindowOS2::OnCommand( 
1198 , wxCommandEvent
&                   rEvent
 
1201     if (GetEventHandler()->ProcessEvent(rEvent
)) 
1204         m_parent
->GetEventHandler()->OnCommand( rWin
 
1207 } // end of wxWindowOS2::OnCommand 
1209 wxObject
* wxWindowOS2::GetChild( 
1214     // Return a pointer to the Nth object in the Panel 
1216     wxNode
*                         pNode 
= GetChildren().First(); 
1219     while (pNode 
&& n
--) 
1220         pNode 
= pNode
->Next(); 
1223         wxObject
*                   pObj 
= (wxObject
*)pNode
->Data(); 
1228 } // end of wxWindowOS2::GetChild 
1230 #endif // WXWIN_COMPATIBILITY 
1233 // Setup background and foreground colours correctly 
1235 void wxWindowOS2::SetupColours() 
1238         SetBackgroundColour(GetParent()->GetBackgroundColour()); 
1239 } // end of wxWindowOS2::SetupColours 
1241 void wxWindowOS2::OnIdle( 
1242   wxIdleEvent
&                      WXUNUSED(rEvent
) 
1246     // Check if we need to send a LEAVE event 
1248     if (m_bMouseInWindow
) 
1252         ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
); 
1253         if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd()) 
1256             // Generate a LEAVE event 
1258             m_bMouseInWindow 
= FALSE
; 
1261             // Unfortunately the mouse button and keyboard state may have changed 
1262             // by the time the OnIdle function is called, so 'state' may be 
1267             if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0) 
1269             if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0); 
1272             wxMouseEvent            
rEvent(wxEVT_LEAVE_WINDOW
); 
1274             InitMouseEvent( rEvent
 
1279             (void)GetEventHandler()->ProcessEvent(rEvent
); 
1283 } // end of wxWindowOS2::OnIdle 
1286 // Set this window to be the child of 'parent'. 
1288 bool wxWindowOS2::Reparent( 
1292     if (!wxWindowBase::Reparent(pParent
)) 
1295     HWND                            hWndChild 
= GetHwnd(); 
1296     HWND                            hWndParent 
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0; 
1298     ::WinSetParent(hWndChild
, hWndParent
, TRUE
); 
1300 } // end of wxWindowOS2::Reparent 
1302 void wxWindowOS2::Clear() 
1304     wxClientDC                      
vDc((wxWindow
*)this); 
1305     wxBrush                         
vBrush( GetBackgroundColour() 
1309     vDc
.SetBackground(vBrush
); 
1311 } // end of wxWindowOS2::Clear 
1313 void wxWindowOS2::Update() 
1315     ::WinUpdateWindow(GetHwnd()); 
1316 } // end of wxWindowOS2::Update 
1318 void wxWindowOS2::Freeze() 
1320    ::WinSendMsg(GetHwnd(), WM_VRNDISABLED
, (MPARAM
)0, (MPARAM
)0); 
1321 } // end of wxWindowOS2::Freeze 
1323 void wxWindowOS2::Thaw() 
1325    ::WinSendMsg(GetHwnd(), WM_VRNENABLED
, (MPARAM
)TRUE
, (MPARAM
)0); 
1328     // We need to refresh everything or otherwise he invalidated area is not 
1332 } // end of wxWindowOS2::Thaw 
1334 void wxWindowOS2::Refresh( 
1336 , const wxRect
*                     pRect
 
1339     HWND                            hWnd 
= GetHwnd(); 
1347             vOs2Rect
.xLeft   
= pRect
->x
; 
1348             vOs2Rect
.yTop    
= pRect
->y
; 
1349             vOs2Rect
.xRight  
= pRect
->x 
+ pRect
->width
; 
1350             vOs2Rect
.yBottom 
= pRect
->y 
+ pRect
->height
; 
1352             ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
); 
1355             ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
); 
1357 } // end of wxWindowOS2::Refresh 
1359 // --------------------------------------------------------------------------- 
1361 // --------------------------------------------------------------------------- 
1363 #if wxUSE_DRAG_AND_DROP 
1364 void wxWindowOS2::SetDropTarget( 
1365   wxDropTarget
*                     pDropTarget
 
1368     if (m_dropTarget 
!= 0) 
1370         m_dropTarget
->Revoke(m_hWnd
); 
1371         delete m_dropTarget
; 
1373     m_dropTarget 
= pDropTarget
; 
1374     if (m_dropTarget 
!= 0) 
1375         m_dropTarget
->Register(m_hWnd
); 
1376 } // end of wxWindowOS2::SetDropTarget 
1380 // old style file-manager drag&drop support: we retain the old-style 
1381 // DragAcceptFiles in parallel with SetDropTarget. 
1383 void wxWindowOS2::DragAcceptFiles( 
1387     HWND                            hWnd 
= GetHwnd(); 
1389     if (hWnd 
&& bAccept
) 
1390         ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L); 
1391 } // end of wxWindowOS2::DragAcceptFiles 
1393 // ---------------------------------------------------------------------------- 
1395 // ---------------------------------------------------------------------------- 
1399 void wxWindowOS2::DoSetToolTip( 
1403     wxWindowBase::DoSetToolTip(pTooltip
); 
1406         m_tooltip
->SetWindow(this); 
1407 } // end of wxWindowOS2::DoSetToolTip 
1409 #endif // wxUSE_TOOLTIPS 
1411 // --------------------------------------------------------------------------- 
1412 // moving and resizing 
1413 // --------------------------------------------------------------------------- 
1416 void wxWindowOS2::DoGetSize( 
1424     if (IsKindOf(CLASSINFO(wxFrame
))) 
1426         wxFrame
*                    pFrame 
= wxDynamicCast(this, wxFrame
); 
1427         hWnd 
= pFrame
->GetFrame(); 
1432     ::WinQueryWindowRect(hWnd
, &vRect
); 
1435         *pWidth 
= vRect
.xRight 
- vRect
.xLeft
; 
1437         // OS/2 PM is backwards from windows 
1438         *pHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
1439 } // end of wxWindowOS2::DoGetSize 
1441 void wxWindowOS2::DoGetPosition( 
1446     HWND                            hWnd 
= GetHwnd(); 
1449     wxWindow
*                       pParent 
= GetParent(); 
1452     // It would seem that WinQueryWindowRect would be the correlary to 
1453     // the WIN32 WinGetRect, but unlike WinGetRect which returns the window 
1454     // origin position in screen coordinates, WinQueryWindowRect returns it 
1455     // relative to itself, i.e. (0,0).  To get the same under PM we must 
1456     // us WinQueryWindowPos.  This call, unlike the WIN32 call, however, 
1457     // returns a position relative to it's parent, so no parent adujstments 
1458     // are needed under OS/2.  Also, windows should be created using 
1459     // wxWindow coordinates, i.e 0,0 is the TOP left so vSwp will already 
1462     ::WinQueryWindowPos(hWnd
, &vSwp
); 
1468     // We may be faking the client origin. So a window that's really at (0, 
1469     // 30) may appear (to wxWin apps) to be at (0, 0). 
1473         wxPoint                     
vPt(pParent
->GetClientAreaOrigin()); 
1483 } // end of wxWindowOS2::DoGetPosition 
1485 void wxWindowOS2::DoScreenToClient( 
1490     HWND                            hWnd 
= GetHwnd(); 
1493     ::WinQueryWindowPos(hWnd
, &vSwp
); 
1499 } // end of wxWindowOS2::DoScreenToClient 
1501 void wxWindowOS2::DoClientToScreen( 
1506     HWND                            hWnd 
= GetHwnd(); 
1509     ::WinQueryWindowPos(hWnd
, &vSwp
); 
1515 } // end of wxWindowOS2::DoClientToScreen 
1518 // Get size *available for subwindows* i.e. excluding menu bar etc. 
1519 // Must be a frame type window 
1521 void wxWindowOS2::DoGetClientSize( 
1526     HWND                            hWnd 
= GetHwnd(); 
1529    ::WinQueryWindowRect(hWnd
, &vRect
); 
1530     if (IsKindOf(CLASSINFO(wxDialog
))) 
1535         // For a Dialog we have to explicitly request the client portion. 
1536         // For a Frame the hWnd IS the client window 
1538         hWndTitle 
= ::WinWindowFromID(hWnd
, FID_TITLEBAR
); 
1539         if (::WinQueryWindowRect(hWndTitle
, &vTitle
)) 
1541             if (vTitle
.yTop 
- vTitle
.yBottom 
== 0) 
1544                 // Dialog has not been created yet, use a default 
1548             vRect
.yTop 
-= (vTitle
.yTop 
- vTitle
.yBottom
); 
1551         ULONG                       uStyle 
= ::WinQueryWindowULong(hWnd
, QWL_STYLE
); 
1554         // Deal with borders 
1556         if (uStyle 
& FCF_DLGBORDER
) 
1563         else if (uStyle 
& FCF_SIZEBORDER
) 
1570         else if (uStyle 
& FCF_BORDER
) 
1577         else // make some kind of adjustment or top sizers ram into the titlebar! 
1586         *pWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
1588         *pHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
1589 } // end of wxWindowOS2::DoGetClientSize 
1591 void wxWindowOS2::DoMoveWindow( 
1600     wxWindow
*                       pParent 
= GetParent(); 
1602     if (pParent 
&& !IsKindOf(CLASSINFO(wxDialog
))) 
1604         int                         nOS2Height 
= GetOS2ParentHeight(pParent
); 
1606         nY 
= nOS2Height 
- (nY 
+ nHeight
); 
1612         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
1613         nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
1615     ::WinSetWindowPos( GetHwnd() 
1621                       ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
1623 } // end of wxWindowOS2::DoMoveWindow 
1626 // Set the size of the window: if the dimensions are positive, just use them, 
1627 // but if any of them is equal to -1, it means that we must find the value for 
1628 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in 
1629 // which case -1 is a valid value for x and y) 
1631 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate 
1632 // the width/height to best suit our contents, otherwise we reuse the current 
1635 void wxWindowOS2::DoSetSize( 
1644     // Get the current size and position... 
1650     wxSize                          
vSize(-1, -1); 
1652     GetPosition(&nCurrentX
, &nCurrentY
); 
1653     GetSize(&nCurrentWidth
, &nCurrentHeight
); 
1656     // ... and don't do anything (avoiding flicker) if it's already ok 
1659     // Must convert Y coords to test for equality under OS/2 
1662     wxWindow
*                       pParent 
= (wxWindow
*)GetParent(); 
1664     if (pParent 
&& !IsKindOf(CLASSINFO(wxDialog
))) 
1666         int                         nOS2Height 
= GetOS2ParentHeight(pParent
); 
1668         nY2 
= nOS2Height 
- (nY2 
+ nHeight
); 
1674         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
1675         nY2 
= vRect
.yTop 
- (nY2 
+ nHeight
); 
1677     if (nX 
== nCurrentX 
&& nY2 
== nCurrentY 
&& 
1678         nWidth 
== nCurrentWidth 
&& nHeight 
== nCurrentHeight
) 
1683     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
1685     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
1688     AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
); 
1692         if (nSizeFlags 
& wxSIZE_AUTO_WIDTH
) 
1694             vSize  
= DoGetBestSize(); 
1700             // Just take the current one 
1702             nWidth 
= nCurrentWidth
; 
1708         if (nSizeFlags 
& wxSIZE_AUTO_HEIGHT
) 
1712                 vSize 
= DoGetBestSize(); 
1718             // just take the current one 
1719             nHeight 
= nCurrentHeight
; 
1728 } // end of wxWindowOS2::DoSetSize 
1730 void wxWindowOS2::DoSetClientSize( 
1735     wxWindow
*                       pParent 
= GetParent(); 
1736     HWND                            hWnd 
= GetHwnd(); 
1737     HWND                            hParentWnd 
= (HWND
)0; 
1742     HWND                            hClientWnd 
= (HWND
)0; 
1744     hClientWnd 
= ::WinWindowFromID(hWnd
, FID_CLIENT
); 
1745     ::WinQueryWindowRect(hClientWnd
, &vRect2
); 
1746     ::WinQueryWindowRect(hWnd
, &vRect
); 
1747     ::WinQueryWindowRect(hParentWnd
, &vRect3
); 
1749     int                             nActualWidth 
= vRect2
.xRight 
- vRect2
.xLeft 
- vRect
.xRight 
+ nWidth
; 
1750     int                             nActualHeight 
= vRect2
.yTop 
- vRect2
.yBottom 
- vRect
.yTop 
+ nHeight
; 
1752     vPoint
.x 
= vRect2
.xLeft
; 
1753     vPoint
.y 
= vRect2
.yBottom
; 
1756         vPoint
.x 
-= vRect3
.xLeft
; 
1757         vPoint
.y 
-= vRect3
.yBottom
; 
1760     DoMoveWindow(vPoint
.x
, vPoint
.y
, nActualWidth
, nActualHeight
); 
1762     wxSizeEvent                     
vEvent(wxSize(nWidth
, nHeight
), m_windowId
); 
1763     vEvent
.SetEventObject(this); 
1764     GetEventHandler()->ProcessEvent(vEvent
); 
1765 } // end of wxWindowOS2::DoSetClientSize 
1767 wxPoint 
wxWindowOS2::GetClientAreaOrigin() const 
1769     return wxPoint(0, 0); 
1770 } // end of wxWindowOS2::GetClientAreaOrigin 
1772 // --------------------------------------------------------------------------- 
1774 // --------------------------------------------------------------------------- 
1776 int wxWindowOS2::GetCharHeight() const 
1779     FONTMETRICS                     vFontMetrics
; 
1781     hPs 
= ::WinGetPS(GetHwnd()); 
1783     if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
)) 
1785         ::WinReleasePS(hPs
); 
1788     ::WinReleasePS(hPs
); 
1789     return(vFontMetrics
.lMaxAscender 
+ vFontMetrics
.lMaxDescender
); 
1790 } // end of wxWindowOS2::GetCharHeight 
1792 int wxWindowOS2::GetCharWidth() const 
1795     FONTMETRICS                     vFontMetrics
; 
1797     hPs 
= ::WinGetPS(GetHwnd()); 
1799     if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
)) 
1801         ::WinReleasePS(hPs
); 
1804     ::WinReleasePS(hPs
); 
1805     return(vFontMetrics
.lAveCharWidth
); 
1806 } // end of wxWindowOS2::GetCharWidth 
1808 void wxWindowOS2::GetTextExtent( 
1809   const wxString
&                   rString
 
1813 , int*                              pExternalLeading
 
1814 , const wxFont
*                     pTheFont
 
1817     POINTL                          avPoint
[TXTBOX_COUNT
]; 
1822     FONTMETRICS                     vFM
; // metrics structure 
1825     ERRORID                         vErrorCode
; // last error id code 
1829     hPS 
= ::WinGetPS(GetHwnd()); 
1831     l 
= rString
.Length(); 
1834         pStr 
= (PCH
)rString
.c_str(); 
1837         // In world coordinates. 
1839         bRc 
= ::GpiQueryTextBox( hPS
 
1842                                 ,TXTBOX_COUNT 
// return maximum information 
1843                                 ,avPoint      
// array of coordinates points 
1847             vPtMin
.x 
= avPoint
[0].x
; 
1848             vPtMax
.x 
= avPoint
[0].x
; 
1849             vPtMin
.y 
= avPoint
[0].y
; 
1850             vPtMax
.y 
= avPoint
[0].y
; 
1851             for (i 
= 1; i 
< 4; i
++) 
1853                 if(vPtMin
.x 
> avPoint
[i
].x
) vPtMin
.x 
= avPoint
[i
].x
; 
1854                 if(vPtMin
.y 
> avPoint
[i
].y
) vPtMin
.y 
= avPoint
[i
].y
; 
1855                 if(vPtMax
.x 
< avPoint
[i
].x
) vPtMax
.x 
= avPoint
[i
].x
; 
1856                 if(vPtMax
.y 
< avPoint
[i
].y
) vPtMax
.y 
= avPoint
[i
].y
; 
1858             bRc 
= ::GpiQueryFontMetrics( hPS
 
1859                                         ,sizeof(FONTMETRICS
) 
1886         *pX 
= (vPtMax
.x 
- vPtMin
.x 
+ 1); 
1888         *pY 
= (vPtMax
.y 
- vPtMin
.y 
+ 1); 
1892             *pDescent 
= vFM
.lMaxDescender
; 
1896     if (pExternalLeading
) 
1899             *pExternalLeading 
= vFM
.lExternalLeading
; 
1901             *pExternalLeading 
= 0; 
1903     ::WinReleasePS(hPS
); 
1904 } // end of wxWindow::GetTextExtent 
1906 bool wxWindowOS2::IsMouseInWindow() const 
1909     // Get the mouse position 
1912     ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
); 
1915     // Find the window which currently has the cursor and go up the window 
1916     // chain until we find this window - or exhaust it 
1918     HWND                            hWnd 
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt
, TRUE
); 
1920     while (hWnd 
&& (hWnd 
!= GetHwnd())) 
1921         hWnd 
= ::WinQueryWindow(hWnd
, QW_PARENT
); 
1923     return hWnd 
!= NULL
; 
1924 } // end of wxWindowOS2::IsMouseInWindow 
1926 #if wxUSE_CARET && WXWIN_COMPATIBILITY 
1927 // --------------------------------------------------------------------------- 
1928 // Caret manipulation 
1929 // --------------------------------------------------------------------------- 
1931 void wxWindowOS2::CreateCaret( 
1936     SetCaret(new wxCaret( this 
1940 } // end of wxWindowOS2::CreateCaret 
1942 void wxWindowOS2::CreateCaret( 
1943   const wxBitmap
*                   pBitmap
 
1946     wxFAIL_MSG("not implemented"); 
1947 } // end of wxWindowOS2::CreateCaret 
1949 void wxWindowOS2::ShowCaret( 
1953     wxCHECK_RET( m_caret
, "no caret to show" ); 
1955     m_caret
->Show(bShow
); 
1956 } // end of wxWindowOS2::ShowCaret 
1958 void wxWindowOS2::DestroyCaret() 
1961 } // end of wxWindowOS2::DestroyCaret 
1963 void wxWindowOS2::SetCaretPos( 
1967     wxCHECK_RET( m_caret
, "no caret to move" ); 
1972 } // end of wxWindowOS2::SetCaretPos 
1974 void wxWindowOS2::GetCaretPos( 
1979     wxCHECK_RET( m_caret
, "no caret to get position of" ); 
1981     m_caret
->GetPosition( pX
 
1984 } // end of wxWindowOS2::GetCaretPos 
1986 #endif //wxUSE_CARET 
1988 // --------------------------------------------------------------------------- 
1990 // --------------------------------------------------------------------------- 
1992 #if wxUSE_MENUS_NATIVE 
1993 static void wxYieldForCommandsOnly() 
1996     // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't 
1997     // want to process it here) 
2001     while (::WinPeekMsg(vHabmain
, &vMsg
, (HWND
)0, WM_COMMAND
, 
2002            WM_COMMAND
,PM_REMOVE
) && vMsg
.msg 
!= WM_QUIT
) 
2004         wxTheApp
->DoMessage((WXMSG
*)&vMsg
); 
2007 #endif // wxUSE_MENUS_NATIVE 
2009 #if wxUSE_MENUS_NATIVE 
2010 bool wxWindowOS2::DoPopupMenu( 
2016     HWND                            hWnd 
= GetHwnd(); 
2017     HWND                            hWndParent 
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0; 
2018     HWND                            hMenu 
= GetHmenuOf(pMenu
); 
2020     pMenu
->SetInvokingWindow(this); 
2023     DoClientToScreen( &nX
 
2026     wxCurrentPopupMenu 
= pMenu
; 
2028     ::WinPopupMenu( hWndParent
 
2034                    ,PU_MOUSEBUTTON2DOWN 
| PU_MOUSEBUTTON2 
| PU_KEYBOARD
 
2036     // we need to do it righ now as otherwise the events are never going to be 
2037     // sent to wxCurrentPopupMenu from ;() 
2039     // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't 
2040     // help and we'd still need wxYieldForCommandsOnly() as the menu may be 
2041     // destroyed as soon as we return (it can be a local variable in the caller 
2042     // for example) and so we do need to process the event immediately 
2043     wxYieldForCommandsOnly(); 
2044     wxCurrentPopupMenu 
= NULL
; 
2046     pMenu
->SetInvokingWindow(NULL
); 
2048 } // end of wxWindowOS2::DoPopupMenu 
2049 #endif // wxUSE_MENUS_NATIVE 
2051 // =========================================================================== 
2052 // pre/post message processing 
2053 // =========================================================================== 
2055 MRESULT 
wxWindowOS2::OS2DefWindowProc( 
2062         return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
); 
2064         return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
); 
2065 } // end of wxWindowOS2::OS2DefWindowProc 
2067 bool wxWindowOS2::OS2ProcessMessage( 
2071 // wxUniversal implements tab traversal itself 
2072 #ifndef __WXUNIVERSAL__ 
2073     QMSG
*                           pQMsg 
= (QMSG
*)pMsg
; 
2075     if (m_hWnd 
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
)) 
2078         // Intercept dialog navigation keys 
2080         bool                        bProcess 
= TRUE
; 
2081         USHORT                      uKeyFlags 
= SHORT1FROMMP(pQMsg
->mp1
); 
2083         if (uKeyFlags 
& KC_KEYUP
) 
2086         if (uKeyFlags 
& KC_ALT
) 
2089         if (!(uKeyFlags 
& KC_VIRTUALKEY
)) 
2094             bool                    bCtrlDown 
= IsCtrlDown(); 
2095             bool                    bShiftDown 
= IsShiftDown(); 
2098             // WM_QUERYDLGCODE: ask the control if it wants the key for itself, 
2099             // don't process it if it's the case (except for Ctrl-Tab/Enter 
2100             // combinations which are always processed) 
2102             ULONG                   ulDlgCode 
= 0; 
2106                 ulDlgCode 
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0); 
2109             bool                    bForward 
= TRUE
; 
2110             bool                    bWindowChange 
= FALSE
; 
2112             switch (SHORT2FROMMP(pQMsg
->mp2
)) 
2115                 // Going to make certain assumptions about specific types of controls 
2116                 // here, so we may have to alter some things later if they prove invalid 
2120                     // Shift tabl will always be a nav-key but tabs may be wanted 
2129                         // Entry Fields want tabs for themselve usually 
2133                             case DLGC_ENTRYFIELD
: 
2143                         // Ctrl-Tab cycles thru notebook pages 
2145                         bWindowChange 
= bCtrlDown
; 
2146                         bForward 
= !bShiftDown
; 
2169                             // ctrl-enter is not processed 
2173                         else if (ulDlgCode 
& DLGC_BUTTON
) 
2176                             // buttons want process Enter themselevs 
2182                             wxButton
*   pBtn 
= wxDynamicCast( GetDefaultItem() 
2186                             if (pBtn 
&& pBtn
->IsEnabled()) 
2189                                 // If we do have a default button, do press it 
2191                                 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */); 
2194                             // else: but if it does not it makes sense to make 
2195                             //       it work like a TAB - and that's what we do. 
2196                             //       Note that Ctrl-Enter always works this way. 
2207                 wxNavigationKeyEvent    vEvent
; 
2209                 vEvent
.SetDirection(bForward
); 
2210                 vEvent
.SetWindowChange(bWindowChange
); 
2211                 vEvent
.SetEventObject(this); 
2213                 if (GetEventHandler()->ProcessEvent(vEvent
)) 
2215                     wxButton
*       pBtn 
= wxDynamicCast(FindFocus(), wxButton
); 
2220                         // The button which has focus should be default 
2229         // Let Dialogs process 
2231         if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0)); 
2235     pMsg 
= pMsg
; // just shut up the compiler 
2236 #endif // __WXUNIVERSAL__ 
2241         // relay mouse move events to the tooltip control 
2242         QMSG
*                       pQMsg 
= (QMSG
*)pMsg
; 
2244         if (pQMsg
->msg 
== WM_MOUSEMOVE 
) 
2245             m_tooltip
->RelayEvent(pMsg
); 
2247 #endif // wxUSE_TOOLTIPS 
2250 } // end of wxWindowOS2::OS2ProcessMessage 
2252 bool wxWindowOS2::OS2TranslateMessage( 
2256 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__) 
2257   return m_acceleratorTable
.Translate(m_hWnd
, pMsg
); 
2261 #endif //wxUSE_ACCEL 
2262 } // end of wxWindowOS2::OS2TranslateMessage 
2264 // --------------------------------------------------------------------------- 
2265 // message params unpackers 
2266 // --------------------------------------------------------------------------- 
2268 void wxWindowOS2::UnpackCommand( 
2276     *pId 
= LOWORD(wParam
); 
2277     *phWnd 
= NULL
;  // or may be GetHWND() ? 
2278     *pCmd 
= LOWORD(lParam
); 
2279 } // end of wxWindowOS2::UnpackCommand 
2281 void wxWindowOS2::UnpackActivate( 
2288     *pState     
= LOWORD(wParam
); 
2289     *phWnd      
= (WXHWND
)lParam
; 
2290 } // end of wxWindowOS2::UnpackActivate 
2292 void wxWindowOS2::UnpackScroll( 
2303     ulId    
= (ULONG
)LONGFROMMP(wParam
); 
2304     hWnd 
= ::WinWindowFromID(GetHwnd(), ulId
); 
2305     if (hWnd 
== m_hWndScrollBarHorz 
|| hWnd 
== m_hWndScrollBarVert
) 
2306         *phWnd 
= NULLHANDLE
; 
2310     *pPos  
= SHORT1FROMMP(lParam
); 
2311     *pCode 
= SHORT2FROMMP(lParam
); 
2312 } // end of wxWindowOS2::UnpackScroll 
2314 void wxWindowOS2::UnpackMenuSelect( 
2322     *pItem 
= (WXWORD
)LOWORD(wParam
); 
2323     *pFlags 
= HIWORD(wParam
); 
2324     *phMenu 
= (WXHMENU
)lParam
; 
2325 } // end of wxWindowOS2::UnpackMenuSelect 
2327 // --------------------------------------------------------------------------- 
2328 // Main wxWindows window proc and the window proc for wxWindow 
2329 // --------------------------------------------------------------------------- 
2332 // Hook for new window just as it's being created, when the window isn't yet 
2333 // associated with the handle 
2335 wxWindowOS2
*                         wxWndHook 
= NULL
; 
2340 MRESULT EXPENTRY 
wxWndProc( 
2348     // Trace all ulMsgs - useful for the debugging 
2351     wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"), 
2352                wxGetMessageName(ulMsg
), wParam
, lParam
); 
2353 #endif // __WXDEBUG__ 
2355     wxWindowOS2
*                    pWnd 
= wxFindWinFromHandle((WXHWND
)hWnd
); 
2358     // When we get the first message for the HWND we just created, we associate 
2359     // it with wxWindow stored in wxWndHook 
2361     if (!pWnd 
&& wxWndHook
) 
2363         wxAssociateWinWithHandle(hWnd
, wxWndHook
); 
2366         pWnd
->SetHWND((WXHWND
)hWnd
); 
2369     MRESULT                         rc 
= (MRESULT
)0; 
2373     // Stop right here if we don't have a valid handle in our wxWindow object. 
2375     if (pWnd 
&& !pWnd
->GetHWND()) 
2377         pWnd
->SetHWND((WXHWND
) hWnd
); 
2378         rc 
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam 
); 
2384             rc 
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
); 
2386             rc 
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
); 
2390 } // end of wxWndProc 
2393 // We will add (or delete) messages we need to handle at this default 
2396 MRESULT 
wxWindowOS2::OS2WindowProc( 
2403     // Did we process the uMsg? 
2405     bool                            bProcessed 
= FALSE
; 
2409     // For most messages we should return 0 when we do process the message 
2411     mResult 
= (MRESULT
)0; 
2419                 bProcessed 
= HandleCreate( (WXLPCREATESTRUCT
)lParam
 
2425                     // Return 0 to bAllow window creation 
2427                     mResult 
= (MRESULT
)(bMayCreate 
? 0 : -1); 
2438             bProcessed 
= HandleMove( LOWORD(lParam
) 
2444             bProcessed 
= HandleSize( LOWORD(lParam
) 
2450         case WM_WINDOWPOSCHANGED
: 
2453             // Dialogs under OS/2 do not get WM_SIZE events at all. 
2454             // Instead they get this, which can function much like WM_SIZE 
2455             // PSWP contains the new sizes and positioning, PSWP+1 the old 
2456             // We use this because ADJUSTWINDOWPOS comes BEFORE the new 
2457             // position is added and our auto layout does a WinQueryWindowRect 
2458             // to get the CURRENT client size.  That is the size used to position 
2459             // child controls, so we need to already be sized 
2460             // in order to get the child controls positoned properly. 
2462             if (IsKindOf(CLASSINFO(wxDialog
))) 
2464                 PSWP                pSwp 
= (PSWP
)PVOIDFROMMP(wParam
); 
2466                 bProcessed 
= HandleSize( pSwp
->cx
 
2478                 UnpackActivate( wParam
 
2484                 bProcessed 
= HandleActivate( wState
 
2492             if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
) 
2493                 bProcessed 
= HandleSetFocus((WXHWND
)(HWND
)wParam
); 
2495                 bProcessed 
= HandleKillFocus((WXHWND
)(HWND
)wParam
); 
2499             bProcessed 
= HandlePaint(); 
2504             // Don't let the DefWindowProc() destroy our window - we'll do it 
2505             // ourselves in ~wxWindow 
2508             mResult 
= (MRESULT
)TRUE
; 
2512             bProcessed 
= HandleShow(wParam 
!= 0, (int)lParam
); 
2516         // Under OS2 PM Joysticks are treated just like mouse events 
2517         // The "Motion" events will be prevelent in joysticks 
2520         case WM_BUTTON1DOWN
: 
2522         case WM_BUTTON1DBLCLK
: 
2523         case WM_BUTTON1MOTIONEND
: 
2524         case WM_BUTTON1MOTIONSTART
: 
2525         case WM_BUTTON2DOWN
: 
2527         case WM_BUTTON2DBLCLK
: 
2528         case WM_BUTTON2MOTIONEND
: 
2529         case WM_BUTTON2MOTIONSTART
: 
2530         case WM_BUTTON3DOWN
: 
2532         case WM_BUTTON3DBLCLK
: 
2533         case WM_BUTTON3MOTIONEND
: 
2534         case WM_BUTTON3MOTIONSTART
: 
2536                 short x 
= LOWORD(lParam
); 
2537                 short y 
= HIWORD(lParam
); 
2539                 bProcessed 
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
); 
2543             bProcessed 
= HandleSysCommand(wParam
, lParam
); 
2550                 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
); 
2552                 bProcessed 
= HandleCommand(id
, cmd
, hwnd
); 
2557             // For these messages we must return TRUE if process the message 
2560         case WM_MEASUREITEM
: 
2562                 int                 nIdCtrl 
= (UINT
)wParam
; 
2564                 if ( uMsg 
== WM_DRAWITEM 
) 
2566                     bProcessed 
= OS2OnDrawItem(nIdCtrl
, 
2567                                               (WXDRAWITEMSTRUCT 
*)lParam
); 
2571                     bProcessed 
= OS2OnMeasureItem(nIdCtrl
, 
2572                                                  (WXMEASUREITEMSTRUCT 
*)lParam
); 
2576                     mResult 
= (MRESULT
)TRUE
; 
2580         case WM_QUERYDLGCODE
: 
2583                 mResult 
= (MRESULT
)m_lDlgCode
; 
2587             //else: get the dlg code from the DefWindowProc() 
2592         // In OS/2 PM all keyboard events are of the WM_CHAR type.  Virtual key and key-up 
2593         // and key-down events are obtained from the WM_CHAR params. 
2597                 USHORT                  uKeyFlags 
= SHORT1FROMMP((MPARAM
)wParam
); 
2599                 if (uKeyFlags 
& KC_KEYUP
) 
2601                     //TODO: check if the cast to WXWORD isn't causing trouble 
2602                     bProcessed 
= HandleKeyUp((WXDWORD
)wParam
, lParam
); 
2605                 else // keydown event 
2608                     // If this has been processed by an event handler, 
2609                     // return 0 now (we've handled it). DON't RETURN 
2610                     // we still need to process further 
2612                     HandleKeyDown((WXDWORD
)wParam
, lParam
); 
2613                     if (uKeyFlags 
& KC_VIRTUALKEY
) 
2615                         USHORT          uVk 
= SHORT2FROMMP((MPARAM
)lParam
); 
2618                         // We consider these message "not interesting" to OnChar 
2620                         if (uVk 
== VK_SHIFT 
|| uVk 
== VK_CTRL 
) 
2628                             // Avoid duplicate messages to OnChar for these ASCII keys: they 
2629                             // will be translated by TranslateMessage() and received in WM_CHAR 
2635                                 // But set processed to FALSE, not TRUE to still pass them to 
2636                                 // the control's default window proc - otherwise built-in 
2637                                 // keyboard handling won't work 
2646                                 bProcessed 
= HandleChar((WXDWORD
)wParam
, lParam
); 
2650                     else // WM_CHAR -- Always an ASCII character 
2652                         bProcessed 
= HandleChar((WXDWORD
)wParam
, lParam
, TRUE
); 
2664                 UnpackScroll( wParam
 
2671                 bProcessed 
= OS2OnScroll( uMsg 
== WM_HSCROLL 
? wxHORIZONTAL
 
2681             switch(SHORT2FROMMP(wParam
)) 
2684                 case SPBN_DOWNARROW
: 
2690                         ::WinSendMsg( HWNDFROMMP(lParam
) 
2693                                      ,MPFROM2SHORT( (USHORT
)10 
2694                                                    ,(USHORT
)SPBQ_UPDATEIFVALID
 
2698                         bProcessed 
= OS2OnScroll( wxVERTICAL
 
2699                                                  ,(int)SHORT2FROMMP(wParam
) 
2706                 case SLN_SLIDERTRACK
: 
2708                         HWND                hWnd 
= ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam
)); 
2709                         wxWindowOS2
*        pChild 
= wxFindWinFromHandle(hWnd
); 
2711                         if (pChild
->IsKindOf(CLASSINFO(wxSlider
))) 
2712                             bProcessed 
= OS2OnScroll( wxVERTICAL
 
2713                                                      ,(int)SHORT2FROMMP(wParam
) 
2714                                                      ,(int)LONGFROMMP(lParam
) 
2722 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400) 
2723         case WM_CTLCOLORCHANGE
: 
2725                 bProcessed 
= HandleCtlColor(&hBrush
); 
2729         case WM_ERASEBACKGROUND
: 
2731             // Returning TRUE to requestw PM to paint the window background 
2732             // in SYSCLR_WINDOW. We don't really want that 
2734             bProcessed 
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
); 
2735             mResult 
= (MRESULT
)(FALSE
); 
2738             // the return value for this message is ignored 
2739         case WM_SYSCOLORCHANGE
: 
2740             bProcessed 
= HandleSysColorChange(); 
2743         case WM_REALIZEPALETTE
: 
2744             bProcessed 
= HandlePaletteChanged(); 
2747         // move all drag and drops to wxDrg 
2749             bProcessed 
= HandleEndDrag(wParam
); 
2753             bProcessed 
= HandleInitDialog((WXHWND
)(HWND
)wParam
); 
2757                 // we never set focus from here 
2762         // wxFrame specific message 
2763         case WM_MINMAXFRAME
: 
2764             bProcessed 
= HandleGetMinMaxInfo((PSWP
)wParam
); 
2767         case WM_SYSVALUECHANGED
: 
2768             // TODO: do something 
2769             mResult 
= (MRESULT
)TRUE
; 
2773         // Comparable to WM_SETPOINTER for windows, only for just controls 
2775         case WM_CONTROLPOINTER
: 
2776             bProcessed 
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID 
2777                                          ,(HWND
)lParam         
// Cursor Handle 
2782                 // Returning TRUE stops the DefWindowProc() from further 
2783                 // processing this message - exactly what we need because we've 
2784                 // just set the cursor. 
2786                 mResult 
= (MRESULT
)TRUE
; 
2793         wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."), 
2794                    wxGetMessageName(uMsg
)); 
2795 #endif // __WXDEBUG__ 
2796         if (IsKindOf(CLASSINFO(wxFrame
))) 
2797             mResult 
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
); 
2798         else if (IsKindOf(CLASSINFO(wxDialog
))) 
2799             mResult 
= ::WinDefDlgProc( m_hWnd
, uMsg
, wParam
, lParam
); 
2801             mResult 
= OS2DefWindowProc(uMsg
, wParam
, lParam
); 
2804 } // end of wxWindowOS2::OS2WindowProc 
2807 // Dialog window proc 
2812 , MPARAM                            
WXUNUSED(wParam
) 
2813 , MPARAM                            
WXUNUSED(lParam
)) 
2815     if (uMsg 
== WM_INITDLG
) 
2818         // For this message, returning TRUE tells system to set focus to the 
2819         // first control in the dialog box 
2821         return (MRESULT
)TRUE
; 
2826         // For all the other ones, FALSE means that we didn't process the 
2831 } // end of wxDlgProc 
2833 wxWindow
* wxFindWinFromHandle( 
2837     wxNode
*                         pNode 
= wxWinHandleList
->Find((long)hWnd
); 
2841     return (wxWindow 
*)pNode
->Data(); 
2842 } // end of wxFindWinFromHandle 
2844 void wxAssociateWinWithHandle( 
2850     // Adding NULL hWnd is (first) surely a result of an error and 
2851     // (secondly) breaks menu command processing 
2853     wxCHECK_RET( hWnd 
!= (HWND
)NULL
, 
2854                  wxT("attempt to add a NULL hWnd to window list ignored") ); 
2857     wxWindow
*                       pOldWin 
= wxFindWinFromHandle((WXHWND
) hWnd
); 
2859     if (pOldWin 
&& (pOldWin 
!= pWin
)) 
2861         wxString                    
str(pWin
->GetClassInfo()->GetClassName()); 
2862         wxLogError( "Bug! Found existing HWND %X for new window of class %s" 
2869         wxWinHandleList
->Append( (long)hWnd
 
2873 } // end of wxAssociateWinWithHandle 
2875 void wxRemoveHandleAssociation( 
2879     wxWinHandleList
->DeleteObject(pWin
); 
2880 } // end of wxRemoveHandleAssociation 
2883 // Default destroyer - override if you destroy it in some other way 
2884 // (e.g. with MDI child windows) 
2886 void wxWindowOS2::OS2DestroyWindow() 
2890 bool wxWindowOS2::OS2GetCreateWindowCoords( 
2892 , const wxSize
&                     rSize
 
2899     bool                            bNonDefault 
= FALSE
; 
2904         // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can 
2905         // just as well set it to CW_USEDEFAULT as well 
2906         rnX 
= rnY 
= CW_USEDEFAULT
; 
2911         rnY 
= rPos
.y 
== -1 ? CW_USEDEFAULT 
: rPos
.y
; 
2917         // As abobe, h is not used at all in this case anyhow 
2919         rnWidth 
= rnHeight 
= CW_USEDEFAULT
; 
2924         rnHeight 
= rSize
.y 
== -1 ? CW_USEDEFAULT 
: rSize
.y
; 
2928 } // end of wxWindowOS2::OS2GetCreateWindowCoords 
2930 bool wxWindowOS2::OS2Create( 
2932 , const char*                       zTitle
 
2934 , const wxPoint
&                    rPos
 
2935 , const wxSize
&                     rSize
 
2947     wxWindow
*                       pParent 
= GetParent(); 
2948     HWND                            hWnd 
= NULLHANDLE
; 
2950     long                            lControlId 
= 0L; 
2951     wxWindowCreationHook            
vHook(this); 
2952     wxString                        
sClassName((wxChar
*)zClass
); 
2954     OS2GetCreateWindowCoords( rPos
 
2962     if (GetWindowStyleFlag() & wxPOPUP_WINDOW
) 
2963         hParent 
= HWND_DESKTOP
; 
2966         if ((bIsChild 
|| HasFlag(wxFRAME_TOOL_WINDOW
)) && pParent 
) 
2969             // This is either a normal child window or a top level window with 
2970             // wxFRAME_TOOL_WINDOW style (see below) 
2972             hParent 
= GetHwndOf(pParent
); 
2977             // This is either a window for which no parent was specified (not 
2978             // much we can do then) or a frame without wxFRAME_TOOL_WINDOW 
2979             // style: we should use NULL parent HWND for it or it would be 
2980             // always on top of its parent which is not what we usually want 
2981             // (in fact, we only want it for frames with the special 
2982             // wxFRAME_TOOL_WINDOW as above) 
2989         lControlId 
= GetId(); 
2990         if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
) 
2992             dwStyle 
|= WS_CLIPSIBLINGS
; 
2996     // For each class "Foo" we have we also have "FooNR" ("no repaint") class 
2997     // which is the same but without CS_[HV]REDRAW class styles so using it 
2998     // ensures that the window is not fully repainted on each resize 
3000     if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE
) 
3002         sClassName 
+= wxT("NR"); 
3006     // If the window being created is a Frame's Statusbar we need to use 
3007     // the actual Frame's size, not its client 
3011         if (IsKindOf(CLASSINFO(wxStatusBar
)) && 
3012             pParent
->IsKindOf(CLASSINFO(wxFrame
))) 
3015             wxFrame
*                pFrame 
= wxDynamicCast(pParent
, wxFrame
); 
3017             ::WinQueryWindowRect((HWND
)pFrame
->GetFrame(), &vRect
); 
3018             nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
3021             nY 
= pParent
->GetSize().y 
- (nY 
+ nHeight
); 
3027         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
3028         nY 
= vRect
.yTop 
- (nY 
+ nHeight
); 
3030     m_hWnd 
= (WXHWND
)::WinCreateWindow( (HWND
)hParent
 
3031                                       ,(PSZ
)sClassName
.c_str() 
3032                                       ,(PSZ
)zTitle 
? zTitle 
: "" 
3046         vError 
= ::WinGetLastError(wxGetInstance()); 
3047         sError 
= wxPMErrorToStr(vError
); 
3050     SubclassWin(m_hWnd
); 
3051     SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
)); 
3058 } // end of WinGuiBase_Window::OS2Create 
3060 // =========================================================================== 
3061 // OS2 PM message handlers 
3062 // =========================================================================== 
3064 // --------------------------------------------------------------------------- 
3065 // window creation/destruction 
3066 // --------------------------------------------------------------------------- 
3068 bool wxWindowOS2::HandleCreate( 
3069   WXLPCREATESTRUCT                  
WXUNUSED(vCs
) 
3073     wxWindowCreateEvent             
vEvent((wxWindow
*)this); 
3075     (void)GetEventHandler()->ProcessEvent(vEvent
); 
3076     *pbMayCreate 
= TRUE
; 
3078 } // end of wxWindowOS2::HandleCreate 
3080 bool wxWindowOS2::HandleDestroy() 
3082     wxWindowDestroyEvent            
vEvent((wxWindow
*)this); 
3084     (void)GetEventHandler()->ProcessEvent(vEvent
); 
3087     // Delete our drop target if we've got one 
3089 #if wxUSE_DRAG_AND_DROP 
3090     if (m_dropTarget 
!= NULL
) 
3092         m_dropTarget
->Revoke(m_hWnd
); 
3093         delete m_dropTarget
; 
3094         m_dropTarget 
= NULL
; 
3096 #endif // wxUSE_DRAG_AND_DROP 
3099     // WM_DESTROY handled 
3102 } // end of wxWindowOS2::HandleDestroy 
3104 // --------------------------------------------------------------------------- 
3106 // --------------------------------------------------------------------------- 
3107 void wxWindowOS2::OnSetFocus( 
3108   wxFocusEvent
&                     rEvent
 
3112 } // end of wxWindowOS2::OnSetFocus 
3114 bool wxWindowOS2::HandleActivate( 
3116 , WXHWND                            
WXUNUSED(hActivate
) 
3119     wxActivateEvent                 
vEvent( wxEVT_ACTIVATE
 
3123     vEvent
.SetEventObject(this); 
3124     return GetEventHandler()->ProcessEvent(vEvent
); 
3125 } // end of wxWindowOS2::HandleActivate 
3127 bool wxWindowOS2::HandleSetFocus( 
3128   WXHWND                            
WXUNUSED(hWnd
) 
3137         m_caret
->OnSetFocus(); 
3139 #endif // wxUSE_CARET 
3142     // If it's a wxTextCtrl don't send the event as it will be done 
3143     // after the control gets to process it from EN_FOCUS handler 
3144     if ( wxDynamicCastThis(wxTextCtrl
) ) 
3148 #endif // wxUSE_TEXTCTRL 
3150     wxFocusEvent                    
vEvent(wxEVT_SET_FOCUS
, m_windowId
); 
3152     vEvent
.SetEventObject(this); 
3153     return GetEventHandler()->ProcessEvent(vEvent
); 
3154 } // end of wxWindowOS2::HandleSetFocus 
3156 bool wxWindowOS2::HandleKillFocus( 
3157   WXHWND                            
WXUNUSED(hWnd
) 
3166         m_caret
->OnKillFocus(); 
3168 #endif // wxUSE_CARET 
3170     wxFocusEvent                    
vEvent( wxEVT_KILL_FOCUS
 
3174     vEvent
.SetEventObject(this); 
3175     return GetEventHandler()->ProcessEvent(vEvent
); 
3176 } // end of wxWindowOS2::HandleKillFocus 
3178 // --------------------------------------------------------------------------- 
3180 // --------------------------------------------------------------------------- 
3182 bool wxWindowOS2::HandleShow( 
3184 , int                               WXUNUSED(nStatus
) 
3187     wxShowEvent                     
vEvent(GetId(), bShow
); 
3189     vEvent
.m_eventObject 
= this; 
3190     return GetEventHandler()->ProcessEvent(vEvent
); 
3191 } // end of wxWindowOS2::HandleShow 
3193 bool wxWindowOS2::HandleInitDialog( 
3194   WXHWND                            
WXUNUSED(hWndFocus
) 
3197     wxInitDialogEvent               
vEvent(GetId()); 
3199     vEvent
.m_eventObject 
= this; 
3200     return GetEventHandler()->ProcessEvent(vEvent
); 
3201 } // end of wxWindowOS2::HandleInitDialog 
3203 bool wxWindowOS2::HandleEndDrag(WXWPARAM 
WXUNUSED(wParam
)) 
3205    // TODO: We'll handle drag and drop later 
3209 bool wxWindowOS2::HandleSetCursor( 
3210   USHORT                            
WXUNUSED(vId
) 
3215     // Under OS/2 PM this allows the pointer to be changed 
3216     // as it passes over a control 
3218     ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
); 
3220 } // end of wxWindowOS2::HandleSetCursor 
3222 // --------------------------------------------------------------------------- 
3223 // owner drawn stuff 
3224 // --------------------------------------------------------------------------- 
3225 bool wxWindowOS2::OS2OnDrawItem( 
3227 , WXDRAWITEMSTRUCT
*                 pItemStruct
 
3230 #if wxUSE_OWNER_DRAWN 
3233 #if wxUSE_MENUS_NATIVE 
3235     // Is it a menu item? 
3241         POWNERITEM                  pMeasureStruct 
= (POWNERITEM
)pItemStruct
; 
3242         wxFrame
*                    pFrame 
= (wxFrame
*)this; 
3243         wxMenuItem
*                 pMenuItem 
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
); 
3244         HDC                         hDC 
= ::GpiQueryDevice(pMeasureStruct
->hps
); 
3245         wxRect                      
vRect( pMeasureStruct
->rclItem
.xLeft
 
3246                                           ,pMeasureStruct
->rclItem
.yBottom
 
3247                                           ,pMeasureStruct
->rclItem
.xRight 
- pMeasureStruct
->rclItem
.xLeft
 
3248                                           ,pMeasureStruct
->rclItem
.yTop 
- pMeasureStruct
->rclItem
.yBottom
 
3253         vDc
.SetHPS(pMeasureStruct
->hps
); 
3255         // Load the wxWindows Pallete and set to RGB mode 
3257         if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
 
3261                                       ,(LONG
)wxTheColourDatabase
->m_nSize
 
3262                                       ,(PLONG
)wxTheColourDatabase
->m_palTable
 
3265             vError 
= ::WinGetLastError(vHabmain
); 
3266             sError 
= wxPMErrorToStr(vError
); 
3267             wxLogError("Unable to set current color table. Error: %s\n", sError
); 
3270         // Set the color table to RGB mode 
3272         if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
 
3280             vError 
= ::WinGetLastError(vHabmain
); 
3281             sError 
= wxPMErrorToStr(vError
); 
3282             wxLogError("Unable to set current color table. Error: %s\n", sError
); 
3285         wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE 
); 
3291         if (pMeasureStruct
->fsAttribute 
== pMeasureStruct
->fsAttributeOld
) 
3294             // Entire Item needs to be redrawn (either it has reappeared from 
3295             // behind another window or is being displayed for the first time 
3297             eAction 
= wxOwnerDrawn::wxODDrawAll
; 
3299             if (pMeasureStruct
->fsAttribute 
& MIA_HILITED
) 
3302                 // If it is currently selected we let the system handle it 
3304                 eStatus 
|= wxOwnerDrawn::wxODSelected
; 
3306             if (pMeasureStruct
->fsAttribute 
& MIA_CHECKED
) 
3309                 // If it is currently checked we draw our own 
3311                 eStatus 
|= wxOwnerDrawn::wxODChecked
; 
3312                 pMeasureStruct
->fsAttributeOld 
= pMeasureStruct
->fsAttribute 
&= ~MIA_CHECKED
; 
3314             if (pMeasureStruct
->fsAttribute 
& MIA_DISABLED
) 
3317                 // If it is currently disabled we let the system handle it 
3319                 eStatus 
|= wxOwnerDrawn::wxODDisabled
; 
3322             // Don't really care about framed (indicationg focus) or NoDismiss 
3327             if (pMeasureStruct
->fsAttribute 
& MIA_HILITED
) 
3329                 eAction 
= wxOwnerDrawn::wxODDrawAll
; 
3330                 eStatus 
|= wxOwnerDrawn::wxODSelected
; 
3332                 // Keep the system from trying to highlight with its bogus colors 
3334                 pMeasureStruct
->fsAttributeOld 
= pMeasureStruct
->fsAttribute 
&= ~MIA_HILITED
; 
3336             else if (!(pMeasureStruct
->fsAttribute 
& MIA_HILITED
)) 
3338                 eAction 
= wxOwnerDrawn::wxODDrawAll
; 
3341                 // Keep the system from trying to highlight with its bogus colors 
3343                 pMeasureStruct
->fsAttribute 
= pMeasureStruct
->fsAttributeOld 
&= ~MIA_HILITED
; 
3348                 // For now we don't care about anything else 
3349                 // just ignore the entire message! 
3355         // Now redraw the item 
3357         return(pMenuItem
->OnDrawItem( vDc
 
3359                                      ,(wxOwnerDrawn::wxODAction
)eAction
 
3360                                      ,(wxOwnerDrawn::wxODStatus
)eStatus
 
3363         // leave the fsAttribute and fsOldAttribute unchanged.  If different, 
3364         // the system will do the highlight or fraeming or disabling for us, 
3365         // otherwise, we'd have to do it ourselves. 
3368 #endif // wxUSE_MENUS_NATIVE 
3370     wxWindow
*                       pItem 
= FindItem(vId
); 
3372     if (pItem 
&& pItem
->IsKindOf(CLASSINFO(wxControl
))) 
3374         return ((wxControl 
*)pItem
)->OS2OnDraw(pItemStruct
); 
3378     pItemStruct 
= pItemStruct
; 
3381 } // end of wxWindowOS2::OS2OnDrawItem 
3383 bool wxWindowOS2::OS2OnMeasureItem( 
3385 , WXMEASUREITEMSTRUCT
*              pItemStruct
 
3388 #if wxUSE_OWNER_DRAWN 
3390     // Is it a menu item? 
3392     if (lId 
== 65536) // I really don't like this...has to be a better indicator 
3394         if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu 
3398             POWNERITEM              pMeasureStruct 
= (POWNERITEM
)pItemStruct
; 
3399             wxFrame
*                pFrame 
= (wxFrame
*)this; 
3400             wxMenuItem
*             pMenuItem 
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
); 
3402             wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE 
); 
3405             if (pMenuItem
->OnMeasureItem( &nWidth
 
3409                 pMeasureStruct
->rclItem
.xRight  
= nWidth
; 
3410                 pMeasureStruct
->rclItem
.xLeft   
= 0L; 
3411                 pMeasureStruct
->rclItem
.yTop    
= nHeight
; 
3412                 pMeasureStruct
->rclItem
.yBottom 
= 0L; 
3418     wxWindow
*                      pItem 
= FindItem(lId
); 
3420     if (pItem 
&& pItem
->IsKindOf(CLASSINFO(wxControl
))) 
3422         return ((wxControl 
*)pItem
)->OS2OnMeasure(pItemStruct
); 
3426     pItemStruct 
= pItemStruct
; 
3427 #endif // wxUSE_OWNER_DRAWN 
3431 // --------------------------------------------------------------------------- 
3432 // colours and palettes 
3433 // --------------------------------------------------------------------------- 
3435 bool wxWindowOS2::HandleSysColorChange() 
3437     wxSysColourChangedEvent         vEvent
; 
3439     vEvent
.SetEventObject(this); 
3440     return GetEventHandler()->ProcessEvent(vEvent
); 
3441 } // end of wxWindowOS2::HandleSysColorChange 
3443 bool wxWindowOS2::HandleCtlColor( 
3444   WXHBRUSH
*                         WXUNUSED(phBrush
) 
3448     // Not much provided with message. So not sure I can do anything with it 
3451 } // end of wxWindowOS2::HandleCtlColor 
3454 // Define for each class of dialog and control 
3455 WXHBRUSH 
wxWindowOS2::OnCtlColor(WXHDC 
WXUNUSED(hDC
), 
3456                                  WXHWND 
WXUNUSED(hWnd
), 
3457                                  WXUINT 
WXUNUSED(nCtlColor
), 
3458                                  WXUINT 
WXUNUSED(message
), 
3459                                  WXWPARAM 
WXUNUSED(wParam
), 
3460                                  WXLPARAM 
WXUNUSED(lParam
)) 
3465 bool wxWindowOS2::HandlePaletteChanged() 
3467     // need to set this to something first 
3468     WXHWND                          hWndPalChange 
= NULLHANDLE
; 
3470     wxPaletteChangedEvent           
vEvent(GetId()); 
3472     vEvent
.SetEventObject(this); 
3473     vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
)); 
3475     return GetEventHandler()->ProcessEvent(vEvent
); 
3476 } // end of wxWindowOS2::HandlePaletteChanged 
3479 // Responds to colour changes: passes event on to children. 
3481 void wxWindowOS2::OnSysColourChanged( 
3482   wxSysColourChangedEvent
&          rEvent
 
3485     wxNode
*                         pNode 
= GetChildren().First(); 
3490         // Only propagate to non-top-level windows 
3492         wxWindow
*                   pWin 
= (wxWindow 
*)pNode
->Data(); 
3494         if (pWin
->GetParent()) 
3496             wxSysColourChangedEvent vEvent
; 
3498             rEvent
.m_eventObject 
= pWin
; 
3499             pWin
->GetEventHandler()->ProcessEvent(vEvent
); 
3501         pNode 
= pNode
->Next(); 
3503 } // end of wxWindowOS2::OnSysColourChanged 
3505 // --------------------------------------------------------------------------- 
3507 // --------------------------------------------------------------------------- 
3509 bool wxWindowOS2::HandlePaint() 
3512     wxPaintEvent                    
vEvent(m_windowId
); 
3517     // Create empty region 
3518     // TODO: get HPS somewhere else if possible 
3519     hPS  
= ::WinGetPS(GetHwnd()); 
3520     hRgn 
= ::GpiCreateRegion(hPS
, 0, NULL
); 
3522     if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
) 
3524          wxLogLastError("CreateRectRgn"); 
3528     m_updateRegion 
= wxRegion(hRgn
, hPS
); 
3530     vEvent
.SetEventObject(this); 
3531     bProcessed 
= GetEventHandler()->ProcessEvent(vEvent
); 
3533     return GetEventHandler()->ProcessEvent(vEvent
); //bProcessed; 
3534 } // end of wxWindowOS2::HandlePaint 
3536 bool wxWindowOS2::HandleEraseBkgnd( 
3543     ::WinQueryWindowPos(GetHwnd(), &vSwp
); 
3544     if (vSwp
.fl 
& SWP_MINIMIZE
) 
3549     vDC
.m_hPS 
= (HPS
)hDC
; // this is really a PS 
3550     vDC
.SetWindow((wxWindow
*)this); 
3553     wxEraseEvent                    
vEvent(m_windowId
, &vDC
); 
3555     vEvent
.SetEventObject(this); 
3557     rc 
= GetEventHandler()->ProcessEvent(vEvent
); 
3560     vDC
.m_hPS 
= NULLHANDLE
; 
3562 } // end of wxWindowOS2::HandleEraseBkgnd 
3564 void wxWindowOS2::OnEraseBackground( 
3565   wxEraseEvent
&                     rEvent
 
3569     HPS                             hPS 
= rEvent
.m_dc
->m_hPS
; 
3571     LONG                            lColor 
= m_backgroundColour
.GetPixel(); 
3573     rc 
= ::WinQueryWindowRect(GetHwnd(), &vRect
); 
3574     rc 
= ::WinFillRect(hPS
, &vRect
, lColor
); 
3575 }  // end of wxWindowOS2::OnEraseBackground 
3577 // --------------------------------------------------------------------------- 
3578 // moving and resizing 
3579 // --------------------------------------------------------------------------- 
3581 bool wxWindowOS2::HandleMinimize() 
3583     wxIconizeEvent                  
vEvent(m_windowId
); 
3585     vEvent
.SetEventObject(this); 
3586     return GetEventHandler()->ProcessEvent(vEvent
); 
3587 } // end of wxWindowOS2::HandleMinimize 
3589 bool wxWindowOS2::HandleMaximize() 
3591     wxMaximizeEvent                 
vEvent(m_windowId
); 
3593     vEvent
.SetEventObject(this); 
3594     return GetEventHandler()->ProcessEvent(vEvent
); 
3595 } // end of wxWindowOS2::HandleMaximize 
3597 bool wxWindowOS2::HandleMove( 
3602     wxMoveEvent                     
vEvent(wxPoint(nX
, nY
), m_windowId
); 
3604     vEvent
.SetEventObject(this); 
3605     return GetEventHandler()->ProcessEvent(vEvent
); 
3606 }  // end of wxWindowOS2::HandleMove 
3608 bool wxWindowOS2::HandleSize( 
3611 , WXUINT                            
WXUNUSED(nFlag
) 
3614     wxSizeEvent                     
vEvent(wxSize(nWidth
, nHeight
), m_windowId
); 
3616     vEvent
.SetEventObject(this); 
3617     return GetEventHandler()->ProcessEvent(vEvent
); 
3618 } // end of wxWindowOS2::HandleSize 
3620 bool wxWindowOS2::HandleGetMinMaxInfo( 
3630             ::WinGetMaxPosition(GetHwnd(), pSwp
); 
3631             m_maxWidth 
= pSwp
->cx
; 
3632             m_maxHeight 
= pSwp
->cy
; 
3636             ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
); 
3637             m_minWidth 
= pSwp
->cx
; 
3638             m_minHeight 
= pSwp
->cy
; 
3645 } // end of wxWindowOS2::HandleGetMinMaxInfo 
3647 // --------------------------------------------------------------------------- 
3649 // --------------------------------------------------------------------------- 
3650 bool wxWindowOS2::HandleCommand( 
3656 #if wxUSE_MENUS_NATIVE 
3657     if (wxCurrentPopupMenu
) 
3659         wxMenu
*                     pPopupMenu 
= wxCurrentPopupMenu
; 
3661         wxCurrentPopupMenu 
= NULL
; 
3662         return pPopupMenu
->OS2Command(wCmd
, wId
); 
3664 #endif // wxUSE_MENUS_NATIVE 
3666     wxWindow
*                       pWin 
= FindItem(wId
); 
3670         pWin 
= wxFindWinFromHandle(hControl
); 
3674         return pWin
->OS2Command(wCmd
, wId
); 
3677 } // end of wxWindowOS2::HandleCommand 
3679 bool wxWindowOS2::HandleSysCommand( 
3681 , WXLPARAM                          
WXUNUSED(lParam
) 
3685     // 4 bits are reserved 
3687     switch (SHORT1FROMMP(wParam
)) 
3690             return HandleMaximize(); 
3693             return HandleMinimize(); 
3696 } // end of wxWindowOS2::HandleSysCommand 
3698 // --------------------------------------------------------------------------- 
3700 // --------------------------------------------------------------------------- 
3701 //TODO!!! check against MSW 
3702 void wxWindowOS2::InitMouseEvent( 
3703   wxMouseEvent
&                     rEvent
 
3711     rEvent
.m_shiftDown   
= ((uFlags 
& VK_SHIFT
) != 0); 
3712     rEvent
.m_controlDown 
= ((uFlags 
& VK_CTRL
) != 0); 
3713     rEvent
.m_leftDown    
= ((uFlags 
& VK_BUTTON1
) != 0); 
3714     rEvent
.m_middleDown  
= ((uFlags 
& VK_BUTTON3
) != 0); 
3715     rEvent
.m_rightDown   
= ((uFlags 
& VK_BUTTON2
) != 0); 
3716     rEvent
.SetTimestamp(s_currentMsg
.time
); 
3717     rEvent
.m_eventObject 
= this; 
3719 #if wxUSE_MOUSEEVENT_HACK 
3722     m_lastMouseEvent 
= rEvent
.GetEventType(); 
3723 #endif // wxUSE_MOUSEEVENT_HACK 
3724 } // end of wxWindowOS2::InitMouseEvent 
3726 bool wxWindowOS2::HandleMouseEvent( 
3734     // The mouse events take consecutive IDs from WM_MOUSEFIRST to 
3735     // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST 
3736     // from the message id and take the value in the table to get wxWin event 
3739     static const wxEventType eventsMouse
[] = 
3753     wxMouseEvent                    
vEvent(eventsMouse
[uMsg 
- WM_MOUSEMOVE
]); 
3755     InitMouseEvent( vEvent
 
3761     return GetEventHandler()->ProcessEvent(vEvent
); 
3762 } // end of wxWindowOS2::HandleMouseEvent 
3764 bool wxWindowOS2::HandleMouseMove( 
3770     if (!m_bMouseInWindow
) 
3773         // Generate an ENTER event 
3775         m_bMouseInWindow 
= TRUE
; 
3777         wxMouseEvent                
vEvent(wxEVT_ENTER_WINDOW
); 
3779         InitMouseEvent( vEvent
 
3785         (void)GetEventHandler()->ProcessEvent(vEvent
); 
3787     return HandleMouseEvent( WM_MOUSEMOVE
 
3792 } // end of wxWindowOS2::HandleMouseMove 
3794 // --------------------------------------------------------------------------- 
3795 // keyboard handling 
3796 // --------------------------------------------------------------------------- 
3799 // Create the key event of the given type for the given key - used by 
3800 // HandleChar and HandleKeyDown/Up 
3802 wxKeyEvent 
wxWindowOS2::CreateKeyEvent( 
3808     wxKeyEvent                      
vEvent(eType
); 
3810     vEvent
.SetId(GetId()); 
3811     vEvent
.m_shiftDown   
= IsShiftDown(); 
3812     vEvent
.m_controlDown 
= IsCtrlDown(); 
3813     vEvent
.m_altDown     
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
; 
3815     vEvent
.m_eventObject 
= (wxWindow 
*)this; // const_cast 
3816     vEvent
.m_keyCode     
= nId
; 
3817     vEvent
.SetTimestamp(s_currentMsg
.time
); 
3820     // Translate the position to client coords 
3825     ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
); 
3826     ::WinQueryWindowRect( GetHwnd() 
3830     vPoint
.x 
-= vRect
.xLeft
; 
3831     vPoint
.y 
-= vRect
.yBottom
; 
3833     vEvent
.m_x 
= vPoint
.x
; 
3834     vEvent
.m_y 
= vPoint
.y
; 
3837 } // end of wxWindowOS2::CreateKeyEvent 
3840 // isASCII is TRUE only when we're called from WM_CHAR handler and not from 
3843 bool wxWindowOS2::HandleChar( 
3849     bool                            bCtrlDown 
= FALSE
; 
3855         // If 1 -> 26, translate to CTRL plus a letter. 
3858         if ((vId 
> 0) && (vId 
< 27)) 
3880     else if ( (vId 
= wxCharCodeOS2ToWX(wParam
)) == 0) 
3883         // It's ASCII and will be processed here only when called from 
3884         // WM_CHAR (i.e. when isASCII = TRUE), don't process it now 
3891         wxKeyEvent                  
vEvent(CreateKeyEvent( wxEVT_CHAR
 
3898             vEvent
.m_controlDown 
= TRUE
; 
3901         if (GetEventHandler()->ProcessEvent(vEvent
)) 
3907 bool wxWindowOS2::HandleKeyDown( 
3912     int                             nId 
= wxCharCodeOS2ToWX(wParam
); 
3917         // Normal ASCII char 
3924         wxKeyEvent                  
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
 
3929         if (GetEventHandler()->ProcessEvent(vEvent
)) 
3935 } // end of wxWindowOS2::HandleKeyDown 
3937 bool wxWindowOS2::HandleKeyUp( 
3942     int                             nId 
= wxCharCodeOS2ToWX(wParam
); 
3947         // Normal ASCII char 
3954         wxKeyEvent                  
vEvent(CreateKeyEvent( wxEVT_KEY_UP
 
3959         if (GetEventHandler()->ProcessEvent(vEvent
)) 
3963 } // end of wxWindowOS2::HandleKeyUp 
3965 // --------------------------------------------------------------------------- 
3967 // --------------------------------------------------------------------------- 
3969 // --------------------------------------------------------------------------- 
3971 // --------------------------------------------------------------------------- 
3973 bool wxWindowOS2::OS2OnScroll( 
3982         wxWindow
*                   pChild 
= wxFindWinFromHandle(hControl
); 
3985             return pChild
->OS2OnScroll( nOrientation
 
3992     wxScrollWinEvent                vEvent
; 
3994     vEvent
.SetPosition(wPos
); 
3995     vEvent
.SetOrientation(nOrientation
); 
3996     vEvent
.m_eventObject 
= this; 
4001             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_LINEUP
; 
4005             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_LINEDOWN
; 
4009             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_PAGEUP
; 
4013             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_PAGEDOWN
; 
4016         case SB_SLIDERPOSITION
: 
4017             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_THUMBRELEASE
; 
4020         case SB_SLIDERTRACK
: 
4021             vEvent
.m_eventType 
= wxEVT_SCROLLWIN_THUMBTRACK
; 
4027     return GetEventHandler()->ProcessEvent(vEvent
); 
4028 } // end of wxWindowOS2::OS2OnScroll 
4030 void wxWindowOS2::MoveChildren( 
4036     for (wxWindowList::Node
* pNode 
= GetChildren().GetFirst(); 
4038          pNode 
= pNode
->GetNext()) 
4040         wxWindow
*                   pWin 
= pNode
->GetData(); 
4042         ::WinQueryWindowPos( GetHwndOf(pWin
) 
4045         if (pWin
->IsKindOf(CLASSINFO(wxControl
))) 
4050             // Must deal with controls that have margins like ENTRYFIELD.  The SWP 
4051             // struct of such a control will have and origin offset from its intended 
4052             // position by the width of the margins. 
4054             pCtrl 
= wxDynamicCast(pWin
, wxControl
); 
4055             vSwp
.y 
-= pCtrl
->GetYComp(); 
4056             vSwp
.x 
-= pCtrl
->GetXComp(); 
4058         ::WinSetWindowPos( GetHwndOf(pWin
) 
4066         if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
))) 
4068             wxRadioBox
*     pRadioBox
; 
4070             pRadioBox 
= wxDynamicCast(pWin
, wxRadioBox
); 
4071             pRadioBox
->AdjustButtons( (int)vSwp
.x
 
4072                                      ,(int)vSwp
.y 
- nDiff
 
4075                                      ,pRadioBox
->GetSizeFlags() 
4078         if (pWin
->IsKindOf(CLASSINFO(wxSlider
))) 
4082             pSlider 
= wxDynamicCast(pWin
, wxSlider
); 
4083             pSlider
->AdjustSubControls( (int)vSwp
.x
 
4084                                        ,(int)vSwp
.y 
- nDiff
 
4087                                        ,(int)pSlider
->GetSizeFlags() 
4091 } // end of wxWindowOS2::MoveChildren 
4094 //  Getting the Y position for a window, like a control, is a real 
4095 //  pain.  There are three sitatuions we must deal with in determining 
4096 //  the OS2 to wxWindows Y coordinate. 
4098 //  1)  The controls are created in a dialog. 
4099 //      This is the easiest since a dialog is created with its original 
4100 //      size so the standard: Y = ParentHeight - (Y + ControlHeight); 
4102 //  2)  The controls are direct children of a frame 
4103 //      In this instance the controls are actually children of the Frame's 
4104 //      client.  During creation the frame's client resizes several times 
4105 //      during creation of the status bar and toolbars.  The CFrame class 
4106 //      will take care of this using its AlterChildPos proc. 
4108 //  3)  The controls are children of a panel, which in turn is a child of 
4110 //      This is the nastiest case.  A panel is created as the only child of 
4111 //      the frame and as such, when a frame has only one child, the child is 
4112 //      expanded to fit the entire client area of the frame.  Because the 
4113 //      controls are created BEFORE this occurs their positions are totally 
4114 //      whacked and any call to WinQueryWindowPos will return invalid 
4115 //      coordinates.  So for this situation we have to compare the size of 
4116 //      the panel at control creation time with that of the frame client.  If 
4117 //      they are the same we can use the standard Y position equation.  If 
4118 //      not, then we must use the Frame Client's dimensions to position them 
4119 //      as that will be the eventual size of the panel after the frame resizes 
4122 int wxWindowOS2::GetOS2ParentHeight( 
4123   wxWindowOS2
*               pParent
 
4126     wxWindowOS2
*             pGrandParent 
= NULL
; 
4131     if (pParent
->IsKindOf(CLASSINFO(wxDialog
))) 
4132         return(pParent
->GetClientSize().y
); 
4135     // Case 2 -- if we are one of the separately built standard Frame 
4136     //           children, like a statusbar, menubar, or toolbar we want to 
4137     //           use the frame, itself, for positioning.  Otherwise we are 
4138     //           child window and want to use the Frame's client. 
4140     else if (pParent
->IsKindOf(CLASSINFO(wxFrame
))) 
4142         if (IsKindOf(CLASSINFO(wxStatusBar
)) || 
4143             IsKindOf(CLASSINFO(wxMenuBar
))   || 
4144             IsKindOf(CLASSINFO(wxToolBar
)) 
4146             return(pParent
->GetSize().y
); 
4148             return(pParent
->GetClientSize().y
); 
4152     // Case 3 -- this is for any window that is the sole child of a Frame. 
4153     //           The grandparent must exist and it must be of type CFrame 
4154     //           and it's height must be different. Otherwise the standard 
4159         pGrandParent 
= pParent
->GetParent(); 
4161             pGrandParent
->IsKindOf(CLASSINFO(wxFrame
)) && 
4162             pGrandParent
->GetClientSize().y 
!= pParent
->GetSize().y
 
4165             int                     nParentHeight 
= 0L; 
4166             int                     nStatusBarHeight 
= 0L; 
4167             wxFrame
*                pFrame 
= wxDynamicCast(pGrandParent
, wxFrame
); 
4168             wxStatusBar
*            pStatbar 
= pFrame
->GetStatusBar(); 
4170             nParentHeight 
= pGrandParent
->GetClientSize().y
; 
4172                 nStatusBarHeight 
= pStatbar
->GetSize().y
; 
4173             nParentHeight 
-= nStatusBarHeight
; 
4174             return(nParentHeight
); 
4178             // Panel is a child of some other kind of window so we'll 
4179             // just use it's original size 
4181             return(pParent
->GetClientSize().y
); 
4184 } // end of wxWindowOS2::GetOS2ParentHeight 
4186 wxWindowCreationHook::wxWindowCreationHook( 
4187   wxWindow
*                         pWinBeingCreated
 
4190     gpWinBeingCreated 
= pWinBeingCreated
; 
4191 } // end of wxWindowCreationHook::wxWindowCreationHook 
4193 wxWindowCreationHook::~wxWindowCreationHook() 
4195     gpWinBeingCreated 
= NULL
; 
4196 } // end of wxWindowCreationHook::~wxWindowCreationHook 
4198 // =========================================================================== 
4200 // =========================================================================== 
4206 ,wxFont
*                            WXUNUSED(pTheFont
) 
4213     hPS 
=::WinGetPS(hWnd
); 
4215     rc 
= ::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &vFM
); 
4219             *pX 
= vFM
.lAveCharWidth
; 
4221             *pY 
= vFM
.lEmHeight 
+ vFM
.lExternalLeading
; 
4230     ::WinReleasePS(hPS
); 
4231 } // end of wxGetCharSize 
4234 // Returns 0 if was a normal ASCII value, not a special key. This indicates that 
4235 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. 
4237 int wxCharCodeOS2ToWX( 
4245         case VK_BACKTAB
:    nId 
= WXK_BACK
; break; 
4246         case VK_TAB
:        nId 
= WXK_TAB
; break; 
4247         case VK_CLEAR
:      nId 
= WXK_CLEAR
; break; 
4248         case VK_ENTER
:      nId 
= WXK_RETURN
; break; 
4249         case VK_SHIFT
:      nId 
= WXK_SHIFT
; break; 
4250         case VK_CTRL
:       nId 
= WXK_CONTROL
; break; 
4251         case VK_PAUSE
:      nId 
= WXK_PAUSE
; break; 
4252         case VK_SPACE
:      nId 
= WXK_SPACE
; break; 
4253         case VK_ESC
:        nId 
= WXK_ESCAPE
; break; 
4254         case VK_END
:        nId 
= WXK_END
; break; 
4255         case VK_HOME 
:      nId 
= WXK_HOME
; break; 
4256         case VK_LEFT 
:      nId 
= WXK_LEFT
; break; 
4257         case VK_UP
:         nId 
= WXK_UP
; break; 
4258         case VK_RIGHT
:      nId 
= WXK_RIGHT
; break; 
4259         case VK_DOWN 
:      nId 
= WXK_DOWN
; break; 
4260         case VK_PRINTSCRN
:  nId 
= WXK_PRINT
; break; 
4261         case VK_INSERT
:     nId 
= WXK_INSERT
; break; 
4262         case VK_DELETE
:     nId 
= WXK_DELETE
; break; 
4263         case VK_F1
:         nId 
= WXK_F1
; break; 
4264         case VK_F2
:         nId 
= WXK_F2
; break; 
4265         case VK_F3
:         nId 
= WXK_F3
; break; 
4266         case VK_F4
:         nId 
= WXK_F4
; break; 
4267         case VK_F5
:         nId 
= WXK_F5
; break; 
4268         case VK_F6
:         nId 
= WXK_F6
; break; 
4269         case VK_F7
:         nId 
= WXK_F7
; break; 
4270         case VK_F8
:         nId 
= WXK_F8
; break; 
4271         case VK_F9
:         nId 
= WXK_F9
; break; 
4272         case VK_F10
:        nId 
= WXK_F10
; break; 
4273         case VK_F11
:        nId 
= WXK_F11
; break; 
4274         case VK_F12
:        nId 
= WXK_F12
; break; 
4275         case VK_F13
:        nId 
= WXK_F13
; break; 
4276         case VK_F14
:        nId 
= WXK_F14
; break; 
4277         case VK_F15
:        nId 
= WXK_F15
; break; 
4278         case VK_F16
:        nId 
= WXK_F16
; break; 
4279         case VK_F17
:        nId 
= WXK_F17
; break; 
4280         case VK_F18
:        nId 
= WXK_F18
; break; 
4281         case VK_F19
:        nId 
= WXK_F19
; break; 
4282         case VK_F20
:        nId 
= WXK_F20
; break; 
4283         case VK_F21
:        nId 
= WXK_F21
; break; 
4284         case VK_F22
:        nId 
= WXK_F22
; break; 
4285         case VK_F23
:        nId 
= WXK_F23
; break; 
4286         case VK_F24
:        nId 
= WXK_F24
; break; 
4287         case VK_NUMLOCK
:    nId 
= WXK_NUMLOCK
; break; 
4288         case VK_SCRLLOCK
:   nId 
= WXK_SCROLL
; break; 
4295 } // end of wxCharCodeOS2ToWX 
4297 int wxCharCodeWXToOS2( 
4307         case WXK_CLEAR
:     nKeySym 
= VK_CLEAR
; break; 
4308         case WXK_SHIFT
:     nKeySym 
= VK_SHIFT
; break; 
4309         case WXK_CONTROL
:   nKeySym 
= VK_CTRL
; break; 
4310         case WXK_PAUSE
:     nKeySym 
= VK_PAUSE
; break; 
4311         case WXK_END
:       nKeySym 
= VK_END
; break; 
4312         case WXK_HOME 
:     nKeySym 
= VK_HOME
; break; 
4313         case WXK_LEFT 
:     nKeySym 
= VK_LEFT
; break; 
4314         case WXK_UP
:        nKeySym 
= VK_UP
; break; 
4315         case WXK_RIGHT
:     nKeySym 
= VK_RIGHT
; break; 
4316         case WXK_DOWN 
:     nKeySym 
= VK_DOWN
; break; 
4317         case WXK_PRINT
:     nKeySym 
= VK_PRINTSCRN
; break; 
4318         case WXK_INSERT
:    nKeySym 
= VK_INSERT
; break; 
4319         case WXK_DELETE
:    nKeySym 
= VK_DELETE
; break; 
4320         case WXK_F1
:        nKeySym 
= VK_F1
; break; 
4321         case WXK_F2
:        nKeySym 
= VK_F2
; break; 
4322         case WXK_F3
:        nKeySym 
= VK_F3
; break; 
4323         case WXK_F4
:        nKeySym 
= VK_F4
; break; 
4324         case WXK_F5
:        nKeySym 
= VK_F5
; break; 
4325         case WXK_F6
:        nKeySym 
= VK_F6
; break; 
4326         case WXK_F7
:        nKeySym 
= VK_F7
; break; 
4327         case WXK_F8
:        nKeySym 
= VK_F8
; break; 
4328         case WXK_F9
:        nKeySym 
= VK_F9
; break; 
4329         case WXK_F10
:       nKeySym 
= VK_F10
; break; 
4330         case WXK_F11
:       nKeySym 
= VK_F11
; break; 
4331         case WXK_F12
:       nKeySym 
= VK_F12
; break; 
4332         case WXK_F13
:       nKeySym 
= VK_F13
; break; 
4333         case WXK_F14
:       nKeySym 
= VK_F14
; break; 
4334         case WXK_F15
:       nKeySym 
= VK_F15
; break; 
4335         case WXK_F16
:       nKeySym 
= VK_F16
; break; 
4336         case WXK_F17
:       nKeySym 
= VK_F17
; break; 
4337         case WXK_F18
:       nKeySym 
= VK_F18
; break; 
4338         case WXK_F19
:       nKeySym 
= VK_F19
; break; 
4339         case WXK_F20
:       nKeySym 
= VK_F20
; break; 
4340         case WXK_F21
:       nKeySym 
= VK_F21
; break; 
4341         case WXK_F22
:       nKeySym 
= VK_F22
; break; 
4342         case WXK_F23
:       nKeySym 
= VK_F23
; break; 
4343         case WXK_F24
:       nKeySym 
= VK_F24
; break; 
4344         case WXK_NUMLOCK
:   nKeySym 
= VK_NUMLOCK
; break; 
4345         case WXK_SCROLL
:    nKeySym 
= VK_SCRLLOCK
; break; 
4348             *bIsVirtual 
= FALSE
; 
4354 } // end of wxCharCodeWXToOS2 
4356 wxWindow
* wxGetActiveWindow() 
4358     HWND                            hWnd 
= ::WinQueryActiveWindow(HWND_DESKTOP
); 
4362         return wxFindWinFromHandle((WXHWND
)hWnd
); 
4365 } // end of wxGetActiveWindow 
4368 const char* wxGetMessageName( 
4373         case 0x0000: return "WM_NULL"; 
4374         case 0x0001: return "WM_CREATE"; 
4375         case 0x0002: return "WM_DESTROY"; 
4376         case 0x0004: return "WM_ENABLE"; 
4377         case 0x0005: return "WM_SHOW"; 
4378         case 0x0006: return "WM_MOVE"; 
4379         case 0x0007: return "WM_SIZE"; 
4380         case 0x0008: return "WM_ADJUSTWINDOWPOS"; 
4381         case 0x0009: return "WM_CALCVALIDRECTS"; 
4382         case 0x000A: return "WM_SETWINDOWPARAMS"; 
4383         case 0x000B: return "WM_QUERYWINDOWPARAMS"; 
4384         case 0x000C: return "WM_HITTEST"; 
4385         case 0x000D: return "WM_ACTIVATE"; 
4386         case 0x000F: return "WM_SETFOCUS"; 
4387         case 0x0010: return "WM_SETSELECTION"; 
4388         case 0x0011: return "WM_PPAINT"; 
4389         case 0x0012: return "WM_PSETFOCUS"; 
4390         case 0x0013: return "WM_PSYSCOLORCHANGE"; 
4391         case 0x0014: return "WM_PSIZE"; 
4392         case 0x0015: return "WM_PACTIVATE"; 
4393         case 0x0016: return "WM_PCONTROL"; 
4394         case 0x0020: return "WM_COMMAND"; 
4395         case 0x0021: return "WM_SYSCOMMAND"; 
4396         case 0x0022: return "WM_HELP"; 
4397         case 0x0023: return "WM_PAINT"; 
4398         case 0x0024: return "WM_TIMER"; 
4399         case 0x0025: return "WM_SEM1"; 
4400         case 0x0026: return "WM_SEM2"; 
4401         case 0x0027: return "WM_SEM3"; 
4402         case 0x0028: return "WM_SEM4"; 
4403         case 0x0029: return "WM_CLOSE"; 
4404         case 0x002A: return "WM_QUIT"; 
4405         case 0x002B: return "WM_SYSCOLORCHANGE"; 
4406         case 0x002D: return "WM_SYSVALUECHANGE"; 
4407         case 0x002E: return "WM_APPTERMINATENOTIFY"; 
4408         case 0x002F: return "WM_PRESPARAMCHANGED"; 
4409         // Control notification messages 
4410         case 0x0030: return "WM_CONTROL"; 
4411         case 0x0031: return "WM_VSCROLL"; 
4412         case 0x0032: return "WM_HSCROLL"; 
4413         case 0x0033: return "WM_INITMENU"; 
4414         case 0x0034: return "WM_MENUSELECT"; 
4415         case 0x0035: return "WM_MENUSEND"; 
4416         case 0x0036: return "WM_DRAWITEM"; 
4417         case 0x0037: return "WM_MEASUREITEM"; 
4418         case 0x0038: return "WM_CONTROLPOINTER"; 
4419         case 0x003A: return "WM_QUERYDLGCODE"; 
4420         case 0x003B: return "WM_INITDLG"; 
4421         case 0x003C: return "WM_SUBSTITUTESTRING"; 
4422         case 0x003D: return "WM_MATCHMNEMONIC"; 
4423         case 0x003E: return "WM_SAVEAPPLICATION"; 
4424         case 0x0129: return "WM_CTLCOLORCHANGE"; 
4425         case 0x0130: return "WM_QUERYCTLTYPE"; 
4427         case 0x0040: return "WM_FLASHWINDOW"; 
4428         case 0x0041: return "WM_FORMATFRAME"; 
4429         case 0x0042: return "WM_UPDATEFRAME"; 
4430         case 0x0043: return "WM_FOCUSCHANGE"; 
4431         case 0x0044: return "WM_SETBORDERSIZE"; 
4432         case 0x0045: return "WM_TRACKFRAME"; 
4433         case 0x0046: return "WM_MINMAXFRAME"; 
4434         case 0x0047: return "WM_SETICON"; 
4435         case 0x0048: return "WM_QUERYICON"; 
4436         case 0x0049: return "WM_SETACCELTABLE"; 
4437         case 0x004A: return "WM_QUERYACCELTABLE"; 
4438         case 0x004B: return "WM_TRANSLATEACCEL"; 
4439         case 0x004C: return "WM_QUERYTRACKINFO"; 
4440         case 0x004D: return "WM_QUERYBORDERSIZE"; 
4441         case 0x004E: return "WM_NEXTMENU"; 
4442         case 0x004F: return "WM_ERASEBACKGROUND"; 
4443         case 0x0050: return "WM_QUERYFRAMEINFO"; 
4444         case 0x0051: return "WM_QUERYFOCUSCHAIN"; 
4445         case 0x0052: return "WM_OWNERPOSCHANGE"; 
4446         case 0x0053: return "WM_CACLFRAMERECT"; 
4447         case 0x0055: return "WM_WINDOWPOSCHANGED"; 
4448         case 0x0056: return "WM_ADJUSTFRAMEPOS"; 
4449         case 0x0059: return "WM_QUERYFRAMECTLCOUNT"; 
4450         case 0x005B: return "WM_QUERYHELPINFO"; 
4451         case 0x005C: return "WM_SETHELPINFO"; 
4452         case 0x005D: return "WM_ERROR"; 
4453         case 0x005E: return "WM_REALIZEPALETTE"; 
4454         // Clipboard messages 
4455         case 0x0060: return "WM_RENDERFMT"; 
4456         case 0x0061: return "WM_RENDERALLFMTS"; 
4457         case 0x0062: return "WM_DESTROYCLIPBOARD"; 
4458         case 0x0063: return "WM_PAINTCLIPBOARD"; 
4459         case 0x0064: return "WM_SIZECLIPBOARD"; 
4460         case 0x0065: return "WM_HSCROLLCLIPBOARD"; 
4461         case 0x0066: return "WM_VSCROLLCLIPBOARD"; 
4462         case 0x0067: return "WM_DRAWCLIPBOARD"; 
4464         case 0x0070: return "WM_MOUSEMOVE"; 
4465         case 0x0071: return "WM_BUTTON1DOWN"; 
4466         case 0x0072: return "WM_BUTTON1UP"; 
4467         case 0x0073: return "WM_BUTTON1DBLCLK"; 
4468         case 0x0074: return "WM_BUTTON2DOWN"; 
4469         case 0x0075: return "WM_BUTTON2UP"; 
4470         case 0x0076: return "WM_BUTTON2DBLCLK"; 
4471         case 0x0077: return "WM_BUTTON3DOWN"; 
4472         case 0x0078: return "WM_BUTTON3UP"; 
4473         case 0x0079: return "WM_BUTTON3DBLCLK"; 
4474         case 0x007D: return "WM_MOUSEMAP"; 
4475         case 0x007E: return "WM_VRNDISABLED"; 
4476         case 0x007F: return "WM_VRNENABLED"; 
4477         case 0x0410: return "WM_CHORD"; 
4478         case 0x0411: return "WM_BUTTON1MOTIONSTART"; 
4479         case 0x0412: return "WM_BUTTON1MOTIONEND"; 
4480         case 0x0413: return "WM_BUTTON1CLICK"; 
4481         case 0x0414: return "WM_BUTTON2MOTIONSTART"; 
4482         case 0x0415: return "WM_BUTTON2MOTIONEND"; 
4483         case 0x0416: return "WM_BUTTON2CLICK"; 
4484         case 0x0417: return "WM_BUTTON3MOTIONSTART"; 
4485         case 0x0418: return "WM_BUTTON3MOTIONEND"; 
4486         case 0x0419: return "WM_BUTTON3CLICK"; 
4487         case 0x0420: return "WM_BEGINDRAG"; 
4488         case 0x0421: return "WM_ENDDRAG"; 
4489         case 0x0422: return "WM_SINGLESELECT"; 
4490         case 0x0423: return "WM_OPEN"; 
4491         case 0x0424: return "WM_CONTEXTMENU"; 
4492         case 0x0425: return "WM_CONTEXTHELP"; 
4493         case 0x0426: return "WM_TEXTEDIT"; 
4494         case 0x0427: return "WM_BEGINSELECT"; 
4495         case 0x0228: return "WM_ENDSELECT"; 
4496         case 0x0429: return "WM_PICKUP"; 
4497         case 0x04C0: return "WM_PENFIRST"; 
4498         case 0x04FF: return "WM_PENLAST"; 
4499         case 0x0500: return "WM_MMPMFIRST"; 
4500         case 0x05FF: return "WM_MMPMLAST"; 
4501         case 0x0600: return "WM_STDDLGFIRST"; 
4502         case 0x06FF: return "WM_STDDLGLAST"; 
4503         case 0x0BD0: return "WM_BIDI_FIRST"; 
4504         case 0x0BFF: return "WM_BIDI_LAST"; 
4506         case 0x007A: return "WM_CHAR"; 
4507         case 0x007B: return "WM_VIOCHAR"; 
4509         case 0x00A0: return "WM_DDE_INITIATE"; 
4510         case 0x00A1: return "WM_DDE_REQUEST"; 
4511         case 0x00A2: return "WM_DDE_ACK"; 
4512         case 0x00A3: return "WM_DDE_DATA"; 
4513         case 0x00A4: return "WM_DDE_ADVISE"; 
4514         case 0x00A5: return "WM_DDE_UNADVISE"; 
4515         case 0x00A6: return "WM_DDE_POKE"; 
4516         case 0x00A7: return "WM_DDE_EXECUTE"; 
4517         case 0x00A8: return "WM_DDE_TERMINATE"; 
4518         case 0x00A9: return "WM_DDE_INITIATEACK"; 
4519         case 0x00AF: return "WM_DDE_LAST"; 
4521         case 0x0120: return "BM_CLICK"; 
4522         case 0x0121: return "BM_QUERYCHECKINDEX"; 
4523         case 0x0122: return "BM_QUERYHILITE"; 
4524         case 0x0123: return "BM_SETHILITE"; 
4525         case 0x0124: return "BM_QUERYCHECK"; 
4526         case 0x0125: return "BM_SETCHECK"; 
4527         case 0x0126: return "BM_SETDEFAULT"; 
4528         case 0x0128: return "BM_AUTOSIZE"; 
4530         case 0x029A: return "CBID_LIST"; 
4531         case 0x029B: return "CBID_EDIT"; 
4532         case 0x0170: return "CBM_SHOWLIST"; 
4533         case 0x0171: return "CBM_HILITE"; 
4534         case 0x0172: return "CBM_ISLISTSHOWING"; 
4536         case 0x0140: return "EM_QUERYCHANGED"; 
4537         case 0x0141: return "EM_QUERYSEL"; 
4538         case 0x0142: return "EM_SETSEL"; 
4539         case 0x0143: return "EM_SETTEXTLIMIT"; 
4540         case 0x0144: return "EM_CUT"; 
4541         case 0x0145: return "EM_COPY"; 
4542         case 0x0146: return "EM_CLEAR"; 
4543         case 0x0147: return "EM_PASTE"; 
4544         case 0x0148: return "EM_QUERYFIRSTCHAR"; 
4545         case 0x0149: return "EM_SETFIRSTCHAR"; 
4546         case 0x014A: return "EM_QUERYREADONLY"; 
4547         case 0x014B: return "EM_SETREADONLY"; 
4548         case 0x014C: return "EM_SETINSERTMODE"; 
4550         case 0x0160: return "LM_QUERYITEMCOUNT"; 
4551         case 0x0161: return "LM_INSERTITEM"; 
4552         case 0x0162: return "LM_SETOPENINDEX"; 
4553         case 0x0163: return "LM_DELETEITEM"; 
4554         case 0x0164: return "LM_SELECTITEM"; 
4555         case 0x0165: return "LM_QUERYSELECTION"; 
4556         case 0x0166: return "LM_SETITEMTEXT"; 
4557         case 0x0167: return "LM_QUERYITEMTEXTLENGTH"; 
4558         case 0x0168: return "LM_QUERYITEMTEXT"; 
4559         case 0x0169: return "LM_SETITEMHANDLE"; 
4560         case 0x016A: return "LM_QUERYITEMHANDLE"; 
4561         case 0x016B: return "LM_SEARCHSTRING"; 
4562         case 0x016C: return "LM_SETITEMHEIGHT"; 
4563         case 0x016D: return "LM_QUERYTOPINDEX"; 
4564         case 0x016E: return "LM_DELETEALL"; 
4565         case 0x016F: return "LM_INSERTMULITEMS"; 
4566         case 0x0660: return "LM_SETITEMWIDTH"; 
4568         case 0x0180: return "MM_INSERTITEM"; 
4569         case 0x0181: return "MM_DELETEITEM"; 
4570         case 0x0182: return "MM_QUERYITEM"; 
4571         case 0x0183: return "MM_SETITEM"; 
4572         case 0x0184: return "MM_QUERYITEMCOUNT"; 
4573         case 0x0185: return "MM_STARTMENUMODE"; 
4574         case 0x0186: return "MM_ENDMENUMODE"; 
4575         case 0x0188: return "MM_REMOVEITEM"; 
4576         case 0x0189: return "MM_SELECTITEM"; 
4577         case 0x018A: return "MM_QUERYSELITEMID"; 
4578         case 0x018B: return "MM_QUERYITEMTEXT"; 
4579         case 0x018C: return "MM_QUERYITEMTEXTLENGTH"; 
4580         case 0x018D: return "MM_SETITEMHANDLE"; 
4581         case 0x018E: return "MM_SETITEMTEXT"; 
4582         case 0x018F: return "MM_ITEMPOSITIONFROMID"; 
4583         case 0x0190: return "MM_ITEMIDFROMPOSITION"; 
4584         case 0x0191: return "MM_QUERYITEMATTR"; 
4585         case 0x0192: return "MM_SETITEMATTR"; 
4586         case 0x0193: return "MM_ISITEMVALID"; 
4587         case 0x0194: return "MM_QUERYITEMRECT"; 
4588         case 0x0431: return "MM_QUERYDEFAULTITEMID"; 
4589         case 0x0432: return "MM_SETDEFAULTITEMID"; 
4591         case 0x01A0: return "SBM_SETSCROLLBAR"; 
4592         case 0x01A1: return "SBM_SETPOS"; 
4593         case 0x01A2: return "SBM_QUERYPOS"; 
4594         case 0x01A3: return "SBM_QUERYRANGE"; 
4595         case 0x01A6: return "SBM_SETTHUMBSIZE"; 
4598         case 0x0F00: return "WM_HELPBASE"; 
4599         case 0x0FFF: return "WM_HELPTOP"; 
4600         // Beginning of user defined messages 
4601         case 0x1000: return "WM_USER"; 
4603         // wxWindows user defined types 
4606         // case 0x1000 + 0: return "LVM_GETBKCOLOR"; 
4607         case 0x1000 + 1: return "LVM_SETBKCOLOR"; 
4608         case 0x1000 + 2: return "LVM_GETIMAGELIST"; 
4609         case 0x1000 + 3: return "LVM_SETIMAGELIST"; 
4610         case 0x1000 + 4: return "LVM_GETITEMCOUNT"; 
4611         case 0x1000 + 5: return "LVM_GETITEMA"; 
4612         case 0x1000 + 75: return "LVM_GETITEMW"; 
4613         case 0x1000 + 6: return "LVM_SETITEMA"; 
4614         case 0x1000 + 76: return "LVM_SETITEMW"; 
4615         case 0x1000 + 7: return "LVM_INSERTITEMA"; 
4616         case 0x1000 + 77: return "LVM_INSERTITEMW"; 
4617         case 0x1000 + 8: return "LVM_DELETEITEM"; 
4618         case 0x1000 + 9: return "LVM_DELETEALLITEMS"; 
4619         case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; 
4620         case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; 
4621         case 0x1000 + 12: return "LVM_GETNEXTITEM"; 
4622         case 0x1000 + 13: return "LVM_FINDITEMA"; 
4623         case 0x1000 + 83: return "LVM_FINDITEMW"; 
4624         case 0x1000 + 14: return "LVM_GETITEMRECT"; 
4625         case 0x1000 + 15: return "LVM_SETITEMPOSITION"; 
4626         case 0x1000 + 16: return "LVM_GETITEMPOSITION"; 
4627         case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; 
4628         case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; 
4629         case 0x1000 + 18: return "LVM_HITTEST"; 
4630         case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; 
4631         case 0x1000 + 20: return "LVM_SCROLL"; 
4632         case 0x1000 + 21: return "LVM_REDRAWITEMS"; 
4633         case 0x1000 + 22: return "LVM_ARRANGE"; 
4634         case 0x1000 + 23: return "LVM_EDITLABELA"; 
4635         case 0x1000 + 118: return "LVM_EDITLABELW"; 
4636         case 0x1000 + 24: return "LVM_GETEDITCONTROL"; 
4637         case 0x1000 + 25: return "LVM_GETCOLUMNA"; 
4638         case 0x1000 + 95: return "LVM_GETCOLUMNW"; 
4639         case 0x1000 + 26: return "LVM_SETCOLUMNA"; 
4640         case 0x1000 + 96: return "LVM_SETCOLUMNW"; 
4641         case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; 
4642         case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; 
4643         case 0x1000 + 28: return "LVM_DELETECOLUMN"; 
4644         case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; 
4645         case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; 
4646         case 0x1000 + 31: return "LVM_GETHEADER"; 
4647         case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; 
4648         case 0x1000 + 34: return "LVM_GETVIEWRECT"; 
4649         case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; 
4650         case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; 
4651         case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; 
4652         case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; 
4653         case 0x1000 + 39: return "LVM_GETTOPINDEX"; 
4654         case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; 
4655         case 0x1000 + 41: return "LVM_GETORIGIN"; 
4656         case 0x1000 + 42: return "LVM_UPDATE"; 
4657         case 0x1000 + 43: return "LVM_SETITEMSTATE"; 
4658         case 0x1000 + 44: return "LVM_GETITEMSTATE"; 
4659         case 0x1000 + 45: return "LVM_GETITEMTEXTA"; 
4660         case 0x1000 + 115: return "LVM_GETITEMTEXTW"; 
4661         case 0x1000 + 46: return "LVM_SETITEMTEXTA"; 
4662         case 0x1000 + 116: return "LVM_SETITEMTEXTW"; 
4663         case 0x1000 + 47: return "LVM_SETITEMCOUNT"; 
4664         case 0x1000 + 48: return "LVM_SORTITEMS"; 
4665         case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; 
4666         case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; 
4667         case 0x1000 + 51: return "LVM_GETITEMSPACING"; 
4668         case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; 
4669         case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; 
4670         case 0x1000 + 53: return "LVM_SETICONSPACING"; 
4671         case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; 
4672         case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; 
4673         case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; 
4674         case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; 
4675         case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; 
4676         case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; 
4677         case 0x1000 + 60: return "LVM_SETHOTITEM"; 
4678         case 0x1000 + 61: return "LVM_GETHOTITEM"; 
4679         case 0x1000 + 62: return "LVM_SETHOTCURSOR"; 
4680         case 0x1000 + 63: return "LVM_GETHOTCURSOR"; 
4681         case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; 
4682         case 0x1000 + 65: return "LVM_SETWORKAREA"; 
4685         case 0x1100 + 0: return "TVM_INSERTITEMA"; 
4686         case 0x1100 + 50: return "TVM_INSERTITEMW"; 
4687         case 0x1100 + 1: return "TVM_DELETEITEM"; 
4688         case 0x1100 + 2: return "TVM_EXPAND"; 
4689         case 0x1100 + 4: return "TVM_GETITEMRECT"; 
4690         case 0x1100 + 5: return "TVM_GETCOUNT"; 
4691         case 0x1100 + 6: return "TVM_GETINDENT"; 
4692         case 0x1100 + 7: return "TVM_SETINDENT"; 
4693         case 0x1100 + 8: return "TVM_GETIMAGELIST"; 
4694         case 0x1100 + 9: return "TVM_SETIMAGELIST"; 
4695         case 0x1100 + 10: return "TVM_GETNEXTITEM"; 
4696         case 0x1100 + 11: return "TVM_SELECTITEM"; 
4697         case 0x1100 + 12: return "TVM_GETITEMA"; 
4698         case 0x1100 + 62: return "TVM_GETITEMW"; 
4699         case 0x1100 + 13: return "TVM_SETITEMA"; 
4700         case 0x1100 + 63: return "TVM_SETITEMW"; 
4701         case 0x1100 + 14: return "TVM_EDITLABELA"; 
4702         case 0x1100 + 65: return "TVM_EDITLABELW"; 
4703         case 0x1100 + 15: return "TVM_GETEDITCONTROL"; 
4704         case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; 
4705         case 0x1100 + 17: return "TVM_HITTEST"; 
4706         case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; 
4707         case 0x1100 + 19: return "TVM_SORTCHILDREN"; 
4708         case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; 
4709         case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; 
4710         case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; 
4711         case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; 
4712         case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; 
4713         case 0x1100 + 24: return "TVM_SETTOOLTIPS"; 
4714         case 0x1100 + 25: return "TVM_GETTOOLTIPS"; 
4717         case 0x1200 + 0: return "HDM_GETITEMCOUNT"; 
4718         case 0x1200 + 1: return "HDM_INSERTITEMA"; 
4719         case 0x1200 + 10: return "HDM_INSERTITEMW"; 
4720         case 0x1200 + 2: return "HDM_DELETEITEM"; 
4721         case 0x1200 + 3: return "HDM_GETITEMA"; 
4722         case 0x1200 + 11: return "HDM_GETITEMW"; 
4723         case 0x1200 + 4: return "HDM_SETITEMA"; 
4724         case 0x1200 + 12: return "HDM_SETITEMW"; 
4725         case 0x1200 + 5: return "HDM_LAYOUT"; 
4726         case 0x1200 + 6: return "HDM_HITTEST"; 
4727         case 0x1200 + 7: return "HDM_GETITEMRECT"; 
4728         case 0x1200 + 8: return "HDM_SETIMAGELIST"; 
4729         case 0x1200 + 9: return "HDM_GETIMAGELIST"; 
4730         case 0x1200 + 15: return "HDM_ORDERTOINDEX"; 
4731         case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; 
4732         case 0x1200 + 17: return "HDM_GETORDERARRAY"; 
4733         case 0x1200 + 18: return "HDM_SETORDERARRAY"; 
4734         case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; 
4737         case 0x1300 + 2: return "TCM_GETIMAGELIST"; 
4738         case 0x1300 + 3: return "TCM_SETIMAGELIST"; 
4739         case 0x1300 + 4: return "TCM_GETITEMCOUNT"; 
4740         case 0x1300 + 5: return "TCM_GETITEMA"; 
4741         case 0x1300 + 60: return "TCM_GETITEMW"; 
4742         case 0x1300 + 6: return "TCM_SETITEMA"; 
4743         case 0x1300 + 61: return "TCM_SETITEMW"; 
4744         case 0x1300 + 7: return "TCM_INSERTITEMA"; 
4745         case 0x1300 + 62: return "TCM_INSERTITEMW"; 
4746         case 0x1300 + 8: return "TCM_DELETEITEM"; 
4747         case 0x1300 + 9: return "TCM_DELETEALLITEMS"; 
4748         case 0x1300 + 10: return "TCM_GETITEMRECT"; 
4749         case 0x1300 + 11: return "TCM_GETCURSEL"; 
4750         case 0x1300 + 12: return "TCM_SETCURSEL"; 
4751         case 0x1300 + 13: return "TCM_HITTEST"; 
4752         case 0x1300 + 14: return "TCM_SETITEMEXTRA"; 
4753         case 0x1300 + 40: return "TCM_ADJUSTRECT"; 
4754         case 0x1300 + 41: return "TCM_SETITEMSIZE"; 
4755         case 0x1300 + 42: return "TCM_REMOVEIMAGE"; 
4756         case 0x1300 + 43: return "TCM_SETPADDING"; 
4757         case 0x1300 + 44: return "TCM_GETROWCOUNT"; 
4758         case 0x1300 + 45: return "TCM_GETTOOLTIPS"; 
4759         case 0x1300 + 46: return "TCM_SETTOOLTIPS"; 
4760         case 0x1300 + 47: return "TCM_GETCURFOCUS"; 
4761         case 0x1300 + 48: return "TCM_SETCURFOCUS"; 
4762         case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; 
4763         case 0x1300 + 50: return "TCM_DESELECTALL"; 
4766         case WM_USER
+1000+1: return "TB_ENABLEBUTTON"; 
4767         case WM_USER
+1000+2: return "TB_CHECKBUTTON"; 
4768         case WM_USER
+1000+3: return "TB_PRESSBUTTON"; 
4769         case WM_USER
+1000+4: return "TB_HIDEBUTTON"; 
4770         case WM_USER
+1000+5: return "TB_INDETERMINATE"; 
4771         case WM_USER
+1000+9: return "TB_ISBUTTONENABLED"; 
4772         case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED"; 
4773         case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED"; 
4774         case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN"; 
4775         case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE"; 
4776         case WM_USER
+1000+17: return "TB_SETSTATE"; 
4777         case WM_USER
+1000+18: return "TB_GETSTATE"; 
4778         case WM_USER
+1000+19: return "TB_ADDBITMAP"; 
4779         case WM_USER
+1000+20: return "TB_ADDBUTTONS"; 
4780         case WM_USER
+1000+21: return "TB_INSERTBUTTON"; 
4781         case WM_USER
+1000+22: return "TB_DELETEBUTTON"; 
4782         case WM_USER
+1000+23: return "TB_GETBUTTON"; 
4783         case WM_USER
+1000+24: return "TB_BUTTONCOUNT"; 
4784         case WM_USER
+1000+25: return "TB_COMMANDTOINDEX"; 
4785         case WM_USER
+1000+26: return "TB_SAVERESTOREA"; 
4786         case WM_USER
+1000+76: return "TB_SAVERESTOREW"; 
4787         case WM_USER
+1000+27: return "TB_CUSTOMIZE"; 
4788         case WM_USER
+1000+28: return "TB_ADDSTRINGA"; 
4789         case WM_USER
+1000+77: return "TB_ADDSTRINGW"; 
4790         case WM_USER
+1000+29: return "TB_GETITEMRECT"; 
4791         case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE"; 
4792         case WM_USER
+1000+31: return "TB_SETBUTTONSIZE"; 
4793         case WM_USER
+1000+32: return "TB_SETBITMAPSIZE"; 
4794         case WM_USER
+1000+33: return "TB_AUTOSIZE"; 
4795         case WM_USER
+1000+35: return "TB_GETTOOLTIPS"; 
4796         case WM_USER
+1000+36: return "TB_SETTOOLTIPS"; 
4797         case WM_USER
+1000+37: return "TB_SETPARENT"; 
4798         case WM_USER
+1000+39: return "TB_SETROWS"; 
4799         case WM_USER
+1000+40: return "TB_GETROWS"; 
4800         case WM_USER
+1000+42: return "TB_SETCMDID"; 
4801         case WM_USER
+1000+43: return "TB_CHANGEBITMAP"; 
4802         case WM_USER
+1000+44: return "TB_GETBITMAP"; 
4803         case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA"; 
4804         case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW"; 
4805         case WM_USER
+1000+46: return "TB_REPLACEBITMAP"; 
4806         case WM_USER
+1000+47: return "TB_SETINDENT"; 
4807         case WM_USER
+1000+48: return "TB_SETIMAGELIST"; 
4808         case WM_USER
+1000+49: return "TB_GETIMAGELIST"; 
4809         case WM_USER
+1000+50: return "TB_LOADIMAGES"; 
4810         case WM_USER
+1000+51: return "TB_GETRECT"; 
4811         case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST"; 
4812         case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST"; 
4813         case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST"; 
4814         case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST"; 
4815         case WM_USER
+1000+56: return "TB_SETSTYLE"; 
4816         case WM_USER
+1000+57: return "TB_GETSTYLE"; 
4817         case WM_USER
+1000+58: return "TB_GETBUTTONSIZE"; 
4818         case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH"; 
4819         case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS"; 
4820         case WM_USER
+1000+61: return "TB_GETTEXTROWS"; 
4821         case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS"; 
4824             static char s_szBuf
[128]; 
4825             sprintf(s_szBuf
, "<unknown message = %d>", nMessage
); 
4829 } // end of wxGetMessageName 
4831 #endif // __WXDEBUG__ 
4835 static void TranslateKbdEventToMouse( 
4843     // Construct the key mask 
4844     ULONG
&                          fwKeys 
= *pFlags
; 
4846     fwKeys 
= VK_BUTTON2
; 
4847     if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0) 
4849     if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0) 
4853     // Simulate right mouse button click 
4857     ::WinQueryMsgPos(vHabmain
, &vPoint
); 
4861     pWin
->ScreenToClient(pX
, pY
); 
4862 } // end of TranslateKbdEventToMouse 
4865 // Find the wxWindow at the current mouse position, returning the mouse 
4867 wxWindow
* wxFindWindowAtPointer( 
4868   wxPoint
&                          WXUNUSED(rPt
) 
4871     return wxFindWindowAtPoint(wxGetMousePosition()); 
4874 wxWindow
* wxFindWindowAtPoint( 
4883     HWND                            hWndHit 
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
); 
4884     wxWindow
*                       pWin 
= wxFindWinFromHandle((WXHWND
)hWndHit
) ; 
4885     HWND                            hWnd 
= hWndHit
; 
4888     // Try to find a window with a wxWindow associated with it 
4890     while (!pWin 
&& (hWnd 
!= 0)) 
4892         hWnd 
= ::WinQueryWindow(hWnd
, QW_PARENT
); 
4893         pWin 
= wxFindWinFromHandle((WXHWND
)hWnd
) ; 
4898 // Get the current mouse position. 
4899 wxPoint 
wxGetMousePosition() 
4903     ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
); 
4904     return wxPoint(vPt
.x
, vPt
.y
);