1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/window.cpp
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
14 #include "wx/wxprec.h"
16 #include "wx/window.h"
25 #include "wx/dcclient.h"
29 #include "wx/layout.h"
30 #include "wx/checkbox.h"
31 #include "wx/combobox.h"
32 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/bmpbuttn.h"
37 #include "wx/msgdlg.h"
38 #include "wx/scrolwin.h"
39 #include "wx/radiobox.h"
40 #include "wx/radiobut.h"
41 #include "wx/slider.h"
42 #include "wx/statbox.h"
43 #include "wx/statusbr.h"
44 #include "wx/toolbar.h"
45 #include "wx/settings.h"
48 #include "wx/textctrl.h"
49 #include "wx/menuitem.h"
53 #include "wx/os2/dcclient.h"
56 #include "wx/ownerdrw.h"
59 #if wxUSE_DRAG_AND_DROP
63 #include "wx/os2/private.h"
66 #include "wx/tooltip.h"
70 #include "wx/notebook.h"
80 // Place compiler, OS specific includes here
84 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
88 // SHORT1FROMMP -- LOWORD
90 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
92 // SHORT2FROMMP -- HIWORD
94 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
95 #endif // GET_X_LPARAM
98 # define CW_USEDEFAULT ((int)0x80000000)
102 #define VK_OEM_1 0xBA
103 #define VK_OEM_PLUS 0xBB
104 #define VK_OEM_COMMA 0xBC
105 #define VK_OEM_MINUS 0xBD
106 #define VK_OEM_PERIOD 0xBE
107 #define VK_OEM_2 0xBF
108 #define VK_OEM_3 0xC0
109 #define VK_OEM_4 0xDB
110 #define VK_OEM_5 0xDC
111 #define VK_OEM_6 0xDD
112 #define VK_OEM_7 0xDE
115 // ---------------------------------------------------------------------------
117 // ---------------------------------------------------------------------------
120 // The last PM message we got (MT-UNSAFE)
124 #if wxUSE_MENUS_NATIVE
125 extern wxMenu
* wxCurrentPopupMenu
;
126 #endif // wxUSE_MENUS_NATIVE
128 // ---------------------------------------------------------------------------
130 // ---------------------------------------------------------------------------
133 // the window proc for all our windows; most gui's have something similar
135 MRESULT EXPENTRY
wxWndProc( HWND hWnd
142 const wxChar
*wxGetMessageName(int message
);
145 wxWindowOS2
* FindWindowForMouseEvent( wxWindow
* pWin
149 void wxRemoveHandleAssociation(wxWindowOS2
* pWin
);
150 void wxAssociateWinWithHandle( HWND hWnd
153 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
156 // get the current state of SHIFT/CTRL keys
158 static inline bool IsKeyDown(LONG key
) {return (::WinGetKeyState(HWND_DESKTOP
, key
) & 0x8000) != 0; }
159 static inline bool IsShiftDown() { return IsKeyDown(VK_SHIFT
); }
160 static inline bool IsCtrlDown() { return IsKeyDown(VK_CTRL
); }
162 static wxWindow
* gpWinBeingCreated
= NULL
;
164 // ---------------------------------------------------------------------------
166 // ---------------------------------------------------------------------------
168 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
170 #ifdef __WXUNIVERSAL__
171 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
)
172 #endif // __WXUNIVERSAL__
174 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
)
175 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
)
176 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
)
177 EVT_IDLE(wxWindowOS2::OnIdle
)
178 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
)
181 // ===========================================================================
183 // ===========================================================================
185 // ---------------------------------------------------------------------------
186 // wxWindow utility functions
187 // ---------------------------------------------------------------------------
190 // Find an item given the PM Window id
192 wxWindow
* wxWindowOS2::FindItem(
197 wxControl
* pItem
= wxDynamicCast(this, wxControl
);
202 // I it we or one of our "internal" children?
204 if (pItem
->GetId() == lId
205 #ifndef __WXUNIVERSAL__
206 || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
)
213 #endif // wxUSE_CONTROLS
215 wxWindowList::compatibility_iterator current
= GetChildren().GetFirst();
219 wxWindow
* pChildWin
= current
->GetData();
220 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
225 current
= current
->GetNext();
228 } // end of wxWindowOS2::FindItem
231 // Find an item given the PM Window handle
233 wxWindow
* wxWindowOS2::FindItemByHWND(
238 wxWindowList::compatibility_iterator current
= GetChildren().GetFirst();
242 wxWindow
* pParent
= current
->GetData();
245 // Do a recursive search.
247 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
254 || pParent
->IsKindOf(CLASSINFO(wxControl
))
255 #endif // wxUSE_CONTROLS
258 wxWindow
* pItem
= current
->GetData();
260 if (pItem
->GetHWND() == hWnd
)
264 if (pItem
->ContainsHWND(hWnd
))
268 current
= current
->GetNext();
271 } // end of wxWindowOS2::FindItemByHWND
274 // Default command handler
276 bool wxWindowOS2::OS2Command( WXUINT
WXUNUSED(uParam
),
277 WXWORD
WXUNUSED(uId
) )
282 // ----------------------------------------------------------------------------
283 // constructors and such
284 // ----------------------------------------------------------------------------
286 void wxWindowOS2::Init()
291 m_bWinCaptured
= false;
293 m_fnOldWndProc
= NULL
;
295 m_bMouseInWindow
= false;
296 m_bLastKeydownProcessed
= false;
303 m_hWndScrollBarHorz
= 0L;
304 m_hWndScrollBarVert
= 0L;
306 memset(&m_vWinSwp
, '\0', sizeof (SWP
));
309 // Pass WM_GETDLGCODE to DefWindowProc()
315 m_bBackgroundTransparent
= false;
318 // As all windows are created with WS_VISIBLE style...
322 #if wxUSE_MOUSEEVENT_HACK
325 m_nLastMouseEvent
= -1;
326 #endif // wxUSE_MOUSEEVENT_HACK
327 } // wxWindowOS2::Init
332 wxWindowOS2::~wxWindowOS2()
336 for (wxWindow
* pWin
= GetParent(); pWin
; pWin
= pWin
->GetParent())
338 wxTopLevelWindow
* pFrame
= wxDynamicCast(pWin
, wxTopLevelWindow
);
342 if (pFrame
->GetLastFocus() == this)
343 pFrame
->SetLastFocus(NULL
);
351 if(!::WinDestroyWindow(GetHWND()))
353 wxLogLastError(wxT("DestroyWindow"));
356 // remove hWnd <-> wxWindow association
358 wxRemoveHandleAssociation(this);
360 } // end of wxWindowOS2::~wxWindowOS2
362 // real construction (Init() must have been called before!)
363 bool wxWindowOS2::Create( wxWindow
* pParent
,
368 const wxString
& rName
)
370 HWND hParent
= NULLHANDLE
;
371 ULONG ulCreateFlags
= 0;
372 WXDWORD dwExStyle
= 0;
374 wxCHECK_MSG(pParent
, false, wxT("can't create wxWindow without parent"));
378 // wxGTK doesn't allow to create controls with static box as the parent so
379 // this will result in a crash when the program is ported to wxGTK - warn
382 // the correct solution is to create the controls as siblings of the
385 wxASSERT_MSG( !wxDynamicCast(pParent
, wxStaticBox
),
386 wxT("wxStaticBox can't be used as a window parent!") );
387 #endif // wxUSE_STATBOX
389 // Ensure groupbox backgrounds are painted
390 if (IsKindOf(CLASSINFO(wxPanel
)))
391 lStyle
&= ~wxCLIP_CHILDREN
;
393 if ( !CreateBase( pParent
405 pParent
->AddChild(this);
406 hParent
= GetWinHwnd(pParent
);
408 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)))
409 ulCreateFlags
|= WS_CLIPSIBLINGS
;
413 // Most wxSTYLES are really PM Class specific styles and will be
414 // set in those class create procs. PM's basic windows styles are
417 ulCreateFlags
|= OS2GetCreateWindowFlags(&dwExStyle
);
420 #ifdef __WXUNIVERSAL__
421 // no 3d effects, we draw them ourselves
423 #endif // !wxUniversal
424 if (lStyle
& wxPOPUP_WINDOW
)
426 ulCreateFlags
&= ~WS_VISIBLE
;
431 ulCreateFlags
|= WS_VISIBLE
;
435 // Generic OS/2 Windows have no Control Data but other classes
436 // that call OS2Create may have some.
438 return(OS2Create( (PSZ
)wxCanvasClassName
443 ,NULL
// Control Data
447 } // end of wxWindowOS2::Create
449 // ---------------------------------------------------------------------------
451 // ---------------------------------------------------------------------------
453 void wxWindowOS2::SetFocus()
455 HWND hWnd
= GetHwnd();
456 wxCHECK_RET( hWnd
, wxT("can't set focus to invalid window") );
459 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
460 } // end of wxWindowOS2::SetFocus
462 void wxWindowOS2::SetFocusFromKbd()
465 // Nothing else to do under OS/2
467 wxWindowBase::SetFocusFromKbd();
468 } // end of wxWindowOS2::SetFocus
470 wxWindow
* wxWindowBase::DoFindFocus()
472 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
476 return wxFindWinFromHandle((WXHWND
)hWnd
);
479 } // wxWindowBase::DoFindFocus
481 void wxWindowOS2::DoEnable( bool bEnable
)
483 HWND hWnd
= GetHwnd();
485 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
488 bool wxWindowOS2::Show( bool bShow
)
490 if (!wxWindowBase::Show(bShow
))
493 HWND hWnd
= GetHwnd();
495 ::WinShowWindow(hWnd
, bShow
);
499 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
502 } // end of wxWindowOS2::Show
504 void wxWindowOS2::Raise()
506 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
507 } // end of wxWindowOS2::Raise
509 void wxWindowOS2::Lower()
511 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
512 } // end of wxWindowOS2::Lower
514 void wxWindowOS2::SetLabel( const wxString
& label
)
516 ::WinSetWindowText(GetHwnd(), label
.c_str());
517 } // end of wxWindowOS2::SetLabel
519 wxString
wxWindowOS2::GetLabel() const
521 return wxGetWindowText(GetHWND());
522 } // end of wxWindowOS2::GetLabel
524 void wxWindowOS2::DoCaptureMouse()
526 HWND hWnd
= GetHwnd();
528 if (hWnd
&& !m_bWinCaptured
)
530 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
531 m_bWinCaptured
= true;
533 } // end of wxWindowOS2::DoCaptureMouse
535 void wxWindowOS2::DoReleaseMouse()
539 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
540 m_bWinCaptured
= false;
542 } // end of wxWindowOS2::ReleaseMouse
544 /* static */ wxWindow
* wxWindowBase::GetCapture()
546 HWND hwnd
= ::WinQueryCapture(HWND_DESKTOP
);
547 return hwnd
? wxFindWinFromHandle((WXHWND
)hwnd
) : NULL
;
548 } // end of wxWindowBase::GetCapture
550 bool wxWindowOS2::SetFont( const wxFont
& rFont
)
552 if (!wxWindowBase::SetFont(rFont
))
558 HWND hWnd
= GetHwnd();
560 wxOS2SetFont( hWnd
, rFont
);
562 } // end of wxWindowOS2::SetFont
564 // check if base implementation is OK
565 bool wxWindowOS2::SetCursor( const wxCursor
& rCursor
)
567 if ( !wxWindowBase::SetCursor(rCursor
))
573 if ( m_cursor
.IsOk() ) {
574 HWND hWnd
= GetHwnd();
578 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
579 ::WinQueryWindowRect(hWnd
, &vRect
);
581 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy())
583 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
587 } // end of wxWindowOS2::SetCursor
589 void wxWindowOS2::WarpPointer(
598 ::WinQueryWindowRect(GetHwnd(), &vRect
);
602 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
603 } // end of wxWindowOS2::WarpPointer
606 // ---------------------------------------------------------------------------
608 // ---------------------------------------------------------------------------
610 int wxWindowOS2::GetScrollPos(
614 if (nOrient
== wxHORIZONTAL
)
615 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
617 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
618 } // end of wxWindowOS2::GetScrollPos
620 int wxWindowOS2::GetScrollRange(
626 if (nOrient
== wxHORIZONTAL
)
627 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
629 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
630 return((int)SHORT2FROMMR(mr
));
631 } // end of wxWindowOS2::GetScrollRange
633 int wxWindowOS2::GetScrollThumb(
637 if (nOrient
== wxHORIZONTAL
)
638 return m_nXThumbSize
;
640 return m_nYThumbSize
;
641 } // end of wxWindowOS2::GetScrollThumb
643 void wxWindowOS2::SetScrollPos(
646 , bool WXUNUSED(bRefresh
)
649 if (nOrient
== wxHORIZONTAL
)
650 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
652 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
653 } // end of wxWindowOS2::SetScrollPos
655 void wxWindowOS2::SetScrollbar( int nOrient
,
659 bool WXUNUSED(bRefresh
) )
661 HWND hWnd
= GetHwnd();
662 int nOldRange
= nRange
- nThumbVisible
;
663 int nRange1
= nOldRange
;
664 int nPageSize
= nThumbVisible
;
665 int nVSBWidth
= wxSystemSettingsNative::GetMetric(wxSYS_VSCROLL_X
,
667 int nHSBHeight
= wxSystemSettingsNative::GetMetric(wxSYS_HSCROLL_Y
,
671 ULONG ulStyle
= WS_VISIBLE
| WS_SYNCPAINT
;
676 wxWindow
* pParent
= GetParent();
678 if (pParent
&& pParent
->IsKindOf(CLASSINFO(wxFrame
)))
682 pFrame
= wxDynamicCast(pParent
, wxFrame
);
683 hWndParent
= pFrame
->GetFrame();
684 hWndClient
= GetHwndOf(pParent
);
689 hWndParent
= GetHwndOf(pParent
);
691 hWndParent
= GetHwnd();
692 hWndClient
= hWndParent
;
694 ::WinQueryWindowPos(hWndClient
, &vSwp
);
695 ::WinQueryWindowPos(hWnd
, &vSwpOwner
);
697 if (nPageSize
> 1 && nRange
> 0)
699 nRange1
+= (nPageSize
- 1);
702 vInfo
.cb
= sizeof(SBCDATA
);
704 vInfo
.posLast
= (SHORT
)nRange1
;
705 vInfo
.posThumb
= (SHORT
)nPos
;
707 if (nOrient
== wxHORIZONTAL
)
710 if (m_hWndScrollBarHorz
== 0L)
713 // Since the scrollbars are usually created before the owner is
714 // sized either via an OnSize event directly or via sizers or
715 // layout constraints, we will initially just use the coords of
716 // the parent window (this is usually a frame client window). But
717 // the bars themselves, are children of the parent frame (i.e
718 // siblings of the frame client. The owner, however is the actual
719 // window being scrolled (or at least the one responsible for
720 // handling the scroll events). The owner will be resized later,
721 // as it is usually a child of a top level window, and when that
722 // is done its scrollbars will be resized and repositioned as well.
724 m_hWndScrollBarHorz
= ::WinCreateWindow( hWndParent
742 // The owner (the scrolled window) is a child of the Frame's
743 // client window, usually. The scrollbars are children of the
744 // frame, itself, and thus are positioned relative to the frame's
745 // origin, not the frame's client window origin.
746 // The starting x position is the same as the starting x position
747 // of the owner, but in terms of the parent frame.
748 // The starting y position is wxSYS_HSCROLL_Y pels below the
749 // origin of the owner in terms of the parent frame.
750 // The horz bar is the same width as the owner and wxSYS_HSCROLL_Y
753 if (nRange1
>= nThumbVisible
)
755 ::WinSetWindowPos( m_hWndScrollBarHorz
757 ,vSwp
.x
+ vSwpOwner
.x
758 ,(vSwp
.y
+ vSwpOwner
.y
) - nHSBHeight
761 ,SWP_MOVE
| SWP_SIZE
| SWP_SHOW
| SWP_ACTIVATE
| SWP_ZORDER
763 ::WinSendMsg( m_hWndScrollBarHorz
766 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
768 ::WinSendMsg( m_hWndScrollBarHorz
770 ,MPFROM2SHORT( (SHORT
)nThumbVisible
777 ::WinShowWindow(m_hWndScrollBarHorz
, FALSE
);
783 if (m_hWndScrollBarVert
== 0L)
786 // Since the scrollbars are usually created before the owner is
787 // sized either via an OnSize event directly or via sizers or
788 // layout constraints, we will initially just use the coords of
789 // the parent window (this is usually a frame client window). But
790 // the bars themselves, are children of the parent frame (i.e
791 // siblings of the frame client. The owner, however is the actual
792 // window being scrolled (or at least the one responsible for
793 // handling the scroll events). The owner will be resized later,
794 // as it is usually a child of a top level window, and when that
795 // is done its scrollbars will be resized and repositioned as well.
797 m_hWndScrollBarVert
= ::WinCreateWindow( hWndParent
801 ,vSwp
.x
+ vSwp
.cx
- nVSBWidth
804 ,vSwp
.cy
- nHSBHeight
815 // The owner (the scrolled window) is a child of the Frame's
816 // client window, usually. The scrollbars are children of the
817 // frame, itself and thus are positioned relative to the frame's
818 // origin, not the frame's client window's origin.
819 // Thus, the x position will be frame client's x (usually a few
820 // pels inside the parent frame, plus the width of the owner.
821 // Since we may be using sizers or layout constraints for multiple
822 // child scrolled windows, the y position will be the frame client's
823 // y pos plus the scrolled windows y position, yielding the y
824 // position of the scrollbar relative to the parent frame (the vert
825 // scrollbar is on the right and starts at the bottom of the
827 // It is wxSYS_VSCROLL_X pels wide and the same height as the owner.
829 if (nRange1
>= nThumbVisible
)
831 ::WinSetWindowPos( m_hWndScrollBarVert
833 ,vSwp
.x
+ vSwpOwner
.x
+ vSwpOwner
.cx
834 ,vSwp
.y
+ vSwpOwner
.y
837 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
839 ::WinSendMsg( m_hWndScrollBarVert
842 ,MPFROM2SHORT(0, (SHORT
)nRange1
)
844 ::WinSendMsg( m_hWndScrollBarVert
846 ,MPFROM2SHORT( (SHORT
)nThumbVisible
853 ::WinShowWindow(m_hWndScrollBarVert
, FALSE
);
855 m_nYThumbSize
= nThumbVisible
;
857 } // end of wxWindowOS2::SetScrollbar
860 void wxWindowOS2::ScrollWindow( int nDx
,
862 const wxRect
* pRect
)
866 ::WinQueryWindowRect(GetHwnd(), &vRect
);
867 int height
= vRect
.yTop
;
870 vRect
.xLeft
= pRect
->x
;
871 vRect
.yTop
= height
- pRect
->y
;
872 vRect
.xRight
= pRect
->x
+ pRect
->width
;
873 vRect
.yBottom
= vRect
.yTop
- pRect
->height
;
875 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite Windows.
876 ::WinScrollWindow( GetHwnd()
883 ,SW_SCROLLCHILDREN
| SW_INVALIDATERGN
885 } // end of wxWindowOS2::ScrollWindow
887 // ---------------------------------------------------------------------------
889 // ---------------------------------------------------------------------------
891 void wxWindowOS2::SubclassWin(
895 HWND hwnd
= (HWND
)hWnd
;
897 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
898 wxAssociateWinWithHandle( hWnd
901 if (!wxCheckWindowWndProc( hWnd
902 ,(WXFARPROC
)wxWndProc
905 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
909 m_fnOldWndProc
= (WXFARPROC
)NULL
;
911 } // end of wxWindowOS2::SubclassWin
913 void wxWindowOS2::UnsubclassWin()
916 // Restore old Window proc
918 HWND hwnd
= GetHWND();
922 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
924 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
926 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
928 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
932 } // end of wxWindowOS2::UnsubclassWin
934 bool wxCheckWindowWndProc(
936 , WXFARPROC fnWndProc
939 static char zBuffer
[512];
942 ::WinQueryClassName((HWND
)hWnd
, (LONG
)512, (PCH
)zBuffer
);
943 ::WinQueryClassInfo(wxGetInstance(), (PSZ
)zBuffer
, &vCls
);
944 return(fnWndProc
== (WXFARPROC
)vCls
.pfnWindowProc
);
945 } // end of WinGuiBase_CheckWindowWndProc
947 void wxWindowOS2::SetWindowStyleFlag(
951 long lFlagsOld
= GetWindowStyleFlag();
953 if (lFlags
== lFlagsOld
)
957 // Update the internal variable
959 wxWindowBase::SetWindowStyleFlag(lFlags
);
962 // Now update the Windows style as well if needed - and if the window had
963 // been already created
969 WXDWORD dwExstyleOld
;
970 long lStyle
= OS2GetStyle( lFlags
973 long lStyleOld
= OS2GetStyle( lFlagsOld
977 if (lStyle
!= lStyleOld
)
980 // Some flags (e.g. WS_VISIBLE or WS_DISABLED) should not be changed by
981 // this function so instead of simply setting the style to the new
982 // value we clear the bits which were set in styleOld but are set in
983 // the new one and set the ones which were not set before
985 long lStyleReal
= ::WinQueryWindowULong(GetHwnd(), QWL_STYLE
);
987 lStyleReal
&= ~lStyleOld
;
988 lStyleReal
|= lStyle
;
990 ::WinSetWindowULong(GetHwnd(), QWL_STYLE
, lStyleReal
);
992 } // end of wxWindowOS2::SetWindowStyleFlag
994 WXDWORD
wxWindowOS2::OS2GetStyle( long lFlags
,
995 WXDWORD
* WXUNUSED(pdwExstyle
) ) const
997 WXDWORD dwStyle
= 0L;
999 if (lFlags
& wxCLIP_CHILDREN
)
1000 dwStyle
|= WS_CLIPCHILDREN
;
1002 if (lFlags
& wxCLIP_SIBLINGS
)
1003 dwStyle
|= WS_CLIPSIBLINGS
;
1006 } // end of wxWindowOS2::OS2GetStyle
1009 // Make a Windows extended style from the given wxWidgets window style
1011 WXDWORD
wxWindowOS2::MakeExtendedStyle(
1013 , bool bEliminateBorders
1017 // Simply fill out with wxWindow extended styles. We'll conjure
1018 // something up in OS2Create and all window redrawing pieces later
1020 WXDWORD dwStyle
= 0;
1022 if (lStyle
& wxTRANSPARENT_WINDOW
)
1023 dwStyle
|= wxTRANSPARENT_WINDOW
;
1025 if (!bEliminateBorders
)
1027 if (lStyle
& wxSUNKEN_BORDER
)
1028 dwStyle
|= wxSUNKEN_BORDER
;
1029 if (lStyle
& wxDOUBLE_BORDER
)
1030 dwStyle
|= wxDOUBLE_BORDER
;
1031 if (lStyle
& wxRAISED_BORDER
)
1032 dwStyle
|= wxRAISED_BORDER
;
1033 if (lStyle
& wxSTATIC_BORDER
)
1034 dwStyle
|= wxSTATIC_BORDER
;
1037 } // end of wxWindowOS2::MakeExtendedStyle
1040 // Setup background and foreground colours correctly
1042 void wxWindowOS2::SetupColours()
1045 SetBackgroundColour(GetParent()->GetBackgroundColour());
1046 } // end of wxWindowOS2::SetupColours
1048 void wxWindowOS2::OnIdle(
1049 wxIdleEvent
& WXUNUSED(rEvent
)
1053 // Check if we need to send a LEAVE event
1055 if (m_bMouseInWindow
)
1059 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1060 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1063 // Generate a LEAVE event
1065 m_bMouseInWindow
= false;
1068 // Unfortunately the mouse button and keyboard state may have changed
1069 // by the time the OnIdle function is called, so 'state' may be
1079 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1081 InitMouseEvent( rEvent
1086 (void)HandleWindowEvent(rEvent
);
1089 } // end of wxWindowOS2::OnIdle
1092 // Set this window to be the child of 'parent'.
1094 bool wxWindowOS2::Reparent( wxWindowBase
* pParent
)
1096 if (!wxWindowBase::Reparent(pParent
))
1099 HWND hWndChild
= GetHwnd();
1100 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1102 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1104 } // end of wxWindowOS2::Reparent
1106 void wxWindowOS2::Update()
1108 ::WinUpdateWindow(GetHwnd());
1109 } // end of wxWindowOS2::Update
1111 void wxWindowOS2::DoFreeze()
1113 ::WinSendMsg(GetHwnd(), WM_VRNDISABLED
, (MPARAM
)0, (MPARAM
)0);
1114 } // end of wxWindowOS2::Freeze
1116 void wxWindowOS2::DoThaw()
1118 ::WinSendMsg(GetHwnd(), WM_VRNENABLED
, (MPARAM
)TRUE
, (MPARAM
)0);
1121 // We need to refresh everything or otherwise he invalidated area is not
1125 } // end of wxWindowOS2::Thaw
1127 void wxWindowOS2::Refresh( bool bEraseBack
,
1128 const wxRect
* pRect
)
1130 HWND hWnd
= GetHwnd();
1139 ::WinQueryWindowRect(GetHwnd(), &vOs2Rect
);
1140 height
= vOs2Rect
.yTop
;
1141 vOs2Rect
.xLeft
= pRect
->x
;
1142 vOs2Rect
.yTop
= height
- pRect
->y
;
1143 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1144 vOs2Rect
.yBottom
= vOs2Rect
.yTop
- pRect
->height
;
1146 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1149 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1150 if (m_hWndScrollBarHorz
!= NULLHANDLE
)
1151 ::WinInvalidateRect(m_hWndScrollBarHorz
, NULL
, TRUE
);
1152 if (m_hWndScrollBarVert
!= NULLHANDLE
)
1153 ::WinInvalidateRect(m_hWndScrollBarVert
, NULL
, TRUE
);
1155 } // end of wxWindowOS2::Refresh
1157 // ---------------------------------------------------------------------------
1159 // ---------------------------------------------------------------------------
1161 #if wxUSE_DRAG_AND_DROP
1162 void wxWindowOS2::SetDropTarget(
1163 wxDropTarget
* pDropTarget
1166 m_dropTarget
= pDropTarget
;
1167 } // end of wxWindowOS2::SetDropTarget
1171 // old style file-manager drag&drop support: we retain the old-style
1172 // DragAcceptFiles in parallel with SetDropTarget.
1174 void wxWindowOS2::DragAcceptFiles(
1178 HWND hWnd
= GetHwnd();
1180 if (hWnd
&& bAccept
)
1181 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1182 } // end of wxWindowOS2::DragAcceptFiles
1184 // ----------------------------------------------------------------------------
1186 // ----------------------------------------------------------------------------
1190 void wxWindowOS2::DoSetToolTip(
1194 wxWindowBase::DoSetToolTip(pTooltip
);
1197 m_tooltip
->SetWindow(this);
1198 } // end of wxWindowOS2::DoSetToolTip
1200 #endif // wxUSE_TOOLTIPS
1202 // ---------------------------------------------------------------------------
1203 // moving and resizing
1204 // ---------------------------------------------------------------------------
1207 void wxWindowOS2::DoGetSize(
1215 if (IsKindOf(CLASSINFO(wxFrame
)))
1217 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1218 hWnd
= pFrame
->GetFrame();
1223 ::WinQueryWindowRect(hWnd
, &vRect
);
1226 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1228 // OS/2 PM is backwards from windows
1229 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1230 } // end of wxWindowOS2::DoGetSize
1232 void wxWindowOS2::DoGetPosition(
1238 // Return parameters assume wxWidgets coordinate system
1243 wxWindow
* pParent
= GetParent();
1246 // It would seem that WinQueryWindowRect would be the correlary to
1247 // the WIN32 WinGetRect, but unlike WinGetRect which returns the window
1248 // origin position in screen coordinates, WinQueryWindowRect returns it
1249 // relative to itself, i.e. (0,0). To get the same under PM we must
1250 // use WinQueryWindowPos. This call, unlike the WIN32 call, however,
1251 // returns a position relative to it's parent, so no parent adujstments
1252 // are needed under OS/2. Also, windows should be created using
1253 // wxWindow coordinates, i.e. 0,0 is the TOP left.
1255 if (IsKindOf(CLASSINFO(wxFrame
)))
1257 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
1258 hWnd
= pFrame
->GetFrame();
1263 ::WinQueryWindowPos(hWnd
, &vSwp
);
1268 // We need to convert to wxWidgets coordinates
1270 DoGetSize(NULL
,&vHeight
);
1271 wxWindow
* pWindow
= wxDynamicCast(this,wxWindow
);
1272 vPoint
.y
= pWindow
->GetOS2ParentHeight(pParent
) - vPoint
.y
- vHeight
;
1275 // We may be faking the client origin. So a window that's really at (0,
1276 // 30) may appear (to wxWin apps) to be at (0, 0).
1280 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1290 } // end of wxWindowOS2::DoGetPosition
1292 void wxWindowOS2::DoScreenToClient(
1297 HWND hWnd
= GetHwnd();
1300 ::WinQueryWindowPos(hWnd
, &vSwp
);
1306 } // end of wxWindowOS2::DoScreenToClient
1308 void wxWindowOS2::DoClientToScreen(
1313 HWND hWnd
= GetHwnd();
1316 ::WinQueryWindowPos(hWnd
, &vSwp
);
1322 } // end of wxWindowOS2::DoClientToScreen
1325 // Get size *available for subwindows* i.e. excluding menu bar etc.
1326 // Must be a frame type window
1328 void wxWindowOS2::DoGetClientSize(
1333 HWND hWnd
= GetHwnd();
1336 ::WinQueryWindowRect(hWnd
, &vRect
);
1337 if (IsKindOf(CLASSINFO(wxDialog
)))
1342 // For a Dialog we have to explicitly request the client portion.
1343 // For a Frame the hWnd IS the client window
1345 hWndTitle
= ::WinWindowFromID(hWnd
, FID_TITLEBAR
);
1346 if (::WinQueryWindowRect(hWndTitle
, &vTitle
))
1348 if (vTitle
.yTop
- vTitle
.yBottom
== 0)
1351 // Dialog has not been created yet, use a default
1355 vRect
.yTop
-= (vTitle
.yTop
- vTitle
.yBottom
);
1358 ULONG uStyle
= ::WinQueryWindowULong(hWnd
, QWL_STYLE
);
1361 // Deal with borders
1363 if (uStyle
& FCF_DLGBORDER
)
1370 else if (uStyle
& FCF_SIZEBORDER
)
1377 else if (uStyle
& FCF_BORDER
)
1384 else // make some kind of adjustment or top sizers ram into the titlebar!
1393 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1395 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1396 } // end of wxWindowOS2::DoGetClientSize
1398 void wxWindowOS2::DoMoveWindow(
1406 // Input parameters assume wxWidgets coordinate system
1409 wxWindow
* pParent
= GetParent();
1410 HWND hWnd
= GetHwnd();
1412 if (pParent
&& !IsKindOf(CLASSINFO(wxDialog
)))
1414 int nOS2Height
= GetOS2ParentHeight(pParent
);
1416 nY
= nOS2Height
- (nY
+ nHeight
);
1422 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
1423 nY
= vRect
.yTop
- (nY
+ nHeight
);
1427 // In the case of a frame whose client is sized, the client cannot be
1428 // large than its parent frame minus its borders! This usually happens
1429 // when using an autosizer to size a frame to precisely hold client
1430 // controls as in the notebook sample.
1432 // In this case, we may need to resize both a frame and its client so we
1433 // need a quick calc of the frame border size, then if the frame
1434 // (less its borders) is smaller than the client, size the frame to
1435 // encompass the client with the appropriate border size.
1437 if (IsKindOf(CLASSINFO(wxFrame
)))
1440 int nWidthFrameDelta
= 0;
1441 int nHeightFrameDelta
= 0;
1444 pFrame
= wxDynamicCast(this, wxFrame
);
1445 hWnd
= pFrame
->GetFrame();
1446 ::WinQueryWindowRect(hWnd
, &vRect
);
1447 ::WinMapWindowPoints(hWnd
, HWND_DESKTOP
, (PPOINTL
)&vRect
, 2);
1449 ::WinCalcFrameRect(hWnd
, &vRect
, TRUE
);
1450 nWidthFrameDelta
= ((vRect
.xLeft
- vFRect
.xLeft
) + (vFRect
.xRight
- vRect
.xRight
));
1451 nHeightFrameDelta
= ((vRect
.yBottom
- vFRect
.yBottom
) + (vFRect
.yTop
- vRect
.yTop
));
1452 // Input values refer to the window position relative to its parent
1453 // which may be the Desktop so we need to calculate
1454 // the new frame values to keep the wxWidgets frame origin constant
1455 nY
-= nHeightFrameDelta
;
1456 nWidth
+= nWidthFrameDelta
;
1457 nHeight
+= nHeightFrameDelta
;
1459 ::WinSetWindowPos( hWnd
1465 ,SWP_SIZE
| SWP_MOVE
1467 if (m_vWinSwp
.cx
== 0 && m_vWinSwp
.cy
== 0 && m_vWinSwp
.fl
== 0)
1471 ::WinQueryWindowPos(hWnd
, &m_vWinSwp
);
1475 // Handle resizing of scrolled windows. The target or window to
1476 // be scrolled is the owner (gets the scroll notifications). The
1477 // parent is usually the parent frame of the scrolled panel window.
1478 // In order to show the scrollbars the target window will be shrunk
1479 // by the size of the scroll bar widths and moved in the X and Y
1480 // directon. That value will be computed as part of the diff for
1481 // moving the children. Everytime the window is sized the
1482 // toplevel OnSize is going to resize the panel to fit the client
1483 // or the whole sizer and will need to me resized. This will send
1484 // a WM_SIZE out which will be intercepted by the ScrollHelper
1485 // which will cause the scrollbars to be displayed via the SetScrollbar
1488 if (IsKindOf(CLASSINFO(wxScrolledWindow
)))
1490 int nAdjustWidth
= 0;
1491 int nAdjustHeight
= 0;
1492 int nHSBHeight
= wxSystemSettingsNative::GetMetric(wxSYS_HSCROLL_Y
,
1494 int nVSBWidth
= wxSystemSettingsNative::GetMetric(wxSYS_VSCROLL_X
,
1498 if (GetScrollBarHorz() == NULLHANDLE
||
1499 !WinIsWindowShowing(GetScrollBarHorz()))
1502 nAdjustHeight
= nHSBHeight
;
1503 if (GetScrollBarVert() == NULLHANDLE
||
1504 !WinIsWindowShowing(GetScrollBarVert()))
1507 nAdjustWidth
= nVSBWidth
;
1508 ::WinQueryWindowPos(hWnd
, &vSwpScroll
);
1509 ::WinSetWindowPos( hWnd
1512 ,vSwpScroll
.y
+ nAdjustHeight
1513 ,vSwpScroll
.cx
- nAdjustWidth
1514 ,vSwpScroll
.cy
- nAdjustHeight
1515 ,SWP_MOVE
| SWP_SIZE
1518 ::WinQueryWindowPos(hWnd
, &m_vWinSwp
);
1520 } // end of wxWindowOS2::DoMoveWindow
1523 // Set the size of the window: if the dimensions are positive, just use them,
1524 // but if any of them is equal to -1, it means that we must find the value for
1525 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1526 // which case -1 is a valid value for x and y)
1528 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1529 // the width/height to best suit our contents, otherwise we reuse the current
1532 void wxWindowOS2::DoSetSize( int nX
,
1539 // Input & output parameters assume wxWidgets coordinate system
1543 // Get the current size and position...
1549 wxSize vSize
= wxDefaultSize
;
1551 GetPosition(&nCurrentX
, &nCurrentY
);
1552 GetSize(&nCurrentWidth
, &nCurrentHeight
);
1555 // ... and don't do anything (avoiding flicker) if it's already ok
1557 if (nX
== nCurrentX
&& nY
== nCurrentY
&&
1558 nWidth
== nCurrentWidth
&& nHeight
== nCurrentHeight
)
1563 if (nX
== wxDefaultCoord
&& !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1565 if (nY
== wxDefaultCoord
&& !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1568 AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
);
1570 if (nWidth
== wxDefaultCoord
)
1572 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1574 vSize
= DoGetBestSize();
1580 // Just take the current one
1582 nWidth
= nCurrentWidth
;
1586 if (nHeight
== wxDefaultCoord
)
1588 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1590 if (vSize
.x
== wxDefaultCoord
)
1592 vSize
= DoGetBestSize();
1598 // just take the current one
1599 nHeight
= nCurrentHeight
;
1603 DoMoveWindow( nX
, nY
, nWidth
, nHeight
);
1604 } // end of wxWindowOS2::DoSetSize
1606 void wxWindowOS2::DoSetClientSize( int nWidth
,
1610 // nX & nY assume wxWidgets coordinate system
1615 GetPosition(&nX
, &nY
);
1617 DoMoveWindow( nX
, nY
, nWidth
, nHeight
);
1619 wxSize
size( nWidth
, nHeight
);
1620 wxSizeEvent
vEvent( size
, m_windowId
);
1621 vEvent
.SetEventObject(this);
1622 HandleWindowEvent(vEvent
);
1623 } // end of wxWindowOS2::DoSetClientSize
1625 // ---------------------------------------------------------------------------
1627 // ---------------------------------------------------------------------------
1629 int wxWindowOS2::GetCharHeight() const
1632 FONTMETRICS vFontMetrics
;
1634 hPs
= ::WinGetPS(GetHwnd());
1636 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1638 ::WinReleasePS(hPs
);
1641 ::WinReleasePS(hPs
);
1642 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1643 } // end of wxWindowOS2::GetCharHeight
1645 int wxWindowOS2::GetCharWidth() const
1648 FONTMETRICS vFontMetrics
;
1650 hPs
= ::WinGetPS(GetHwnd());
1652 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1654 ::WinReleasePS(hPs
);
1657 ::WinReleasePS(hPs
);
1658 return(vFontMetrics
.lAveCharWidth
);
1659 } // end of wxWindowOS2::GetCharWidth
1661 void wxWindowOS2::DoGetTextExtent( const wxString
& rString
,
1665 int* pExternalLeading
,
1666 const wxFont
* WXUNUSED(pTheFont
) ) const
1668 POINTL avPoint
[TXTBOX_COUNT
];
1673 FONTMETRICS vFM
; // metrics structure
1677 hPS
= ::WinGetPS(GetHwnd());
1679 l
= rString
.length();
1683 // In world coordinates.
1685 bRc
= ::GpiQueryTextBox( hPS
,
1687 (char*) rString
.wx_str(),
1688 TXTBOX_COUNT
,// return maximum information
1689 avPoint
// array of coordinates points
1693 vPtMin
.x
= avPoint
[0].x
;
1694 vPtMax
.x
= avPoint
[0].x
;
1695 vPtMin
.y
= avPoint
[0].y
;
1696 vPtMax
.y
= avPoint
[0].y
;
1697 for (i
= 1; i
< 4; i
++)
1699 if(vPtMin
.x
> avPoint
[i
].x
) vPtMin
.x
= avPoint
[i
].x
;
1700 if(vPtMin
.y
> avPoint
[i
].y
) vPtMin
.y
= avPoint
[i
].y
;
1701 if(vPtMax
.x
< avPoint
[i
].x
) vPtMax
.x
= avPoint
[i
].x
;
1702 if(vPtMax
.y
< avPoint
[i
].y
) vPtMax
.y
= avPoint
[i
].y
;
1704 bRc
= ::GpiQueryFontMetrics( hPS
1705 ,sizeof(FONTMETRICS
)
1732 *pX
= (vPtMax
.x
- vPtMin
.x
+ 1);
1734 *pY
= (vPtMax
.y
- vPtMin
.y
+ 1);
1738 *pDescent
= vFM
.lMaxDescender
;
1742 if (pExternalLeading
)
1745 *pExternalLeading
= vFM
.lExternalLeading
;
1747 *pExternalLeading
= 0;
1749 ::WinReleasePS(hPS
);
1750 } // end of wxWindow::DoGetTextExtent
1752 bool wxWindowOS2::IsMouseInWindow() const
1755 // Get the mouse position
1758 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
1761 // Find the window which currently has the cursor and go up the window
1762 // chain until we find this window - or exhaust it
1764 HWND hWnd
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt
, TRUE
);
1766 while (hWnd
&& (hWnd
!= GetHwnd()))
1767 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
1769 return hWnd
!= NULL
;
1770 } // end of wxWindowOS2::IsMouseInWindow
1773 // ---------------------------------------------------------------------------
1775 // ---------------------------------------------------------------------------
1777 #if wxUSE_MENUS_NATIVE
1778 bool wxWindowOS2::DoPopupMenu( wxMenu
* pMenu
, int nX
, int nY
)
1780 HWND hWndOwner
= GetHwnd();
1781 HWND hWndParent
= GetHwnd();
1782 HWND hMenu
= GetHmenuOf(pMenu
);
1783 bool bIsWaiting
= true;
1788 if ( nX
== -1 && nY
== -1 )
1790 wxPoint mouse
= wxGetMousePosition();
1791 nX
= mouse
.x
; nY
= mouse
.y
;
1795 DoClientToScreen( &nX
1798 DoGetSize(0,&nHeight
);
1802 ::WinPopupMenu( hWndParent
1808 ,PU_HCONSTRAIN
| PU_VCONSTRAIN
| PU_MOUSEBUTTON1
| PU_KEYBOARD
1815 ::WinGetMsg(vHabmain
,&vMsg
, (HWND
)0, 0, 0);
1816 if (vMsg
.msg
== WM_COMMAND
)
1818 ::WinDispatchMsg(vHabmain
, (PQMSG
)&vMsg
);
1822 } // end of wxWindowOS2::DoPopupMenu
1823 #endif // wxUSE_MENUS_NATIVE
1825 // ===========================================================================
1826 // pre/post message processing
1827 // ===========================================================================
1829 MRESULT
wxWindowOS2::OS2DefWindowProc( WXUINT uMsg
,
1834 return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1836 return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1837 } // end of wxWindowOS2::OS2DefWindowProc
1839 bool wxWindowOS2::OS2ProcessMessage( WXMSG
* pMsg
)
1841 // wxUniversal implements tab traversal itself
1842 #ifndef __WXUNIVERSAL__
1843 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1845 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
1848 // Intercept dialog navigation keys
1850 bool bProcess
= true;
1851 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
1853 if (uKeyFlags
& KC_KEYUP
)
1856 if (uKeyFlags
& KC_ALT
)
1859 if (!(uKeyFlags
& KC_VIRTUALKEY
))
1864 bool bCtrlDown
= IsCtrlDown();
1865 bool bShiftDown
= IsShiftDown();
1868 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1869 // don't process it if it's the case (except for Ctrl-Tab/Enter
1870 // combinations which are always processed)
1872 ULONG ulDlgCode
= 0;
1876 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
1879 bool bForward
= true;
1880 bool bWindowChange
= false;
1882 switch (SHORT2FROMMP(pQMsg
->mp2
))
1885 // Going to make certain assumptions about specific types of controls
1886 // here, so we may have to alter some things later if they prove invalid
1890 // Shift tabl will always be a nav-key but tabs may be wanted
1899 // Entry Fields want tabs for themselve usually
1903 case DLGC_ENTRYFIELD
:
1913 // Ctrl-Tab cycles thru notebook pages
1915 bWindowChange
= bCtrlDown
;
1916 bForward
= !bShiftDown
;
1939 // ctrl-enter is not processed
1943 else if (ulDlgCode
& DLGC_BUTTON
)
1946 // buttons want process Enter themselevs
1952 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
1953 wxButton
* pBtn
= NULL
;
1957 pBtn
= wxDynamicCast(tlw
->GetDefaultItem(), wxButton
);
1960 if (pBtn
&& pBtn
->IsEnabled())
1963 // If we do have a default button, do press it
1965 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
1968 else if (!IsTopLevel())
1971 // if not a top level window, let parent
1976 // else: but if it does not it makes sense to make
1977 // it work like a TAB - and that's what we do.
1978 // Note that Ctrl-Enter always works this way.
1989 wxNavigationKeyEvent vEvent
;
1991 vEvent
.SetDirection(bForward
);
1992 vEvent
.SetWindowChange(bWindowChange
);
1993 vEvent
.SetEventObject(this);
1995 if (HandleWindowEvent(vEvent
))
1997 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
2002 // The button which has focus should be default
2011 // Let Dialogs process
2013 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
2017 pMsg
= pMsg
; // just shut up the compiler
2018 #endif // __WXUNIVERSAL__
2021 } // end of wxWindowOS2::OS2ProcessMessage
2023 bool wxWindowOS2::OS2TranslateMessage( WXMSG
* pMsg
)
2025 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2026 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
2030 #endif //wxUSE_ACCEL
2031 } // end of wxWindowOS2::OS2TranslateMessage
2033 bool wxWindowOS2::OS2ShouldPreProcessMessage( WXMSG
* WXUNUSED(pMsg
) )
2035 // preprocess all messages by default
2037 } // end of wxWindowOS2::OS2ShouldPreProcessMessage
2039 // ---------------------------------------------------------------------------
2040 // message params unpackers
2041 // ---------------------------------------------------------------------------
2043 void wxWindowOS2::UnpackCommand(
2051 *pId
= LOWORD(wParam
);
2052 *phWnd
= NULL
; // or may be GetHWND() ?
2053 *pCmd
= LOWORD(lParam
);
2054 } // end of wxWindowOS2::UnpackCommand
2056 void wxWindowOS2::UnpackActivate(
2063 *pState
= LOWORD(wParam
);
2064 *phWnd
= (WXHWND
)lParam
;
2065 } // end of wxWindowOS2::UnpackActivate
2067 void wxWindowOS2::UnpackScroll(
2078 ulId
= (ULONG
)LONGFROMMP(wParam
);
2079 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
2080 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
2081 *phWnd
= NULLHANDLE
;
2085 *pPos
= SHORT1FROMMP(lParam
);
2086 *pCode
= SHORT2FROMMP(lParam
);
2087 } // end of wxWindowOS2::UnpackScroll
2089 void wxWindowOS2::UnpackMenuSelect(
2097 *pItem
= (WXWORD
)LOWORD(wParam
);
2098 *pFlags
= HIWORD(wParam
);
2099 *phMenu
= (WXHMENU
)lParam
;
2100 } // end of wxWindowOS2::UnpackMenuSelect
2102 // ---------------------------------------------------------------------------
2103 // Main wxWidgets window proc and the window proc for wxWindow
2104 // ---------------------------------------------------------------------------
2107 // Hook for new window just as it's being created, when the window isn't yet
2108 // associated with the handle
2110 wxWindowOS2
* wxWndHook
= NULL
;
2115 MRESULT EXPENTRY
wxWndProc(
2122 wxWindowOS2
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
2125 // When we get the first message for the HWND we just created, we associate
2126 // it with wxWindow stored in wxWndHook
2128 if (!pWnd
&& wxWndHook
)
2130 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2133 pWnd
->SetHWND((WXHWND
)hWnd
);
2136 MRESULT rc
= (MRESULT
)0;
2140 // Stop right here if we don't have a valid handle in our wxWindow object.
2142 if (pWnd
&& !pWnd
->GetHWND())
2144 pWnd
->SetHWND((WXHWND
) hWnd
);
2145 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2152 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2153 if ( (pWnd
->GetScrollBarHorz() != NULLHANDLE
||
2154 pWnd
->GetScrollBarVert() != NULLHANDLE
) &&
2157 if (pWnd
->GetScrollBarHorz() != NULLHANDLE
)
2158 ::WinInvalidateRect(pWnd
->GetScrollBarHorz(), NULL
, TRUE
);
2159 if (pWnd
->GetScrollBarVert() != NULLHANDLE
)
2160 ::WinInvalidateRect(pWnd
->GetScrollBarVert(), NULL
, TRUE
);
2164 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2168 } // end of wxWndProc
2171 // We will add (or delete) messages we need to handle at this default
2174 MRESULT
wxWindowOS2::OS2WindowProc( WXUINT uMsg
,
2179 // Did we process the uMsg?
2181 bool bProcessed
= false;
2185 // For most messages we should return 0 when we do process the message
2187 mResult
= (MRESULT
)0;
2195 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2201 // Return 0 to bAllow window creation
2203 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2214 bProcessed
= HandleMove( LOWORD(lParam
)
2220 bProcessed
= HandleSize( LOWORD(lParam
)
2226 case WM_WINDOWPOSCHANGED
:
2229 // Dialogs under OS/2 do not get WM_SIZE events at all.
2230 // Instead they get this, which can function much like WM_SIZE
2231 // PSWP contains the new sizes and positioning, PSWP+1 the old
2232 // We use this because ADJUSTWINDOWPOS comes BEFORE the new
2233 // position is added and our auto layout does a WinQueryWindowRect
2234 // to get the CURRENT client size. That is the size used to position
2235 // child controls, so we need to already be sized
2236 // in order to get the child controls positoned properly.
2238 if (IsKindOf(CLASSINFO(wxDialog
)) || IsKindOf(CLASSINFO(wxFrame
)))
2240 PSWP pSwp
= (PSWP
)PVOIDFROMMP(wParam
);
2241 PSWP pSwp2
= pSwp
++;
2243 if (!(pSwp
->cx
== pSwp2
->cx
&&
2244 pSwp
->cy
== pSwp2
->cy
))
2245 bProcessed
= HandleSize( pSwp
->cx
2249 if (IsKindOf(CLASSINFO(wxFrame
)))
2251 wxFrame
* pFrame
= wxDynamicCast(this, wxFrame
);
2255 if (pFrame
->GetStatusBar())
2256 pFrame
->PositionStatusBar();
2257 if (pFrame
->GetToolBar())
2258 pFrame
->PositionToolBar();
2269 UnpackActivate( wParam
2275 bProcessed
= HandleActivate( wState
2283 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2284 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2286 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2290 bProcessed
= HandlePaint();
2295 // Don't let the DefWindowProc() destroy our window - we'll do it
2296 // ourselves in ~wxWindow
2299 mResult
= (MRESULT
)TRUE
;
2303 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2307 // Under OS2 PM Joysticks are treated just like mouse events
2308 // The "Motion" events will be prevelent in joysticks
2311 case WM_BUTTON1DOWN
:
2313 case WM_BUTTON1DBLCLK
:
2314 case WM_BUTTON1MOTIONEND
:
2315 case WM_BUTTON1MOTIONSTART
:
2316 case WM_BUTTON2DOWN
:
2318 case WM_BUTTON2DBLCLK
:
2319 case WM_BUTTON2MOTIONEND
:
2320 case WM_BUTTON2MOTIONSTART
:
2321 case WM_BUTTON3DOWN
:
2323 case WM_BUTTON3DBLCLK
:
2324 case WM_BUTTON3MOTIONEND
:
2325 case WM_BUTTON3MOTIONSTART
:
2327 short nX
= LOWORD(wParam
);
2328 short nY
= HIWORD(wParam
);
2331 // Redirect the event to a static control if necessary
2333 if (this == GetCapture())
2335 bProcessed
= HandleMouseEvent( uMsg
2338 ,(WXUINT
)SHORT2FROMMP(lParam
)
2343 wxWindow
* pWin
= FindWindowForMouseEvent( this
2347 if (!pWin
->IsOfStandardClass())
2349 if (uMsg
== WM_BUTTON1DOWN
&& pWin
->CanAcceptFocus() )
2352 bProcessed
= pWin
->HandleMouseEvent( uMsg
2355 ,(WXUINT
)SHORT2FROMMP(lParam
)
2362 bProcessed
= HandleSysCommand(wParam
, lParam
);
2369 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2371 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2376 // For these messages we must return TRUE if process the message
2379 case WM_MEASUREITEM
:
2381 int nIdCtrl
= (UINT
)wParam
;
2383 if ( uMsg
== WM_DRAWITEM
)
2385 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2386 (WXDRAWITEMSTRUCT
*)lParam
);
2390 return MRFROMLONG(OS2OnMeasureItem( nIdCtrl
2391 ,(WXMEASUREITEMSTRUCT
*)lParam
2396 mResult
= (MRESULT
)TRUE
;
2400 case WM_QUERYDLGCODE
:
2401 if (!IsOfStandardClass())
2405 mResult
= (MRESULT
)m_lDlgCode
;
2410 //else: get the dlg code from the DefWindowProc()
2415 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2416 // and key-down events are obtained from the WM_CHAR params.
2420 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2422 if (uKeyFlags
& KC_KEYUP
)
2424 //TODO: check if the cast to WXWORD isn't causing trouble
2425 bProcessed
= HandleKeyUp(wParam
, lParam
);
2428 else // keydown event
2430 m_bLastKeydownProcessed
= false;
2432 // If this has been processed by an event handler,
2433 // return 0 now (we've handled it). DON't RETURN
2434 // we still need to process further
2436 m_bLastKeydownProcessed
= HandleKeyDown(wParam
, lParam
);
2437 if (uKeyFlags
& KC_VIRTUALKEY
)
2439 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2442 // We consider these message "not interesting" to OnChar
2455 // Avoid duplicate messages to OnChar for these ASCII keys: they
2456 // will be translated by TranslateMessage() and received in WM_CHAR
2461 // But set processed to false, not true to still pass them to
2462 // the control's default window proc - otherwise built-in
2463 // keyboard handling won't work
2468 bProcessed
= HandleChar(wParam
, lParam
);
2472 else // WM_CHAR -- Always an ASCII character
2474 if (m_bLastKeydownProcessed
)
2477 // The key was handled in the EVT_KEY_DOWN and handling
2478 // a key in an EVT_KEY_DOWN handler is meant, by
2479 // design, to prevent EVT_CHARs from happening
2481 m_bLastKeydownProcessed
= false;
2484 else // do generate a CHAR event
2486 bProcessed
= HandleChar(wParam
, lParam
, true);
2499 UnpackScroll( wParam
2506 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2516 switch(SHORT2FROMMP(wParam
))
2520 HWND hWnd
= ::WinWindowFromID((HWND
)GetHwnd(), SHORT1FROMMP(wParam
));
2521 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2528 if (pWin
->IsKindOf(CLASSINFO(wxBitmapButton
)))
2530 wxBitmapButton
* pBitmapButton
= wxDynamicCast(pWin
, wxBitmapButton
);
2532 pBitmapButton
->OS2OnDraw((WXDRAWITEMSTRUCT
*)lParam
);
2538 case BKN_PAGESELECTEDPENDING
:
2540 PPAGESELECTNOTIFY pPage
= (PPAGESELECTNOTIFY
)lParam
;
2542 if ((pPage
->ulPageIdNew
!= pPage
->ulPageIdCur
) &&
2543 (pPage
->ulPageIdNew
> 0L && pPage
->ulPageIdCur
> 0L))
2545 wxWindowOS2
* pWin
= wxFindWinFromHandle(pPage
->hwndBook
);
2546 wxBookCtrlEvent
vEvent( wxEVT_NOTEBOOK_PAGE_CHANGED
2547 ,(int)SHORT1FROMMP(wParam
)
2548 ,(int)pPage
->ulPageIdNew
2549 ,(int)pPage
->ulPageIdCur
2556 if (pWin
->IsKindOf(CLASSINFO(wxNotebook
)))
2558 wxNotebook
* pNotebook
= wxDynamicCast(pWin
, wxNotebook
);
2560 vEvent
.SetEventObject(pWin
);
2561 pNotebook
->OnSelChange(vEvent
);
2573 case BN_CLICKED
: // Dups as LN_SELECT and CBN_LBSELECT
2575 HWND hWnd
= ::WinWindowFromID((HWND
)GetHwnd(), SHORT1FROMMP(wParam
));
2576 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2584 // Simulate a WM_COMMAND here, as wxWidgets expects all control
2585 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2587 if (pWin
->IsKindOf(CLASSINFO(wxRadioBox
)))
2589 wxRadioBox
* pRadioBox
= wxDynamicCast(pWin
, wxRadioBox
);
2591 pRadioBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2592 ,(WXWORD
)SHORT1FROMMP(wParam
)
2595 if (pWin
->IsKindOf(CLASSINFO(wxRadioButton
)))
2597 wxRadioButton
* pRadioButton
= wxDynamicCast(pWin
, wxRadioButton
);
2599 pRadioButton
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2600 ,(WXWORD
)SHORT1FROMMP(wParam
)
2603 if (pWin
->IsKindOf(CLASSINFO(wxCheckBox
)))
2605 wxCheckBox
* pCheckBox
= wxDynamicCast(pWin
, wxCheckBox
);
2607 pCheckBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2608 ,(WXWORD
)SHORT1FROMMP(wParam
)
2611 if (pWin
->IsKindOf(CLASSINFO(wxListBox
)))
2613 wxListBox
* pListBox
= wxDynamicCast(pWin
, wxListBox
);
2615 pListBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2616 ,(WXWORD
)SHORT1FROMMP(wParam
)
2618 if (pListBox
->GetWindowStyle() & wxLB_OWNERDRAW
)
2621 if (pWin
->IsKindOf(CLASSINFO(wxComboBox
)))
2623 wxComboBox
* pComboBox
= wxDynamicCast(pWin
, wxComboBox
);
2625 pComboBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2626 ,(WXWORD
)SHORT1FROMMP(wParam
)
2629 if (pWin
->IsKindOf(CLASSINFO(wxChoice
)))
2631 wxChoice
* pChoice
= wxDynamicCast(pWin
, wxChoice
);
2633 pChoice
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2634 ,(WXWORD
)SHORT1FROMMP(wParam
)
2643 HWND hWnd
= HWNDFROMMP(lParam
);
2644 wxWindowOS2
* pWin
= wxFindWinFromHandle(hWnd
);
2652 // Simulate a WM_COMMAND here, as wxWidgets expects all control
2653 // button clicks to generate WM_COMMAND msgs, not WM_CONTROL
2655 if (pWin
->IsKindOf(CLASSINFO(wxListBox
)))
2657 wxListBox
* pListBox
= wxDynamicCast(pWin
, wxListBox
);
2659 pListBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2660 ,(WXWORD
)SHORT1FROMMP(wParam
)
2662 if (pListBox
->GetWindowStyle() & wxLB_OWNERDRAW
)
2666 if (pWin
->IsKindOf(CLASSINFO(wxComboBox
)))
2668 wxComboBox
* pComboBox
= wxDynamicCast(pWin
, wxComboBox
);
2670 pComboBox
->OS2Command( (WXUINT
)SHORT2FROMMP(wParam
)
2671 ,(WXWORD
)SHORT1FROMMP(wParam
)
2679 case SPBN_DOWNARROW
:
2685 ::WinSendMsg( HWNDFROMMP(lParam
)
2688 ,MPFROM2SHORT( (USHORT
)10
2689 ,(USHORT
)SPBQ_UPDATEIFVALID
2693 bProcessed
= OS2OnScroll( wxVERTICAL
2694 ,(WXWORD
)SHORT2FROMMP(wParam
)
2701 case SLN_SLIDERTRACK
:
2703 HWND hWnd
= ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam
));
2704 wxWindowOS2
* pChild
= wxFindWinFromHandle(hWnd
);
2711 if (pChild
->IsKindOf(CLASSINFO(wxSlider
)))
2712 bProcessed
= OS2OnScroll( wxVERTICAL
2713 ,(WXWORD
)SHORT2FROMMP(wParam
)
2714 ,(WXWORD
)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
2758 mResult
= (MRESULT
)FALSE
;
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
;
2790 #if wxUSE_MENUS_NATIVE
2792 if (wxCurrentPopupMenu
)
2794 if (GetHmenuOf(wxCurrentPopupMenu
) == (HWND
)lParam
)
2796 // Break out of msg loop in DoPopupMenu
2797 ::WinPostMsg((HWND
)lParam
,WM_COMMAND
,wParam
,0);
2801 #endif // wxUSE_MENUS_NATIVE
2807 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2808 wxGetMessageName(uMsg
));
2809 #endif // __WXDEBUG__
2810 if (IsKindOf(CLASSINFO(wxFrame
)))
2811 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2812 else if (IsKindOf(CLASSINFO(wxDialog
)))
2813 mResult
= ::WinDefDlgProc( m_hWnd
, uMsg
, wParam
, lParam
);
2815 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2818 } // end of wxWindowOS2::OS2WindowProc
2820 // ----------------------------------------------------------------------------
2821 // wxWindow <-> HWND map
2822 // ----------------------------------------------------------------------------
2824 wxWinHashTable
*wxWinHandleHash
= NULL
;
2826 wxWindow
* wxFindWinFromHandle(
2830 return (wxWindow
*)wxWinHandleHash
->Get((long)hWnd
);
2831 } // end of wxFindWinFromHandle
2833 void wxAssociateWinWithHandle(
2839 // Adding NULL hWnd is (first) surely a result of an error and
2840 // (secondly) breaks menu command processing
2842 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2843 wxT("attempt to add a NULL hWnd to window list ignored") );
2845 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2847 if (pOldWin
&& (pOldWin
!= pWin
))
2849 wxString
Newstr(pWin
->GetClassInfo()->GetClassName());
2850 wxString
Oldstr(pOldWin
->GetClassInfo()->GetClassName());
2851 wxLogError( wxT("Bug! New window of class %s has same HWND %X as old window of class %s"),
2859 wxWinHandleHash
->Put( (long)hWnd
2863 } // end of wxAssociateWinWithHandle
2865 void wxRemoveHandleAssociation( wxWindowOS2
* pWin
)
2867 wxWinHandleHash
->Delete((long)pWin
->GetHWND());
2868 } // end of wxRemoveHandleAssociation
2871 // Default destroyer - override if you destroy it in some other way
2872 // (e.g. with MDI child windows)
2874 void wxWindowOS2::OS2DestroyWindow()
2878 bool wxWindowOS2::OS2GetCreateWindowCoords( const wxPoint
& rPos
,
2879 const wxSize
& rSize
,
2883 int& rnHeight
) const
2885 bool bNonDefault
= false;
2886 static const int DEFAULT_Y
= 200;
2887 static const int DEFAULT_H
= 250;
2889 if (rPos
.x
== wxDefaultCoord
)
2891 rnX
= rnY
= CW_USEDEFAULT
;
2896 rnY
= rPos
.y
== wxDefaultCoord
? DEFAULT_Y
: rPos
.y
;
2899 if (rSize
.x
== wxDefaultCoord
)
2901 rnWidth
= rnHeight
= CW_USEDEFAULT
;
2906 rnHeight
= rSize
.y
== wxDefaultCoord
? DEFAULT_H
: rSize
.y
;
2910 } // end of wxWindowOS2::OS2GetCreateWindowCoords
2912 WXHWND
wxWindowOS2::OS2GetParent() const
2914 return m_parent
? m_parent
->GetHWND() : NULL
;
2917 bool wxWindowOS2::OS2Create( PSZ zClass
,
2918 const wxChar
* zTitle
,
2920 const wxPoint
& rPos
,
2921 const wxSize
& rSize
,
2923 WXDWORD
WXUNUSED(dwExStyle
),
2932 long lControlId
= 0L;
2933 wxWindowCreationHook
vHook(this);
2934 wxString
sClassName((wxChar
*)zClass
);
2935 wxString
sTitle(zTitle
? zTitle
: wxEmptyString
);
2937 OS2GetCreateWindowCoords( rPos
2947 lControlId
= GetId();
2948 if (GetWindowStyleFlag() & wxCLIP_SIBLINGS
)
2950 dwStyle
|= WS_CLIPSIBLINGS
;
2954 // For each class "Foo" we have we also have "FooNR" ("no repaint") class
2955 // which is the same but without CS_[HV]REDRAW class styles so using it
2956 // ensures that the window is not fully repainted on each resize
2958 if (!HasFlag(wxFULL_REPAINT_ON_RESIZE
))
2960 sClassName
+= wxT("NR");
2962 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)OS2GetParent()
2978 vError
= ::WinGetLastError(wxGetInstance());
2979 sError
= wxPMErrorToStr(vError
);
2982 SubclassWin(m_hWnd
);
2983 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
2985 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
2987 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
2989 if (!::WinSetPresParam( m_hWnd
2995 vError
= ::WinGetLastError(vHabmain
);
2996 sError
= wxPMErrorToStr(vError
);
2997 wxLogError(wxT("Error creating frame. Error: %s\n"), sError
.c_str());
3006 } // end of wxWindowOS2::OS2Create
3008 // ===========================================================================
3009 // OS2 PM message handlers
3010 // ===========================================================================
3012 // ---------------------------------------------------------------------------
3013 // window creation/destruction
3014 // ---------------------------------------------------------------------------
3016 bool wxWindowOS2::HandleCreate( WXLPCREATESTRUCT
WXUNUSED(vCs
),
3019 wxWindowCreateEvent
vEvent((wxWindow
*)this);
3021 (void)HandleWindowEvent(vEvent
);
3022 *pbMayCreate
= true;
3024 } // end of wxWindowOS2::HandleCreate
3026 bool wxWindowOS2::HandleDestroy()
3028 wxWindowDestroyEvent
vEvent((wxWindow
*)this);
3029 vEvent
.SetId(GetId());
3030 (void)HandleWindowEvent(vEvent
);
3033 // Delete our drop target if we've got one
3035 #if wxUSE_DRAG_AND_DROP
3036 wxDELETE(m_dropTarget
);
3037 #endif // wxUSE_DRAG_AND_DROP
3040 // WM_DESTROY handled
3043 } // end of wxWindowOS2::HandleDestroy
3045 // ---------------------------------------------------------------------------
3047 // ---------------------------------------------------------------------------
3048 void wxWindowOS2::OnSetFocus(
3049 wxFocusEvent
& rEvent
3053 } // end of wxWindowOS2::OnSetFocus
3055 bool wxWindowOS2::HandleActivate(
3057 , WXHWND
WXUNUSED(hActivate
)
3060 wxActivateEvent
vEvent( wxEVT_ACTIVATE
3064 vEvent
.SetEventObject(this);
3065 return HandleWindowEvent(vEvent
);
3066 } // end of wxWindowOS2::HandleActivate
3068 bool wxWindowOS2::HandleSetFocus( WXHWND
WXUNUSED(hWnd
) )
3071 // Notify the parent keeping track of focus for the kbd navigation
3072 // purposes that we got it
3074 wxChildFocusEvent
vEventFocus((wxWindow
*)this);
3075 (void)HandleWindowEvent(vEventFocus
);
3083 m_caret
->OnSetFocus();
3085 #endif // wxUSE_CARET
3088 // If it's a wxTextCtrl don't send the event as it will be done
3089 // after the control gets to process it from EN_FOCUS handler
3090 if ( wxDynamicCastThis(wxTextCtrl
) )
3094 #endif // wxUSE_TEXTCTRL
3096 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
3098 vEvent
.SetEventObject(this);
3099 return HandleWindowEvent(vEvent
);
3100 } // end of wxWindowOS2::HandleSetFocus
3102 bool wxWindowOS2::HandleKillFocus( WXHWND hWnd
)
3110 m_caret
->OnKillFocus();
3112 #endif // wxUSE_CARET
3116 // If it's a wxTextCtrl don't send the event as it will be done
3117 // after the control gets to process it.
3119 wxTextCtrl
* pCtrl
= wxDynamicCastThis(wxTextCtrl
);
3128 // Don't send the event when in the process of being deleted. This can
3129 // only cause problems if the event handler tries to access the object.
3131 if ( m_isBeingDeleted
)
3136 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
3140 vEvent
.SetEventObject(this);
3143 // wxFindWinFromHandle() may return NULL, it is ok
3145 vEvent
.SetWindow(wxFindWinFromHandle(hWnd
));
3146 return HandleWindowEvent(vEvent
);
3147 } // end of wxWindowOS2::HandleKillFocus
3149 // ---------------------------------------------------------------------------
3151 // ---------------------------------------------------------------------------
3153 bool wxWindowOS2::HandleShow(
3155 , int WXUNUSED(nStatus
)
3158 wxShowEvent
vEvent(GetId(), bShow
);
3160 vEvent
.SetEventObject(this);
3161 return HandleWindowEvent(vEvent
);
3162 } // end of wxWindowOS2::HandleShow
3164 bool wxWindowOS2::HandleInitDialog( WXHWND
WXUNUSED(hWndFocus
) )
3166 wxInitDialogEvent
vEvent(GetId());
3168 vEvent
.SetEventObject(this);
3169 return HandleWindowEvent(vEvent
);
3170 } // end of wxWindowOS2::HandleInitDialog
3172 bool wxWindowOS2::HandleEndDrag(WXWPARAM
WXUNUSED(wParam
))
3174 // TODO: We'll handle drag and drop later
3178 bool wxWindowOS2::HandleSetCursor( USHORT
WXUNUSED(vId
),
3182 // Under OS/2 PM this allows the pointer to be changed
3183 // as it passes over a control
3185 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
3187 } // end of wxWindowOS2::HandleSetCursor
3189 // ---------------------------------------------------------------------------
3190 // owner drawn stuff
3191 // ---------------------------------------------------------------------------
3192 bool wxWindowOS2::OS2OnDrawItem( int vId
,
3193 WXDRAWITEMSTRUCT
* pItemStruct
)
3195 #if wxUSE_OWNER_DRAWN
3196 wxClientDC
vDc(this);
3198 #if wxUSE_MENUS_NATIVE
3200 // Is it a menu item?
3206 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3207 wxFrame
* pFrame
= (wxFrame
*)this;
3208 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3209 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
3210 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
3211 ,pMeasureStruct
->rclItem
.yBottom
3212 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
3213 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
3216 wxPMDCImpl
*impl
= (wxPMDCImpl
*) vDc
.GetImpl();
3217 impl
->SetHDC( hDC
, false );
3218 impl
->SetHPS( pMeasureStruct
->hps
);
3220 // Load the wxWidgets Pallete and set to RGB mode
3222 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3226 ,(LONG
)wxTheColourDatabase
->m_nSize
3227 ,(PLONG
)wxTheColourDatabase
->m_palTable
3230 vError
= ::WinGetLastError(vHabmain
);
3231 sError
= wxPMErrorToStr(vError
);
3232 wxLogError(wxT("Unable to set current color table (1). Error: %s\n"), sError
.c_str());
3235 // Set the color table to RGB mode
3237 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3245 vError
= ::WinGetLastError(vHabmain
);
3246 sError
= wxPMErrorToStr(vError
);
3247 wxLogError(wxT("Unable to set current color table (2). Error: %s\n"), sError
.c_str());
3250 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3255 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
3258 // Entire Item needs to be redrawn (either it has reappeared from
3259 // behind another window or is being displayed for the first time
3261 eAction
= wxOwnerDrawn::wxODDrawAll
;
3263 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3266 // If it is currently selected we let the system handle it
3268 eStatus
|= wxOwnerDrawn::wxODSelected
;
3270 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
3273 // If it is currently checked we draw our own
3275 eStatus
|= wxOwnerDrawn::wxODChecked
;
3276 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
3278 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
3281 // If it is currently disabled we let the system handle it
3283 eStatus
|= wxOwnerDrawn::wxODDisabled
;
3286 // Don't really care about framed (indicationg focus) or NoDismiss
3291 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3293 eAction
= wxOwnerDrawn::wxODDrawAll
;
3294 eStatus
|= wxOwnerDrawn::wxODSelected
;
3296 // Keep the system from trying to highlight with its bogus colors
3298 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
3300 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
3302 eAction
= wxOwnerDrawn::wxODDrawAll
;
3305 // Keep the system from trying to highlight with its bogus colors
3307 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
3312 // For now we don't care about anything else
3313 // just ignore the entire message!
3319 // Now redraw the item
3321 return(pMenuItem
->OnDrawItem( vDc
3323 ,(wxOwnerDrawn::wxODAction
)eAction
3324 ,(wxOwnerDrawn::wxODStatus
)eStatus
3327 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3328 // the system will do the highlight or fraeming or disabling for us,
3329 // otherwise, we'd have to do it ourselves.
3332 #endif // wxUSE_MENUS_NATIVE
3334 wxWindow
* pItem
= FindItem(vId
);
3336 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3338 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
3342 pItemStruct
= pItemStruct
;
3345 } // end of wxWindowOS2::OS2OnDrawItem
3347 long wxWindowOS2::OS2OnMeasureItem( int lId
,
3348 WXMEASUREITEMSTRUCT
* pItemStruct
)
3350 #if wxUSE_OWNER_DRAWN
3352 // Is it a menu item?
3354 if (lId
== 65536) // I really don't like this...has to be a better indicator
3356 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3360 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3361 wxFrame
* pFrame
= (wxFrame
*)this;
3362 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3364 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3367 if (pMenuItem
->OnMeasureItem( &nWidth
3373 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3374 pMeasureStruct
->rclItem
.xLeft
= 0L;
3375 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3376 pMeasureStruct
->rclItem
.yBottom
= 0L;
3377 mRc
= MRFROM2SHORT(nHeight
, nWidth
);
3378 return LONGFROMMR(mRc
);
3383 wxWindow
* pItem
= FindItem(lId
);
3385 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3389 vItem
.idItem
= (LONG
)pItemStruct
;
3390 return ((wxControl
*)pItem
)->OS2OnMeasure((WXMEASUREITEMSTRUCT
*)&vItem
);
3394 pItemStruct
= pItemStruct
;
3395 #endif // wxUSE_OWNER_DRAWN
3399 // ---------------------------------------------------------------------------
3400 // colours and palettes
3401 // ---------------------------------------------------------------------------
3403 bool wxWindowOS2::HandleSysColorChange()
3405 wxSysColourChangedEvent vEvent
;
3407 vEvent
.SetEventObject(this);
3408 return HandleWindowEvent(vEvent
);
3409 } // end of wxWindowOS2::HandleSysColorChange
3411 bool wxWindowOS2::HandleCtlColor( WXHBRUSH
* WXUNUSED(phBrush
) )
3414 // Not much provided with message. So not sure I can do anything with it
3417 } // end of wxWindowOS2::HandleCtlColor
3420 // Define for each class of dialog and control
3421 WXHBRUSH
wxWindowOS2::OnCtlColor(WXHDC
WXUNUSED(hDC
),
3422 WXHWND
WXUNUSED(hWnd
),
3423 WXUINT
WXUNUSED(nCtlColor
),
3424 WXUINT
WXUNUSED(message
),
3425 WXWPARAM
WXUNUSED(wParam
),
3426 WXLPARAM
WXUNUSED(lParam
))
3431 bool wxWindowOS2::HandlePaletteChanged()
3433 // need to set this to something first
3434 WXHWND hWndPalChange
= NULLHANDLE
;
3436 wxPaletteChangedEvent
vEvent(GetId());
3438 vEvent
.SetEventObject(this);
3439 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3441 return HandleWindowEvent(vEvent
);
3442 } // end of wxWindowOS2::HandlePaletteChanged
3445 // Responds to colour changes: passes event on to children.
3447 void wxWindowOS2::OnSysColourChanged(
3448 wxSysColourChangedEvent
& rEvent
3451 wxWindowList::compatibility_iterator node
= GetChildren().GetFirst();
3456 // Only propagate to non-top-level windows
3458 wxWindow
* pWin
= (wxWindow
*)node
->GetData();
3460 if (pWin
->GetParent())
3462 wxSysColourChangedEvent vEvent
;
3464 rEvent
.SetEventObject(pWin
);
3465 pWin
->HandleWindowEvent(vEvent
);
3467 node
= node
->GetNext();
3469 } // end of wxWindowOS2::OnSysColourChanged
3471 // ---------------------------------------------------------------------------
3473 // ---------------------------------------------------------------------------
3475 void wxWindow::OnPaint (
3476 wxPaintEvent
& rEvent
3479 HDC hDC
= (HDC
)wxPaintDCImpl::FindDCInCache((wxWindow
*) rEvent
.GetEventObject());
3483 OS2DefWindowProc( (WXUINT
)WM_PAINT
3488 } // end of wxWindow::OnPaint
3490 bool wxWindowOS2::HandlePaint()
3493 wxPaintEvent
vEvent(m_windowId
);
3497 // Create empty region
3498 // TODO: get HPS somewhere else if possible
3499 hPS
= ::WinGetPS(GetHwnd());
3500 hRgn
= ::GpiCreateRegion(hPS
, 0, NULL
);
3502 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
)
3504 wxLogLastError(wxT("CreateRectRgn"));
3507 // Get all the rectangles from the region, convert the individual
3508 // rectangles to "the other" coordinate system and reassemble a
3509 // region from the rectangles, to be feed into m_updateRegion.
3512 PRECTL pUpdateRects
= NULL
;
3513 vRgnData
.ulDirection
= RECTDIR_LFRT_TOPBOT
;
3514 if (::GpiQueryRegionRects( hPS
// Pres space
3515 ,hRgn
// Handle of region to query
3516 ,NULL
// Return all RECTs
3517 ,&vRgnData
// Will contain number or RECTs in region
3518 ,NULL
// NULL to return number of RECTs
3521 pUpdateRects
= new RECTL
[vRgnData
.crcReturned
];
3522 vRgnData
.crc
= vRgnData
.crcReturned
;
3523 vRgnData
.ircStart
= 1;
3524 if (::GpiQueryRegionRects( hPS
// Pres space of source
3525 ,hRgn
// Handle of source region
3526 ,NULL
// Return all RECTs
3527 ,&vRgnData
// Operations set to return rects
3528 ,pUpdateRects
// Will contain the actual RECTS
3533 ::WinQueryWindowRect(GetHwnd(), &vRect
);
3534 height
= vRect
.yTop
;
3536 for(size_t i
= 0; i
< vRgnData
.crc
; i
++)
3539 rectHeight
= pUpdateRects
[i
].yTop
- pUpdateRects
[i
].yBottom
;
3540 pUpdateRects
[i
].yBottom
= height
- pUpdateRects
[i
].yTop
;
3541 pUpdateRects
[i
].yTop
= pUpdateRects
[i
].yBottom
+ rectHeight
;
3543 ::GpiSetRegion(hPS
, hRgn
, vRgnData
.crc
, pUpdateRects
);
3544 delete [] pUpdateRects
;
3547 m_updateRegion
= wxRegion(hRgn
, hPS
);
3549 vEvent
.SetEventObject(this);
3550 bProcessed
= HandleWindowEvent(vEvent
);
3553 IsKindOf(CLASSINFO(wxPanel
)) &&
3554 GetChildren().GetCount() == 0
3558 // OS/2 needs to process this right here, not by the default proc
3559 // Window's default proc correctly paints everything, OS/2 does not.
3560 // For decorative panels that typically have no children, we draw
3566 hPS
= ::WinBeginPaint( GetHwnd()
3572 ::GpiCreateLogColorTable( hPS
3576 ,(LONG
)wxTheColourDatabase
->m_nSize
3577 ,(PLONG
)wxTheColourDatabase
->m_palTable
3579 ::GpiCreateLogColorTable( hPS
3586 if (::WinIsWindowVisible(GetHWND()))
3587 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3590 LINEBUNDLE vLineBundle
;
3592 vLineBundle
.lColor
= 0x00000000; // Black
3593 vLineBundle
.usMixMode
= FM_OVERPAINT
;
3594 vLineBundle
.fxWidth
= 1;
3595 vLineBundle
.lGeomWidth
= 1;
3596 vLineBundle
.usType
= LINETYPE_SOLID
;
3597 vLineBundle
.usEnd
= 0;
3598 vLineBundle
.usJoin
= 0;
3601 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
3605 ::WinQueryWindowRect(GetHwnd(), &vRect
);
3615 else if (!bProcessed
&&
3616 IsKindOf(CLASSINFO(wxPanel
))
3620 // Panel with children, usually fills a frame client so no borders.
3625 hPS
= ::WinBeginPaint( GetHwnd()
3631 ::GpiCreateLogColorTable( hPS
3635 ,(LONG
)wxTheColourDatabase
->m_nSize
3636 ,(PLONG
)wxTheColourDatabase
->m_palTable
3638 ::GpiCreateLogColorTable( hPS
3646 if (::WinIsWindowVisible(GetHWND()))
3647 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3653 } // end of wxWindowOS2::HandlePaint
3655 bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC
)
3660 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3661 if (vSwp
.fl
& SWP_MINIMIZE
)
3664 wxClientDC
vDC(this);
3665 wxPMDCImpl
*impl
= (wxPMDCImpl
*) vDC
.GetImpl();
3667 impl
->SetHPS((HPS
)hDC
); // this is really a PS
3669 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3671 vEvent
.SetEventObject(this);
3673 rc
= HandleWindowEvent(vEvent
);
3675 impl
->SetHPS(NULLHANDLE
);
3677 } // end of wxWindowOS2::HandleEraseBkgnd
3679 void wxWindowOS2::OnEraseBackground(wxEraseEvent
& rEvent
)
3682 wxPMDCImpl
*impl
= (wxPMDCImpl
*) rEvent
.GetDC()->GetImpl();
3683 HPS hPS
= impl
->GetHPS();
3685 LONG lColor
= m_backgroundColour
.GetPixel();
3687 rc
= ::WinQueryWindowRect(GetHwnd(), &vRect
);
3688 rc
= ::WinFillRect(hPS
, &vRect
, lColor
);
3689 } // end of wxWindowOS2::OnEraseBackground
3691 // ---------------------------------------------------------------------------
3692 // moving and resizing
3693 // ---------------------------------------------------------------------------
3695 bool wxWindowOS2::HandleMinimize()
3697 wxIconizeEvent
vEvent(m_windowId
);
3699 vEvent
.SetEventObject(this);
3700 return HandleWindowEvent(vEvent
);
3701 } // end of wxWindowOS2::HandleMinimize
3703 bool wxWindowOS2::HandleMaximize()
3705 wxMaximizeEvent
vEvent(m_windowId
);
3707 vEvent
.SetEventObject(this);
3708 return HandleWindowEvent(vEvent
);
3709 } // end of wxWindowOS2::HandleMaximize
3711 bool wxWindowOS2::HandleMove( int nX
, int nY
)
3714 wxMoveEvent
vEvent(pt
, m_windowId
);
3716 vEvent
.SetEventObject(this);
3717 return HandleWindowEvent(vEvent
);
3718 } // end of wxWindowOS2::HandleMove
3720 bool wxWindowOS2::HandleSize( int nWidth
,
3722 WXUINT
WXUNUSED(nFlag
) )
3724 wxSize
sz(nWidth
, nHeight
);
3725 wxSizeEvent
vEvent(sz
, m_windowId
);
3727 vEvent
.SetEventObject(this);
3728 return HandleWindowEvent(vEvent
);
3729 } // end of wxWindowOS2::HandleSize
3731 bool wxWindowOS2::HandleGetMinMaxInfo( PSWP pSwp
)
3738 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3739 m_maxWidth
= pSwp
->cx
;
3740 m_maxHeight
= pSwp
->cy
;
3744 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3745 m_minWidth
= pSwp
->cx
;
3746 m_minHeight
= pSwp
->cy
;
3753 } // end of wxWindowOS2::HandleGetMinMaxInfo
3755 // ---------------------------------------------------------------------------
3757 // ---------------------------------------------------------------------------
3758 bool wxWindowOS2::HandleCommand( WXWORD wId
,
3762 #if wxUSE_MENUS_NATIVE
3763 if (wxCurrentPopupMenu
)
3765 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3767 wxCurrentPopupMenu
= NULL
;
3768 return pPopupMenu
->OS2Command(wCmd
, wId
);
3770 #endif // wxUSE_MENUS_NATIVE
3772 wxWindow
* pWin
= FindItem(wId
);
3776 pWin
= wxFindWinFromHandle(hControl
);
3780 return pWin
->OS2Command(wCmd
, wId
);
3783 } // end of wxWindowOS2::HandleCommand
3785 bool wxWindowOS2::HandleSysCommand( WXWPARAM wParam
,
3786 WXLPARAM
WXUNUSED(lParam
) )
3789 // 4 bits are reserved
3791 switch (SHORT1FROMMP(wParam
))
3794 return HandleMaximize();
3797 return HandleMinimize();
3800 } // end of wxWindowOS2::HandleSysCommand
3802 // ---------------------------------------------------------------------------
3804 // ---------------------------------------------------------------------------
3805 //TODO: check against MSW
3806 void wxWindowOS2::InitMouseEvent(
3807 wxMouseEvent
& rEvent
3814 DoGetSize(0, &nHeight
);
3816 // Convert to wxWidgets standard coordinate system!
3817 rEvent
.m_y
= nHeight
- nY
;
3818 rEvent
.m_shiftDown
= ((uFlags
& KC_SHIFT
) != 0);
3819 rEvent
.m_controlDown
= ((uFlags
& KC_CTRL
) != 0);
3820 rEvent
.m_altDown
= ((uFlags
& KC_ALT
) != 0);
3821 rEvent
.m_leftDown
= IsKeyDown(VK_BUTTON1
);
3822 rEvent
.m_middleDown
= IsKeyDown(VK_BUTTON3
);
3823 rEvent
.m_rightDown
= IsKeyDown(VK_BUTTON2
);
3824 rEvent
.SetTimestamp(s_currentMsg
.time
);
3825 rEvent
.SetEventObject(this);
3826 rEvent
.SetId(GetId());
3828 #if wxUSE_MOUSEEVENT_HACK
3831 m_lastMouseEvent
= rEvent
.GetEventType();
3832 #endif // wxUSE_MOUSEEVENT_HACK
3833 } // end of wxWindowOS2::InitMouseEvent
3835 bool wxWindowOS2::HandleMouseEvent( WXUINT uMsg
,
3840 bool bProcessed
= false;
3843 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3844 // WM_MOUSELAST, so it's enough to subtract WM_MOUSEMOVE == WM_MOUSEFIRST
3845 // from the message id and take the value in the table to get wxWin event
3848 static const wxEventType eventsMouse
[] =
3863 if ((uMsg
>= WM_MOUSEMOVE
) && (uMsg
<= WM_BUTTON3DBLCLK
))
3865 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3867 InitMouseEvent( vEvent
3873 bProcessed
= HandleWindowEvent(vEvent
);
3876 HPOINTER hCursor
= (HPOINTER
)GetCursor().GetHCURSOR();
3878 if (hCursor
!= NULLHANDLE
)
3880 ::WinSetPointer(HWND_DESKTOP
, hCursor
);
3886 } // end of wxWindowOS2::HandleMouseEvent
3888 bool wxWindowOS2::HandleMouseMove( int nX
,
3892 if (!m_bMouseInWindow
)
3895 // Generate an ENTER event
3897 m_bMouseInWindow
= true;
3899 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3901 InitMouseEvent( vEvent
3907 (void)HandleWindowEvent(vEvent
);
3909 return HandleMouseEvent( WM_MOUSEMOVE
3914 } // end of wxWindowOS2::HandleMouseMove
3916 // ---------------------------------------------------------------------------
3917 // keyboard handling
3918 // ---------------------------------------------------------------------------
3921 // Create the key event of the given type for the given key - used by
3922 // HandleChar and HandleKeyDown/Up
3924 wxKeyEvent
wxWindowOS2::CreateKeyEvent(
3931 wxKeyEvent
vEvent(eType
);
3933 vEvent
.SetId(GetId());
3934 vEvent
.m_shiftDown
= IsShiftDown();
3935 vEvent
.m_controlDown
= IsCtrlDown();
3936 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3938 vEvent
.SetEventObject((wxWindow
*)this); // const_cast
3939 vEvent
.m_keyCode
= nId
;
3940 vEvent
.m_rawCode
= (wxUint32
)wParam
;
3941 vEvent
.m_rawFlags
= (wxUint32
)lParam
;
3942 vEvent
.SetTimestamp(s_currentMsg
.time
);
3945 // Translate the position to client coords
3950 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3951 ::WinQueryWindowRect( GetHwnd()
3955 vPoint
.x
-= vRect
.xLeft
;
3956 vPoint
.y
-= vRect
.yBottom
;
3958 vEvent
.m_x
= vPoint
.x
;
3959 vEvent
.m_y
= vPoint
.y
;
3962 } // end of wxWindowOS2::CreateKeyEvent
3965 // isASCII is true only when we're called from WM_CHAR handler and not from
3968 bool wxWindowOS2::HandleChar( WXWPARAM
WXUNUSED(wParam
),
3972 bool bCtrlDown
= false;
3975 if (m_bLastKeydownProcessed
)
3978 // The key was handled in the EVT_KEY_DOWN. Handling a key in an
3979 // EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs
3980 // from happening, so just bail out at this point.
3982 m_bLastKeydownProcessed
= false;
3988 // If 1 -> 26, translate to either special keycode or just set
3989 // ctrlDown. IOW, Ctrl-C should result in keycode == 3 and
3990 // ControlDown() == true.
3992 vId
= SHORT1FROMMP(lParam
);
3993 if ((vId
> 0) && (vId
< 27))
4015 else // we're called from WM_KEYDOWN
4017 vId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4022 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
, vId
, lParam
));
4026 vEvent
.m_controlDown
= true;
4029 return (HandleWindowEvent(vEvent
));
4032 bool wxWindowOS2::HandleKeyDown( WXWPARAM wParam
,
4035 int nId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4040 // Normal ASCII char
4042 nId
= SHORT1FROMMP(lParam
);
4047 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
4053 if (HandleWindowEvent(vEvent
))
4059 } // end of wxWindowOS2::HandleKeyDown
4061 bool wxWindowOS2::HandleKeyUp( WXWPARAM wParam
,
4064 int nId
= wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam
));
4069 // Normal ASCII char
4071 nId
= CHAR1FROMMP(lParam
);
4076 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
4082 if (HandleWindowEvent(vEvent
))
4086 } // end of wxWindowOS2::HandleKeyUp
4088 // ---------------------------------------------------------------------------
4090 // ---------------------------------------------------------------------------
4092 // ---------------------------------------------------------------------------
4094 // ---------------------------------------------------------------------------
4096 bool wxWindowOS2::OS2OnScroll( int nOrientation
,
4103 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
4106 return pChild
->OS2OnScroll( nOrientation
4113 wxScrollWinEvent vEvent
;
4115 vEvent
.SetPosition(wPos
);
4116 vEvent
.SetOrientation(nOrientation
);
4117 vEvent
.SetEventObject(this);
4122 vEvent
.SetEventType(wxEVT_SCROLLWIN_LINEUP
);
4126 vEvent
.SetEventType(wxEVT_SCROLLWIN_LINEDOWN
);
4130 vEvent
.SetEventType(wxEVT_SCROLLWIN_PAGEUP
);
4134 vEvent
.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN
);
4137 case SB_SLIDERPOSITION
:
4138 vEvent
.SetEventType(wxEVT_SCROLLWIN_THUMBRELEASE
);
4141 case SB_SLIDERTRACK
:
4142 vEvent
.SetEventType(wxEVT_SCROLLWIN_THUMBTRACK
);
4148 return HandleWindowEvent(vEvent
);
4149 } // end of wxWindowOS2::OS2OnScroll
4152 // Getting the Y position for a window, like a control, is a real
4153 // pain. There are three situations we must deal with in determining
4154 // the OS2 to wxWidgets Y coordinate.
4156 // 1) The controls are created in a dialog.
4157 // This is the easiest since a dialog is created with its original
4158 // size so the standard: Y = ParentHeight - (Y + ControlHeight);
4160 // 2) The controls are direct children of a frame
4161 // In this instance the controls are actually children of the Frame's
4162 // client. During creation the frame's client resizes several times
4163 // during creation of the status bar and toolbars. The CFrame class
4164 // will take care of this using its AlterChildPos proc.
4166 // 3) The controls are children of a panel, which in turn is a child of
4168 // The panel may be one of many, in which case the same treatment
4169 // as 1 applies. It may be the only child, though.
4170 // This is the nastiest case. A panel is created as the only child of
4171 // the frame and as such, when a frame has only one child, the child is
4172 // expanded to fit the entire client area of the frame. Because the
4173 // controls are created BEFORE this occurs their positions are totally
4174 // whacked and any call to WinQueryWindowPos will return invalid
4175 // coordinates. So for this situation we have to compare the size of
4176 // the panel at control creation time with that of the frame client. If
4177 // they are the same we can use the standard Y position equation. If
4178 // not, then we must use the Frame Client's dimensions to position them
4179 // as that will be the eventual size of the panel after the frame resizes
4182 int wxWindowOS2::GetOS2ParentHeight( wxWindowOS2
* pParent
)
4189 if (pParent
->IsKindOf(CLASSINFO(wxDialog
)))
4190 return(pParent
->GetClientSize().y
);
4193 // Case 2 -- if we are one of the separately built standard Frame
4194 // children, like a statusbar, menubar, or toolbar we want to
4195 // use the frame, itself, for positioning. Otherwise we are
4196 // child window and want to use the Frame's client.
4198 else if (pParent
->IsKindOf(CLASSINFO(wxFrame
)))
4200 if (IsKindOf(CLASSINFO(wxStatusBar
)) ||
4201 IsKindOf(CLASSINFO(wxMenuBar
)) ||
4202 IsKindOf(CLASSINFO(wxToolBar
))
4205 if (IsKindOf(CLASSINFO(wxToolBar
)))
4207 wxFrame
* pFrame
= wxDynamicCast(GetParent(), wxFrame
);
4209 if (pFrame
->GetToolBar() == this)
4210 return(pParent
->GetSize().y
);
4212 return(pParent
->GetClientSize().y
);
4215 return(pParent
->GetSize().y
);
4218 return(pParent
->GetClientSize().y
);
4221 // Case -- this is for any window that is the sole child of a Frame.
4222 // The grandparent must exist and it must be of type CFrame
4223 // and it's height must be different. Otherwise the standard
4227 return(pParent
->GetClientSize().y
);
4229 else // We must be a child of the screen
4232 wxDisplaySize(NULL
,&nHeight
);
4235 } // end of wxWindowOS2::GetOS2ParentHeight
4238 // OS/2 needs a lot extra manipulation to deal with layouts
4239 // for canvas windows, particularly scrolled ones.
4241 wxWindowCreationHook::wxWindowCreationHook(
4242 wxWindow
* pWinBeingCreated
4245 gpWinBeingCreated
= pWinBeingCreated
;
4246 } // end of wxWindowCreationHook::wxWindowCreationHook
4248 wxWindowCreationHook::~wxWindowCreationHook()
4250 gpWinBeingCreated
= NULL
;
4251 } // end of wxWindowCreationHook::~wxWindowCreationHook
4253 // ===========================================================================
4255 // ===========================================================================
4261 ,wxFont
* WXUNUSED(pTheFont
)
4268 hPS
=::WinGetPS(hWnd
);
4270 rc
= ::GpiQueryFontMetrics(hPS
, sizeof(FONTMETRICS
), &vFM
);
4274 *pX
= vFM
.lAveCharWidth
;
4276 *pY
= vFM
.lEmHeight
+ vFM
.lExternalLeading
;
4285 ::WinReleasePS(hPS
);
4286 } // end of wxGetCharSize
4289 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
4290 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
4292 int wxCharCodeOS2ToWX(
4300 case VK_BACKTAB
: nId
= WXK_BACK
; break;
4301 case VK_TAB
: nId
= WXK_TAB
; break;
4302 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
4303 case VK_ENTER
: nId
= WXK_RETURN
; break;
4304 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
4305 case VK_CTRL
: nId
= WXK_CONTROL
; break;
4306 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
4307 case VK_SPACE
: nId
= WXK_SPACE
; break;
4308 case VK_PAGEUP
: nId
= WXK_PAGEUP
; break;
4309 case VK_PAGEDOWN
: nId
= WXK_PAGEDOWN
; break;
4310 case VK_ESC
: nId
= WXK_ESCAPE
; break;
4311 case VK_END
: nId
= WXK_END
; break;
4312 case VK_HOME
: nId
= WXK_HOME
; break;
4313 case VK_LEFT
: nId
= WXK_LEFT
; break;
4314 case VK_UP
: nId
= WXK_UP
; break;
4315 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
4316 case VK_DOWN
: nId
= WXK_DOWN
; break;
4317 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
4318 case VK_INSERT
: nId
= WXK_INSERT
; break;
4319 case VK_DELETE
: nId
= WXK_DELETE
; break;
4320 case VK_CAPSLOCK
: nId
= WXK_CAPITAL
; break;
4321 case VK_F1
: nId
= WXK_F1
; break;
4322 case VK_F2
: nId
= WXK_F2
; break;
4323 case VK_F3
: nId
= WXK_F3
; break;
4324 case VK_F4
: nId
= WXK_F4
; break;
4325 case VK_F5
: nId
= WXK_F5
; break;
4326 case VK_F6
: nId
= WXK_F6
; break;
4327 case VK_F7
: nId
= WXK_F7
; break;
4328 case VK_F8
: nId
= WXK_F8
; break;
4329 case VK_F9
: nId
= WXK_F9
; break;
4330 case VK_F10
: nId
= WXK_F10
; break;
4331 case VK_F11
: nId
= WXK_F11
; break;
4332 case VK_F12
: nId
= WXK_F12
; break;
4333 case VK_F13
: nId
= WXK_F13
; break;
4334 case VK_F14
: nId
= WXK_F14
; break;
4335 case VK_F15
: nId
= WXK_F15
; break;
4336 case VK_F16
: nId
= WXK_F16
; break;
4337 case VK_F17
: nId
= WXK_F17
; break;
4338 case VK_F18
: nId
= WXK_F18
; break;
4339 case VK_F19
: nId
= WXK_F19
; break;
4340 case VK_F20
: nId
= WXK_F20
; break;
4341 case VK_F21
: nId
= WXK_F21
; break;
4342 case VK_F22
: nId
= WXK_F22
; break;
4343 case VK_F23
: nId
= WXK_F23
; break;
4344 case VK_F24
: nId
= WXK_F24
; break;
4345 case VK_OEM_1
: nId
= ';'; break;
4346 case VK_OEM_PLUS
: nId
= '+'; break;
4347 case VK_OEM_COMMA
: nId
= ','; break;
4348 case VK_OEM_MINUS
: nId
= '-'; break;
4349 case VK_OEM_PERIOD
: nId
= '.'; break;
4350 case VK_OEM_2
: nId
= '/'; break;
4351 case VK_OEM_3
: nId
= '~'; break;
4352 case VK_OEM_4
: nId
= '['; break;
4353 case VK_OEM_5
: nId
= '\\'; break;
4354 case VK_OEM_6
: nId
= ']'; break;
4355 case VK_OEM_7
: nId
= '\''; break;
4356 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
4357 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
4364 } // end of wxCharCodeOS2ToWX
4366 int wxCharCodeWXToOS2( int nId
,
4375 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
4376 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
4377 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
4378 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
4379 case WXK_PAGEUP
: nKeySym
= VK_PAGEUP
; break;
4380 case WXK_PAGEDOWN
: nKeySym
= VK_PAGEDOWN
; break;
4381 case WXK_END
: nKeySym
= VK_END
; break;
4382 case WXK_HOME
: nKeySym
= VK_HOME
; break;
4383 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
4384 case WXK_UP
: nKeySym
= VK_UP
; break;
4385 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
4386 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
4387 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
4388 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
4389 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
4390 case WXK_F1
: nKeySym
= VK_F1
; break;
4391 case WXK_F2
: nKeySym
= VK_F2
; break;
4392 case WXK_F3
: nKeySym
= VK_F3
; break;
4393 case WXK_F4
: nKeySym
= VK_F4
; break;
4394 case WXK_F5
: nKeySym
= VK_F5
; break;
4395 case WXK_F6
: nKeySym
= VK_F6
; break;
4396 case WXK_F7
: nKeySym
= VK_F7
; break;
4397 case WXK_F8
: nKeySym
= VK_F8
; break;
4398 case WXK_F9
: nKeySym
= VK_F9
; break;
4399 case WXK_F10
: nKeySym
= VK_F10
; break;
4400 case WXK_F11
: nKeySym
= VK_F11
; break;
4401 case WXK_F12
: nKeySym
= VK_F12
; break;
4402 case WXK_F13
: nKeySym
= VK_F13
; break;
4403 case WXK_F14
: nKeySym
= VK_F14
; break;
4404 case WXK_F15
: nKeySym
= VK_F15
; break;
4405 case WXK_F16
: nKeySym
= VK_F16
; break;
4406 case WXK_F17
: nKeySym
= VK_F17
; break;
4407 case WXK_F18
: nKeySym
= VK_F18
; break;
4408 case WXK_F19
: nKeySym
= VK_F19
; break;
4409 case WXK_F20
: nKeySym
= VK_F20
; break;
4410 case WXK_F21
: nKeySym
= VK_F21
; break;
4411 case WXK_F22
: nKeySym
= VK_F22
; break;
4412 case WXK_F23
: nKeySym
= VK_F23
; break;
4413 case WXK_F24
: nKeySym
= VK_F24
; break;
4414 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
4415 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
4419 *bIsVirtual
= false;
4425 } // end of wxCharCodeWXToOS2
4428 bool wxGetKeyState(wxKeyCode key
)
4430 wxASSERT_MSG(key
!= WXK_LBUTTON
&& key
!= WXK_RBUTTON
&& key
!=
4431 WXK_MBUTTON
, wxT("can't use wxGetKeyState() for mouse buttons"));
4433 const LONG vk
= wxCharCodeWXToOS2(key
);
4434 // if the requested key is a LED key, return true if the led is pressed
4435 if ( key
== WXK_NUMLOCK
|| key
== WXK_CAPITAL
|| key
== WXK_SCROLL
)
4437 // low order bit means LED is highlighted and high order one means the
4438 // key is down; for compatibility with the other ports return true if
4439 // either one is set
4440 return ::WinGetKeyState(HWND_DESKTOP
, vk
) != 0;
4445 return IsKeyDown(vk
);
4450 wxWindow
* wxGetActiveWindow()
4452 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
4456 return wxFindWinFromHandle((WXHWND
)hWnd
);
4459 } // end of wxGetActiveWindow
4462 const wxChar
* wxGetMessageName( int nMessage
)
4466 case 0x0000: return wxT("WM_NULL");
4467 case 0x0001: return wxT("WM_CREATE");
4468 case 0x0002: return wxT("WM_DESTROY");
4469 case 0x0004: return wxT("WM_ENABLE");
4470 case 0x0005: return wxT("WM_SHOW");
4471 case 0x0006: return wxT("WM_MOVE");
4472 case 0x0007: return wxT("WM_SIZE");
4473 case 0x0008: return wxT("WM_ADJUSTWINDOWPOS");
4474 case 0x0009: return wxT("WM_CALCVALIDRECTS");
4475 case 0x000A: return wxT("WM_SETWINDOWPARAMS");
4476 case 0x000B: return wxT("WM_QUERYWINDOWPARAMS");
4477 case 0x000C: return wxT("WM_HITTEST");
4478 case 0x000D: return wxT("WM_ACTIVATE");
4479 case 0x000F: return wxT("WM_SETFOCUS");
4480 case 0x0010: return wxT("WM_SETSELECTION");
4481 case 0x0011: return wxT("WM_PPAINT");
4482 case 0x0012: return wxT("WM_PSETFOCUS");
4483 case 0x0013: return wxT("WM_PSYSCOLORCHANGE");
4484 case 0x0014: return wxT("WM_PSIZE");
4485 case 0x0015: return wxT("WM_PACTIVATE");
4486 case 0x0016: return wxT("WM_PCONTROL");
4487 case 0x0020: return wxT("WM_COMMAND");
4488 case 0x0021: return wxT("WM_SYSCOMMAND");
4489 case 0x0022: return wxT("WM_HELP");
4490 case 0x0023: return wxT("WM_PAINT");
4491 case 0x0024: return wxT("WM_TIMER");
4492 case 0x0025: return wxT("WM_SEM1");
4493 case 0x0026: return wxT("WM_SEM2");
4494 case 0x0027: return wxT("WM_SEM3");
4495 case 0x0028: return wxT("WM_SEM4");
4496 case 0x0029: return wxT("WM_CLOSE");
4497 case 0x002A: return wxT("WM_QUIT");
4498 case 0x002B: return wxT("WM_SYSCOLORCHANGE");
4499 case 0x002D: return wxT("WM_SYSVALUECHANGE");
4500 case 0x002E: return wxT("WM_APPTERMINATENOTIFY");
4501 case 0x002F: return wxT("WM_PRESPARAMCHANGED");
4502 // Control notification messages
4503 case 0x0030: return wxT("WM_CONTROL");
4504 case 0x0031: return wxT("WM_VSCROLL");
4505 case 0x0032: return wxT("WM_HSCROLL");
4506 case 0x0033: return wxT("WM_INITMENU");
4507 case 0x0034: return wxT("WM_MENUSELECT");
4508 case 0x0035: return wxT("WM_MENUSEND");
4509 case 0x0036: return wxT("WM_DRAWITEM");
4510 case 0x0037: return wxT("WM_MEASUREITEM");
4511 case 0x0038: return wxT("WM_CONTROLPOINTER");
4512 case 0x003A: return wxT("WM_QUERYDLGCODE");
4513 case 0x003B: return wxT("WM_INITDLG");
4514 case 0x003C: return wxT("WM_SUBSTITUTESTRING");
4515 case 0x003D: return wxT("WM_MATCHMNEMONIC");
4516 case 0x003E: return wxT("WM_SAVEAPPLICATION");
4517 case 0x0129: return wxT("WM_CTLCOLORCHANGE");
4518 case 0x0130: return wxT("WM_QUERYCTLTYPE");
4520 case 0x0040: return wxT("WM_FLASHWINDOW");
4521 case 0x0041: return wxT("WM_FORMATFRAME");
4522 case 0x0042: return wxT("WM_UPDATEFRAME");
4523 case 0x0043: return wxT("WM_FOCUSCHANGE");
4524 case 0x0044: return wxT("WM_SETBORDERSIZE");
4525 case 0x0045: return wxT("WM_TRACKFRAME");
4526 case 0x0046: return wxT("WM_MINMAXFRAME");
4527 case 0x0047: return wxT("WM_SETICON");
4528 case 0x0048: return wxT("WM_QUERYICON");
4529 case 0x0049: return wxT("WM_SETACCELTABLE");
4530 case 0x004A: return wxT("WM_QUERYACCELTABLE");
4531 case 0x004B: return wxT("WM_TRANSLATEACCEL");
4532 case 0x004C: return wxT("WM_QUERYTRACKINFO");
4533 case 0x004D: return wxT("WM_QUERYBORDERSIZE");
4534 case 0x004E: return wxT("WM_NEXTMENU");
4535 case 0x004F: return wxT("WM_ERASEBACKGROUND");
4536 case 0x0050: return wxT("WM_QUERYFRAMEINFO");
4537 case 0x0051: return wxT("WM_QUERYFOCUSCHAIN");
4538 case 0x0052: return wxT("WM_OWNERPOSCHANGE");
4539 case 0x0053: return wxT("WM_CACLFRAMERECT");
4540 case 0x0055: return wxT("WM_WINDOWPOSCHANGED");
4541 case 0x0056: return wxT("WM_ADJUSTFRAMEPOS");
4542 case 0x0059: return wxT("WM_QUERYFRAMECTLCOUNT");
4543 case 0x005B: return wxT("WM_QUERYHELPINFO");
4544 case 0x005C: return wxT("WM_SETHELPINFO");
4545 case 0x005D: return wxT("WM_ERROR");
4546 case 0x005E: return wxT("WM_REALIZEPALETTE");
4547 // Clipboard messages
4548 case 0x0060: return wxT("WM_RENDERFMT");
4549 case 0x0061: return wxT("WM_RENDERALLFMTS");
4550 case 0x0062: return wxT("WM_DESTROYCLIPBOARD");
4551 case 0x0063: return wxT("WM_PAINTCLIPBOARD");
4552 case 0x0064: return wxT("WM_SIZECLIPBOARD");
4553 case 0x0065: return wxT("WM_HSCROLLCLIPBOARD");
4554 case 0x0066: return wxT("WM_VSCROLLCLIPBOARD");
4555 case 0x0067: return wxT("WM_DRAWCLIPBOARD");
4557 case 0x0070: return wxT("WM_MOUSEMOVE");
4558 case 0x0071: return wxT("WM_BUTTON1DOWN");
4559 case 0x0072: return wxT("WM_BUTTON1UP");
4560 case 0x0073: return wxT("WM_BUTTON1DBLCLK");
4561 case 0x0074: return wxT("WM_BUTTON2DOWN");
4562 case 0x0075: return wxT("WM_BUTTON2UP");
4563 case 0x0076: return wxT("WM_BUTTON2DBLCLK");
4564 case 0x0077: return wxT("WM_BUTTON3DOWN");
4565 case 0x0078: return wxT("WM_BUTTON3UP");
4566 case 0x0079: return wxT("WM_BUTTON3DBLCLK");
4567 case 0x007D: return wxT("WM_MOUSEMAP");
4568 case 0x007E: return wxT("WM_VRNDISABLED");
4569 case 0x007F: return wxT("WM_VRNENABLED");
4570 case 0x0410: return wxT("WM_CHORD");
4571 case 0x0411: return wxT("WM_BUTTON1MOTIONSTART");
4572 case 0x0412: return wxT("WM_BUTTON1MOTIONEND");
4573 case 0x0413: return wxT("WM_BUTTON1CLICK");
4574 case 0x0414: return wxT("WM_BUTTON2MOTIONSTART");
4575 case 0x0415: return wxT("WM_BUTTON2MOTIONEND");
4576 case 0x0416: return wxT("WM_BUTTON2CLICK");
4577 case 0x0417: return wxT("WM_BUTTON3MOTIONSTART");
4578 case 0x0418: return wxT("WM_BUTTON3MOTIONEND");
4579 case 0x0419: return wxT("WM_BUTTON3CLICK");
4580 case 0x0420: return wxT("WM_BEGINDRAG");
4581 case 0x0421: return wxT("WM_ENDDRAG");
4582 case 0x0422: return wxT("WM_SINGLESELECT");
4583 case 0x0423: return wxT("WM_OPEN");
4584 case 0x0424: return wxT("WM_CONTEXTMENU");
4585 case 0x0425: return wxT("WM_CONTEXTHELP");
4586 case 0x0426: return wxT("WM_TEXTEDIT");
4587 case 0x0427: return wxT("WM_BEGINSELECT");
4588 case 0x0228: return wxT("WM_ENDSELECT");
4589 case 0x0429: return wxT("WM_PICKUP");
4590 case 0x04C0: return wxT("WM_PENFIRST");
4591 case 0x04FF: return wxT("WM_PENLAST");
4592 case 0x0500: return wxT("WM_MMPMFIRST");
4593 case 0x05FF: return wxT("WM_MMPMLAST");
4594 case 0x0600: return wxT("WM_STDDLGFIRST");
4595 case 0x06FF: return wxT("WM_STDDLGLAST");
4596 case 0x0BD0: return wxT("WM_BIDI_FIRST");
4597 case 0x0BFF: return wxT("WM_BIDI_LAST");
4599 case 0x007A: return wxT("WM_CHAR");
4600 case 0x007B: return wxT("WM_VIOCHAR");
4602 case 0x00A0: return wxT("WM_DDE_INITIATE");
4603 case 0x00A1: return wxT("WM_DDE_REQUEST");
4604 case 0x00A2: return wxT("WM_DDE_ACK");
4605 case 0x00A3: return wxT("WM_DDE_DATA");
4606 case 0x00A4: return wxT("WM_DDE_ADVISE");
4607 case 0x00A5: return wxT("WM_DDE_UNADVISE");
4608 case 0x00A6: return wxT("WM_DDE_POKE");
4609 case 0x00A7: return wxT("WM_DDE_EXECUTE");
4610 case 0x00A8: return wxT("WM_DDE_TERMINATE");
4611 case 0x00A9: return wxT("WM_DDE_INITIATEACK");
4612 case 0x00AF: return wxT("WM_DDE_LAST");
4614 case 0x0120: return wxT("BM_CLICK");
4615 case 0x0121: return wxT("BM_QUERYCHECKINDEX");
4616 case 0x0122: return wxT("BM_QUERYHILITE");
4617 case 0x0123: return wxT("BM_SETHILITE");
4618 case 0x0124: return wxT("BM_QUERYCHECK");
4619 case 0x0125: return wxT("BM_SETCHECK");
4620 case 0x0126: return wxT("BM_SETDEFAULT");
4621 case 0x0128: return wxT("BM_AUTOSIZE");
4623 case 0x029A: return wxT("CBID_LIST");
4624 case 0x029B: return wxT("CBID_EDIT");
4625 case 0x0170: return wxT("CBM_SHOWLIST");
4626 case 0x0171: return wxT("CBM_HILITE");
4627 case 0x0172: return wxT("CBM_ISLISTSHOWING");
4629 case 0x0140: return wxT("EM_QUERYCHANGED");
4630 case 0x0141: return wxT("EM_QUERYSEL");
4631 case 0x0142: return wxT("EM_SETSEL");
4632 case 0x0143: return wxT("EM_SETTEXTLIMIT");
4633 case 0x0144: return wxT("EM_CUT");
4634 case 0x0145: return wxT("EM_COPY");
4635 case 0x0146: return wxT("EM_CLEAR");
4636 case 0x0147: return wxT("EM_PASTE");
4637 case 0x0148: return wxT("EM_QUERYFIRSTCHAR");
4638 case 0x0149: return wxT("EM_SETFIRSTCHAR");
4639 case 0x014A: return wxT("EM_QUERYREADONLY");
4640 case 0x014B: return wxT("EM_SETREADONLY");
4641 case 0x014C: return wxT("EM_SETINSERTMODE");
4643 case 0x0160: return wxT("LM_QUERYITEMCOUNT");
4644 case 0x0161: return wxT("LM_INSERTITEM");
4645 case 0x0162: return wxT("LM_SETOPENINDEX");
4646 case 0x0163: return wxT("LM_DELETEITEM");
4647 case 0x0164: return wxT("LM_SELECTITEM");
4648 case 0x0165: return wxT("LM_QUERYSELECTION");
4649 case 0x0166: return wxT("LM_SETITEMTEXT");
4650 case 0x0167: return wxT("LM_QUERYITEMTEXTLENGTH");
4651 case 0x0168: return wxT("LM_QUERYITEMTEXT");
4652 case 0x0169: return wxT("LM_SETITEMHANDLE");
4653 case 0x016A: return wxT("LM_QUERYITEMHANDLE");
4654 case 0x016B: return wxT("LM_SEARCHSTRING");
4655 case 0x016C: return wxT("LM_SETITEMHEIGHT");
4656 case 0x016D: return wxT("LM_QUERYTOPINDEX");
4657 case 0x016E: return wxT("LM_DELETEALL");
4658 case 0x016F: return wxT("LM_INSERTMULITEMS");
4659 case 0x0660: return wxT("LM_SETITEMWIDTH");
4661 case 0x0180: return wxT("MM_INSERTITEM");
4662 case 0x0181: return wxT("MM_DELETEITEM");
4663 case 0x0182: return wxT("MM_QUERYITEM");
4664 case 0x0183: return wxT("MM_SETITEM");
4665 case 0x0184: return wxT("MM_QUERYITEMCOUNT");
4666 case 0x0185: return wxT("MM_STARTMENUMODE");
4667 case 0x0186: return wxT("MM_ENDMENUMODE");
4668 case 0x0188: return wxT("MM_REMOVEITEM");
4669 case 0x0189: return wxT("MM_SELECTITEM");
4670 case 0x018A: return wxT("MM_QUERYSELITEMID");
4671 case 0x018B: return wxT("MM_QUERYITEMTEXT");
4672 case 0x018C: return wxT("MM_QUERYITEMTEXTLENGTH");
4673 case 0x018D: return wxT("MM_SETITEMHANDLE");
4674 case 0x018E: return wxT("MM_SETITEMTEXT");
4675 case 0x018F: return wxT("MM_ITEMPOSITIONFROMID");
4676 case 0x0190: return wxT("MM_ITEMIDFROMPOSITION");
4677 case 0x0191: return wxT("MM_QUERYITEMATTR");
4678 case 0x0192: return wxT("MM_SETITEMATTR");
4679 case 0x0193: return wxT("MM_ISITEMVALID");
4680 case 0x0194: return wxT("MM_QUERYITEMRECT");
4681 case 0x0431: return wxT("MM_QUERYDEFAULTITEMID");
4682 case 0x0432: return wxT("MM_SETDEFAULTITEMID");
4684 case 0x01A0: return wxT("SBM_SETSCROLLBAR");
4685 case 0x01A1: return wxT("SBM_SETPOS");
4686 case 0x01A2: return wxT("SBM_QUERYPOS");
4687 case 0x01A3: return wxT("SBM_QUERYRANGE");
4688 case 0x01A6: return wxT("SBM_SETTHUMBSIZE");
4691 case 0x0F00: return wxT("WM_HELPBASE");
4692 case 0x0FFF: return wxT("WM_HELPTOP");
4693 // Beginning of user defined messages
4694 case 0x1000: return wxT("WM_USER");
4696 // wxWidgets user defined types
4699 // case 0x1000 + 0: return wxT("LVM_GETBKCOLOR");
4700 case 0x1000 + 1: return wxT("LVM_SETBKCOLOR");
4701 case 0x1000 + 2: return wxT("LVM_GETIMAGELIST");
4702 case 0x1000 + 3: return wxT("LVM_SETIMAGELIST");
4703 case 0x1000 + 4: return wxT("LVM_GETITEMCOUNT");
4704 case 0x1000 + 5: return wxT("LVM_GETITEMA");
4705 case 0x1000 + 75: return wxT("LVM_GETITEMW");
4706 case 0x1000 + 6: return wxT("LVM_SETITEMA");
4707 case 0x1000 + 76: return wxT("LVM_SETITEMW");
4708 case 0x1000 + 7: return wxT("LVM_INSERTITEMA");
4709 case 0x1000 + 77: return wxT("LVM_INSERTITEMW");
4710 case 0x1000 + 8: return wxT("LVM_DELETEITEM");
4711 case 0x1000 + 9: return wxT("LVM_DELETEALLITEMS");
4712 case 0x1000 + 10: return wxT("LVM_GETCALLBACKMASK");
4713 case 0x1000 + 11: return wxT("LVM_SETCALLBACKMASK");
4714 case 0x1000 + 12: return wxT("LVM_GETNEXTITEM");
4715 case 0x1000 + 13: return wxT("LVM_FINDITEMA");
4716 case 0x1000 + 83: return wxT("LVM_FINDITEMW");
4717 case 0x1000 + 14: return wxT("LVM_GETITEMRECT");
4718 case 0x1000 + 15: return wxT("LVM_SETITEMPOSITION");
4719 case 0x1000 + 16: return wxT("LVM_GETITEMPOSITION");
4720 case 0x1000 + 17: return wxT("LVM_GETSTRINGWIDTHA");
4721 case 0x1000 + 87: return wxT("LVM_GETSTRINGWIDTHW");
4722 case 0x1000 + 18: return wxT("LVM_HITTEST");
4723 case 0x1000 + 19: return wxT("LVM_ENSUREVISIBLE");
4724 case 0x1000 + 20: return wxT("LVM_SCROLL");
4725 case 0x1000 + 21: return wxT("LVM_REDRAWITEMS");
4726 case 0x1000 + 22: return wxT("LVM_ARRANGE");
4727 case 0x1000 + 23: return wxT("LVM_EDITLABELA");
4728 case 0x1000 + 118: return wxT("LVM_EDITLABELW");
4729 case 0x1000 + 24: return wxT("LVM_GETEDITCONTROL");
4730 case 0x1000 + 25: return wxT("LVM_GETCOLUMNA");
4731 case 0x1000 + 95: return wxT("LVM_GETCOLUMNW");
4732 case 0x1000 + 26: return wxT("LVM_SETCOLUMNA");
4733 case 0x1000 + 96: return wxT("LVM_SETCOLUMNW");
4734 case 0x1000 + 27: return wxT("LVM_INSERTCOLUMNA");
4735 case 0x1000 + 97: return wxT("LVM_INSERTCOLUMNW");
4736 case 0x1000 + 28: return wxT("LVM_DELETECOLUMN");
4737 case 0x1000 + 29: return wxT("LVM_GETCOLUMNWIDTH");
4738 case 0x1000 + 30: return wxT("LVM_SETCOLUMNWIDTH");
4739 case 0x1000 + 31: return wxT("LVM_GETHEADER");
4740 case 0x1000 + 33: return wxT("LVM_CREATEDRAGIMAGE");
4741 case 0x1000 + 34: return wxT("LVM_GETVIEWRECT");
4742 case 0x1000 + 35: return wxT("LVM_GETTEXTCOLOR");
4743 case 0x1000 + 36: return wxT("LVM_SETTEXTCOLOR");
4744 case 0x1000 + 37: return wxT("LVM_GETTEXTBKCOLOR");
4745 case 0x1000 + 38: return wxT("LVM_SETTEXTBKCOLOR");
4746 case 0x1000 + 39: return wxT("LVM_GETTOPINDEX");
4747 case 0x1000 + 40: return wxT("LVM_GETCOUNTPERPAGE");
4748 case 0x1000 + 41: return wxT("LVM_GETORIGIN");
4749 case 0x1000 + 42: return wxT("LVM_UPDATE");
4750 case 0x1000 + 43: return wxT("LVM_SETITEMSTATE");
4751 case 0x1000 + 44: return wxT("LVM_GETITEMSTATE");
4752 case 0x1000 + 45: return wxT("LVM_GETITEMTEXTA");
4753 case 0x1000 + 115: return wxT("LVM_GETITEMTEXTW");
4754 case 0x1000 + 46: return wxT("LVM_SETITEMTEXTA");
4755 case 0x1000 + 116: return wxT("LVM_SETITEMTEXTW");
4756 case 0x1000 + 47: return wxT("LVM_SETITEMCOUNT");
4757 case 0x1000 + 48: return wxT("LVM_SORTITEMS");
4758 case 0x1000 + 49: return wxT("LVM_SETITEMPOSITION32");
4759 case 0x1000 + 50: return wxT("LVM_GETSELECTEDCOUNT");
4760 case 0x1000 + 51: return wxT("LVM_GETITEMSPACING");
4761 case 0x1000 + 52: return wxT("LVM_GETISEARCHSTRINGA");
4762 case 0x1000 + 117: return wxT("LVM_GETISEARCHSTRINGW");
4763 case 0x1000 + 53: return wxT("LVM_SETICONSPACING");
4764 case 0x1000 + 54: return wxT("LVM_SETEXTENDEDLISTVIEWSTYLE");
4765 case 0x1000 + 55: return wxT("LVM_GETEXTENDEDLISTVIEWSTYLE");
4766 case 0x1000 + 56: return wxT("LVM_GETSUBITEMRECT");
4767 case 0x1000 + 57: return wxT("LVM_SUBITEMHITTEST");
4768 case 0x1000 + 58: return wxT("LVM_SETCOLUMNORDERARRAY");
4769 case 0x1000 + 59: return wxT("LVM_GETCOLUMNORDERARRAY");
4770 case 0x1000 + 60: return wxT("LVM_SETHOTITEM");
4771 case 0x1000 + 61: return wxT("LVM_GETHOTITEM");
4772 case 0x1000 + 62: return wxT("LVM_SETHOTCURSOR");
4773 case 0x1000 + 63: return wxT("LVM_GETHOTCURSOR");
4774 case 0x1000 + 64: return wxT("LVM_APPROXIMATEVIEWRECT");
4775 case 0x1000 + 65: return wxT("LVM_SETWORKAREA");
4778 case 0x1100 + 0: return wxT("TVM_INSERTITEMA");
4779 case 0x1100 + 50: return wxT("TVM_INSERTITEMW");
4780 case 0x1100 + 1: return wxT("TVM_DELETEITEM");
4781 case 0x1100 + 2: return wxT("TVM_EXPAND");
4782 case 0x1100 + 4: return wxT("TVM_GETITEMRECT");
4783 case 0x1100 + 5: return wxT("TVM_GETCOUNT");
4784 case 0x1100 + 6: return wxT("TVM_GETINDENT");
4785 case 0x1100 + 7: return wxT("TVM_SETINDENT");
4786 case 0x1100 + 8: return wxT("TVM_GETIMAGELIST");
4787 case 0x1100 + 9: return wxT("TVM_SETIMAGELIST");
4788 case 0x1100 + 10: return wxT("TVM_GETNEXTITEM");
4789 case 0x1100 + 11: return wxT("TVM_SELECTITEM");
4790 case 0x1100 + 12: return wxT("TVM_GETITEMA");
4791 case 0x1100 + 62: return wxT("TVM_GETITEMW");
4792 case 0x1100 + 13: return wxT("TVM_SETITEMA");
4793 case 0x1100 + 63: return wxT("TVM_SETITEMW");
4794 case 0x1100 + 14: return wxT("TVM_EDITLABELA");
4795 case 0x1100 + 65: return wxT("TVM_EDITLABELW");
4796 case 0x1100 + 15: return wxT("TVM_GETEDITCONTROL");
4797 case 0x1100 + 16: return wxT("TVM_GETVISIBLECOUNT");
4798 case 0x1100 + 17: return wxT("TVM_HITTEST");
4799 case 0x1100 + 18: return wxT("TVM_CREATEDRAGIMAGE");
4800 case 0x1100 + 19: return wxT("TVM_SORTCHILDREN");
4801 case 0x1100 + 20: return wxT("TVM_ENSUREVISIBLE");
4802 case 0x1100 + 21: return wxT("TVM_SORTCHILDRENCB");
4803 case 0x1100 + 22: return wxT("TVM_ENDEDITLABELNOW");
4804 case 0x1100 + 23: return wxT("TVM_GETISEARCHSTRINGA");
4805 case 0x1100 + 64: return wxT("TVM_GETISEARCHSTRINGW");
4806 case 0x1100 + 24: return wxT("TVM_SETTOOLTIPS");
4807 case 0x1100 + 25: return wxT("TVM_GETTOOLTIPS");
4810 case 0x1200 + 0: return wxT("HDM_GETITEMCOUNT");
4811 case 0x1200 + 1: return wxT("HDM_INSERTITEMA");
4812 case 0x1200 + 10: return wxT("HDM_INSERTITEMW");
4813 case 0x1200 + 2: return wxT("HDM_DELETEITEM");
4814 case 0x1200 + 3: return wxT("HDM_GETITEMA");
4815 case 0x1200 + 11: return wxT("HDM_GETITEMW");
4816 case 0x1200 + 4: return wxT("HDM_SETITEMA");
4817 case 0x1200 + 12: return wxT("HDM_SETITEMW");
4818 case 0x1200 + 5: return wxT("HDM_LAYOUT");
4819 case 0x1200 + 6: return wxT("HDM_HITTEST");
4820 case 0x1200 + 7: return wxT("HDM_GETITEMRECT");
4821 case 0x1200 + 8: return wxT("HDM_SETIMAGELIST");
4822 case 0x1200 + 9: return wxT("HDM_GETIMAGELIST");
4823 case 0x1200 + 15: return wxT("HDM_ORDERTOINDEX");
4824 case 0x1200 + 16: return wxT("HDM_CREATEDRAGIMAGE");
4825 case 0x1200 + 17: return wxT("HDM_GETORDERARRAY");
4826 case 0x1200 + 18: return wxT("HDM_SETORDERARRAY");
4827 case 0x1200 + 19: return wxT("HDM_SETHOTDIVIDER");
4830 case 0x1300 + 2: return wxT("TCM_GETIMAGELIST");
4831 case 0x1300 + 3: return wxT("TCM_SETIMAGELIST");
4832 case 0x1300 + 4: return wxT("TCM_GETITEMCOUNT");
4833 case 0x1300 + 5: return wxT("TCM_GETITEMA");
4834 case 0x1300 + 60: return wxT("TCM_GETITEMW");
4835 case 0x1300 + 6: return wxT("TCM_SETITEMA");
4836 case 0x1300 + 61: return wxT("TCM_SETITEMW");
4837 case 0x1300 + 7: return wxT("TCM_INSERTITEMA");
4838 case 0x1300 + 62: return wxT("TCM_INSERTITEMW");
4839 case 0x1300 + 8: return wxT("TCM_DELETEITEM");
4840 case 0x1300 + 9: return wxT("TCM_DELETEALLITEMS");
4841 case 0x1300 + 10: return wxT("TCM_GETITEMRECT");
4842 case 0x1300 + 11: return wxT("TCM_GETCURSEL");
4843 case 0x1300 + 12: return wxT("TCM_SETCURSEL");
4844 case 0x1300 + 13: return wxT("TCM_HITTEST");
4845 case 0x1300 + 14: return wxT("TCM_SETITEMEXTRA");
4846 case 0x1300 + 40: return wxT("TCM_ADJUSTRECT");
4847 case 0x1300 + 41: return wxT("TCM_SETITEMSIZE");
4848 case 0x1300 + 42: return wxT("TCM_REMOVEIMAGE");
4849 case 0x1300 + 43: return wxT("TCM_SETPADDING");
4850 case 0x1300 + 44: return wxT("TCM_GETROWCOUNT");
4851 case 0x1300 + 45: return wxT("TCM_GETTOOLTIPS");
4852 case 0x1300 + 46: return wxT("TCM_SETTOOLTIPS");
4853 case 0x1300 + 47: return wxT("TCM_GETCURFOCUS");
4854 case 0x1300 + 48: return wxT("TCM_SETCURFOCUS");
4855 case 0x1300 + 49: return wxT("TCM_SETMINTABWIDTH");
4856 case 0x1300 + 50: return wxT("TCM_DESELECTALL");
4859 case WM_USER
+1000+1: return wxT("TB_ENABLEBUTTON");
4860 case WM_USER
+1000+2: return wxT("TB_CHECKBUTTON");
4861 case WM_USER
+1000+3: return wxT("TB_PRESSBUTTON");
4862 case WM_USER
+1000+4: return wxT("TB_HIDEBUTTON");
4863 case WM_USER
+1000+5: return wxT("TB_INDETERMINATE");
4864 case WM_USER
+1000+9: return wxT("TB_ISBUTTONENABLED");
4865 case WM_USER
+1000+10: return wxT("TB_ISBUTTONCHECKED");
4866 case WM_USER
+1000+11: return wxT("TB_ISBUTTONPRESSED");
4867 case WM_USER
+1000+12: return wxT("TB_ISBUTTONHIDDEN");
4868 case WM_USER
+1000+13: return wxT("TB_ISBUTTONINDETERMINATE");
4869 case WM_USER
+1000+17: return wxT("TB_SETSTATE");
4870 case WM_USER
+1000+18: return wxT("TB_GETSTATE");
4871 case WM_USER
+1000+19: return wxT("TB_ADDBITMAP");
4872 case WM_USER
+1000+20: return wxT("TB_ADDBUTTONS");
4873 case WM_USER
+1000+21: return wxT("TB_INSERTBUTTON");
4874 case WM_USER
+1000+22: return wxT("TB_DELETEBUTTON");
4875 case WM_USER
+1000+23: return wxT("TB_GETBUTTON");
4876 case WM_USER
+1000+24: return wxT("TB_BUTTONCOUNT");
4877 case WM_USER
+1000+25: return wxT("TB_COMMANDTOINDEX");
4878 case WM_USER
+1000+26: return wxT("TB_SAVERESTOREA");
4879 case WM_USER
+1000+76: return wxT("TB_SAVERESTOREW");
4880 case WM_USER
+1000+27: return wxT("TB_CUSTOMIZE");
4881 case WM_USER
+1000+28: return wxT("TB_ADDSTRINGA");
4882 case WM_USER
+1000+77: return wxT("TB_ADDSTRINGW");
4883 case WM_USER
+1000+29: return wxT("TB_GETITEMRECT");
4884 case WM_USER
+1000+30: return wxT("TB_BUTTONSTRUCTSIZE");
4885 case WM_USER
+1000+31: return wxT("TB_SETBUTTONSIZE");
4886 case WM_USER
+1000+32: return wxT("TB_SETBITMAPSIZE");
4887 case WM_USER
+1000+33: return wxT("TB_AUTOSIZE");
4888 case WM_USER
+1000+35: return wxT("TB_GETTOOLTIPS");
4889 case WM_USER
+1000+36: return wxT("TB_SETTOOLTIPS");
4890 case WM_USER
+1000+37: return wxT("TB_SETPARENT");
4891 case WM_USER
+1000+39: return wxT("TB_SETROWS");
4892 case WM_USER
+1000+40: return wxT("TB_GETROWS");
4893 case WM_USER
+1000+42: return wxT("TB_SETCMDID");
4894 case WM_USER
+1000+43: return wxT("TB_CHANGEBITMAP");
4895 case WM_USER
+1000+44: return wxT("TB_GETBITMAP");
4896 case WM_USER
+1000+45: return wxT("TB_GETBUTTONTEXTA");
4897 case WM_USER
+1000+75: return wxT("TB_GETBUTTONTEXTW");
4898 case WM_USER
+1000+46: return wxT("TB_REPLACEBITMAP");
4899 case WM_USER
+1000+47: return wxT("TB_SETINDENT");
4900 case WM_USER
+1000+48: return wxT("TB_SETIMAGELIST");
4901 case WM_USER
+1000+49: return wxT("TB_GETIMAGELIST");
4902 case WM_USER
+1000+50: return wxT("TB_LOADIMAGES");
4903 case WM_USER
+1000+51: return wxT("TB_GETRECT");
4904 case WM_USER
+1000+52: return wxT("TB_SETHOTIMAGELIST");
4905 case WM_USER
+1000+53: return wxT("TB_GETHOTIMAGELIST");
4906 case WM_USER
+1000+54: return wxT("TB_SETDISABLEDIMAGELIST");
4907 case WM_USER
+1000+55: return wxT("TB_GETDISABLEDIMAGELIST");
4908 case WM_USER
+1000+56: return wxT("TB_SETSTYLE");
4909 case WM_USER
+1000+57: return wxT("TB_GETSTYLE");
4910 case WM_USER
+1000+58: return wxT("TB_GETBUTTONSIZE");
4911 case WM_USER
+1000+59: return wxT("TB_SETBUTTONWIDTH");
4912 case WM_USER
+1000+60: return wxT("TB_SETMAXTEXTROWS");
4913 case WM_USER
+1000+61: return wxT("TB_GETTEXTROWS");
4914 case WM_USER
+1000+41: return wxT("TB_GETBITMAPFLAGS");
4917 static wxString s_szBuf
;
4918 s_szBuf
.Printf(wxT("<unknown message = %d>"), nMessage
);
4919 return s_szBuf
.c_str();
4921 } // end of wxGetMessageName
4923 #endif // __WXDEBUG__
4927 static void TranslateKbdEventToMouse(
4935 // Construct the key mask
4936 ULONG
& fwKeys
= *pFlags
;
4938 fwKeys
= VK_BUTTON2
;
4939 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4941 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4945 // Simulate right mouse button click
4949 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4953 pWin
->ScreenToClient(pX
, pY
);
4954 } // end of TranslateKbdEventToMouse
4957 // Find the wxWindow at the current mouse position, returning the mouse
4959 wxWindow
* wxFindWindowAtPointer(wxPoint
& WXUNUSED(rPt
))
4961 return wxFindWindowAtPoint(wxGetMousePosition());
4964 wxWindow
* wxFindWindowAtPoint(const wxPoint
& rPt
)
4971 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4972 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4973 HWND hWnd
= hWndHit
;
4976 // Try to find a window with a wxWindow associated with it
4978 while (!pWin
&& (hWnd
!= 0))
4980 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4981 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4986 // Get the current mouse position.
4987 wxPoint
wxGetMousePosition()
4991 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4992 return wxPoint(vPt
.x
, vPt
.y
);
4995 wxMouseState
wxGetMouseState()
4998 wxPoint pt
= wxGetMousePosition();
5001 ms
.SetLeftDown(IsKeyDown(VK_BUTTON1
));
5002 ms
.SetMiddleDown(IsKeyDown(VK_BUTTON3
));
5003 ms
.SetRightDown(IsKeyDown(VK_BUTTON2
));
5004 ms
.SetControlDown(IsCtrlDown());
5005 ms
.SetShiftDown(IsShiftDown());
5006 ms
.SetAltDown(IsKeyDown(VK_ALT
)|IsKeyDown(VK_ALTGRAF
));
5007 ms
.SetMetaDown(IsKeyDown(VK_ALTGRAF
));
5012 wxWindowOS2
* FindWindowForMouseEvent( wxWindow
* pWin
,
5013 short* WXUNUSED(pnX
),
5014 short* WXUNUSED(pnY
) )
5016 HWND hWnd
= GetHwndOf(pWin
);
5017 HWND hWndUnderMouse
;
5019 BOOL rcEnabled
= FALSE
;
5020 BOOL rcVisible
= FALSE
;
5022 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
5023 hWndUnderMouse
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, TRUE
);
5024 if (hWndUnderMouse
!= HWND_DESKTOP
)
5026 wxWindow
* pWinUnderMouse
= wxFindWinFromHandle((WXHWND
)hWndUnderMouse
);
5030 wxWindowList::compatibility_iterator current
= pWinUnderMouse
->GetChildren().GetFirst();
5031 wxWindow
* pGrandChild
= NULL
;
5035 ::WinMapWindowPoints(HWND_DESKTOP
, hWndUnderMouse
, &vPoint
, 1);
5037 // Find a child window mouse might be under
5041 wxWindow
* pChild
= current
->GetData();
5043 vPoint2
.x
= vPoint
.x
;
5044 vPoint2
.y
= vPoint
.y
;
5045 ::WinMapWindowPoints(hWndUnderMouse
, pChild
->GetHWND(), &vPoint2
, 1);
5046 ::WinQueryWindowRect(pChild
->GetHWND(), &vRect
);
5047 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint2
))
5049 if (pChild
->IsTopLevel())
5052 wxWindowList::compatibility_iterator current2
=pChild
->GetChildren().GetFirst();
5056 wxWindow
* pGrandChild
= current2
->GetData();
5058 vPoint3
.x
= vPoint2
.x
;
5059 vPoint3
.y
= vPoint2
.y
;
5060 ::WinMapWindowPoints( pChild
->GetHWND()
5061 ,pGrandChild
->GetHWND()
5065 ::WinQueryWindowRect(pGrandChild
->GetHWND(), &vRect
);
5066 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint3
))
5068 hWndUnderMouse
= GetHwndOf(pGrandChild
);
5069 pWinUnderMouse
= pGrandChild
;
5072 current2
= current2
->GetNext();
5077 hWndUnderMouse
= GetHwndOf(pChild
);
5078 pWinUnderMouse
= pChild
;
5079 rcVisible
= ::WinIsWindowVisible(hWndUnderMouse
);
5080 rcEnabled
= ::WinIsWindowEnabled(hWndUnderMouse
);
5081 if (rcVisible
&& rcEnabled
)
5084 current
= current
->GetNext();
5088 rcVisible
= ::WinIsWindowVisible(hWndUnderMouse
);
5089 rcEnabled
= ::WinIsWindowEnabled(hWndUnderMouse
);
5093 // Check that we have a child window which is susceptible to receive mouse
5094 // events: for this it must be shown and enabled
5096 if ( hWndUnderMouse
&&
5097 hWndUnderMouse
!= hWnd
&&
5098 rcVisible
&& rcEnabled
)
5100 wxWindow
* pWinUnderMouse
= wxFindWinFromHandle((WXHWND
)hWndUnderMouse
);
5105 // Translate the mouse coords to the other window coords
5107 pWin
= pWinUnderMouse
;
5111 } // end of FindWindowForMouseEvent