1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/window.h"
26 #include "wx/dcclient.h"
30 #include "wx/layout.h"
31 #include "wx/dialog.h"
33 #include "wx/listbox.h"
34 #include "wx/button.h"
35 #include "wx/msgdlg.h"
36 #include "wx/scrolwin.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
49 #include "wx/menuitem.h"
52 #include "wx/os2/private.h"
55 #include "wx/tooltip.h"
66 #include "wx/textctrl.h"
71 // Place compiler, OS specific includes here
75 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
79 // SHORT1FROMMP -- LOWORD
81 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
83 // SHORT2FROMMP -- HIWORD
85 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
86 #endif // GET_X_LPARAM
89 # define CW_USEDEFAULT ((int)0x80000000)
92 // ---------------------------------------------------------------------------
94 // ---------------------------------------------------------------------------
97 // The last PM message we got (MT-UNSAFE)
101 #if wxUSE_MENUS_NATIVE
102 wxMenu
* wxCurrentPopupMenu
= NULL
;
103 #endif // wxUSE_MENUS_NATIVE
105 #if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
106 extern wxChar wxCanvasClassName
[];
108 wxList
* wxWinHandleList
= NULL
;
110 // ---------------------------------------------------------------------------
112 // ---------------------------------------------------------------------------
115 // the window proc for all our windows; most gui's have something similar
117 MRESULT EXPENTRY
wxWndProc( HWND hWnd
124 const char *wxGetMessageName(int message
);
127 void wxRemoveHandleAssociation(wxWindowOS2
* pWin
);
128 void wxAssociateWinWithHandle( HWND hWnd
131 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
134 // This magical function is used to translate VK_APPS key presses to right
139 static void TranslateKbdEventToMouse( wxWindow
* pWin
146 // get the current state of SHIFT/CTRL keys
148 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; }
149 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; }
150 // ---------------------------------------------------------------------------
152 // ---------------------------------------------------------------------------
154 // in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
156 #ifdef __WXUNIVERSAL__
157 IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2
, wxWindowBase
)
159 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
160 #endif // __WXUNIVERSAL__/__WXPM__
162 BEGIN_EVENT_TABLE(wxWindowOS2
, wxWindowBase
)
163 EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground
)
164 EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged
)
165 EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog
)
166 EVT_IDLE(wxWindowOS2::OnIdle
)
167 EVT_SET_FOCUS(wxWindowOS2::OnSetFocus
)
170 // ===========================================================================
172 // ===========================================================================
174 // ---------------------------------------------------------------------------
175 // wxWindow utility functions
176 // ---------------------------------------------------------------------------
179 // Find an item given the PM Window id
181 wxWindow
* wxWindowOS2::FindItem(
186 wxControl
* pItem
= wxDynamicCast(this, wxControl
);
191 // I it we or one of our "internal" children?
193 if (pItem
->GetId() == lId
194 #ifndef __WXUNIVERSAL__
195 || (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
)
202 #endif // wxUSE_CONTROLS
204 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
208 wxWindow
* pChildWin
= pCurrent
->GetData();
209 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
214 pCurrent
= pCurrent
->GetNext();
217 } // end of wxWindowOS2::FindItem
220 // Find an item given the PM Window handle
222 wxWindow
* wxWindowOS2::FindItemByHWND(
227 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
231 wxWindow
* pParent
= pCurrent
->GetData();
234 // Do a recursive search.
236 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
243 || pParent
->IsKindOf(CLASSINFO(wxControl
))
244 #endif // wxUSE_CONTROLS
247 wxWindow
* pItem
= pCurrent
->GetData();
249 if (pItem
->GetHWND() == hWnd
)
253 if (pItem
->ContainsHWND(hWnd
))
257 pCurrent
= pCurrent
->GetNext();
260 } // end of wxWindowOS2::FindItemByHWND
263 // Default command handler
265 bool wxWindowOS2::OS2Command(
266 WXUINT
WXUNUSED(uParam
)
267 , WXWORD
WXUNUSED(uId
)
273 // ----------------------------------------------------------------------------
274 // constructors and such
275 // ----------------------------------------------------------------------------
277 void wxWindowOS2::Init()
287 m_bDoubleClickAllowed
= 0;
288 m_bWinCaptured
= FALSE
;
290 m_isBeingDeleted
= FALSE
;
293 m_bMouseInWindow
= FALSE
;
300 m_hWndScrollBarHorz
= 0L;
301 m_hWndScrollBarVert
= 0L;
304 // Pass WM_GETDLGCODE to DefWindowProc()
309 m_bBackgroundTransparent
= FALSE
;
312 // As all windows are created with WS_VISIBLE style...
316 #if wxUSE_MOUSEEVENT_HACK
319 m_nLastMouseEvent
= -1;
320 #endif // wxUSE_MOUSEEVENT_HACK
321 } // wxWindowOS2::Init
326 wxWindowOS2::~wxWindowOS2()
328 m_isBeingDeleted
= TRUE
;
330 OS2DetachWindowMenu();
331 for (wxWindow
* pWin
= GetParent(); pWin
; pWin
= pWin
->GetParent())
333 wxFrame
* pFrame
= wxDynamicCast(pWin
, wxFrame
);
337 if (pFrame
->GetLastFocus() == this)
338 pFrame
->SetLastFocus((wxWindow
*)NULL
);
345 m_parent
->RemoveChild(this);
349 if(!::WinDestroyWindow(GetHWND()))
350 wxLogLastError(wxT("DestroyWindow"));
352 // remove hWnd <-> wxWindow association
354 wxRemoveHandleAssociation(this);
356 } // end of wxWindowOS2::~wxWindowOS2
358 // real construction (Init() must have been called before!)
359 bool wxWindowOS2::Create(
362 , const wxPoint
& rPos
363 , const wxSize
& rSize
365 , const wxString
& rName
368 HWND hParent
= NULLHANDLE
;
369 wxPoint vPos
= rPos
; // The OS/2 position
370 ULONG ulCreateFlags
= 0;
371 WXDWORD dwExStyle
= 0;
373 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
375 if ( !CreateBase( pParent
389 pParent
->AddChild(this);
390 hParent
= GetWinHwnd(pParent
);
392 // OS2 uses normal coordinates, no bassackwards Windows ones
394 if (pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
395 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
398 wxWindow
* pGrandParent
= NULL
;
400 pGrandParent
= pParent
->GetParent();
402 nTempy
= pGrandParent
->GetSize().y
- (vPos
.y
+ rSize
.y
);
404 nTempy
= pParent
->GetSize().y
- (vPos
.y
+ rSize
.y
);
407 nTempy
= pParent
->GetSize().y
- (vPos
.y
+ rSize
.y
);
409 if ( pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)) ||
410 pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
))
412 ulCreateFlags
|= WS_CLIPSIBLINGS
;
418 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
419 hParent
= HWND_DESKTOP
;
420 vPos
.y
= vRect
.yTop
- (vPos
.y
+ rSize
.y
);
424 // Most wxSTYLES are really PM Class specific styles and will be
425 // set in those class create procs. PM's basic windows styles are
428 ulCreateFlags
|= WS_VISIBLE
;
431 #ifdef __WXUNIVERSAL__
432 // no 3d effects, we draw them ourselves
434 #else // !wxUniversal
435 if (lStyle
& wxCLIP_SIBLINGS
)
436 ulCreateFlags
|= WS_CLIPSIBLINGS
;
438 if (lStyle
& wxCLIP_CHILDREN
)
439 ulCreateFlags
|= WS_CLIPCHILDREN
;
445 dwExStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
450 // Add the simple border style as we'll use this to draw borders
452 if (lStyle
& wxSIMPLE_BORDER
)
453 dwExStyle
|= wxSIMPLE_BORDER
;
455 if (lStyle
& wxPOPUP_WINDOW
)
457 // a popup window floats on top of everything
459 // exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
461 // it is also created hidden as other top level windows
462 ulCreateFlags
&= ~WS_VISIBLE
;
467 // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
468 // and no presentation parameters
471 ,(PSZ
)wxCanvasClassName
476 ,WidthDefault(rSize
.x
)
477 ,HeightDefault(rSize
.y
)
487 } // end of wxWindowOS2::Create
489 // ---------------------------------------------------------------------------
491 // ---------------------------------------------------------------------------
493 void wxWindowOS2::SetFocus()
495 HWND hWnd
= GetHwnd();
496 wxCHECK_RET( hWnd
, _T("can't set focus to invalid window") );
499 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
500 } // end of wxWindowOS2::SetFocus
502 wxWindow
* wxWindowBase::FindFocus()
504 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
508 return wxFindWinFromHandle((WXHWND
)hWnd
);
511 } // wxWindowBase::FindFocus
513 bool wxWindowOS2::Enable(
517 if (!wxWindowBase::Enable(bEnable
))
520 HWND hWnd
= GetHwnd();
523 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
525 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
529 wxWindow
* pChild
= pNode
->GetData();
531 pChild
->Enable(bEnable
);
532 pNode
= pNode
->GetNext();
535 } // end of wxWindowOS2::Enable
537 bool wxWindowOS2::Show(
541 if (!wxWindowBase::Show(bShow
))
544 HWND hWnd
= GetHwnd();
546 ::WinShowWindow(hWnd
, bShow
);
550 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
553 } // end of wxWindowOS2::Show
555 void wxWindowOS2::Raise()
557 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
558 } // end of wxWindowOS2::Raise
560 void wxWindowOS2::Lower()
562 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
563 } // end of wxWindowOS2::Lower
565 void wxWindowOS2::SetTitle(
566 const wxString
& rTitle
569 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
570 } // end of wxWindowOS2::SetTitle
572 wxString
wxWindowOS2::GetTitle() const
574 return wxGetWindowText(GetHWND());
575 } // end of wxWindowOS2::GetTitle
577 void wxWindowOS2::CaptureMouse()
579 HWND hWnd
= GetHwnd();
581 if (hWnd
&& !m_bWinCaptured
)
583 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
584 m_bWinCaptured
= TRUE
;
586 } // end of wxWindowOS2::GetTitle
588 void wxWindowOS2::ReleaseMouse()
592 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
593 m_bWinCaptured
= FALSE
;
595 } // end of wxWindowOS2::ReleaseMouse
597 /* static */ wxWindow
* wxWindowBase::GetCapture()
599 HWND hwnd
= ::WinQueryCapture(HWND_DESKTOP
);
600 return hwnd
? wxFindWinFromHandle((WXHWND
)hwnd
) : (wxWindow
*)NULL
;
601 } // end of wxWindowBase::GetCapture
603 bool wxWindowOS2::SetFont(
607 if (!wxWindowBase::SetFont(rFont
))
613 HWND hWnd
= GetHwnd();
619 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), rFont
.GetFaceName().c_str());
620 return (bool)::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
), (PVOID
)zFont
);
625 bool wxWindowOS2::SetCursor(
626 const wxCursor
& rCursor
627 ) // check if base implementation is OK
629 if ( !wxWindowBase::SetCursor(rCursor
))
635 if ( m_cursor
.Ok() ) {
636 HWND hWnd
= GetHwnd();
640 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
641 ::WinQueryWindowRect(hWnd
, &vRect
);
643 if (::WinPtInRect(vHabmain
, &vRect
, &vPoint
) && !wxIsBusy())
645 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
649 } // end of wxWindowOS2::SetCursor
651 void wxWindowOS2::WarpPointer(
660 ::WinQueryWindowRect(GetHwnd(), &vRect
);
664 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
665 } // end of wxWindowOS2::WarpPointer
667 #if WXWIN_COMPATIBILITY
668 void wxWindowOS2::OS2DeviceToLogical (float *x
, float *y
) const
671 #endif // WXWIN_COMPATIBILITY
673 // ---------------------------------------------------------------------------
675 // ---------------------------------------------------------------------------
677 #if WXWIN_COMPATIBILITY
678 void wxWindowOS2::SetScrollRange(
684 int nRange1
= nRange
;
685 int nPageSize
= GetScrollPage(nOrient
);
687 if (nPpageSize
> 1 && nRange
> 0)
689 nRange1
+= (nPageSize
- 1);
692 if (nOrient
== wxHORIZONTAL
)
694 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
695 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
699 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
700 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
702 } // end of wxWindowOS2::SetScrollRange
704 void wxWindowOS2::SetScrollPage(
710 if (nOrient
== wxHORIZONTAL
)
711 m_nXThumbSize
= nPage
;
713 m_nYThumbSize
= nPage
;
714 } // end of wxWindowOS2::SetScrollPage
716 int wxWindowOS2::OldGetScrollRange(
721 HWND hWnd
= GetHwnd();
725 mRc
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L);
726 return(SHORT2FROMMR(mRc
));
729 } // end of wxWindowOS2::OldGetScrollRange
731 int wxWindowOS2::GetScrollPage(
735 if (nOrient
== wxHORIZONTAL
)
736 return m_nXThumbSize
;
738 return m_nYThumbSize
;
739 } // end of wxWindowOS2::GetScrollPage
740 #endif // WXWIN_COMPATIBILITY
742 int wxWindowOS2::GetScrollPos(
746 if (nOrient
== wxHORIZONTAL
)
747 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
749 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
750 } // end of wxWindowOS2::GetScrollPos
752 int wxWindowOS2::GetScrollRange(
758 if (nOrient
== wxHORIZONTAL
)
759 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
761 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
762 return((int)SHORT2FROMMR(mr
));
763 } // end of wxWindowOS2::GetScrollRange
765 int wxWindowOS2::GetScrollThumb(
769 if (nOrient
== wxHORIZONTAL
)
770 return m_nXThumbSize
;
772 return m_nYThumbSize
;
773 } // end of wxWindowOS2::GetScrollThumb
775 void wxWindowOS2::SetScrollPos(
778 , bool WXUNUSED(bRefresh
)
781 if (nOrient
== wxHORIZONTAL
)
782 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
784 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
785 } // end of wxWindowOS2::SetScrollPos
787 void wxWindowOS2::SetScrollbar(
792 , bool WXUNUSED(bRefresh
)
795 int nOldRange
= nRange
- nThumbVisible
;
796 int nRange1
= nOldRange
;
797 int nPageSize
= nThumbVisible
;
799 HWND hWnd
= GetHwnd();
800 ULONG ulStyle
= WS_VISIBLE
| WS_SYNCPAINT
;
803 ::WinQueryWindowRect(hWnd
, &vRect
);
804 if (nPageSize
> 1 && nRange
> 0)
806 nRange1
+= (nPageSize
- 1);
809 vInfo
.cb
= sizeof(SBCDATA
);
811 vInfo
.posLast
= (SHORT
)nRange1
;
812 vInfo
.posThumb
= nPos
;
814 if (nOrient
== wxHORIZONTAL
)
817 if (m_hWndScrollBarHorz
== 0L)
820 // We create the scrollbars with the desktop so that they are not
821 // registered as child windows of the window in order that child
822 // windows may be scrolled without scrolling the scrollbars themselves!
824 m_hWndScrollBarHorz
= ::WinCreateWindow( hWnd
830 ,vRect
.xRight
- vRect
.xLeft
844 // Only want to resize the scrollbar if it changes, otherwise
845 // we'd probably end up in a recursive loop until we crash the call stack
846 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
847 // generates those events.
849 ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect2
);
850 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
851 vRect2
.xRight
== vRect
.xRight
&&
852 vRect2
.yBottom
== vRect
.yBottom
&&
853 vRect2
.yTop
== vRect
.yTop
856 ::WinSetWindowPos( m_hWndScrollBarHorz
860 ,vRect
.xRight
- vRect
.xLeft
862 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
865 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
866 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
872 if (m_hWndScrollBarVert
== 0L)
874 m_hWndScrollBarVert
= ::WinCreateWindow( hWnd
881 ,vRect
.yTop
- (vRect
.yBottom
+ 20)
894 // Only want to resize the scrollbar if it changes, otherwise
895 // we'd probably end up in a recursive loop until we crash the call stack
896 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
897 // generates those events.
899 ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect2
);
900 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
901 vRect2
.xRight
== vRect
.xRight
&&
902 vRect2
.yBottom
== vRect
.yBottom
&&
903 vRect2
.yTop
== vRect
.yTop
906 ::WinSetWindowPos( m_hWndScrollBarVert
911 ,vRect
.yTop
- (vRect
.yBottom
+ 20)
912 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
915 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
916 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
918 m_nYThumbSize
= nThumbVisible
;
920 } // end of wxWindowOS2::SetScrollbar
922 void wxWindowOS2::ScrollWindow(
925 , const wxRect
* pRect
931 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite wxWin.
934 vRect2
.xLeft
= pRect
->x
;
935 vRect2
.yTop
= pRect
->y
+ pRect
->height
;
936 vRect2
.xRight
= pRect
->x
+ pRect
->width
;
937 vRect2
.yBottom
= pRect
->y
;
941 ::WinQueryWindowRect(GetHwnd(), &vRect2
);
942 ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect
);
943 vRect2
.yBottom
+= vRect
.yTop
- vRect
.yBottom
;
944 ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect
);
945 vRect2
.xRight
-= vRect
.xRight
- vRect
.xLeft
;
949 ::WinScrollWindow( GetHwnd()
959 ::WinScrollWindow( GetHwnd()
971 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
976 wxWindow
* pChildWin
= pCurrent
->GetData();
978 if (pChildWin
->GetHWND() != NULLHANDLE
)
980 ::WinQueryWindowPos(pChildWin
->GetHWND(), &vSwp
);
981 ::WinQueryWindowRect(pChildWin
->GetHWND(), &vRect
);
982 if (pChildWin
->GetHWND() == m_hWndScrollBarVert
||
983 pChildWin
->GetHWND() == m_hWndScrollBarHorz
)
985 ::WinSetWindowPos( pChildWin
->GetHWND()
991 ,SWP_MOVE
| SWP_SHOW
| SWP_ZORDER
996 ::WinSetWindowPos( pChildWin
->GetHWND()
1002 ,SWP_MOVE
| SWP_ZORDER
1004 ::WinInvalidateRect(pChildWin
->GetHWND(), &vRect
, FALSE
);
1007 pCurrent
= pCurrent
->GetNext();
1009 } // end of wxWindowOS2::ScrollWindow
1011 // ---------------------------------------------------------------------------
1013 // ---------------------------------------------------------------------------
1015 void wxWindowOS2::SubclassWin(
1019 HWND hwnd
= (HWND
)hWnd
;
1021 wxASSERT_MSG( !m_fnOldWndProc
, wxT("subclassing window twice?") );
1022 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
1023 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
1024 } // end of wxWindowOS2::SubclassWin
1026 void wxWindowOS2::UnsubclassWin()
1029 // Restore old Window proc
1031 HWND hwnd
= GetHWND();
1035 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
1037 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
1039 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
1041 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
1045 } // end of wxWindowOS2::UnsubclassWin
1048 // Make a Windows extended style from the given wxWindows window style
1050 WXDWORD
wxWindowOS2::MakeExtendedStyle(
1052 , bool bEliminateBorders
1056 // Simply fill out with wxWindow extended styles. We'll conjure
1057 // something up in OS2Create and all window redrawing pieces later
1059 WXDWORD dwStyle
= 0;
1061 if (lStyle
& wxTRANSPARENT_WINDOW
)
1062 dwStyle
|= wxTRANSPARENT_WINDOW
;
1064 if (!bEliminateBorders
)
1066 if (lStyle
& wxSUNKEN_BORDER
)
1067 dwStyle
|= wxSUNKEN_BORDER
;
1068 if (lStyle
& wxDOUBLE_BORDER
)
1069 dwStyle
|= wxDOUBLE_BORDER
;
1070 if (lStyle
& wxRAISED_BORDER
)
1071 dwStyle
|= wxRAISED_BORDER
;
1072 if (lStyle
& wxSTATIC_BORDER
)
1073 dwStyle
|= wxSTATIC_BORDER
;
1076 } // end of wxWindowOS2::MakeExtendedStyle
1079 // Determines whether simulated 3D effects or CTL3D should be used,
1080 // applying a default border style if required, and returning an extended
1081 // style to pass to OS2Create.
1083 WXDWORD
wxWindowOS2::Determine3DEffects(
1084 WXDWORD dwDefaultBorderStyle
1088 WXDWORD dwStyle
= 0L;
1091 // Native PM does not have any specialize 3D effects like WIN32 does,
1092 // so we have to try and invent them.
1096 // If matches certain criteria, then assume no 3D effects
1097 // unless specifically requested (dealt with in MakeExtendedStyle)
1100 !IsKindOf(CLASSINFO(wxControl
)) ||
1101 (m_windowStyle
& wxNO_BORDER
)
1105 return MakeExtendedStyle(m_windowStyle
, FALSE
);
1109 // 1) App can specify global 3D effects
1111 *pbWant3D
= wxTheApp
->GetAuto3D();
1114 // 2) If the parent is being drawn with user colours, or simple border
1115 // specified, switch effects off.
1118 (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) ||
1119 (m_windowStyle
& wxSIMPLE_BORDER
)
1124 // 3) Control can override this global setting by defining
1125 // a border style, e.g. wxSUNKEN_BORDER
1127 if ((m_windowStyle
& wxDOUBLE_BORDER
) ||
1128 (m_windowStyle
& wxRAISED_BORDER
) ||
1129 (m_windowStyle
& wxSTATIC_BORDER
) ||
1130 (m_windowStyle
& wxSUNKEN_BORDER
)
1134 dwStyle
= MakeExtendedStyle( m_windowStyle
1139 // If we want 3D, but haven't specified a border here,
1140 // apply the default border style specified.
1142 if (dwDefaultBorderStyle
&& (*pbWant3D
) &&
1143 !((m_windowStyle
& wxDOUBLE_BORDER
) ||
1144 (m_windowStyle
& wxRAISED_BORDER
) ||
1145 (m_windowStyle
& wxSTATIC_BORDER
) ||
1146 (m_windowStyle
& wxSIMPLE_BORDER
)
1149 dwStyle
|= dwDefaultBorderStyle
;
1151 } // end of wxWindowOS2::Determine3DEffects
1153 #if WXWIN_COMPATIBILITY
1154 void wxWindowOS2::OnCommand(
1156 , wxCommandEvent
& rEvent
1159 if (GetEventHandler()->ProcessEvent(rEvent
))
1162 m_parent
->GetEventHandler()->OnCommand( rWin
1165 } // end of wxWindowOS2::OnCommand
1167 wxObject
* wxWindowOS2::GetChild(
1172 // Return a pointer to the Nth object in the Panel
1174 wxNode
* pNode
= GetChildren().First();
1177 while (pNode
&& n
--)
1178 pNode
= pNode
->Next();
1181 wxObject
* pObj
= (wxObject
*)pNode
->Data();
1186 } // end of wxWindowOS2::GetChild
1188 #endif // WXWIN_COMPATIBILITY
1191 // Setup background and foreground colours correctly
1193 void wxWindowOS2::SetupColours()
1196 SetBackgroundColour(GetParent()->GetBackgroundColour());
1197 } // end of wxWindowOS2::SetupColours
1199 void wxWindowOS2::OnIdle(
1200 wxIdleEvent
& WXUNUSED(rEvent
)
1204 // Check if we need to send a LEAVE event
1206 if (m_bMouseInWindow
)
1210 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1211 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1214 // Generate a LEAVE event
1216 m_bMouseInWindow
= FALSE
;
1219 // Unfortunately the mouse button and keyboard state may have changed
1220 // by the time the OnIdle function is called, so 'state' may be
1225 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
1227 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
1230 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1232 InitMouseEvent( rEvent
1237 (void)GetEventHandler()->ProcessEvent(rEvent
);
1241 } // end of wxWindowOS2::OnIdle
1244 // Set this window to be the child of 'parent'.
1246 bool wxWindowOS2::Reparent(
1250 if (!wxWindowBase::Reparent(pParent
))
1253 HWND hWndChild
= GetHwnd();
1254 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1256 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1258 } // end of wxWindowOS2::Reparent
1260 void wxWindowOS2::Clear()
1262 wxClientDC
vDc((wxWindow
*)this);
1263 wxBrush
vBrush( GetBackgroundColour()
1267 vDc
.SetBackground(vBrush
);
1269 } // end of wxWindowOS2::Clear
1271 void wxWindowOS2::Refresh(
1273 , const wxRect
* pRect
1276 HWND hWnd
= GetHwnd();
1284 vOs2Rect
.xLeft
= pRect
->x
;
1285 vOs2Rect
.yTop
= pRect
->y
;
1286 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1287 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
1289 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1292 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1294 } // end of wxWindowOS2::Refresh
1296 // ---------------------------------------------------------------------------
1298 // ---------------------------------------------------------------------------
1300 #if wxUSE_DRAG_AND_DROP
1301 void wxWindowOS2::SetDropTarget(
1302 wxDropTarget
* pDropTarget
1305 if (m_dropTarget
!= 0)
1307 m_dropTarget
->Revoke(m_hWnd
);
1308 delete m_dropTarget
;
1310 m_dropTarget
= pDropTarget
;
1311 if (m_dropTarget
!= 0)
1312 m_dropTarget
->Register(m_hWnd
);
1313 } // end of wxWindowOS2::SetDropTarget
1317 // old style file-manager drag&drop support: we retain the old-style
1318 // DragAcceptFiles in parallel with SetDropTarget.
1320 void wxWindowOS2::DragAcceptFiles(
1324 HWND hWnd
= GetHwnd();
1326 if (hWnd
&& bAccept
)
1327 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1328 } // end of wxWindowOS2::DragAcceptFiles
1330 // ----------------------------------------------------------------------------
1332 // ----------------------------------------------------------------------------
1336 void wxWindowOS2::DoSetToolTip(
1340 wxWindowBase::DoSetToolTip(pTooltip
);
1343 m_tooltip
->SetWindow(this);
1344 } // end of wxWindowOS2::DoSetToolTip
1346 #endif // wxUSE_TOOLTIPS
1348 // ---------------------------------------------------------------------------
1349 // moving and resizing
1350 // ---------------------------------------------------------------------------
1353 void wxWindowOS2::DoGetSize(
1358 HWND hWnd
= GetHwnd();
1361 ::WinQueryWindowRect(hWnd
, &vRect
);
1364 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1366 // OS/2 PM is backwards from windows
1367 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1368 } // end of wxWindowOS2::DoGetSize
1370 void wxWindowOS2::DoGetPosition(
1375 HWND hWnd
= GetHwnd();
1379 ::WinQueryWindowRect(hWnd
, &vRect
);
1381 vPoint
.x
= vRect
.xLeft
;
1382 vPoint
.y
= vRect
.yBottom
;
1385 // We do the adjustments with respect to the parent only for the "real"
1386 // children, not for the dialogs/frames
1390 HWND hParentWnd
= 0;
1391 wxWindow
* pParent
= GetParent();
1394 hParentWnd
= GetWinHwnd(pParent
);
1397 // Since we now have the absolute screen coords, if there's a parent we
1398 // must subtract its bottom left corner
1404 ::WinQueryWindowRect(hParentWnd
, &vRect2
);
1405 vPoint
.x
-= vRect
.xLeft
;
1406 vPoint
.y
-= vRect
.yBottom
;
1410 // We may be faking the client origin. So a window that's really at (0,
1411 // 30) may appear (to wxWin apps) to be at (0, 0).
1414 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1425 } // end of wxWindowOS2::DoGetPosition
1427 void wxWindowOS2::DoScreenToClient(
1432 HWND hWnd
= GetHwnd();
1435 ptl
.x
= pX
? *pX
: 0;
1436 ptl
.y
= pY
? *pY
: 0;
1438 ::WinMapWindowPoints(HWND_DESKTOP
, hWnd
, &ptl
, 1);
1445 } // end of wxWindowOS2::DoScreenToClient
1447 void wxWindowOS2::DoClientToScreen(
1452 HWND hWnd
= GetHwnd();
1455 ptl
.x
= pX
? *pX
: 0;
1456 ptl
.y
= pY
? *pY
: 0;
1458 ::WinMapWindowPoints(hWnd
, HWND_DESKTOP
, &ptl
, 1);
1464 } // end of wxWindowOS2::DoClientToScreen
1467 // Get size *available for subwindows* i.e. excluding menu bar etc.
1468 // Must be a frame type window
1470 void wxWindowOS2::DoGetClientSize(
1475 HWND hWnd
= GetHwnd();
1479 if (IsKindOf(CLASSINFO(wxFrame
)))
1480 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1482 hWndClient
= NULLHANDLE
;
1483 if( hWndClient
== NULLHANDLE
)
1484 ::WinQueryWindowRect(GetHwnd(), &vRect
);
1486 ::WinQueryWindowRect(hWndClient
, &vRect
);
1489 *pWidth
= vRect
.xRight
;
1491 *pHeight
= vRect
.yTop
;
1492 } // end of wxWindowOS2::DoGetClientSize
1494 void wxWindowOS2::DoMoveWindow(
1501 #if 0 // x and y coords should already be in os2 coordinates
1504 wxWindow
* pParent
= GetParent();
1507 hParent
= GetWinHwnd(pParent
);
1509 hParent
= HWND_DESKTOP
;
1510 ::WinQueryWindowRect(hParent
, &vRect
);
1511 nY
= vRect
.yTop
- (nY
+ nHeight
);
1513 if ( !::WinSetWindowPos( GetHwnd()
1519 ,SWP_SIZE
| SWP_MOVE
1522 wxLogLastError("MoveWindow");
1524 } // end of wxWindowOS2::DoMoveWindow
1527 // Set the size of the window: if the dimensions are positive, just use them,
1528 // but if any of them is equal to -1, it means that we must find the value for
1529 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1530 // which case -1 is a valid value for x and y)
1532 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1533 // the width/height to best suit our contents, otherwise we reuse the current
1536 void wxWindowOS2::DoSetSize(
1545 // Get the current size and position...
1551 wxSize
vSize(-1, -1);
1553 GetPosition(&nCurrentX
, &nCurrentY
);
1554 GetSize(&nCurrentWidth
, &nCurrentHeight
);
1556 // ... 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
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1565 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1568 AdjustForParentClientOrigin(nX
, nY
, nSizeFlags
);
1572 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1574 vSize
= DoGetBestSize();
1580 // Just take the current one
1582 nWidth
= nCurrentWidth
;
1588 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1592 vSize
= DoGetBestSize();
1598 // just take the current one
1599 nHeight
= nCurrentHeight
;
1608 } // end of wxWindowOS2::DoSetSize
1610 void wxWindowOS2::DoSetClientSize(
1615 wxWindow
* pParent
= GetParent();
1616 HWND hWnd
= GetHwnd();
1618 HWND hParentWnd
= (HWND
)0;
1619 HWND hClientWnd
= (HWND
)0;
1624 hClientWnd
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1625 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1628 hParentWnd
= (HWND
) pParent
->GetHWND();
1630 ::WinQueryWindowRect(hWnd
, &vRect
);
1631 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1633 // Find the difference between the entire window (title bar and all)
1634 // and the client area; add this to the new client size to move the
1635 // window. OS/2 is backward from windows on height
1637 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1638 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1641 // If there's a parent, must subtract the parent's bottom left corner
1642 // since MoveWindow moves relative to the parent
1646 vPoint
.x
= vRect2
.xLeft
;
1647 vPoint
.y
= vRect2
.yBottom
;
1650 vPoint
.x
-= vRect3
.xLeft
;
1651 vPoint
.y
-= vRect3
.yBottom
;
1654 HWND hParentWnd
= (HWND
)0;
1655 HWND hClientWnd
= (HWND
)0;
1659 hClientWnd
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1660 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1661 ::WinQueryWindowRect(hWnd
, &vRect2
);
1664 hParentWnd
= (HWND
) pParent
->GetHWND();
1666 ::WinQueryWindowRect(hWnd
, &vRect
);
1668 // Find the difference between the entire window (title bar and all)
1669 // and the client area; add this to the new client size to move the
1670 // window. OS/2 is backward from windows on height
1672 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1673 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1675 nActualWidth
= nWidth
;
1676 nActualHeight
= nHeight
;
1678 // If there's a parent, must subtract the parent's bottom left corner
1679 // since MoveWindow moves relative to the parent
1683 vPoint
.x
= vRect2
.xLeft
;
1684 vPoint
.y
= vRect2
.yBottom
;
1687 ::WinMapWindowPoints(hWnd
, hParentWnd
, &vPoint
, 1);
1691 DoMoveWindow(vPoint
.x
, vPoint
.y
, nActualWidth
, nActualHeight
);
1693 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
1694 vEvent
.SetEventObject(this);
1695 GetEventHandler()->ProcessEvent(vEvent
);
1696 } // end of wxWindowOS2::DoSetClientSize
1698 wxPoint
wxWindowOS2::GetClientAreaOrigin() const
1700 return wxPoint(0, 0);
1701 } // end of wxWindowOS2::GetClientAreaOrigin
1703 // ---------------------------------------------------------------------------
1705 // ---------------------------------------------------------------------------
1707 int wxWindowOS2::GetCharHeight() const
1710 FONTMETRICS vFontMetrics
;
1712 hPs
= ::WinGetPS(GetHwnd());
1714 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1716 ::WinReleasePS(hPs
);
1719 ::WinReleasePS(hPs
);
1720 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1721 } // end of wxWindowOS2::GetCharHeight
1723 int wxWindowOS2::GetCharWidth() const
1726 FONTMETRICS vFontMetrics
;
1728 hPs
= ::WinGetPS(GetHwnd());
1730 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1732 ::WinReleasePS(hPs
);
1735 ::WinReleasePS(hPs
);
1736 return(vFontMetrics
.lAveCharWidth
);
1737 } // end of wxWindowOS2::GetCharWidth
1739 void wxWindowOS2::GetTextExtent(
1740 const wxString
& rString
1744 , int* pExternalLeading
1745 , const wxFont
* pTheFont
1748 const wxFont
* pFontToUse
= pTheFont
;
1751 hPs
= ::WinGetPS(GetHwnd());
1753 // Just prevent compiler warnings
1754 wxString dummy
= rString
;
1757 pDescent
= pDescent
;
1758 pExternalLeading
= pExternalLeading
;
1760 // TODO: Will have to play with fonts later
1763 pFontToUse = &m_font;
1766 HFONT hFfontOld = 0;
1768 if (pFontToUse && pFontToUse->Ok())
1771 hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
1773 hFontOld = (HFONT)SelectObject(dc,fnt);
1778 GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
1779 GetTextMetrics(dc, &tm);
1781 if ( fontToUse && fnt && hfontOld )
1782 SelectObject(dc, hfontOld);
1784 ReleaseDC(hWnd, dc);
1791 *descent = tm.tmDescent;
1792 if ( externalLeading )
1793 *externalLeading = tm.tmExternalLeading;
1795 ::WinReleasePS(hPs
);
1798 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1799 // ---------------------------------------------------------------------------
1800 // Caret manipulation
1801 // ---------------------------------------------------------------------------
1803 void wxWindowOS2::CreateCaret(
1808 SetCaret(new wxCaret( this
1812 } // end of wxWindowOS2::CreateCaret
1814 void wxWindowOS2::CreateCaret(
1815 const wxBitmap
* pBitmap
1818 wxFAIL_MSG("not implemented");
1819 } // end of wxWindowOS2::CreateCaret
1821 void wxWindowOS2::ShowCaret(
1825 wxCHECK_RET( m_caret
, "no caret to show" );
1827 m_caret
->Show(bShow
);
1828 } // end of wxWindowOS2::ShowCaret
1830 void wxWindowOS2::DestroyCaret()
1833 } // end of wxWindowOS2::DestroyCaret
1835 void wxWindowOS2::SetCaretPos(
1839 wxCHECK_RET( m_caret
, "no caret to move" );
1844 } // end of wxWindowOS2::SetCaretPos
1846 void wxWindowOS2::GetCaretPos(
1851 wxCHECK_RET( m_caret
, "no caret to get position of" );
1853 m_caret
->GetPosition( pX
1856 } // end of wxWindowOS2::GetCaretPos
1858 #endif //wxUSE_CARET
1860 // ---------------------------------------------------------------------------
1862 // ---------------------------------------------------------------------------
1864 #if wxUSE_MENUS_NATIVE
1865 static void wxYieldForCommandsOnly()
1868 // Peek all WM_COMMANDs (it will always return WM_QUIT too but we don't
1869 // want to process it here)
1873 while (::WinPeekMsg(vHabmain
, &vMsg
, (HWND
)0, WM_COMMAND
,
1874 WM_COMMAND
,PM_REMOVE
) && vMsg
.msg
!= WM_QUIT
)
1876 wxTheApp
->DoMessage((WXMSG
*)&vMsg
);
1879 #endif // wxUSE_MENUS_NATIVE
1881 #if wxUSE_MENUS_NATIVE
1882 bool wxWindowOS2::DoPopupMenu(
1888 HWND hWnd
= GetHwnd();
1889 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1890 HWND hMenu
= GetHmenuOf(pMenu
);
1892 pMenu
->SetInvokingWindow(this);
1895 DoClientToScreen( &nX
1898 wxCurrentPopupMenu
= pMenu
;
1900 ::WinPopupMenu( hWndParent
1906 ,PU_MOUSEBUTTON2DOWN
| PU_MOUSEBUTTON2
| PU_KEYBOARD
1908 // we need to do it righ now as otherwise the events are never going to be
1909 // sent to wxCurrentPopupMenu from ;()
1911 // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
1912 // help and we'd still need wxYieldForCommandsOnly() as the menu may be
1913 // destroyed as soon as we return (it can be a local variable in the caller
1914 // for example) and so we do need to process the event immediately
1915 wxYieldForCommandsOnly();
1916 wxCurrentPopupMenu
= NULL
;
1918 pMenu
->SetInvokingWindow(NULL
);
1920 } // end of wxWindowOS2::DoPopupMenu
1921 #endif // wxUSE_MENUS_NATIVE
1923 // ===========================================================================
1924 // pre/post message processing
1925 // ===========================================================================
1927 MRESULT
wxWindowOS2::OS2DefWindowProc(
1934 return (MRESULT
)m_fnOldWndProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1936 return ::WinDefWindowProc(GetHWND(), uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1937 } // end of wxWindowOS2::OS2DefWindowProc
1939 bool wxWindowOS2::OS2ProcessMessage(
1943 // wxUniversal implements tab traversal itself
1944 #ifndef __WXUNIVERSAL__
1945 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1947 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
1950 // Intercept dialog navigation keys
1952 bool bProcess
= TRUE
;
1953 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
1955 if (uKeyFlags
& KC_KEYUP
)
1958 if (uKeyFlags
& KC_ALT
)
1961 if (!(uKeyFlags
& KC_VIRTUALKEY
))
1966 bool bCtrlDown
= IsCtrlDown();
1967 bool bShiftDown
= IsShiftDown();
1970 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1971 // don't process it if it's the case (except for Ctrl-Tab/Enter
1972 // combinations which are always processed)
1974 ULONG ulDlgCode
= 0;
1978 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
1981 bool bForward
= TRUE
;
1982 bool bWindowChange
= FALSE
;
1984 switch (SHORT2FROMMP(pQMsg
->mp2
))
1987 // Going to make certain assumptions about specific types of controls
1988 // here, so we may have to alter some things later if they prove invalid
1992 // Shift tabl will always be a nav-key but tabs may be wanted
2001 // Entry Fields want tabs for themselve usually
2005 case DLGC_ENTRYFIELD
:
2015 // Ctrl-Tab cycles thru notebook pages
2017 bWindowChange
= bCtrlDown
;
2018 bForward
= !bShiftDown
;
2041 // ctrl-enter is not processed
2045 else if (ulDlgCode
& DLGC_BUTTON
)
2048 // buttons want process Enter themselevs
2054 wxButton
* pBtn
= wxDynamicCast( GetDefaultItem()
2058 if (pBtn
&& pBtn
->IsEnabled())
2061 // If we do have a default button, do press it
2063 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
2066 // else: but if it does not it makes sense to make
2067 // it work like a TAB - and that's what we do.
2068 // Note that Ctrl-Enter always works this way.
2079 wxNavigationKeyEvent vEvent
;
2081 vEvent
.SetDirection(bForward
);
2082 vEvent
.SetWindowChange(bWindowChange
);
2083 vEvent
.SetEventObject(this);
2085 if (GetEventHandler()->ProcessEvent(vEvent
))
2087 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
2092 // The button which has focus should be default
2101 // Let Dialogs process
2103 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
2107 pMsg
= pMsg
; // just shut up the compiler
2108 #endif // __WXUNIVERSAL__
2113 // relay mouse move events to the tooltip control
2114 QMSG
* pQMsg
= (QMSG
*)pMsg
;
2116 if (pQMsg
->msg
== WM_MOUSEMOVE
)
2117 m_tooltip
->RelayEvent(pMsg
);
2119 #endif // wxUSE_TOOLTIPS
2122 } // end of wxWindowOS2::OS2ProcessMessage
2124 bool wxWindowOS2::OS2TranslateMessage(
2128 #if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
2129 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
2133 #endif //wxUSE_ACCEL
2134 } // end of wxWindowOS2::OS2TranslateMessage
2136 // ---------------------------------------------------------------------------
2137 // message params unpackers
2138 // ---------------------------------------------------------------------------
2140 void wxWindowOS2::UnpackCommand(
2148 *pId
= LOWORD(wParam
);
2149 *phWnd
= NULL
; // or may be GetHWND() ?
2150 *pCmd
= LOWORD(lParam
);
2151 } // end of wxWindowOS2::UnpackCommand
2153 void wxWindowOS2::UnpackActivate(
2160 *pState
= LOWORD(wParam
);
2161 *phWnd
= (WXHWND
)lParam
;
2162 } // end of wxWindowOS2::UnpackActivate
2164 void wxWindowOS2::UnpackScroll(
2175 ulId
= (ULONG
)LONGFROMMP(wParam
);
2176 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
2177 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
2178 *phWnd
= NULLHANDLE
;
2182 *pPos
= SHORT1FROMMP(lParam
);
2183 *pCode
= SHORT2FROMMP(lParam
);
2184 } // end of wxWindowOS2::UnpackScroll
2186 void wxWindowOS2::UnpackMenuSelect(
2194 *pItem
= (WXWORD
)LOWORD(wParam
);
2195 *pFlags
= HIWORD(wParam
);
2196 *phMenu
= (WXHMENU
)lParam
;
2197 } // end of wxWindowOS2::UnpackMenuSelect
2199 // ---------------------------------------------------------------------------
2200 // Main wxWindows window proc and the window proc for wxWindow
2201 // ---------------------------------------------------------------------------
2204 // Hook for new window just as it's being created, when the window isn't yet
2205 // associated with the handle
2207 wxWindowOS2
* wxWndHook
= NULL
;
2212 MRESULT EXPENTRY
wxWndProc(
2220 // Trace all ulMsgs - useful for the debugging
2223 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
2224 wxGetMessageName(ulMsg
), wParam
, lParam
);
2225 #endif // __WXDEBUG__
2227 wxWindowOS2
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
2230 // When we get the first message for the HWND we just created, we associate
2231 // it with wxWindow stored in wxWndHook
2233 if (!pWnd
&& wxWndHook
)
2235 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2238 pWnd
->SetHWND((WXHWND
)hWnd
);
2241 MRESULT rc
= (MRESULT
)0;
2245 // Stop right here if we don't have a valid handle in our wxWindow object.
2247 if (pWnd
&& !pWnd
->GetHWND())
2249 pWnd
->SetHWND((WXHWND
) hWnd
);
2250 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2256 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2258 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2262 } // end of wxWndProc
2265 // We will add (or delete) messages we need to handle at this default
2268 MRESULT
wxWindowOS2::OS2WindowProc(
2275 // Did we process the uMsg?
2277 bool bProcessed
= FALSE
;
2281 // For most messages we should return 0 when we do process the message
2283 mResult
= (MRESULT
)0;
2291 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2297 // Return 0 to bAllow window creation
2299 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2310 bProcessed
= HandleMove( LOWORD(lParam
)
2316 bProcessed
= HandleSize( LOWORD(lParam
)
2327 UnpackActivate( wParam
2333 bProcessed
= HandleActivate( wState
2341 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2342 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2344 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2348 bProcessed
= HandlePaint();
2353 // Don't let the DefWindowProc() destroy our window - we'll do it
2354 // ourselves in ~wxWindow
2357 mResult
= (MRESULT
)TRUE
;
2361 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2365 // Under OS2 PM Joysticks are treated just like mouse events
2366 // The "Motion" events will be prevelent in joysticks
2369 case WM_BUTTON1DOWN
:
2371 case WM_BUTTON1DBLCLK
:
2372 case WM_BUTTON1MOTIONEND
:
2373 case WM_BUTTON1MOTIONSTART
:
2374 case WM_BUTTON2DOWN
:
2376 case WM_BUTTON2DBLCLK
:
2377 case WM_BUTTON2MOTIONEND
:
2378 case WM_BUTTON2MOTIONSTART
:
2379 case WM_BUTTON3DOWN
:
2381 case WM_BUTTON3DBLCLK
:
2382 case WM_BUTTON3MOTIONEND
:
2383 case WM_BUTTON3MOTIONSTART
:
2385 short x
= LOWORD(lParam
);
2386 short y
= HIWORD(lParam
);
2388 bProcessed
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
);
2392 bProcessed
= HandleSysCommand(wParam
, lParam
);
2399 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2401 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2406 // For these messages we must return TRUE if process the message
2409 case WM_MEASUREITEM
:
2411 int nIdCtrl
= (UINT
)wParam
;
2413 if ( uMsg
== WM_DRAWITEM
)
2415 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2416 (WXDRAWITEMSTRUCT
*)lParam
);
2420 bProcessed
= OS2OnMeasureItem(nIdCtrl
,
2421 (WXMEASUREITEMSTRUCT
*)lParam
);
2425 mResult
= (MRESULT
)TRUE
;
2429 case WM_QUERYDLGCODE
:
2432 mResult
= (MRESULT
)m_lDlgCode
;
2436 //else: get the dlg code from the DefWindowProc()
2441 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2442 // and key-down events are obtained from the WM_CHAR params.
2446 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2448 if (uKeyFlags
& KC_KEYUP
)
2450 //TODO: check if the cast to WXWORD isn't causing trouble
2451 bProcessed
= HandleKeyUp((WXWORD
)wParam
, lParam
);
2454 else // keydown event
2457 // If this has been processed by an event handler,
2458 // return 0 now (we've handled it). DON't RETURN
2459 // we still need to process further
2461 HandleKeyDown((WXWORD
)wParam
, lParam
);
2462 if (uKeyFlags
& KC_VIRTUALKEY
)
2464 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2467 // We consider these message "not interesting" to OnChar
2469 if (uVk
== VK_SHIFT
|| uVk
== VK_CTRL
)
2477 // Avoid duplicate messages to OnChar for these ASCII keys: they
2478 // will be translated by TranslateMessage() and received in WM_CHAR
2484 // But set processed to FALSE, not TRUE to still pass them to
2485 // the control's default window proc - otherwise built-in
2486 // keyboard handling won't work
2495 bProcessed
= HandleChar((WXWORD
)wParam
, lParam
);
2499 else // WM_CHAR -- Always an ASCII character
2501 bProcessed
= HandleChar((WXWORD
)wParam
, lParam
, TRUE
);
2513 UnpackScroll( wParam
2520 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2529 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2530 case WM_CTLCOLORCHANGE
:
2532 bProcessed
= HandleCtlColor(&hBrush
);
2536 case WM_ERASEBACKGROUND
:
2538 // Returning TRUE to requestw PM to paint the window background
2539 // in SYSCLR_WINDOW. We don't really want that
2541 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
2542 mResult
= (MRESULT
)(FALSE
);
2546 // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
2547 // things such as colors and fonts and such
2549 case WM_QUERYWINDOWPARAMS
:
2551 PWNDPARAMS pWndParams
= (PWNDPARAMS
)wParam
;
2553 bProcessed
= HandleWindowParams( pWndParams
2559 // the return value for this message is ignored
2560 case WM_SYSCOLORCHANGE
:
2561 bProcessed
= HandleSysColorChange();
2564 case WM_REALIZEPALETTE
:
2565 bProcessed
= HandlePaletteChanged();
2568 case WM_PRESPARAMCHANGED
:
2569 bProcessed
= HandlePresParamChanged(wParam
);
2573 // move all drag and drops to wxDrg
2575 bProcessed
= HandleEndDrag(wParam
);
2579 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
2583 // we never set focus from here
2588 // wxFrame specific message
2589 case WM_MINMAXFRAME
:
2590 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
2593 case WM_SYSVALUECHANGED
:
2594 // TODO: do something
2595 mResult
= (MRESULT
)TRUE
;
2599 // Comparable to WM_SETPOINTER for windows, only for just controls
2601 case WM_CONTROLPOINTER
:
2602 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
2603 ,(HWND
)lParam
// Cursor Handle
2608 // Returning TRUE stops the DefWindowProc() from further
2609 // processing this message - exactly what we need because we've
2610 // just set the cursor.
2612 mResult
= (MRESULT
)TRUE
;
2619 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2620 wxGetMessageName(uMsg
));
2621 #endif // __WXDEBUG__
2622 if (IsKindOf(CLASSINFO(wxFrame
)))
2623 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2625 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2628 } // end of wxWindowOS2::OS2WindowProc
2631 // Dialog window proc
2636 , MPARAM
WXUNUSED(wParam
)
2637 , MPARAM
WXUNUSED(lParam
))
2639 if (uMsg
== WM_INITDLG
)
2642 // For this message, returning TRUE tells system to set focus to the
2643 // first control in the dialog box
2645 return (MRESULT
)TRUE
;
2650 // For all the other ones, FALSE means that we didn't process the
2655 } // end of wxDlgProc
2657 wxWindow
* wxFindWinFromHandle(
2661 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
2665 return (wxWindow
*)pNode
->Data();
2666 } // end of wxFindWinFromHandle
2668 void wxAssociateWinWithHandle(
2674 // Adding NULL hWnd is (first) surely a result of an error and
2675 // (secondly) breaks menu command processing
2677 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2678 wxT("attempt to add a NULL hWnd to window list ignored") );
2681 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2683 if (pOldWin
&& (pOldWin
!= pWin
))
2685 wxString
str(pWin
->GetClassInfo()->GetClassName());
2686 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2693 wxWinHandleList
->Append( (long)hWnd
2697 } // end of wxAssociateWinWithHandle
2699 void wxRemoveHandleAssociation(
2703 wxWinHandleList
->DeleteObject(pWin
);
2704 } // end of wxRemoveHandleAssociation
2707 // Default destroyer - override if you destroy it in some other way
2708 // (e.g. with MDI child windows)
2710 void wxWindowOS2::OS2DestroyWindow()
2714 void wxWindowOS2::OS2DetachWindowMenu()
2716 #ifndef __WXUNIVERSAL__
2719 HMENU hMenu
= (HMENU
)m_hMenu
;
2721 int nN
= (int)::WinSendMsg(hMenu
, MM_QUERYITEMCOUNT
, 0, 0);
2724 for (i
= 0; i
< nN
; i
++)
2727 int nChars
= (int)::WinSendMsg( hMenu
2729 ,MPFROM2SHORT(i
, nN
)
2734 wxLogLastError(wxT("GetMenuString"));
2738 if (wxStrcmp(zBuf
, wxT("&Window")) == 0)
2740 ::WinSendMsg(hMenu
, MM_DELETEITEM
, MPFROM2SHORT(i
, TRUE
), 0);
2745 #endif // __WXUNIVERSAL__
2746 } // end of wxWindowOS2::OS2DetachWindowMenu
2748 bool wxWindowOS2::OS2Create(
2751 , const wxChar
* zTitle
2758 , WXHWND
WXUNUSED(hZOrder
)
2759 , unsigned long ulId
2770 long lHeight1
= 20L;
2772 int nNeedsubclass
= 0;
2773 PCSZ pszClass
= zClass
;
2776 // Find parent's size, if it exists, to set up a possible default
2777 // panel size the size of the parent window
2789 // check to see if the new window is a standard control
2791 if ((ULONG
)zClass
== (ULONG
)WC_BUTTON
||
2792 (ULONG
)zClass
== (ULONG
)WC_COMBOBOX
||
2793 (ULONG
)zClass
== (ULONG
)WC_CONTAINER
||
2794 (ULONG
)zClass
== (ULONG
)WC_ENTRYFIELD
||
2795 (ULONG
)zClass
== (ULONG
)WC_FRAME
||
2796 (ULONG
)zClass
== (ULONG
)WC_LISTBOX
||
2797 (ULONG
)zClass
== (ULONG
)WC_MENU
||
2798 (ULONG
)zClass
== (ULONG
)WC_NOTEBOOK
||
2799 (ULONG
)zClass
== (ULONG
)WC_SCROLLBAR
||
2800 (ULONG
)zClass
== (ULONG
)WC_SPINBUTTON
||
2801 (ULONG
)zClass
== (ULONG
)WC_STATIC
||
2802 (ULONG
)zClass
== (ULONG
)WC_TITLEBAR
||
2803 (ULONG
)zClass
== (ULONG
)WC_VALUESET
2810 // no standard controls
2811 if(wxString (wxT("wxFrameClass")) == wxString(zClass
) )
2813 pszClass
= WC_FRAME
;
2820 nControlId
= FID_CLIENT
;
2825 if ( GetWindowStyleFlag() & wxPOPUP_WINDOW
)
2827 // popup windows should have desktop as parent because they shouldn't
2828 // be limited to the parents client area as child windows usually are
2829 parent
= HWND_DESKTOP
;
2842 // We will either have a registered class via string name or a standard PM Class via a long
2844 m_hWnd
= (WXHWND
)::WinCreateWindow(parent
, zClass
,
2845 (PSZ
)zTitle
? zTitle
: wxT(""),
2846 dwStyle
, lX1
, lY1
, lWidth
, lHeight
,
2847 hOwner
, HWND_TOP
, (ULONG
)nControlId
,
2848 pCtlData
, pPresParams
);
2852 vError
= ::WinGetLastError(vHabmain
);
2853 sError
= wxPMErrorToStr(vError
);
2854 wxLogError("Can't create window of class %s!. Error: %s\n", zClass
, sError
);
2857 m_dwExStyle
= dwExStyle
;
2858 ::WinSetWindowULong(m_hWnd
, QWL_USER
, (ULONG
) this);
2862 wxNode
* pNode
= wxWinHandleList
->Member(this);
2866 HWND hWnd
= (HWND
)pNode
->GetKeyInteger();
2868 if (hWnd
!= (HWND
)m_hWnd
)
2871 wxLogError("A second HWND association is being added for the same window!");
2875 wxAssociateWinWithHandle((HWND
)m_hWnd
2879 // Now need to subclass window.
2883 wxAssociateWinWithHandle((HWND
)m_hWnd
,this);
2887 SubclassWin(GetHWND());
2890 } // end of wxWindowOS2::OS2Create
2892 // ===========================================================================
2893 // OS2 PM message handlers
2894 // ===========================================================================
2896 // ---------------------------------------------------------------------------
2897 // window creation/destruction
2898 // ---------------------------------------------------------------------------
2900 bool wxWindowOS2::HandleCreate(
2901 WXLPCREATESTRUCT
WXUNUSED(vCs
)
2905 wxWindowCreateEvent
vEvent((wxWindow
*)this);
2907 (void)GetEventHandler()->ProcessEvent(vEvent
);
2908 *pbMayCreate
= TRUE
;
2910 } // end of wxWindowOS2::HandleCreate
2912 bool wxWindowOS2::HandleDestroy()
2914 wxWindowDestroyEvent
vEvent((wxWindow
*)this);
2916 (void)GetEventHandler()->ProcessEvent(vEvent
);
2919 // Delete our drop target if we've got one
2921 #if wxUSE_DRAG_AND_DROP
2922 if (m_dropTarget
!= NULL
)
2924 m_dropTarget
->Revoke(m_hWnd
);
2925 delete m_dropTarget
;
2926 m_dropTarget
= NULL
;
2928 #endif // wxUSE_DRAG_AND_DROP
2931 // WM_DESTROY handled
2934 } // end of wxWindowOS2::HandleDestroy
2936 // ---------------------------------------------------------------------------
2938 // ---------------------------------------------------------------------------
2939 void wxWindowOS2::OnSetFocus(
2940 wxFocusEvent
& rEvent
2944 } // end of wxWindowOS2::OnSetFocus
2946 bool wxWindowOS2::HandleActivate(
2948 , WXHWND
WXUNUSED(hActivate
)
2951 wxActivateEvent
vEvent( wxEVT_ACTIVATE
2955 vEvent
.SetEventObject(this);
2956 return GetEventHandler()->ProcessEvent(vEvent
);
2957 } // end of wxWindowOS2::HandleActivate
2959 bool wxWindowOS2::HandleSetFocus(
2960 WXHWND
WXUNUSED(hWnd
)
2969 m_caret
->OnSetFocus();
2971 #endif // wxUSE_CARET
2974 // If it's a wxTextCtrl don't send the event as it will be done
2975 // after the control gets to process it from EN_FOCUS handler
2976 if ( wxDynamicCastThis(wxTextCtrl
) )
2980 #endif // wxUSE_TEXTCTRL
2982 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
2984 vEvent
.SetEventObject(this);
2985 return GetEventHandler()->ProcessEvent(vEvent
);
2986 } // end of wxWindowOS2::HandleSetFocus
2988 bool wxWindowOS2::HandleKillFocus(
2989 WXHWND
WXUNUSED(hWnd
)
2998 m_caret
->OnKillFocus();
3000 #endif // wxUSE_CARET
3002 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
3006 vEvent
.SetEventObject(this);
3007 return GetEventHandler()->ProcessEvent(vEvent
);
3008 } // end of wxWindowOS2::HandleKillFocus
3010 // ---------------------------------------------------------------------------
3012 // ---------------------------------------------------------------------------
3014 bool wxWindowOS2::HandleShow(
3016 , int WXUNUSED(nStatus
)
3019 wxShowEvent
vEvent(GetId(), bShow
);
3021 vEvent
.m_eventObject
= this;
3022 return GetEventHandler()->ProcessEvent(vEvent
);
3023 } // end of wxWindowOS2::HandleShow
3025 bool wxWindowOS2::HandleInitDialog(
3026 WXHWND
WXUNUSED(hWndFocus
)
3029 wxInitDialogEvent
vEvent(GetId());
3031 vEvent
.m_eventObject
= this;
3032 return GetEventHandler()->ProcessEvent(vEvent
);
3033 } // end of wxWindowOS2::HandleInitDialog
3035 bool wxWindowOS2::HandleEndDrag(WXWPARAM
WXUNUSED(wParam
))
3037 // TODO: We'll handle drag and drop later
3041 bool wxWindowOS2::HandleSetCursor(
3042 USHORT
WXUNUSED(vId
)
3047 // Under OS/2 PM this allows the pointer to be changed
3048 // as it passes over a control
3050 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
3052 } // end of wxWindowOS2::HandleSetCursor
3054 // ---------------------------------------------------------------------------
3055 // owner drawn stuff
3056 // ---------------------------------------------------------------------------
3057 bool wxWindowOS2::OS2OnDrawItem(
3059 , WXDRAWITEMSTRUCT
* pItemStruct
3062 #if wxUSE_OWNER_DRAWN
3065 #if wxUSE_MENUS_NATIVE
3067 // Is it a menu item?
3073 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3074 wxFrame
* pFrame
= (wxFrame
*)this;
3075 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3076 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
3077 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
3078 ,pMeasureStruct
->rclItem
.yBottom
3079 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
3080 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
3085 vDc
.SetHPS(pMeasureStruct
->hps
);
3087 // Load the wxWindows Pallete and set to RGB mode
3089 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3093 ,(LONG
)wxTheColourDatabase
->m_nSize
3094 ,(PLONG
)wxTheColourDatabase
->m_palTable
3097 vError
= ::WinGetLastError(vHabmain
);
3098 sError
= wxPMErrorToStr(vError
);
3099 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3102 // Set the color table to RGB mode
3104 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
3112 vError
= ::WinGetLastError(vHabmain
);
3113 sError
= wxPMErrorToStr(vError
);
3114 wxLogError("Unable to set current color table. Error: %s\n", sError
);
3117 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3123 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
3126 // Entire Item needs to be redrawn (either it has reappeared from
3127 // behind another window or is being displayed for the first time
3129 eAction
= wxOwnerDrawn::wxODDrawAll
;
3131 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3134 // If it is currently selected we let the system handle it
3136 eStatus
|= wxOwnerDrawn::wxODSelected
;
3138 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
3141 // If it is currently checked we draw our own
3143 eStatus
|= wxOwnerDrawn::wxODChecked
;
3144 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
3146 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
3149 // If it is currently disabled we let the system handle it
3151 eStatus
|= wxOwnerDrawn::wxODDisabled
;
3154 // Don't really care about framed (indicationg focus) or NoDismiss
3159 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
3161 eAction
= wxOwnerDrawn::wxODDrawAll
;
3162 eStatus
|= wxOwnerDrawn::wxODSelected
;
3164 // Keep the system from trying to highlight with its bogus colors
3166 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
3168 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
3170 eAction
= wxOwnerDrawn::wxODDrawAll
;
3173 // Keep the system from trying to highlight with its bogus colors
3175 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
3180 // For now we don't care about anything else
3181 // just ignore the entire message!
3187 // Now redraw the item
3189 return(pMenuItem
->OnDrawItem( vDc
3191 ,(wxOwnerDrawn::wxODAction
)eAction
3192 ,(wxOwnerDrawn::wxODStatus
)eStatus
3195 // leave the fsAttribute and fsOldAttribute unchanged. If different,
3196 // the system will do the highlight or fraeming or disabling for us,
3197 // otherwise, we'd have to do it ourselves.
3200 #endif // wxUSE_MENUS_NATIVE
3202 wxWindow
* pItem
= FindItem(vId
);
3204 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3206 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
3210 pItemStruct
= pItemStruct
;
3213 } // end of wxWindowOS2::OS2OnDrawItem
3215 bool wxWindowOS2::OS2OnMeasureItem(
3217 , WXMEASUREITEMSTRUCT
* pItemStruct
3220 #if wxUSE_OWNER_DRAWN
3222 // Is it a menu item?
3224 if (lId
== 65536) // I really don't like this...has to be a better indicator
3226 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3230 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3231 wxFrame
* pFrame
= (wxFrame
*)this;
3232 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3234 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3237 if (pMenuItem
->OnMeasureItem( &nWidth
3241 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3242 pMeasureStruct
->rclItem
.xLeft
= 0L;
3243 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3244 pMeasureStruct
->rclItem
.yBottom
= 0L;
3250 wxWindow
* pItem
= FindItem(lId
);
3252 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3254 return ((wxControl
*)pItem
)->OS2OnMeasure(pItemStruct
);
3258 pItemStruct
= pItemStruct
;
3259 #endif // wxUSE_OWNER_DRAWN
3263 // ---------------------------------------------------------------------------
3264 // colours and palettes
3265 // ---------------------------------------------------------------------------
3267 bool wxWindowOS2::HandleSysColorChange()
3269 wxSysColourChangedEvent vEvent
;
3271 vEvent
.SetEventObject(this);
3272 return GetEventHandler()->ProcessEvent(vEvent
);
3273 } // end of wxWindowOS2::HandleSysColorChange
3275 bool wxWindowOS2::HandleCtlColor(
3276 WXHBRUSH
* WXUNUSED(phBrush
)
3280 // Not much provided with message. So not sure I can do anything with it
3283 } // end of wxWindowOS2::HandleCtlColor
3285 bool wxWindowOS2::HandleWindowParams(
3286 PWNDPARAMS
WXUNUSED(pWndParams
)
3287 , WXLPARAM
WXUNUSED(lParam
)
3290 // TODO: I'll do something here, just not sure what yet
3294 // Define for each class of dialog and control
3295 WXHBRUSH
wxWindowOS2::OnCtlColor(WXHDC
WXUNUSED(hDC
),
3296 WXHWND
WXUNUSED(hWnd
),
3297 WXUINT
WXUNUSED(nCtlColor
),
3298 WXUINT
WXUNUSED(message
),
3299 WXWPARAM
WXUNUSED(wParam
),
3300 WXLPARAM
WXUNUSED(lParam
))
3305 bool wxWindowOS2::HandlePaletteChanged()
3307 // need to set this to something first
3308 WXHWND hWndPalChange
= NULLHANDLE
;
3310 wxPaletteChangedEvent
vEvent(GetId());
3312 vEvent
.SetEventObject(this);
3313 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3315 return GetEventHandler()->ProcessEvent(vEvent
);
3316 } // end of wxWindowOS2::HandlePaletteChanged
3318 bool wxWindowOS2::HandlePresParamChanged(
3319 WXWPARAM
WXUNUSED(wParam
)
3323 // TODO: Once again I'll do something here when I need it
3325 //wxQueryNewPaletteEvent event(GetId());
3326 //event.SetEventObject(this);
3327 // if the background is erased
3328 // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
3330 return FALSE
; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
3334 // Responds to colour changes: passes event on to children.
3336 void wxWindowOS2::OnSysColourChanged(
3337 wxSysColourChangedEvent
& rEvent
3340 wxNode
* pNode
= GetChildren().First();
3345 // Only propagate to non-top-level windows
3347 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
3349 if (pWin
->GetParent())
3351 wxSysColourChangedEvent vEvent
;
3353 rEvent
.m_eventObject
= pWin
;
3354 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
3356 pNode
= pNode
->Next();
3358 } // end of wxWindowOS2::OnSysColourChanged
3360 // ---------------------------------------------------------------------------
3362 // ---------------------------------------------------------------------------
3364 bool wxWindowOS2::HandlePaint()
3367 wxPaintEvent
vEvent(m_windowId
);
3372 // Create empty region
3373 // TODO: get HPS somewhere else if possible
3374 hPS
= ::WinGetPS(GetHwnd());
3375 hRgn
= ::GpiCreateRegion(hPS
, 0, NULL
);
3377 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_ERROR
)
3379 wxLogLastError("CreateRectRgn");
3383 m_updateRegion
= wxRegion(hRgn
, hPS
);
3385 vEvent
.SetEventObject(this);
3386 bProcessed
= GetEventHandler()->ProcessEvent(vEvent
);
3392 hPS
= ::WinBeginPaint( GetHwnd()
3399 ::GpiCreateLogColorTable( hPS
3403 ,(LONG
)wxTheColourDatabase
->m_nSize
3404 ,(PLONG
)wxTheColourDatabase
->m_palTable
3407 ::GpiCreateLogColorTable( hPS
3415 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3419 LINEBUNDLE vLineBundle
;
3421 vLineBundle
.lColor
= 0x00000000; // Black
3422 vLineBundle
.usMixMode
= FM_OVERPAINT
;
3423 vLineBundle
.fxWidth
= 1;
3424 vLineBundle
.lGeomWidth
= 1;
3425 vLineBundle
.usType
= LINETYPE_SOLID
;
3426 vLineBundle
.usEnd
= 0;
3427 vLineBundle
.usJoin
= 0;
3430 ,LBB_COLOR
| LBB_MIX_MODE
| LBB_WIDTH
| LBB_GEOM_WIDTH
| LBB_TYPE
3434 ::WinQueryWindowRect(GetHwnd(), &vRect
);
3444 ::GpiDestroyRegion(hPS
, hRgn
);
3445 ::WinReleasePS(hPS
);
3447 return GetEventHandler()->ProcessEvent(vEvent
); //bProcessed;
3448 } // end of wxWindowOS2::HandlePaint
3450 bool wxWindowOS2::HandleEraseBkgnd(
3457 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3458 if (vSwp
.fl
& SWP_MINIMIZE
)
3463 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
3464 vDC
.SetWindow((wxWindow
*)this);
3467 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3469 vEvent
.SetEventObject(this);
3471 rc
= GetEventHandler()->ProcessEvent(vEvent
);
3474 vDC
.m_hPS
= NULLHANDLE
;
3476 } // end of wxWindowOS2::HandleEraseBkgnd
3478 void wxWindowOS2::OnEraseBackground(
3479 wxEraseEvent
& rEvent
3483 HPS hPS
= rEvent
.m_dc
->m_hPS
;
3485 LONG lColor
= m_backgroundColour
.GetPixel();
3487 rc
= ::WinQueryWindowRect(GetHwnd(), &vRect
);
3488 rc
= ::WinFillRect(hPS
, &vRect
, lColor
);
3489 } // end of wxWindowOS2::OnEraseBackground
3491 // ---------------------------------------------------------------------------
3492 // moving and resizing
3493 // ---------------------------------------------------------------------------
3495 bool wxWindowOS2::HandleMinimize()
3497 wxIconizeEvent
vEvent(m_windowId
);
3499 vEvent
.SetEventObject(this);
3500 return GetEventHandler()->ProcessEvent(vEvent
);
3501 } // end of wxWindowOS2::HandleMinimize
3503 bool wxWindowOS2::HandleMaximize()
3505 wxMaximizeEvent
vEvent(m_windowId
);
3507 vEvent
.SetEventObject(this);
3508 return GetEventHandler()->ProcessEvent(vEvent
);
3509 } // end of wxWindowOS2::HandleMaximize
3511 bool wxWindowOS2::HandleMove(
3516 wxMoveEvent
vEvent(wxPoint(nX
, nY
), m_windowId
);
3518 vEvent
.SetEventObject(this);
3519 return GetEventHandler()->ProcessEvent(vEvent
);
3520 } // end of wxWindowOS2::HandleMove
3522 bool wxWindowOS2::HandleSize(
3525 , WXUINT
WXUNUSED(nFlag
)
3528 wxSizeEvent
vEvent(wxSize(nWidth
, nHeight
), m_windowId
);
3530 vEvent
.SetEventObject(this);
3531 return GetEventHandler()->ProcessEvent(vEvent
);
3532 } // end of wxWindowOS2::HandleSize
3534 bool wxWindowOS2::HandleGetMinMaxInfo(
3544 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3545 m_maxWidth
= pSwp
->cx
;
3546 m_maxHeight
= pSwp
->cy
;
3550 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3551 m_minWidth
= pSwp
->cx
;
3552 m_minHeight
= pSwp
->cy
;
3559 } // end of wxWindowOS2::HandleGetMinMaxInfo
3561 // ---------------------------------------------------------------------------
3563 // ---------------------------------------------------------------------------
3564 bool wxWindowOS2::HandleCommand(
3570 #if wxUSE_MENUS_NATIVE
3571 if (wxCurrentPopupMenu
)
3573 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3575 wxCurrentPopupMenu
= NULL
;
3576 return pPopupMenu
->OS2Command(wCmd
, wId
);
3578 #endif // wxUSE_MENUS_NATIVE
3580 wxWindow
* pWin
= FindItem(wId
);
3584 pWin
= wxFindWinFromHandle(hControl
);
3588 return pWin
->OS2Command(wCmd
, wId
);
3591 } // end of wxWindowOS2::HandleCommand
3593 bool wxWindowOS2::HandleSysCommand(
3595 , WXLPARAM
WXUNUSED(lParam
)
3599 // 4 bits are reserved
3601 switch (SHORT1FROMMP(wParam
))
3604 return HandleMaximize();
3607 return HandleMinimize();
3610 } // end of wxWindowOS2::HandleSysCommand
3612 // ---------------------------------------------------------------------------
3614 // ---------------------------------------------------------------------------
3615 //TODO!!! check against MSW
3616 void wxWindowOS2::InitMouseEvent(
3617 wxMouseEvent
& rEvent
3625 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
3626 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
3627 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
3628 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
3629 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
3630 rEvent
.SetTimestamp(s_currentMsg
.time
);
3631 rEvent
.m_eventObject
= this;
3633 #if wxUSE_MOUSEEVENT_HACK
3636 m_lastMouseEvent
= rEvent
.GetEventType();
3637 #endif // wxUSE_MOUSEEVENT_HACK
3638 } // end of wxWindowOS2::InitMouseEvent
3640 bool wxWindowOS2::HandleMouseEvent(
3648 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3649 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3650 // from the message id and take the value in the table to get wxWin event
3653 static const wxEventType eventsMouse
[] =
3667 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3669 InitMouseEvent( vEvent
3675 return GetEventHandler()->ProcessEvent(vEvent
);
3676 } // end of wxWindowOS2::HandleMouseEvent
3678 bool wxWindowOS2::HandleMouseMove(
3684 if (!m_bMouseInWindow
)
3687 // Generate an ENTER event
3689 m_bMouseInWindow
= TRUE
;
3691 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3693 InitMouseEvent( vEvent
3699 (void)GetEventHandler()->ProcessEvent(vEvent
);
3701 return HandleMouseEvent( WM_MOUSEMOVE
3706 } // end of wxWindowOS2::HandleMouseMove
3708 // ---------------------------------------------------------------------------
3709 // keyboard handling
3710 // ---------------------------------------------------------------------------
3713 // Create the key event of the given type for the given key - used by
3714 // HandleChar and HandleKeyDown/Up
3716 wxKeyEvent
wxWindowOS2::CreateKeyEvent(
3722 wxKeyEvent
vEvent(eType
);
3724 vEvent
.SetId(GetId());
3725 vEvent
.m_shiftDown
= IsShiftDown();
3726 vEvent
.m_controlDown
= IsCtrlDown();
3727 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3729 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
3730 vEvent
.m_keyCode
= nId
;
3731 vEvent
.SetTimestamp(s_currentMsg
.time
);
3734 // Translate the position to client coords
3739 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3740 ::WinQueryWindowRect( GetHwnd()
3744 vPoint
.x
-= vRect
.xLeft
;
3745 vPoint
.y
-= vRect
.yBottom
;
3747 vEvent
.m_x
= vPoint
.x
;
3748 vEvent
.m_y
= vPoint
.y
;
3751 } // end of wxWindowOS2::CreateKeyEvent
3754 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3757 bool wxWindowOS2::HandleChar(
3763 bool bCtrlDown
= FALSE
;
3769 // If 1 -> 26, translate to CTRL plus a letter.
3772 if ((vId
> 0) && (vId
< 27))
3794 else if ( (vId
= wxCharCodeOS2ToWX(wParam
)) == 0)
3797 // It's ASCII and will be processed here only when called from
3798 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3805 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
3812 vEvent
.m_controlDown
= TRUE
;
3815 if (GetEventHandler()->ProcessEvent(vEvent
))
3821 bool wxWindowOS2::HandleKeyDown(
3826 int nId
= wxCharCodeOS2ToWX(wParam
);
3831 // Normal ASCII char
3838 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3843 if (GetEventHandler()->ProcessEvent(vEvent
))
3849 } // end of wxWindowOS2::HandleKeyDown
3851 bool wxWindowOS2::HandleKeyUp(
3856 int nId
= wxCharCodeOS2ToWX(wParam
);
3861 // Normal ASCII char
3868 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
3873 if (GetEventHandler()->ProcessEvent(vEvent
))
3877 } // end of wxWindowOS2::HandleKeyUp
3879 // ---------------------------------------------------------------------------
3881 // ---------------------------------------------------------------------------
3883 // ---------------------------------------------------------------------------
3885 // ---------------------------------------------------------------------------
3887 bool wxWindowOS2::OS2OnScroll(
3896 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
3899 return pChild
->OS2OnScroll( nOrientation
3906 wxScrollWinEvent vEvent
;
3908 vEvent
.SetPosition(wPos
);
3909 vEvent
.SetOrientation(nOrientation
);
3910 vEvent
.m_eventObject
= this;
3915 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
3919 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
3923 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
3927 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
3930 case SB_SLIDERPOSITION
:
3931 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
3934 case SB_SLIDERTRACK
:
3935 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
3941 return GetEventHandler()->ProcessEvent(vEvent
);
3942 } // end of wxWindowOS2::OS2OnScroll
3944 // ===========================================================================
3946 // ===========================================================================
3949 WXHWND
WXUNUSED(hWnd
)
3952 ,wxFont
* WXUNUSED(pTheFont
)
3955 // TODO: we'll do this later
3956 } // end of wxGetCharSize
3959 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
3960 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3962 int wxCharCodeOS2ToWX(
3970 case VK_BACKTAB
: nId
= WXK_BACK
; break;
3971 case VK_TAB
: nId
= WXK_TAB
; break;
3972 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
3973 case VK_ENTER
: nId
= WXK_RETURN
; break;
3974 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
3975 case VK_CTRL
: nId
= WXK_CONTROL
; break;
3976 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
3977 case VK_SPACE
: nId
= WXK_SPACE
; break;
3978 case VK_ESC
: nId
= WXK_ESCAPE
; break;
3979 case VK_END
: nId
= WXK_END
; break;
3980 case VK_HOME
: nId
= WXK_HOME
; break;
3981 case VK_LEFT
: nId
= WXK_LEFT
; break;
3982 case VK_UP
: nId
= WXK_UP
; break;
3983 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
3984 case VK_DOWN
: nId
= WXK_DOWN
; break;
3985 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
3986 case VK_INSERT
: nId
= WXK_INSERT
; break;
3987 case VK_DELETE
: nId
= WXK_DELETE
; break;
3988 case VK_F1
: nId
= WXK_F1
; break;
3989 case VK_F2
: nId
= WXK_F2
; break;
3990 case VK_F3
: nId
= WXK_F3
; break;
3991 case VK_F4
: nId
= WXK_F4
; break;
3992 case VK_F5
: nId
= WXK_F5
; break;
3993 case VK_F6
: nId
= WXK_F6
; break;
3994 case VK_F7
: nId
= WXK_F7
; break;
3995 case VK_F8
: nId
= WXK_F8
; break;
3996 case VK_F9
: nId
= WXK_F9
; break;
3997 case VK_F10
: nId
= WXK_F10
; break;
3998 case VK_F11
: nId
= WXK_F11
; break;
3999 case VK_F12
: nId
= WXK_F12
; break;
4000 case VK_F13
: nId
= WXK_F13
; break;
4001 case VK_F14
: nId
= WXK_F14
; break;
4002 case VK_F15
: nId
= WXK_F15
; break;
4003 case VK_F16
: nId
= WXK_F16
; break;
4004 case VK_F17
: nId
= WXK_F17
; break;
4005 case VK_F18
: nId
= WXK_F18
; break;
4006 case VK_F19
: nId
= WXK_F19
; break;
4007 case VK_F20
: nId
= WXK_F20
; break;
4008 case VK_F21
: nId
= WXK_F21
; break;
4009 case VK_F22
: nId
= WXK_F22
; break;
4010 case VK_F23
: nId
= WXK_F23
; break;
4011 case VK_F24
: nId
= WXK_F24
; break;
4012 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
4013 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
4020 } // end of wxCharCodeOS2ToWX
4022 int wxCharCodeWXToOS2(
4032 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
4033 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
4034 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
4035 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
4036 case WXK_END
: nKeySym
= VK_END
; break;
4037 case WXK_HOME
: nKeySym
= VK_HOME
; break;
4038 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
4039 case WXK_UP
: nKeySym
= VK_UP
; break;
4040 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
4041 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
4042 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
4043 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
4044 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
4045 case WXK_F1
: nKeySym
= VK_F1
; break;
4046 case WXK_F2
: nKeySym
= VK_F2
; break;
4047 case WXK_F3
: nKeySym
= VK_F3
; break;
4048 case WXK_F4
: nKeySym
= VK_F4
; break;
4049 case WXK_F5
: nKeySym
= VK_F5
; break;
4050 case WXK_F6
: nKeySym
= VK_F6
; break;
4051 case WXK_F7
: nKeySym
= VK_F7
; break;
4052 case WXK_F8
: nKeySym
= VK_F8
; break;
4053 case WXK_F9
: nKeySym
= VK_F9
; break;
4054 case WXK_F10
: nKeySym
= VK_F10
; break;
4055 case WXK_F11
: nKeySym
= VK_F11
; break;
4056 case WXK_F12
: nKeySym
= VK_F12
; break;
4057 case WXK_F13
: nKeySym
= VK_F13
; break;
4058 case WXK_F14
: nKeySym
= VK_F14
; break;
4059 case WXK_F15
: nKeySym
= VK_F15
; break;
4060 case WXK_F16
: nKeySym
= VK_F16
; break;
4061 case WXK_F17
: nKeySym
= VK_F17
; break;
4062 case WXK_F18
: nKeySym
= VK_F18
; break;
4063 case WXK_F19
: nKeySym
= VK_F19
; break;
4064 case WXK_F20
: nKeySym
= VK_F20
; break;
4065 case WXK_F21
: nKeySym
= VK_F21
; break;
4066 case WXK_F22
: nKeySym
= VK_F22
; break;
4067 case WXK_F23
: nKeySym
= VK_F23
; break;
4068 case WXK_F24
: nKeySym
= VK_F24
; break;
4069 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
4070 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
4073 *bIsVirtual
= FALSE
;
4079 } // end of wxCharCodeWXToOS2
4081 wxWindow
* wxGetActiveWindow()
4083 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
4087 return wxFindWinFromHandle((WXHWND
)hWnd
);
4090 } // end of wxGetActiveWindow
4093 const char* wxGetMessageName(
4098 case 0x0000: return "WM_NULL";
4099 case 0x0001: return "WM_CREATE";
4100 case 0x0002: return "WM_DESTROY";
4101 case 0x0004: return "WM_ENABLE";
4102 case 0x0005: return "WM_SHOW";
4103 case 0x0006: return "WM_MOVE";
4104 case 0x0007: return "WM_SIZE";
4105 case 0x0008: return "WM_ADJUSTWINDOWPOS";
4106 case 0x0009: return "WM_CALCVALIDRECTS";
4107 case 0x000A: return "WM_SETWINDOWPARAMS";
4108 case 0x000B: return "WM_QUERYWINDOWPARAMS";
4109 case 0x000C: return "WM_HITTEST";
4110 case 0x000D: return "WM_ACTIVATE";
4111 case 0x000F: return "WM_SETFOCUS";
4112 case 0x0010: return "WM_SETSELECTION";
4113 case 0x0011: return "WM_PPAINT";
4114 case 0x0012: return "WM_PSETFOCUS";
4115 case 0x0013: return "WM_PSYSCOLORCHANGE";
4116 case 0x0014: return "WM_PSIZE";
4117 case 0x0015: return "WM_PACTIVATE";
4118 case 0x0016: return "WM_PCONTROL";
4119 case 0x0020: return "WM_COMMAND";
4120 case 0x0021: return "WM_SYSCOMMAND";
4121 case 0x0022: return "WM_HELP";
4122 case 0x0023: return "WM_PAINT";
4123 case 0x0024: return "WM_TIMER";
4124 case 0x0025: return "WM_SEM1";
4125 case 0x0026: return "WM_SEM2";
4126 case 0x0027: return "WM_SEM3";
4127 case 0x0028: return "WM_SEM4";
4128 case 0x0029: return "WM_CLOSE";
4129 case 0x002A: return "WM_QUIT";
4130 case 0x002B: return "WM_SYSCOLORCHANGE";
4131 case 0x002D: return "WM_SYSVALUECHANGE";
4132 case 0x002E: return "WM_APPTERMINATENOTIFY";
4133 case 0x002F: return "WM_PRESPARAMCHANGED";
4134 // Control notification messages
4135 case 0x0030: return "WM_CONTROL";
4136 case 0x0031: return "WM_VSCROLL";
4137 case 0x0032: return "WM_HSCROLL";
4138 case 0x0033: return "WM_INITMENU";
4139 case 0x0034: return "WM_MENUSELECT";
4140 case 0x0035: return "WM_MENUSEND";
4141 case 0x0036: return "WM_DRAWITEM";
4142 case 0x0037: return "WM_MEASUREITEM";
4143 case 0x0038: return "WM_CONTROLPOINTER";
4144 case 0x003A: return "WM_QUERYDLGCODE";
4145 case 0x003B: return "WM_INITDLG";
4146 case 0x003C: return "WM_SUBSTITUTESTRING";
4147 case 0x003D: return "WM_MATCHMNEMONIC";
4148 case 0x003E: return "WM_SAVEAPPLICATION";
4149 case 0x0129: return "WM_CTLCOLORCHANGE";
4150 case 0x0130: return "WM_QUERYCTLTYPE";
4152 case 0x0040: return "WM_FLASHWINDOW";
4153 case 0x0041: return "WM_FORMATFRAME";
4154 case 0x0042: return "WM_UPDATEFRAME";
4155 case 0x0043: return "WM_FOCUSCHANGE";
4156 case 0x0044: return "WM_SETBORDERSIZE";
4157 case 0x0045: return "WM_TRACKFRAME";
4158 case 0x0046: return "WM_MINMAXFRAME";
4159 case 0x0047: return "WM_SETICON";
4160 case 0x0048: return "WM_QUERYICON";
4161 case 0x0049: return "WM_SETACCELTABLE";
4162 case 0x004A: return "WM_QUERYACCELTABLE";
4163 case 0x004B: return "WM_TRANSLATEACCEL";
4164 case 0x004C: return "WM_QUERYTRACKINFO";
4165 case 0x004D: return "WM_QUERYBORDERSIZE";
4166 case 0x004E: return "WM_NEXTMENU";
4167 case 0x004F: return "WM_ERASEBACKGROUND";
4168 case 0x0050: return "WM_QUERYFRAMEINFO";
4169 case 0x0051: return "WM_QUERYFOCUSCHAIN";
4170 case 0x0052: return "WM_OWNERPOSCHANGE";
4171 case 0x0053: return "WM_CACLFRAMERECT";
4172 case 0x0055: return "WM_WINDOWPOSCHANGED";
4173 case 0x0056: return "WM_ADJUSTFRAMEPOS";
4174 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
4175 case 0x005B: return "WM_QUERYHELPINFO";
4176 case 0x005C: return "WM_SETHELPINFO";
4177 case 0x005D: return "WM_ERROR";
4178 case 0x005E: return "WM_REALIZEPALETTE";
4179 // Clipboard messages
4180 case 0x0060: return "WM_RENDERFMT";
4181 case 0x0061: return "WM_RENDERALLFMTS";
4182 case 0x0062: return "WM_DESTROYCLIPBOARD";
4183 case 0x0063: return "WM_PAINTCLIPBOARD";
4184 case 0x0064: return "WM_SIZECLIPBOARD";
4185 case 0x0065: return "WM_HSCROLLCLIPBOARD";
4186 case 0x0066: return "WM_VSCROLLCLIPBOARD";
4187 case 0x0067: return "WM_DRAWCLIPBOARD";
4189 case 0x0070: return "WM_MOUSEMOVE";
4190 case 0x0071: return "WM_BUTTON1DOWN";
4191 case 0x0072: return "WM_BUTTON1UP";
4192 case 0x0073: return "WM_BUTTON1DBLCLK";
4193 case 0x0074: return "WM_BUTTON2DOWN";
4194 case 0x0075: return "WM_BUTTON2UP";
4195 case 0x0076: return "WM_BUTTON2DBLCLK";
4196 case 0x0077: return "WM_BUTTON3DOWN";
4197 case 0x0078: return "WM_BUTTON3UP";
4198 case 0x0079: return "WM_BUTTON3DBLCLK";
4199 case 0x007D: return "WM_MOUSEMAP";
4200 case 0x007E: return "WM_VRNDISABLED";
4201 case 0x007F: return "WM_VRNENABLED";
4202 case 0x0410: return "WM_CHORD";
4203 case 0x0411: return "WM_BUTTON1MOTIONSTART";
4204 case 0x0412: return "WM_BUTTON1MOTIONEND";
4205 case 0x0413: return "WM_BUTTON1CLICK";
4206 case 0x0414: return "WM_BUTTON2MOTIONSTART";
4207 case 0x0415: return "WM_BUTTON2MOTIONEND";
4208 case 0x0416: return "WM_BUTTON2CLICK";
4209 case 0x0417: return "WM_BUTTON3MOTIONSTART";
4210 case 0x0418: return "WM_BUTTON3MOTIONEND";
4211 case 0x0419: return "WM_BUTTON3CLICK";
4212 case 0x0420: return "WM_BEGINDRAG";
4213 case 0x0421: return "WM_ENDDRAG";
4214 case 0x0422: return "WM_SINGLESELECT";
4215 case 0x0423: return "WM_OPEN";
4216 case 0x0424: return "WM_CONTEXTMENU";
4217 case 0x0425: return "WM_CONTEXTHELP";
4218 case 0x0426: return "WM_TEXTEDIT";
4219 case 0x0427: return "WM_BEGINSELECT";
4220 case 0x0228: return "WM_ENDSELECT";
4221 case 0x0429: return "WM_PICKUP";
4222 case 0x04C0: return "WM_PENFIRST";
4223 case 0x04FF: return "WM_PENLAST";
4224 case 0x0500: return "WM_MMPMFIRST";
4225 case 0x05FF: return "WM_MMPMLAST";
4226 case 0x0600: return "WM_STDDLGFIRST";
4227 case 0x06FF: return "WM_STDDLGLAST";
4228 case 0x0BD0: return "WM_BIDI_FIRST";
4229 case 0x0BFF: return "WM_BIDI_LAST";
4231 case 0x007A: return "WM_CHAR";
4232 case 0x007B: return "WM_VIOCHAR";
4234 case 0x00A0: return "WM_DDE_INITIATE";
4235 case 0x00A1: return "WM_DDE_REQUEST";
4236 case 0x00A2: return "WM_DDE_ACK";
4237 case 0x00A3: return "WM_DDE_DATA";
4238 case 0x00A4: return "WM_DDE_ADVISE";
4239 case 0x00A5: return "WM_DDE_UNADVISE";
4240 case 0x00A6: return "WM_DDE_POKE";
4241 case 0x00A7: return "WM_DDE_EXECUTE";
4242 case 0x00A8: return "WM_DDE_TERMINATE";
4243 case 0x00A9: return "WM_DDE_INITIATEACK";
4244 case 0x00AF: return "WM_DDE_LAST";
4246 case 0x0120: return "BM_CLICK";
4247 case 0x0121: return "BM_QUERYCHECKINDEX";
4248 case 0x0122: return "BM_QUERYHILITE";
4249 case 0x0123: return "BM_SETHILITE";
4250 case 0x0124: return "BM_QUERYCHECK";
4251 case 0x0125: return "BM_SETCHECK";
4252 case 0x0126: return "BM_SETDEFAULT";
4253 case 0x0128: return "BM_AUTOSIZE";
4255 case 0x029A: return "CBID_LIST";
4256 case 0x029B: return "CBID_EDIT";
4257 case 0x0170: return "CBM_SHOWLIST";
4258 case 0x0171: return "CBM_HILITE";
4259 case 0x0172: return "CBM_ISLISTSHOWING";
4261 case 0x0140: return "EM_QUERYCHANGED";
4262 case 0x0141: return "EM_QUERYSEL";
4263 case 0x0142: return "EM_SETSEL";
4264 case 0x0143: return "EM_SETTEXTLIMIT";
4265 case 0x0144: return "EM_CUT";
4266 case 0x0145: return "EM_COPY";
4267 case 0x0146: return "EM_CLEAR";
4268 case 0x0147: return "EM_PASTE";
4269 case 0x0148: return "EM_QUERYFIRSTCHAR";
4270 case 0x0149: return "EM_SETFIRSTCHAR";
4271 case 0x014A: return "EM_QUERYREADONLY";
4272 case 0x014B: return "EM_SETREADONLY";
4273 case 0x014C: return "EM_SETINSERTMODE";
4275 case 0x0160: return "LM_QUERYITEMCOUNT";
4276 case 0x0161: return "LM_INSERTITEM";
4277 case 0x0162: return "LM_SETOPENINDEX";
4278 case 0x0163: return "LM_DELETEITEM";
4279 case 0x0164: return "LM_SELECTITEM";
4280 case 0x0165: return "LM_QUERYSELECTION";
4281 case 0x0166: return "LM_SETITEMTEXT";
4282 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
4283 case 0x0168: return "LM_QUERYITEMTEXT";
4284 case 0x0169: return "LM_SETITEMHANDLE";
4285 case 0x016A: return "LM_QUERYITEMHANDLE";
4286 case 0x016B: return "LM_SEARCHSTRING";
4287 case 0x016C: return "LM_SETITEMHEIGHT";
4288 case 0x016D: return "LM_QUERYTOPINDEX";
4289 case 0x016E: return "LM_DELETEALL";
4290 case 0x016F: return "LM_INSERTMULITEMS";
4291 case 0x0660: return "LM_SETITEMWIDTH";
4293 case 0x0180: return "MM_INSERTITEM";
4294 case 0x0181: return "MM_DELETEITEM";
4295 case 0x0182: return "MM_QUERYITEM";
4296 case 0x0183: return "MM_SETITEM";
4297 case 0x0184: return "MM_QUERYITEMCOUNT";
4298 case 0x0185: return "MM_STARTMENUMODE";
4299 case 0x0186: return "MM_ENDMENUMODE";
4300 case 0x0188: return "MM_REMOVEITEM";
4301 case 0x0189: return "MM_SELECTITEM";
4302 case 0x018A: return "MM_QUERYSELITEMID";
4303 case 0x018B: return "MM_QUERYITEMTEXT";
4304 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
4305 case 0x018D: return "MM_SETITEMHANDLE";
4306 case 0x018E: return "MM_SETITEMTEXT";
4307 case 0x018F: return "MM_ITEMPOSITIONFROMID";
4308 case 0x0190: return "MM_ITEMIDFROMPOSITION";
4309 case 0x0191: return "MM_QUERYITEMATTR";
4310 case 0x0192: return "MM_SETITEMATTR";
4311 case 0x0193: return "MM_ISITEMVALID";
4312 case 0x0194: return "MM_QUERYITEMRECT";
4313 case 0x0431: return "MM_QUERYDEFAULTITEMID";
4314 case 0x0432: return "MM_SETDEFAULTITEMID";
4316 case 0x01A0: return "SBM_SETSCROLLBAR";
4317 case 0x01A1: return "SBM_SETPOS";
4318 case 0x01A2: return "SBM_QUERYPOS";
4319 case 0x01A3: return "SBM_QUERYRANGE";
4320 case 0x01A6: return "SBM_SETTHUMBSIZE";
4323 case 0x0F00: return "WM_HELPBASE";
4324 case 0x0FFF: return "WM_HELPTOP";
4325 // Beginning of user defined messages
4326 case 0x1000: return "WM_USER";
4328 // wxWindows user defined types
4331 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
4332 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4333 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4334 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4335 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4336 case 0x1000 + 5: return "LVM_GETITEMA";
4337 case 0x1000 + 75: return "LVM_GETITEMW";
4338 case 0x1000 + 6: return "LVM_SETITEMA";
4339 case 0x1000 + 76: return "LVM_SETITEMW";
4340 case 0x1000 + 7: return "LVM_INSERTITEMA";
4341 case 0x1000 + 77: return "LVM_INSERTITEMW";
4342 case 0x1000 + 8: return "LVM_DELETEITEM";
4343 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4344 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4345 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4346 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4347 case 0x1000 + 13: return "LVM_FINDITEMA";
4348 case 0x1000 + 83: return "LVM_FINDITEMW";
4349 case 0x1000 + 14: return "LVM_GETITEMRECT";
4350 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4351 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4352 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4353 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4354 case 0x1000 + 18: return "LVM_HITTEST";
4355 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4356 case 0x1000 + 20: return "LVM_SCROLL";
4357 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4358 case 0x1000 + 22: return "LVM_ARRANGE";
4359 case 0x1000 + 23: return "LVM_EDITLABELA";
4360 case 0x1000 + 118: return "LVM_EDITLABELW";
4361 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4362 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4363 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4364 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4365 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4366 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4367 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4368 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4369 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4370 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4371 case 0x1000 + 31: return "LVM_GETHEADER";
4372 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4373 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4374 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4375 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4376 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4377 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4378 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4379 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4380 case 0x1000 + 41: return "LVM_GETORIGIN";
4381 case 0x1000 + 42: return "LVM_UPDATE";
4382 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4383 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4384 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4385 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4386 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4387 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4388 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4389 case 0x1000 + 48: return "LVM_SORTITEMS";
4390 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4391 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4392 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4393 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4394 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4395 case 0x1000 + 53: return "LVM_SETICONSPACING";
4396 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4397 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4398 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4399 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4400 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4401 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4402 case 0x1000 + 60: return "LVM_SETHOTITEM";
4403 case 0x1000 + 61: return "LVM_GETHOTITEM";
4404 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4405 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4406 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4407 case 0x1000 + 65: return "LVM_SETWORKAREA";
4410 case 0x1100 + 0: return "TVM_INSERTITEMA";
4411 case 0x1100 + 50: return "TVM_INSERTITEMW";
4412 case 0x1100 + 1: return "TVM_DELETEITEM";
4413 case 0x1100 + 2: return "TVM_EXPAND";
4414 case 0x1100 + 4: return "TVM_GETITEMRECT";
4415 case 0x1100 + 5: return "TVM_GETCOUNT";
4416 case 0x1100 + 6: return "TVM_GETINDENT";
4417 case 0x1100 + 7: return "TVM_SETINDENT";
4418 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4419 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4420 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4421 case 0x1100 + 11: return "TVM_SELECTITEM";
4422 case 0x1100 + 12: return "TVM_GETITEMA";
4423 case 0x1100 + 62: return "TVM_GETITEMW";
4424 case 0x1100 + 13: return "TVM_SETITEMA";
4425 case 0x1100 + 63: return "TVM_SETITEMW";
4426 case 0x1100 + 14: return "TVM_EDITLABELA";
4427 case 0x1100 + 65: return "TVM_EDITLABELW";
4428 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4429 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4430 case 0x1100 + 17: return "TVM_HITTEST";
4431 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4432 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4433 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4434 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4435 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4436 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4437 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4438 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4439 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4442 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4443 case 0x1200 + 1: return "HDM_INSERTITEMA";
4444 case 0x1200 + 10: return "HDM_INSERTITEMW";
4445 case 0x1200 + 2: return "HDM_DELETEITEM";
4446 case 0x1200 + 3: return "HDM_GETITEMA";
4447 case 0x1200 + 11: return "HDM_GETITEMW";
4448 case 0x1200 + 4: return "HDM_SETITEMA";
4449 case 0x1200 + 12: return "HDM_SETITEMW";
4450 case 0x1200 + 5: return "HDM_LAYOUT";
4451 case 0x1200 + 6: return "HDM_HITTEST";
4452 case 0x1200 + 7: return "HDM_GETITEMRECT";
4453 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4454 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4455 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4456 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4457 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4458 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4459 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4462 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4463 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4464 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4465 case 0x1300 + 5: return "TCM_GETITEMA";
4466 case 0x1300 + 60: return "TCM_GETITEMW";
4467 case 0x1300 + 6: return "TCM_SETITEMA";
4468 case 0x1300 + 61: return "TCM_SETITEMW";
4469 case 0x1300 + 7: return "TCM_INSERTITEMA";
4470 case 0x1300 + 62: return "TCM_INSERTITEMW";
4471 case 0x1300 + 8: return "TCM_DELETEITEM";
4472 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4473 case 0x1300 + 10: return "TCM_GETITEMRECT";
4474 case 0x1300 + 11: return "TCM_GETCURSEL";
4475 case 0x1300 + 12: return "TCM_SETCURSEL";
4476 case 0x1300 + 13: return "TCM_HITTEST";
4477 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4478 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4479 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4480 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4481 case 0x1300 + 43: return "TCM_SETPADDING";
4482 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4483 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4484 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4485 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4486 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4487 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4488 case 0x1300 + 50: return "TCM_DESELECTALL";
4491 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
4492 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
4493 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
4494 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
4495 case WM_USER
+1000+5: return "TB_INDETERMINATE";
4496 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
4497 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
4498 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
4499 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
4500 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
4501 case WM_USER
+1000+17: return "TB_SETSTATE";
4502 case WM_USER
+1000+18: return "TB_GETSTATE";
4503 case WM_USER
+1000+19: return "TB_ADDBITMAP";
4504 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
4505 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
4506 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
4507 case WM_USER
+1000+23: return "TB_GETBUTTON";
4508 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
4509 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
4510 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
4511 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
4512 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
4513 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
4514 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
4515 case WM_USER
+1000+29: return "TB_GETITEMRECT";
4516 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
4517 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
4518 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
4519 case WM_USER
+1000+33: return "TB_AUTOSIZE";
4520 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
4521 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
4522 case WM_USER
+1000+37: return "TB_SETPARENT";
4523 case WM_USER
+1000+39: return "TB_SETROWS";
4524 case WM_USER
+1000+40: return "TB_GETROWS";
4525 case WM_USER
+1000+42: return "TB_SETCMDID";
4526 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
4527 case WM_USER
+1000+44: return "TB_GETBITMAP";
4528 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
4529 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
4530 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
4531 case WM_USER
+1000+47: return "TB_SETINDENT";
4532 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
4533 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
4534 case WM_USER
+1000+50: return "TB_LOADIMAGES";
4535 case WM_USER
+1000+51: return "TB_GETRECT";
4536 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
4537 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
4538 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
4539 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
4540 case WM_USER
+1000+56: return "TB_SETSTYLE";
4541 case WM_USER
+1000+57: return "TB_GETSTYLE";
4542 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
4543 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
4544 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
4545 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
4546 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
4549 static char s_szBuf
[128];
4550 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
4554 } // end of wxGetMessageName
4556 #endif // __WXDEBUG__
4560 static void TranslateKbdEventToMouse(
4568 // Construct the key mask
4569 ULONG
& fwKeys
= *pFlags
;
4571 fwKeys
= VK_BUTTON2
;
4572 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4574 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4578 // Simulate right mouse button click
4582 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4586 pWin
->ScreenToClient(pX
, pY
);
4587 } // end of TranslateKbdEventToMouse
4590 // Find the wxWindow at the current mouse position, returning the mouse
4592 wxWindow
* wxFindWindowAtPointer(
4593 wxPoint
& WXUNUSED(rPt
)
4596 return wxFindWindowAtPoint(wxGetMousePosition());
4599 wxWindow
* wxFindWindowAtPoint(
4608 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4609 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4610 HWND hWnd
= hWndHit
;
4613 // Try to find a window with a wxWindow associated with it
4615 while (!pWin
&& (hWnd
!= 0))
4617 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4618 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4623 // Get the current mouse position.
4624 wxPoint
wxGetMousePosition()
4628 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4629 return wxPoint(vPt
.x
, vPt
.y
);