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"
41 #include "wx/ownerdrw.h"
44 #if wxUSE_DRAG_AND_DROP
48 #include "wx/menuitem.h"
51 #include "wx/os2/private.h"
54 #include "wx/tooltip.h"
65 #include "wx/textctrl.h"
70 // Place compiler, OS specific includes here
74 // Standard macros -- these are for OS/2 PM, but most GUI's have something similar
78 // SHORT1FROMMP -- LOWORD
80 #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp))
82 // SHORT2FROMMP -- HIWORD
84 #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16))
85 #endif // GET_X_LPARAM
88 # define CW_USEDEFAULT ((int)0x80000000)
91 // ---------------------------------------------------------------------------
93 // ---------------------------------------------------------------------------
96 // The last Windows message we got (MT-UNSAFE)
100 wxMenu
* wxCurrentPopupMenu
= NULL
;
101 extern wxList WXDLLEXPORT wxPendingDelete
;
102 #if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
103 extern wxChar wxCanvasClassName
[];
105 wxList
* wxWinHandleList
= NULL
;
107 // ---------------------------------------------------------------------------
109 // ---------------------------------------------------------------------------
112 // the window proc for all our windows; most gui's have something similar
114 MRESULT EXPENTRY
wxWndProc( HWND hWnd
121 const char *wxGetMessageName(int message
);
124 void wxRemoveHandleAssociation(wxWindow
* pWin
);
125 void wxAssociateWinWithHandle( HWND hWnd
128 wxWindow
* wxFindWinFromHandle(WXHWND hWnd
);
131 // This magical function is used to translate VK_APPS key presses to right
134 static void TranslateKbdEventToMouse( wxWindow
* pWin
141 // get the current state of SHIFT/CTRL keys
143 static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x8000) != 0; }
144 static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x8000) != 0; }
145 // ---------------------------------------------------------------------------
147 // ---------------------------------------------------------------------------
149 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
151 BEGIN_EVENT_TABLE(wxWindow
, wxWindowBase
)
152 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
153 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
154 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
155 EVT_IDLE(wxWindow::OnIdle
)
156 EVT_SET_FOCUS(wxWindow::OnSetFocus
)
159 // ===========================================================================
161 // ===========================================================================
164 // Find an item given the PM Window id
166 wxWindow
* wxWindow::FindItem(
170 wxControl
* pItem
= wxDynamicCast( this
177 // I it we or one of our "internal" children?
179 if (pItem
->GetId() == lId
||
180 (pItem
->GetSubcontrols().Index(lId
) != wxNOT_FOUND
))
186 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
190 wxWindow
* pChildWin
= pCurrent
->GetData();
191 wxWindow
* pWnd
= pChildWin
->FindItem(lId
);
196 pCurrent
= pCurrent
->GetNext();
199 } // end of wxWindow::FindItem
202 // Find an item given the PM Window handle
204 wxWindow
* wxWindow::FindItemByHWND(
209 wxWindowList::Node
* pCurrent
= GetChildren().GetFirst();
213 wxWindow
* pParent
= pCurrent
->GetData();
216 // Do a recursive search.
218 wxWindow
* pWnd
= pParent
->FindItemByHWND(hWnd
);
223 if (!bControlOnly
|| pParent
->IsKindOf(CLASSINFO(wxControl
)))
225 wxWindow
* pItem
= pCurrent
->GetData();
227 if (pItem
->GetHWND() == hWnd
)
231 if (pItem
->ContainsHWND(hWnd
))
235 pCurrent
= pCurrent
->GetNext();
238 } // end of wxWindow::FindItemByHWND
241 // Default command handler
243 bool wxWindow::OS2Command(
244 WXUINT
WXUNUSED(uParam
)
245 , WXWORD
WXUNUSED(uId
)
251 // ----------------------------------------------------------------------------
252 // constructors and such
253 // ----------------------------------------------------------------------------
255 void wxWindow::Init()
265 m_bDoubleClickAllowed
= 0;
266 m_bWinCaptured
= FALSE
;
268 m_isBeingDeleted
= FALSE
;
271 m_bMouseInWindow
= FALSE
;
280 // Pass WM_GETDLGCODE to DefWindowProc()
285 m_bBackgroundTransparent
= FALSE
;
288 // As all windows are created with WS_VISIBLE style...
292 #if wxUSE_MOUSEEVENT_HACK
295 m_nLastMouseEvent
= -1;
296 #endif // wxUSE_MOUSEEVENT_HACK
302 wxWindow::~wxWindow()
304 m_isBeingDeleted
= TRUE
;
306 OS2DetachWindowMenu();
308 m_parent
->RemoveChild(this);
313 if(!::WinDestroyWindow(GetHWND()))
314 wxLogLastError(wxT("DestroyWindow"));
316 // remove hWnd <-> wxWindow association
318 wxRemoveHandleAssociation(this);
320 } // end of wxWindow::~wxWindow
322 bool wxWindow::Create(
325 , const wxPoint
& rPos
326 , const wxSize
& rSize
328 , const wxString
& rName
331 HWND hParent
= NULLHANDLE
;
333 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
335 if ( !CreateBase( pParent
347 pParent
->AddChild(this);
348 hParent
= GetWinHwnd(pParent
);
351 hParent
= HWND_DESKTOP
;
353 ULONG ulCreateFlags
= 0L;
357 // Most wxSTYLES are really PM Class specific styles and will be
358 // set in those class create procs. PM's basic windows styles are
361 ulCreateFlags
|= WS_VISIBLE
;
364 if ( lStyle
& wxCLIP_SIBLINGS
)
365 ulCreateFlags
|= WS_CLIPSIBLINGS
;
367 if (lStyle
& wxCLIP_CHILDREN
)
368 ulCreateFlags
|= WS_CLIPCHILDREN
;
371 // Empty stuff for now since PM has no custome 3D effects
372 // Doesn't mean someone cannot make some up though
375 WXDWORD dwExStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
378 // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
379 // and no presentation parameters
382 ,(PSZ
)wxCanvasClassName
387 ,WidthDefault(rSize
.x
)
388 ,HeightDefault(rSize
.y
)
395 } // end of wxWindow::Create
397 // ---------------------------------------------------------------------------
399 // ---------------------------------------------------------------------------
401 void wxWindow::SetFocus()
403 HWND hWnd
= GetHwnd();
406 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
407 } // end of wxWindow::SetFocus
409 wxWindow
* wxWindowBase::FindFocus()
411 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
415 return wxFindWinFromHandle((WXHWND
)hWnd
);
418 } // wxWindowBase::FindFocus
420 bool wxWindow::Enable(
424 if (!wxWindowBase::Enable(bEnable
))
427 HWND hWnd
= GetHwnd();
430 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
432 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
436 wxWindow
* pChild
= pNode
->GetData();
438 pChild
->Enable(bEnable
);
439 pNode
= pNode
->GetNext();
442 } // end of wxWindow::Enable
448 if (!wxWindowBase::Show(bShow
))
451 HWND hWnd
= GetHwnd();
453 ::WinShowWindow(hWnd
, bShow
);
457 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
460 } // end of wxWindow::Show
462 void wxWindow::Raise()
464 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
465 } // end of wxWindow::Raise
467 void wxWindow::Lower()
469 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
470 } // end of wxWindow::Lower
472 void wxWindow::SetTitle(
473 const wxString
& rTitle
476 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
477 } // end of wxWindow::SetTitle
479 wxString
wxWindow::GetTitle() const
481 return wxGetWindowText(GetHWND());
482 } // end of wxWindow::GetTitle
484 void wxWindow::CaptureMouse()
486 HWND hWnd
= GetHwnd();
488 if (hWnd
&& !m_bWinCaptured
)
490 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
491 m_bWinCaptured
= TRUE
;
493 } // end of wxWindow::GetTitle
495 void wxWindow::ReleaseMouse()
499 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
500 m_bWinCaptured
= FALSE
;
502 } // end of wxWindow::ReleaseMouse
504 bool wxWindow::SetFont(
508 if (!wxWindowBase::SetFont(rFont
))
514 HWND hWnd
= GetHwnd();
520 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), rFont
.GetFaceName().c_str());
521 return(::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
), (PVOID
)zFont
));
526 bool wxWindow::SetCursor(
527 const wxCursor
& rCursor
528 ) // check if base implementation is OK
530 if ( !wxWindowBase::SetCursor(rCursor
))
536 wxASSERT_MSG( m_cursor
.Ok(),
537 wxT("cursor must be valid after call to the base version"));
539 HWND hWnd
= GetHwnd();
545 hPS
= ::WinGetPS(hWnd
);
547 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
548 ::WinQueryWindowRect(hWnd
, &vRect
);
550 hRGN
= ::GpiCreateRegion(hPS
, 1L, &vRect
);
552 if ((::GpiPtInRegion(hPS
, hRGN
, &vPoint
) == PRGN_INSIDE
) && !wxIsBusy())
554 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
557 } // end of wxWindow::SetCursor
559 void wxWindow::WarpPointer(
568 ::WinQueryWindowRect(GetHwnd(), &vRect
);
572 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
573 } // end of wxWindow::WarpPointer
575 #if WXWIN_COMPATIBILITY
576 void wxWindow::OS2DeviceToLogical (float *x
, float *y
) const
579 #endif // WXWIN_COMPATIBILITY
581 // ---------------------------------------------------------------------------
583 // ---------------------------------------------------------------------------
585 #if WXWIN_COMPATIBILITY
586 void wxWindow::SetScrollRange(
592 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, nRange
));
593 } // end of wxWindow::SetScrollRange
595 void wxWindow::SetScrollPage(
601 if ( orient
== wxHORIZONTAL
)
607 int wxWindow::OldGetScrollRange(
612 HWND hWnd
= GetHwnd();
616 mRc
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L);
617 return(SHORT2FROMMR(mRc
));
620 } // end of wxWindow::OldGetScrollRange
622 int wxWindow::GetScrollPage(
626 if (nOrient
== wxHORIZONTAL
)
627 return m_nXThumbSize
;
629 return m_nYThumbSize
;
630 } // end of wxWindow::GetScrollPage
631 #endif // WXWIN_COMPATIBILITY
633 int wxWindow::GetScrollPos(
637 return((int)::WinSendMsg(GetHwnd(), SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
638 } // end of wxWindow::GetScrollPos
640 int wxWindow::GetScrollRange(
646 mr
= ::WinSendMsg(GetHwnd(), SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
647 return((int)SHORT2FROMMR(mr
));
648 } // end of wxWindow::GetScrollRange
650 int wxWindow::GetScrollThumb(
654 WNDPARAMS vWndParams
;
657 ::WinSendMsg(GetHwnd(), WM_QUERYWINDOWPARAMS
, (MPARAM
)&vWndParams
, (MPARAM
)NULL
);
658 pSbcd
= (PSBCDATA
)vWndParams
.pCtlData
;
659 return((int)pSbcd
->posThumb
);
660 } // end of wxWindow::GetScrollThumb
662 void wxWindow::SetScrollPos(
668 ::WinSendMsg(GetHwnd(), SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
669 } // end of wxWindow::SetScrollPos(
671 void wxWindow::SetScrollbar(
679 ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, nRange
));
680 if (nOrient
== wxHORIZONTAL
)
682 m_nXThumbSize
= nThumbVisible
;
686 m_nYThumbSize
= nThumbVisible
;
688 } // end of wxWindow::SetScrollbar
690 void wxWindow::ScrollWindow(
693 , const wxRect
* pRect
700 vRect2
.xLeft
= pRect
->x
;
701 vRect2
.yTop
= pRect
->y
;
702 vRect2
.xRight
= pRect
->x
+ pRect
->width
;
703 vRect2
.yBottom
= pRect
->y
+ pRect
->height
;
707 ::WinScrollWindow(GetHwnd(), (LONG
)nDx
, (LONG
)nDy
, &vRect2
, NULL
, NULLHANDLE
, NULL
, 0L);
709 ::WinScrollWindow(GetHwnd(), nDx
, nDy
, NULL
, NULL
, NULLHANDLE
, NULL
, 0L);
710 } // end of wxWindow::ScrollWindow
712 // ---------------------------------------------------------------------------
714 // ---------------------------------------------------------------------------
716 void wxWindow::SubclassWin(
720 HWND hwnd
= (HWND
)hWnd
;
722 wxASSERT_MSG( !m_fnOldWndProc
, wxT("subclassing window twice?") );
723 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
724 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
725 } // end of wxWindow::SubclassWin
727 void wxWindow::UnsubclassWin()
730 // Restore old Window proc
732 HWND hwnd
= GetHWND();
736 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
738 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
740 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
742 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
746 } // end of wxWindow::UnsubclassWin
749 // Make a Windows extended style from the given wxWindows window style
751 WXDWORD
wxWindow::MakeExtendedStyle(
753 , bool bEliminateBorders
757 // PM does not support extended style
761 } // end of wxWindow::MakeExtendedStyle
764 // Determines whether native 3D effects or CTL3D should be used,
765 // applying a default border style if required, and returning an extended
766 // style to pass to CreateWindowEx.
768 WXDWORD
wxWindow::Determine3DEffects(
769 WXDWORD dwDefaultBorderStyle
773 WXDWORD dwStyle
= 0L;
776 // Native PM does not have any specialize 3D effects like WIN32 does
780 } // end of wxWindow::Determine3DEffects
782 #if WXWIN_COMPATIBILITY
783 void wxWindow::OnCommand(
785 , wxCommandEvent
& rEvent
788 if (GetEventHandler()->ProcessEvent(rEvent
))
791 m_parent
->GetEventHandler()->OnCommand( rWin
794 } // end of wxWindow::OnCommand
796 wxObject
* wxWindow::GetChild(
801 // Return a pointer to the Nth object in the Panel
803 wxNode
* pNode
= GetChildren().First();
807 pNode
= pNode
->Next();
810 wxObject
* pObj
= (wxObject
*)pNode
->Data();
815 } // end of wxWindow::GetChild
817 #endif // WXWIN_COMPATIBILITY
820 // Setup background and foreground colours correctly
822 void wxWindow::SetupColours()
825 SetBackgroundColour(GetParent()->GetBackgroundColour());
826 } // end of wxWindow::SetupColours
828 void wxWindow::OnIdle(
833 // Check if we need to send a LEAVE event
835 if (m_bMouseInWindow
)
839 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
840 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
843 // Generate a LEAVE event
845 m_bMouseInWindow
= FALSE
;
848 // Unfortunately the mouse button and keyboard state may have changed
849 // by the time the OnIdle function is called, so 'state' may be
854 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
856 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
859 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
861 InitMouseEvent( rEvent
866 (void)GetEventHandler()->ProcessEvent(rEvent
);
870 } // end of wxWindow::OnIdle
873 // Set this window to be the child of 'parent'.
875 bool wxWindow::Reparent(
879 if (!wxWindowBase::Reparent(pParent
))
882 HWND hWndChild
= GetHwnd();
883 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
885 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
887 } // end of wxWindow::Reparent
889 void wxWindow::Clear()
891 wxClientDC
vDc(this);
892 wxBrush
vBrush( GetBackgroundColour()
896 vDc
.SetBackground(vBrush
);
898 } // end of wxWindow::Clear
900 void wxWindow::Refresh(
902 , const wxRect
* pRect
905 HWND hWnd
= GetHwnd();
913 vOs2Rect
.xLeft
= pRect
->x
;
914 vOs2Rect
.yTop
= pRect
->y
;
915 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
916 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
918 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
921 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
923 } // end of wxWindow::Refresh
925 // ---------------------------------------------------------------------------
927 // ---------------------------------------------------------------------------
929 #if wxUSE_DRAG_AND_DROP
930 void wxWindow::SetDropTarget(
931 wxDropTarget
* pDropTarget
934 if (m_dropTarget
!= 0)
936 m_dropTarget
->Revoke(m_hWnd
);
939 m_dropTarget
= pDropTarget
;
940 if (m_dropTarget
!= 0)
941 m_dropTarget
->Register(m_hWnd
);
942 } // end of wxWindow::SetDropTarget
946 // old style file-manager drag&drop support: we retain the old-style
947 // DragAcceptFiles in parallel with SetDropTarget.
949 void wxWindow::DragAcceptFiles(
953 HWND hWnd
= GetHwnd();
956 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
957 } // end of wxWindow::DragAcceptFiles
959 // ----------------------------------------------------------------------------
961 // ----------------------------------------------------------------------------
965 void wxWindow::DoSetToolTip(
969 wxWindowBase::DoSetToolTip(pTooltip
);
972 m_tooltip
->SetWindow(this);
973 } // end of wxWindow::DoSetToolTip
975 #endif // wxUSE_TOOLTIPS
977 // ---------------------------------------------------------------------------
978 // moving and resizing
979 // ---------------------------------------------------------------------------
982 void wxWindow::DoGetSize(
987 HWND hWnd
= GetHwnd();
990 ::WinQueryWindowRect(hWnd
, &vRect
);
993 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
995 // OS/2 PM is backwards from windows
996 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
997 } // end of wxWindow::DoGetSize
999 void wxWindow::DoGetPosition(
1004 HWND hWnd
= GetHwnd();
1008 ::WinQueryWindowRect(hWnd
, &vRect
);
1010 vPoint
.x
= vRect
.xLeft
;
1011 vPoint
.y
= vRect
.yBottom
;
1014 // We do the adjustments with respect to the parent only for the "real"
1015 // children, not for the dialogs/frames
1019 HWND hParentWnd
= 0;
1020 wxWindow
* pParent
= GetParent();
1023 hParentWnd
= GetWinHwnd(pParent
);
1026 // Since we now have the absolute screen coords, if there's a parent we
1027 // must subtract its bottom left corner
1033 ::WinQueryWindowRect(hParentWnd
, &vRect2
);
1034 vPoint
.x
-= vRect
.xLeft
;
1035 vPoint
.y
-= vRect
.yBottom
;
1039 // We may be faking the client origin. So a window that's really at (0,
1040 // 30) may appear (to wxWin apps) to be at (0, 0).
1042 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1052 } // end of wxWindow::DoGetPosition
1054 void wxWindow::DoScreenToClient(
1059 HWND hWnd
= GetHwnd();
1062 ::WinQueryWindowPos(hWnd
, &vSwp
);
1068 } // end of wxWindow::DoScreenToClient
1070 void wxWindow::DoClientToScreen(
1075 HWND hWnd
= GetHwnd();
1078 ::WinQueryWindowPos(hWnd
, &vSwp
);
1084 } // end of wxWindow::DoClientToScreen
1087 // Get size *available for subwindows* i.e. excluding menu bar etc.
1088 // Must be a frame type window
1090 void wxWindow::DoGetClientSize(
1095 HWND hWnd
= GetHwnd();
1099 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1100 if( hWndClient
== NULLHANDLE
)
1101 ::WinQueryWindowRect(GetHwnd(), &vRect
);
1103 ::WinQueryWindowRect(hWndClient
, &vRect
);
1106 *pWidth
= vRect
.xRight
;
1108 *pHeight
= vRect
.yTop
;
1109 } // end of wxWindow::DoGetClientSize
1111 void wxWindow::DoMoveWindow(
1118 if ( !::WinSetWindowPos( GetHwnd()
1124 ,SWP_SIZE
| SWP_MOVE
1127 wxLogLastError("MoveWindow");
1129 } // end of wxWindow::DoMoveWindow
1132 // Set the size of the window: if the dimensions are positive, just use them,
1133 // but if any of them is equal to -1, it means that we must find the value for
1134 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1135 // which case -1 is a valid value for x and y)
1137 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1138 // the width/height to best suit our contents, otherwise we reuse the current
1141 void wxWindow::DoSetSize(
1150 // Get the current size and position...
1156 wxSize
vSize(-1, -1);
1158 GetPosition( &nCurrentX
1161 GetSize( &nCurrentWidth
1166 // ... and don't do anything (avoiding flicker) if it's already ok
1168 if ( nX
== nCurrentX
&&
1170 nWidth
== nCurrentWidth
&&
1171 nHeight
== nCurrentHeight
1177 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1179 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1182 AdjustForParentClientOrigin( nX
1189 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1191 vSize
= DoGetBestSize();
1197 // Just take the current one
1199 nWidth
= nCurrentWidth
;
1205 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1209 vSize
= DoGetBestSize();
1215 // just take the current one
1216 nHeight
= nCurrentHeight
;
1225 } // end of wxWindow::DoSetSize
1227 void wxWindow::DoSetClientSize(
1232 wxWindow
* pParent
= GetParent();
1233 HWND hWnd
= GetHwnd();
1234 HWND hParentWnd
= (HWND
)0;
1235 HWND hClientWnd
= (HWND
)0;
1240 hClientWnd
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1241 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1244 hParentWnd
= (HWND
) pParent
->GetHWND();
1246 ::WinQueryWindowRect(hWnd
, &vRect
);
1247 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1249 // Find the difference between the entire window (title bar and all)
1250 // and the client area; add this to the new client size to move the
1251 // window. OS/2 is backward from windows on height
1253 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1254 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1257 // If there's a parent, must subtract the parent's bottom left corner
1258 // since MoveWindow moves relative to the parent
1262 vPoint
.x
= vRect2
.xLeft
;
1263 vPoint
.y
= vRect2
.yBottom
;
1266 vPoint
.x
-= vRect3
.xLeft
;
1267 vPoint
.y
-= vRect3
.yBottom
;
1270 DoMoveWindow( vPoint
.x
1276 wxSizeEvent
vEvent( wxSize( nWidth
1282 vEvent
.SetEventObject(this);
1283 GetEventHandler()->ProcessEvent(vEvent
);
1284 } // end of wxWindow::DoSetClientSize
1286 wxPoint
wxWindow::GetClientAreaOrigin() const
1288 return wxPoint(0, 0);
1289 } // end of wxWindow::GetClientAreaOrigin
1291 void wxWindow::AdjustForParentClientOrigin(
1298 // Don't do it for the dialogs/frames - they float independently of their
1303 wxWindow
* pParent
= GetParent();
1305 if (!(nSizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && pParent
)
1307 wxPoint
vPoint(pParent
->GetClientAreaOrigin());
1312 } // end of wxWindow::AdjustForParentClientOrigin
1314 // ---------------------------------------------------------------------------
1316 // ---------------------------------------------------------------------------
1318 int wxWindow::GetCharHeight() const
1321 FONTMETRICS vFontMetrics
;
1324 hPs
= ::WinGetPS(GetHwnd());
1326 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1328 ::WinReleasePS(hPs
);
1331 ::WinReleasePS(hPs
);
1332 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1333 } // end of wxWindow::GetCharHeight
1335 int wxWindow::GetCharWidth() const
1338 FONTMETRICS vFontMetrics
;
1340 hPs
= ::WinGetPS(GetHwnd());
1342 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1344 ::WinReleasePS(hPs
);
1347 ::WinReleasePS(hPs
);
1348 return(vFontMetrics
.lAveCharWidth
);
1349 } // end of wxWindow::GetCharWidth
1351 void wxWindow::GetTextExtent(
1352 const wxString
& rString
1356 , int* pExternalLeading
1357 , const wxFont
* pTheFont
1360 const wxFont
* pFontToUse
= pTheFont
;
1363 hPs
= ::WinGetPS(GetHwnd());
1365 // TODO: Will have to play with fonts later
1368 pFontToUse = &m_font;
1371 HFONT hFfontOld = 0;
1373 if (pFontToUse && pFontToUse->Ok())
1376 hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
1378 hFontOld = (HFONT)SelectObject(dc,fnt);
1383 GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
1384 GetTextMetrics(dc, &tm);
1386 if ( fontToUse && fnt && hfontOld )
1387 SelectObject(dc, hfontOld);
1389 ReleaseDC(hWnd, dc);
1396 *descent = tm.tmDescent;
1397 if ( externalLeading )
1398 *externalLeading = tm.tmExternalLeading;
1400 ::WinReleasePS(hPs
);
1403 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1404 // ---------------------------------------------------------------------------
1405 // Caret manipulation
1406 // ---------------------------------------------------------------------------
1408 void wxWindow::CreateCaret(
1413 SetCaret(new wxCaret( this
1417 } // end of wxWindow::CreateCaret
1419 void wxWindow::CreateCaret(
1420 const wxBitmap
* pBitmap
1423 wxFAIL_MSG("not implemented");
1424 } // end of wxWindow::CreateCaret
1426 void wxWindow::ShowCaret(
1430 wxCHECK_RET( m_caret
, "no caret to show" );
1432 m_caret
->Show(bShow
);
1433 } // end of wxWindow::ShowCaret
1435 void wxWindow::DestroyCaret()
1438 } // end of wxWindow::DestroyCaret
1440 void wxWindow::SetCaretPos(
1444 wxCHECK_RET( m_caret
, "no caret to move" );
1449 } // end of wxWindow::SetCaretPos
1451 void wxWindow::GetCaretPos(
1456 wxCHECK_RET( m_caret
, "no caret to get position of" );
1458 m_caret
->GetPosition( pX
1461 } // end of wxWindow::GetCaretPos
1463 #endif //wxUSE_CARET
1465 // ---------------------------------------------------------------------------
1467 // ---------------------------------------------------------------------------
1469 bool wxWindow::DoPopupMenu(
1475 HWND hWnd
= GetHwnd();
1476 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1477 HWND hMenu
= GetHmenuOf(pMenu
);
1479 pMenu
->SetInvokingWindow(this);
1482 DoClientToScreen( &nX
1485 wxCurrentPopupMenu
= pMenu
;
1487 ::WinPopupMenu( hWndParent
1493 ,PU_MOUSEBUTTON2DOWN
| PU_MOUSEBUTTON2
| PU_KEYBOARD
1496 wxCurrentPopupMenu
= NULL
;
1498 pMenu
->SetInvokingWindow(NULL
);
1500 } // end of wxWindow::DoPopupMenu
1502 // ===========================================================================
1503 // pre/post message processing
1504 // ===========================================================================
1506 MRESULT
wxWindow::OS2DefWindowProc(
1513 return (MRESULT
)m_fnOldWndProc(GetHWND(), (ULONG
)uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1515 return ::WinDefWindowProc(GetHWND(), (ULONG
)uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1516 } // end of wxWindow::OS2DefWindowProc
1518 bool wxWindow::OS2ProcessMessage(
1522 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1524 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
1527 // Intercept dialog navigation keys
1529 bool bProcess
= TRUE
;
1530 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
1532 if (uKeyFlags
& KC_KEYUP
)
1535 if (uKeyFlags
& KC_ALT
)
1538 if (!(uKeyFlags
& KC_VIRTUALKEY
))
1543 bool bCtrlDown
= IsCtrlDown();
1544 bool bShiftDown
= IsShiftDown();
1547 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1548 // don't process it if it's the case (except for Ctrl-Tab/Enter
1549 // combinations which are always processed)
1551 ULONG ulDlgCode
= 0;
1555 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
1558 bool bForward
= TRUE
;
1559 bool bWindowChange
= FALSE
;
1561 switch (SHORT2FROMMP(pQMsg
->mp2
))
1564 // Going to make certain assumptions about specific types of controls
1565 // here, so we may have to alter some things later if they prove invalid
1569 // Shift tabl will always be a nav-key but tabs may be wanted
1578 // Entry Fields want tabs for themselve usually
1582 case DLGC_ENTRYFIELD
:
1592 // Ctrl-Tab cycles thru notebook pages
1594 bWindowChange
= bCtrlDown
;
1595 bForward
= !bShiftDown
;
1618 // ctrl-enter is not processed
1622 else if (ulDlgCode
& DLGC_BUTTON
)
1625 // buttons want process Enter themselevs
1631 wxPanel
* pPanel
= wxDynamicCast(this, wxPanel
);
1632 wxButton
* pBtn
= NULL
;
1637 // Panel may have a default button which should
1638 // be activated by Enter
1640 pBtn
= pPanel
->GetDefaultItem();
1643 if (pBtn
&& pBtn
->IsEnabled())
1646 // If we do have a default button, do press it
1648 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
1651 // else: but if it does not it makes sense to make
1652 // it work like a TAB - and that's what we do.
1653 // Note that Ctrl-Enter always works this way.
1664 wxNavigationKeyEvent vEvent
;
1666 vEvent
.SetDirection(bForward
);
1667 vEvent
.SetWindowChange(bWindowChange
);
1668 vEvent
.SetEventObject(this);
1670 if (GetEventHandler()->ProcessEvent(vEvent
))
1672 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
1677 // The button which has focus should be default
1686 // Let Dialogs process
1688 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
1695 // relay mouse move events to the tooltip control
1696 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1698 if (pQMsg
->msg
== WM_MOUSEMOVE
)
1699 m_tooltip
->RelayEvent(pMsg
);
1701 #endif // wxUSE_TOOLTIPS
1704 } // end of wxWindow::OS2ProcessMessage
1706 bool wxWindow::OS2TranslateMessage(
1711 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
1714 #endif //wxUSE_ACCEL
1715 } // end of wxWindow::OS2TranslateMessage
1717 // ---------------------------------------------------------------------------
1718 // message params unpackers
1719 // ---------------------------------------------------------------------------
1721 void wxWindow::UnpackCommand(
1729 *pId
= LOWORD(wParam
);
1730 *phWnd
= NULL
; // or may be GetHWND() ?
1731 *pCmd
= LOWORD(lParam
);
1732 } // end of wxWindow::UnpackCommand
1734 void wxWindow::UnpackActivate(
1741 *pState
= LOWORD(wParam
);
1742 *phWnd
= (WXHWND
)lParam
;
1743 } // end of wxWindow::UnpackActivate
1745 void wxWindow::UnpackScroll(
1753 *pCode
= LOWORD(wParam
);
1754 *pPos
= HIWORD(wParam
);
1755 *phWnd
= (WXHWND
)lParam
;
1756 } // end of wxWindow::UnpackScroll
1758 void wxWindow::UnpackMenuSelect(
1766 *pItem
= (WXWORD
)LOWORD(wParam
);
1767 *pFlags
= HIWORD(wParam
);
1768 *phMenu
= (WXHMENU
)lParam
;
1769 } // end of wxWindow::UnpackMenuSelect
1771 // ---------------------------------------------------------------------------
1772 // Main wxWindows window proc and the window proc for wxWindow
1773 // ---------------------------------------------------------------------------
1776 // Hook for new window just as it's being created, when the window isn't yet
1777 // associated with the handle
1779 wxWindow
* wxWndHook
= NULL
;
1784 MRESULT EXPENTRY
wxWndProc(
1792 // Trace all ulMsgs - useful for the debugging
1795 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1796 wxGetMessageName(ulMsg
), wParam
, lParam
);
1797 #endif // __WXDEBUG__
1799 wxWindow
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
1802 // When we get the first message for the HWND we just created, we associate
1803 // it with wxWindow stored in wxWndHook
1805 if (!pWnd
&& wxWndHook
)
1807 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
1810 pWnd
->SetHWND((WXHWND
)hWnd
);
1813 MRESULT rc
= (MRESULT
)0;
1817 // Stop right here if we don't have a valid handle in our wxWindow object.
1819 if (pWnd
&& !pWnd
->GetHWND())
1821 pWnd
->SetHWND((WXHWND
) hWnd
);
1822 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
1828 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
1830 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
1834 } // end of wxWndProc
1837 // We will add (or delete) messages we need to handle at this default
1840 MRESULT
wxWindow::OS2WindowProc(
1847 // Did we process the uMsg?
1849 bool bProcessed
= FALSE
;
1856 // For most messages we should return 0 when we do process the message
1858 mResult
= (MRESULT
)0;
1866 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
1872 // Return 0 to bAllow window creation
1874 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
1885 bProcessed
= HandleMove( LOWORD(lParam
)
1891 bProcessed
= HandleSize( LOWORD(lParam
)
1902 UnpackActivate( wParam
1908 bProcessed
= HandleActivate( wState
1916 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
1917 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
1919 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
1923 bProcessed
= HandlePaint();
1928 // Don't let the DefWindowProc() destroy our window - we'll do it
1929 // ourselves in ~wxWindow
1932 mResult
= (MRESULT
)TRUE
;
1936 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
1940 // Under OS2 PM Joysticks are treated just like mouse events
1941 // The "Motion" events will be prevelent in joysticks
1944 case WM_BUTTON1DOWN
:
1946 case WM_BUTTON1DBLCLK
:
1947 case WM_BUTTON1MOTIONEND
:
1948 case WM_BUTTON1MOTIONSTART
:
1949 case WM_BUTTON2DOWN
:
1951 case WM_BUTTON2DBLCLK
:
1952 case WM_BUTTON2MOTIONEND
:
1953 case WM_BUTTON2MOTIONSTART
:
1954 case WM_BUTTON3DOWN
:
1956 case WM_BUTTON3DBLCLK
:
1957 case WM_BUTTON3MOTIONEND
:
1958 case WM_BUTTON3MOTIONSTART
:
1960 short x
= LOWORD(lParam
);
1961 short y
= HIWORD(lParam
);
1963 bProcessed
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
);
1967 bProcessed
= HandleSysCommand(wParam
, lParam
);
1974 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
1976 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
1981 // For these messages we must return TRUE if process the message
1984 case WM_MEASUREITEM
:
1986 int nIdCtrl
= (UINT
)wParam
;
1988 if ( uMsg
== WM_DRAWITEM
)
1990 bProcessed
= OS2OnDrawItem(nIdCtrl
,
1991 (WXDRAWITEMSTRUCT
*)lParam
);
1995 bProcessed
= OS2OnMeasureItem(nIdCtrl
,
1996 (WXMEASUREITEMSTRUCT
*)lParam
);
2000 mResult
= (MRESULT
)TRUE
;
2004 case WM_QUERYDLGCODE
:
2007 mResult
= (MRESULT
)m_lDlgCode
;
2011 //else: get the dlg code from the DefWindowProc()
2016 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2017 // and key-down events are obtained from the WM_CHAR params.
2021 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2023 if (uKeyFlags
& KC_KEYUP
)
2025 bProcessed
= HandleKeyUp((WXDWORD
)wParam
, lParam
);
2028 else // keydown event
2031 // If this has been processed by an event handler,
2032 // return 0 now (we've handled it). DON't RETURN
2033 // we still need to process further
2035 HandleKeyDown((WXDWORD
)wParam
, lParam
);
2036 if (uKeyFlags
& KC_VIRTUALKEY
)
2038 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2041 // We consider these message "not interesting" to OnChar
2043 if (uVk
== VK_SHIFT
|| uVk
== VK_CTRL
)
2051 // Avoid duplicate messages to OnChar for these ASCII keys: they
2052 // will be translated by TranslateMessage() and received in WM_CHAR
2058 // But set processed to FALSE, not TRUE to still pass them to
2059 // the control's default window proc - otherwise built-in
2060 // keyboard handling won't work
2069 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
);
2073 else // WM_CHAR -- Always an ASCII character
2075 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
, TRUE
);
2087 UnpackScroll( wParam
2094 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2103 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2104 case WM_CTLCOLORCHANGE
:
2106 bProcessed
= HandleCtlColor(&hBrush
);
2110 case WM_ERASEBACKGROUND
:
2112 // Returning TRUE to requestw PM to paint the window background
2113 // in SYSCLR_WINDOW. We don't really want that
2115 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
2116 mResult
= (MRESULT
)(FALSE
);
2120 // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
2121 // things such as colors and fonts and such
2123 case WM_QUERYWINDOWPARAMS
:
2125 PWNDPARAMS pWndParams
= (PWNDPARAMS
)wParam
;
2127 bProcessed
= HandleWindowParams( pWndParams
2133 // the return value for this message is ignored
2134 case WM_SYSCOLORCHANGE
:
2135 bProcessed
= HandleSysColorChange();
2138 case WM_REALIZEPALETTE
:
2139 bProcessed
= HandlePaletteChanged();
2142 case WM_PRESPARAMCHANGED
:
2143 bProcessed
= HandlePresParamChanged(wParam
);
2147 // move all drag and drops to wxDrg
2149 bProcessed
= HandleEndDrag(wParam
);
2153 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
2157 // we never set focus from here
2162 // wxFrame specific message
2163 case WM_MINMAXFRAME
:
2164 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
2167 case WM_SYSVALUECHANGED
:
2168 // TODO: do something
2169 mResult
= (MRESULT
)TRUE
;
2173 // Comparable to WM_SETPOINTER for windows, only for just controls
2175 case WM_CONTROLPOINTER
:
2176 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
2177 ,(HWND
)lParam
// Cursor Handle
2182 // Returning TRUE stops the DefWindowProc() from further
2183 // processing this message - exactly what we need because we've
2184 // just set the cursor.
2186 mResult
= (MRESULT
)TRUE
;
2193 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2194 wxGetMessageName(uMsg
));
2195 #endif // __WXDEBUG__
2196 if (IsKindOf(CLASSINFO(wxFrame
)))
2197 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2199 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2202 } // end of wxWindow::OS2WindowProc
2205 // Dialog window proc
2213 if (uMsg
== WM_INITDLG
)
2216 // For this message, returning TRUE tells system to set focus to the
2217 // first control in the dialog box
2219 return (MRESULT
)TRUE
;
2224 // For all the other ones, FALSE means that we didn't process the
2229 } // end of wxDlgProc
2231 wxWindow
* wxFindWinFromHandle(
2235 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
2239 return (wxWindow
*)pNode
->Data();
2240 } // end of wxFindWinFromHandle
2242 void wxAssociateWinWithHandle(
2248 // Adding NULL hWnd is (first) surely a result of an error and
2249 // (secondly) breaks menu command processing
2251 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2252 wxT("attempt to add a NULL hWnd to window list ignored") );
2255 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2257 if (pOldWin
&& (pOldWin
!= pWin
))
2259 wxString
str(pWin
->GetClassInfo()->GetClassName());
2260 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2267 wxWinHandleList
->Append( (long)hWnd
2271 } // end of wxAssociateWinWithHandle
2273 void wxRemoveHandleAssociation(
2277 wxWinHandleList
->DeleteObject(pWin
);
2278 } // end of wxRemoveHandleAssociation
2281 // Default destroyer - override if you destroy it in some other way
2282 // (e.g. with MDI child windows)
2284 void wxWindow::OS2DestroyWindow()
2288 void wxWindow::OS2DetachWindowMenu()
2292 HMENU hMenu
= (HMENU
)m_hMenu
;
2294 int nN
= (int)::WinSendMsg(hMenu
, MM_QUERYITEMCOUNT
, 0, 0);
2297 for (i
= 0; i
< nN
; i
++)
2300 int nChars
= (int)::WinSendMsg( hMenu
2302 ,MPFROM2SHORT(i
, nN
)
2307 wxLogLastError(wxT("GetMenuString"));
2311 if (wxStrcmp(zBuf
, wxT("&Window")) == 0)
2313 ::WinSendMsg(hMenu
, MM_DELETEITEM
, MPFROM2SHORT(i
, TRUE
), 0);
2318 } // end of wxWindow::OS2DetachWindowMenu
2320 bool wxWindow::OS2Create(
2323 , const wxChar
* zTitle
2331 , unsigned long ulId
2341 long lHeight1
= 20L;
2343 int nNeedsubclass
= 0;
2344 PCSZ pszClass
= zClass
;
2347 // Find parent's size, if it exists, to set up a possible default
2348 // panel size the size of the parent window
2365 // check to see if the new window is a standard control
2367 if ((ULONG
)zClass
== (ULONG
)WC_BUTTON
||
2368 (ULONG
)zClass
== (ULONG
)WC_COMBOBOX
||
2369 (ULONG
)zClass
== (ULONG
)WC_CONTAINER
||
2370 (ULONG
)zClass
== (ULONG
)WC_ENTRYFIELD
||
2371 (ULONG
)zClass
== (ULONG
)WC_FRAME
||
2372 (ULONG
)zClass
== (ULONG
)WC_LISTBOX
||
2373 (ULONG
)zClass
== (ULONG
)WC_MENU
||
2374 (ULONG
)zClass
== (ULONG
)WC_NOTEBOOK
||
2375 (ULONG
)zClass
== (ULONG
)WC_SCROLLBAR
||
2376 (ULONG
)zClass
== (ULONG
)WC_SPINBUTTON
||
2377 (ULONG
)zClass
== (ULONG
)WC_STATIC
||
2378 (ULONG
)zClass
== (ULONG
)WC_TITLEBAR
||
2379 (ULONG
)zClass
== (ULONG
)WC_VALUESET
2386 // no standard controls
2387 if(wxString (wxT("wxFrameClass")) == wxString(zClass
) )
2389 pszClass
= WC_FRAME
;
2396 nControlId
= FID_CLIENT
;
2401 // We will either have a registered class via string name or a standard PM Class via a long
2403 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)hParent
2405 ,(PSZ
)zTitle
? zTitle
: wxT("")
2419 vError
= ::WinGetLastError(vHabmain
);
2420 sError
= wxPMErrorToStr(vError
);
2421 wxLogError("Can't create window of class %s!. Error: %s\n", zClass
, sError
);
2424 ::WinSetWindowULong(m_hWnd
, QWL_USER
, (ULONG
) this);
2428 wxNode
* pNode
= wxWinHandleList
->Member(this);
2432 HWND hWnd
= (HWND
)pNode
->GetKeyInteger();
2434 if (hWnd
!= (HWND
)m_hWnd
)
2437 wxLogError("A second HWND association is being added for the same window!");
2441 wxAssociateWinWithHandle((HWND
)m_hWnd
2445 // Now need to subclass window.
2449 wxAssociateWinWithHandle((HWND
)m_hWnd
,this);
2453 SubclassWin(GetHWND());
2456 } // end of wxWindow::OS2Create
2458 // ===========================================================================
2459 // OS2 PM message handlers
2460 // ===========================================================================
2462 // ---------------------------------------------------------------------------
2463 // window creation/destruction
2464 // ---------------------------------------------------------------------------
2466 bool wxWindow::HandleCreate(
2467 WXLPCREATESTRUCT vCs
2471 wxWindowCreateEvent
vEvent(this);
2473 (void)GetEventHandler()->ProcessEvent(vEvent
);
2474 *pbMayCreate
= TRUE
;
2476 } // end of wxWindow::HandleCreate
2478 bool wxWindow::HandleDestroy()
2480 wxWindowDestroyEvent
vEvent(this);
2482 (void)GetEventHandler()->ProcessEvent(vEvent
);
2485 // Delete our drop target if we've got one
2487 #if wxUSE_DRAG_AND_DROP
2488 if (m_dropTarget
!= NULL
)
2490 m_dropTarget
->Revoke(m_hWnd
);
2491 delete m_dropTarget
;
2492 m_dropTarget
= NULL
;
2494 #endif // wxUSE_DRAG_AND_DROP
2497 // WM_DESTROY handled
2500 } // end of wxWindow::HandleDestroy
2502 // ---------------------------------------------------------------------------
2504 // ---------------------------------------------------------------------------
2505 void wxWindow::OnSetFocus(
2506 wxFocusEvent
& rEvent
2510 // Panel wants to track the window which was the last to have focus in it,
2511 // so we want to set ourselves as the window which last had focus
2513 // Notice that it's also important to do it upwards the tree becaus
2514 // otherwise when the top level panel gets focus, it won't set it back to
2515 // us, but to some other sibling
2517 wxWindow
* pWin
= this;
2521 wxWindow
* pParent
= pWin
->GetParent();
2522 wxPanel
* pPanel
= wxDynamicCast( pParent
2527 pPanel
->SetLastFocus(pWin
);
2532 wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
2533 GetClassInfo()->GetClassName(), GetHandle());
2536 } // end of wxWindow::OnSetFocus
2538 bool wxWindow::HandleActivate(
2540 , WXHWND
WXUNUSED(hActivate
)
2543 wxActivateEvent
vEvent( wxEVT_ACTIVATE
2547 vEvent
.SetEventObject(this);
2548 return GetEventHandler()->ProcessEvent(vEvent
);
2549 } // end of wxWindow::HandleActivate
2551 bool wxWindow::HandleSetFocus(
2552 WXHWND
WXUNUSED(hWnd
)
2561 m_caret
->OnSetFocus();
2563 #endif // wxUSE_CARET
2566 // Panel wants to track the window which was the last to have focus in it
2568 wxPanel
* pPanel
= wxDynamicCast( GetParent()
2573 pPanel
->SetLastFocus(this);
2576 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
2578 vEvent
.SetEventObject(this);
2579 return GetEventHandler()->ProcessEvent(vEvent
);
2580 } // end of wxWindow::HandleSetFocus
2582 bool wxWindow::HandleKillFocus(
2583 WXHWND
WXUNUSED(hWnd
)
2592 m_caret
->OnKillFocus();
2594 #endif // wxUSE_CARET
2596 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
2600 vEvent
.SetEventObject(this);
2601 return GetEventHandler()->ProcessEvent(vEvent
);
2602 } // end of wxWindow::HandleKillFocus
2604 // ---------------------------------------------------------------------------
2606 // ---------------------------------------------------------------------------
2608 bool wxWindow::HandleShow(
2613 wxShowEvent
vEvent( GetId()
2617 vEvent
.m_eventObject
= this;
2618 return GetEventHandler()->ProcessEvent(vEvent
);
2619 } // end of wxWindow::HandleShow
2621 bool wxWindow::HandleInitDialog(
2622 WXHWND
WXUNUSED(hWndFocus
)
2625 wxInitDialogEvent
vEvent(GetId());
2627 vEvent
.m_eventObject
= this;
2628 return GetEventHandler()->ProcessEvent(vEvent
);
2629 } // end of wxWindow::HandleInitDialog
2631 bool wxWindow::HandleEndDrag(WXWPARAM wParam
)
2633 // TODO: We'll handle drag and drop later
2637 bool wxWindow::HandleSetCursor(
2643 // Under OS/2 PM this allows the pointer to be changed
2644 // as it passes over a control
2646 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
2648 } // end of wxWindow::HandleSetCursor
2650 // ---------------------------------------------------------------------------
2651 // owner drawn stuff
2652 // ---------------------------------------------------------------------------
2653 bool wxWindow::OS2OnDrawItem(
2655 , WXDRAWITEMSTRUCT
* pItemStruct
2660 #if wxUSE_OWNER_DRAWN
2662 // Is it a menu item?
2666 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
2667 wxFrame
* pFrame
= (wxFrame
*)this;
2668 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
2669 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
2670 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
2671 ,pMeasureStruct
->rclItem
.yBottom
2672 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
2673 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
2678 vDc
.SetHPS(pMeasureStruct
->hps
);
2680 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
2686 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
2689 // Entire Item needs to be redrawn (either it has reappeared from
2690 // behind another window or is being displayed for the first time
2692 eAction
= wxOwnerDrawn::wxODDrawAll
;
2694 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
2697 // If it is currently selected we let the system handle it
2699 eStatus
|= wxOwnerDrawn::wxODSelected
;
2701 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
2704 // If it is currently checked we draw our own
2706 eStatus
|= wxOwnerDrawn::wxODChecked
;
2707 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
2709 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
2712 // If it is currently disabled we let the system handle it
2714 eStatus
|= wxOwnerDrawn::wxODDisabled
;
2717 // Don't really care about framed (indicationg focus) or NoDismiss
2723 // For now we don't care about doing our own highlighting so we'll
2724 // just ignore the entie message!
2729 // Now redraw the item
2731 return(pMenuItem
->OnDrawItem( vDc
2733 ,(wxOwnerDrawn::wxODAction
)eAction
2734 ,(wxOwnerDrawn::wxODStatus
)eStatus
2737 // leave the fsAttribute and fsOldAttribute unchanged. If different,
2738 // the system will do the highlight or fraeming or disabling for us,
2739 // otherwise, we'd have to do it ourselves.
2743 wxWindow
* pItem
= FindItem(vId
);
2745 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
2747 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
2751 } // end of wxWindow::OS2OnDrawItem
2753 bool wxWindow::OS2OnMeasureItem(
2755 , WXMEASUREITEMSTRUCT
* pItemStruct
2759 // Is it a menu item?
2761 if (lId
== 65536) // I really don't like this...has to be a better indicator
2763 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
2767 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
2768 wxFrame
* pFrame
= (wxFrame
*)this;
2769 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
2771 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
2774 if (pMenuItem
->OnMeasureItem( &nWidth
2778 pMeasureStruct
->rclItem
.xRight
= nWidth
;
2779 pMeasureStruct
->rclItem
.xLeft
= 0L;
2780 pMeasureStruct
->rclItem
.yTop
= nHeight
;
2781 pMeasureStruct
->rclItem
.yBottom
= 0L;
2787 wxWindow
* pItem
= FindItem(id
);
2789 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
2791 return ((wxControl
*)pItem
)->OS2OnMeasure(pItemStruct
);
2796 // ---------------------------------------------------------------------------
2797 // colours and palettes
2798 // ---------------------------------------------------------------------------
2800 bool wxWindow::HandleSysColorChange()
2802 wxSysColourChangedEvent vEvent
;
2804 vEvent
.SetEventObject(this);
2805 return GetEventHandler()->ProcessEvent(vEvent
);
2806 } // end of wxWindow::HandleSysColorChange
2808 bool wxWindow::HandleCtlColor(
2813 // Not much provided with message. So not sure I can do anything with it
2816 } // end of wxWindow::HandleCtlColor
2818 bool wxWindow::HandleWindowParams(
2819 PWNDPARAMS pWndParams
2823 // TODO: I'll do something here, just not sure what yet
2827 // Define for each class of dialog and control
2828 WXHBRUSH
wxWindow::OnCtlColor(WXHDC hDC
,
2838 bool wxWindow::HandlePaletteChanged()
2840 // need to set this to something first
2841 WXHWND hWndPalChange
= NULLHANDLE
;
2843 wxPaletteChangedEvent
vEvent(GetId());
2845 vEvent
.SetEventObject(this);
2846 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
2848 return GetEventHandler()->ProcessEvent(vEvent
);
2849 } // end of wxWindow::HandlePaletteChanged
2851 bool wxWindow::HandlePresParamChanged(
2856 // TODO: Once again I'll do something here when I need it
2858 //wxQueryNewPaletteEvent event(GetId());
2859 //event.SetEventObject(this);
2860 // if the background is erased
2861 // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
2863 return FALSE
; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
2867 // Responds to colour changes: passes event on to children.
2869 void wxWindow::OnSysColourChanged(
2870 wxSysColourChangedEvent
& rEvent
2873 wxNode
* pNode
= GetChildren().First();
2878 // Only propagate to non-top-level windows
2880 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
2882 if (pWin
->GetParent())
2884 wxSysColourChangedEvent vEvent
;
2886 rEvent
.m_eventObject
= pWin
;
2887 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
2889 pNode
= pNode
->Next();
2891 } // end of wxWindow::OnSysColourChanged
2893 // ---------------------------------------------------------------------------
2895 // ---------------------------------------------------------------------------
2897 bool wxWindow::HandlePaint()
2899 HRGN hRgn
= NULLHANDLE
;
2900 wxPaintEvent vEvent
;
2904 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_NULL
)
2906 wxLogLastError("CreateRectRgn");
2910 m_updateRegion
= wxRegion(hRgn
);
2911 vEvent
.SetEventObject(this);
2912 if (!GetEventHandler()->ProcessEvent(vEvent
))
2916 hPS
= ::WinBeginPaint( GetHwnd()
2922 ::GpiCreateLogColorTable( hPS
2926 ,(LONG
)wxTheColourDatabase
->m_nSize
2927 ,(PLONG
)wxTheColourDatabase
->m_palTable
2929 ::GpiCreateLogColorTable( hPS
2937 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
2941 return (GetEventHandler()->ProcessEvent(vEvent
));
2942 } // end of wxWindow::HandlePaint
2944 bool wxWindow::HandleEraseBkgnd(
2950 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
2951 if (vSwp
.fl
& SWP_MINIMIZE
)
2956 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
2957 vDC
.SetWindow(this);
2960 wxEraseEvent
vEvent(m_windowId
, &vDC
);
2962 vEvent
.SetEventObject(this);
2964 bool rc
= GetEventHandler()->ProcessEvent(vEvent
);
2967 vDC
.m_hPS
= NULLHANDLE
;
2969 } // end of wxWindow::HandleEraseBkgnd
2971 void wxWindow::OnEraseBackground(
2972 wxEraseEvent
& rEvent
2976 HPS hPS
= rEvent
.m_dc
->m_hPS
;
2978 ::WinQueryWindowRect(GetHwnd(), &vRect
);
2979 ::WinFillRect(hPS
, &vRect
, m_backgroundColour
.GetPixel());
2980 } // end of wxWindow::OnEraseBackground
2982 // ---------------------------------------------------------------------------
2983 // moving and resizing
2984 // ---------------------------------------------------------------------------
2986 bool wxWindow::HandleMinimize()
2988 wxIconizeEvent
vEvent(m_windowId
);
2990 vEvent
.SetEventObject(this);
2991 return GetEventHandler()->ProcessEvent(vEvent
);
2992 } // end of wxWindow::HandleMinimize
2994 bool wxWindow::HandleMaximize()
2996 wxMaximizeEvent
vEvent(m_windowId
);
2998 vEvent
.SetEventObject(this);
2999 return GetEventHandler()->ProcessEvent(vEvent
);
3000 } // end of wxWindow::HandleMaximize
3002 bool wxWindow::HandleMove(
3007 wxMoveEvent
vEvent( wxPoint( nX
3013 vEvent
.SetEventObject(this);
3014 return GetEventHandler()->ProcessEvent(vEvent
);
3015 } // end of wxWindow::HandleMove
3017 bool wxWindow::HandleSize(
3020 , WXUINT
WXUNUSED(nFlag
)
3023 wxSizeEvent
vEvent( wxSize( nWidth
3029 vEvent
.SetEventObject(this);
3030 return GetEventHandler()->ProcessEvent(vEvent
);
3031 } // end of wxWindow::HandleSize
3033 bool wxWindow::HandleGetMinMaxInfo(
3043 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3044 m_maxWidth
= pSwp
->cx
;
3045 m_maxHeight
= pSwp
->cy
;
3049 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3050 m_minWidth
= pSwp
->cx
;
3051 m_minHeight
= pSwp
->cy
;
3058 } // end of wxWindow::HandleGetMinMaxInfo
3060 // ---------------------------------------------------------------------------
3062 // ---------------------------------------------------------------------------
3063 bool wxWindow::HandleCommand(
3069 if (wxCurrentPopupMenu
)
3071 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3073 wxCurrentPopupMenu
= NULL
;
3074 return pPopupMenu
->OS2Command(wCmd
, wId
);
3077 wxWindow
* pWin
= FindItem(wId
);
3081 pWin
= wxFindWinFromHandle(hControl
);
3085 return pWin
->OS2Command( wCmd
3089 } // end of wxWindow::HandleCommand
3091 bool wxWindow::HandleSysCommand(
3097 // 4 bits are reserved
3099 switch (SHORT1FROMMP(wParam
))
3102 return HandleMaximize();
3105 return HandleMinimize();
3108 } // end of wxWindow::HandleSysCommand
3110 // ---------------------------------------------------------------------------
3112 // ---------------------------------------------------------------------------
3114 void wxWindow::InitMouseEvent(
3115 wxMouseEvent
& rEvent
3123 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
3124 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
3125 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
3126 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
3127 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
3128 rEvent
.SetTimestamp(s_currentMsg
.time
);
3129 rEvent
.m_eventObject
= this;
3131 #if wxUSE_MOUSEEVENT_HACK
3134 m_lastMouseEvent
= rEvent
.GetEventType();
3135 #endif // wxUSE_MOUSEEVENT_HACK
3136 } // end of wxWindow::InitMouseEvent
3138 bool wxWindow::HandleMouseEvent(
3146 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3147 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3148 // from the message id and take the value in the table to get wxWin event
3151 static const wxEventType eventsMouse
[] =
3165 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3167 InitMouseEvent( vEvent
3173 return GetEventHandler()->ProcessEvent(vEvent
);
3174 } // end of wxWindow::HandleMouseEvent
3176 bool wxWindow::HandleMouseMove(
3182 if (!m_bMouseInWindow
)
3185 // Generate an ENTER event
3187 m_bMouseInWindow
= TRUE
;
3189 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3191 InitMouseEvent( vEvent
3197 (void)GetEventHandler()->ProcessEvent(vEvent
);
3199 return HandleMouseEvent( WM_MOUSEMOVE
3204 } // end of wxWindow::HandleMouseMove
3206 // ---------------------------------------------------------------------------
3207 // keyboard handling
3208 // ---------------------------------------------------------------------------
3211 // Create the key event of the given type for the given key - used by
3212 // HandleChar and HandleKeyDown/Up
3214 wxKeyEvent
wxWindow::CreateKeyEvent(
3220 wxKeyEvent
vEvent(eType
);
3222 vEvent
.SetId(GetId());
3223 vEvent
.m_shiftDown
= IsShiftDown();
3224 vEvent
.m_controlDown
= IsCtrlDown();
3225 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3227 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
3228 vEvent
.m_keyCode
= nId
;
3229 vEvent
.SetTimestamp(s_currentMsg
.time
);
3232 // Translate the position to client coords
3237 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3238 ::WinQueryWindowRect( GetHwnd()
3242 vPoint
.x
-= vRect
.xLeft
;
3243 vPoint
.y
-= vRect
.yBottom
;
3245 vEvent
.m_x
= vPoint
.x
;
3246 vEvent
.m_y
= vPoint
.y
;
3249 } // end of wxWindow::CreateKeyEvent
3252 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3255 bool wxWindow::HandleChar(
3261 bool bCtrlDown
= FALSE
;
3267 // If 1 -> 26, translate to CTRL plus a letter.
3270 if ((vId
> 0) && (vId
< 27))
3292 else if ( (vId
= wxCharCodeOS2ToWX(wParam
)) == 0)
3295 // It's ASCII and will be processed here only when called from
3296 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3303 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
3310 vEvent
.m_controlDown
= TRUE
;
3313 if (GetEventHandler()->ProcessEvent(vEvent
))
3319 bool wxWindow::HandleKeyDown(
3324 int nId
= wxCharCodeOS2ToWX(wParam
);
3329 // Normal ASCII char
3336 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3341 if (GetEventHandler()->ProcessEvent(vEvent
))
3347 } // end of wxWindow::HandleKeyDown
3349 bool wxWindow::HandleKeyUp(
3354 int nId
= wxCharCodeOS2ToWX(wParam
);
3359 // Normal ASCII char
3366 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
3371 if (GetEventHandler()->ProcessEvent(vEvent
))
3375 } // end of wxWindow::HandleKeyUp
3377 // ---------------------------------------------------------------------------
3379 // ---------------------------------------------------------------------------
3381 // ---------------------------------------------------------------------------
3383 // ---------------------------------------------------------------------------
3385 bool wxWindow::OS2OnScroll(
3394 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
3397 return pChild
->OS2OnScroll( nOrientation
3404 wxScrollWinEvent vEvent
;
3406 vEvent
.SetPosition(wPos
);
3407 vEvent
.SetOrientation(nOrientation
);
3408 vEvent
.m_eventObject
= this;
3413 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
3417 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
3421 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
3425 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
3428 case SB_SLIDERPOSITION
:
3429 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
3432 case SB_SLIDERTRACK
:
3433 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
3439 return GetEventHandler()->ProcessEvent(vEvent
);
3440 } // end of wxWindow::OS2OnScroll
3442 // ===========================================================================
3444 // ===========================================================================
3453 // TODO: we'll do this later
3454 } // end of wxGetCharSize
3457 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
3458 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3460 int wxCharCodeOS2ToWX(
3468 case VK_BACKTAB
: nId
= WXK_BACK
; break;
3469 case VK_TAB
: nId
= WXK_TAB
; break;
3470 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
3471 case VK_ENTER
: nId
= WXK_RETURN
; break;
3472 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
3473 case VK_CTRL
: nId
= WXK_CONTROL
; break;
3474 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
3475 case VK_SPACE
: nId
= WXK_SPACE
; break;
3476 case VK_ESC
: nId
= WXK_ESCAPE
; break;
3477 case VK_END
: nId
= WXK_END
; break;
3478 case VK_HOME
: nId
= WXK_HOME
; break;
3479 case VK_LEFT
: nId
= WXK_LEFT
; break;
3480 case VK_UP
: nId
= WXK_UP
; break;
3481 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
3482 case VK_DOWN
: nId
= WXK_DOWN
; break;
3483 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
3484 case VK_INSERT
: nId
= WXK_INSERT
; break;
3485 case VK_DELETE
: nId
= WXK_DELETE
; break;
3486 case VK_F1
: nId
= WXK_F1
; break;
3487 case VK_F2
: nId
= WXK_F2
; break;
3488 case VK_F3
: nId
= WXK_F3
; break;
3489 case VK_F4
: nId
= WXK_F4
; break;
3490 case VK_F5
: nId
= WXK_F5
; break;
3491 case VK_F6
: nId
= WXK_F6
; break;
3492 case VK_F7
: nId
= WXK_F7
; break;
3493 case VK_F8
: nId
= WXK_F8
; break;
3494 case VK_F9
: nId
= WXK_F9
; break;
3495 case VK_F10
: nId
= WXK_F10
; break;
3496 case VK_F11
: nId
= WXK_F11
; break;
3497 case VK_F12
: nId
= WXK_F12
; break;
3498 case VK_F13
: nId
= WXK_F13
; break;
3499 case VK_F14
: nId
= WXK_F14
; break;
3500 case VK_F15
: nId
= WXK_F15
; break;
3501 case VK_F16
: nId
= WXK_F16
; break;
3502 case VK_F17
: nId
= WXK_F17
; break;
3503 case VK_F18
: nId
= WXK_F18
; break;
3504 case VK_F19
: nId
= WXK_F19
; break;
3505 case VK_F20
: nId
= WXK_F20
; break;
3506 case VK_F21
: nId
= WXK_F21
; break;
3507 case VK_F22
: nId
= WXK_F22
; break;
3508 case VK_F23
: nId
= WXK_F23
; break;
3509 case VK_F24
: nId
= WXK_F24
; break;
3510 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
3511 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
3518 } // end of wxCharCodeOS2ToWX
3520 int wxCharCodeWXToOS2(
3530 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
3531 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
3532 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
3533 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
3534 case WXK_END
: nKeySym
= VK_END
; break;
3535 case WXK_HOME
: nKeySym
= VK_HOME
; break;
3536 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
3537 case WXK_UP
: nKeySym
= VK_UP
; break;
3538 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
3539 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
3540 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
3541 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
3542 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
3543 case WXK_F1
: nKeySym
= VK_F1
; break;
3544 case WXK_F2
: nKeySym
= VK_F2
; break;
3545 case WXK_F3
: nKeySym
= VK_F3
; break;
3546 case WXK_F4
: nKeySym
= VK_F4
; break;
3547 case WXK_F5
: nKeySym
= VK_F5
; break;
3548 case WXK_F6
: nKeySym
= VK_F6
; break;
3549 case WXK_F7
: nKeySym
= VK_F7
; break;
3550 case WXK_F8
: nKeySym
= VK_F8
; break;
3551 case WXK_F9
: nKeySym
= VK_F9
; break;
3552 case WXK_F10
: nKeySym
= VK_F10
; break;
3553 case WXK_F11
: nKeySym
= VK_F11
; break;
3554 case WXK_F12
: nKeySym
= VK_F12
; break;
3555 case WXK_F13
: nKeySym
= VK_F13
; break;
3556 case WXK_F14
: nKeySym
= VK_F14
; break;
3557 case WXK_F15
: nKeySym
= VK_F15
; break;
3558 case WXK_F16
: nKeySym
= VK_F16
; break;
3559 case WXK_F17
: nKeySym
= VK_F17
; break;
3560 case WXK_F18
: nKeySym
= VK_F18
; break;
3561 case WXK_F19
: nKeySym
= VK_F19
; break;
3562 case WXK_F20
: nKeySym
= VK_F20
; break;
3563 case WXK_F21
: nKeySym
= VK_F21
; break;
3564 case WXK_F22
: nKeySym
= VK_F22
; break;
3565 case WXK_F23
: nKeySym
= VK_F23
; break;
3566 case WXK_F24
: nKeySym
= VK_F24
; break;
3567 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
3568 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
3571 *bIsVirtual
= FALSE
;
3577 } // end of wxCharCodeWXToOS2
3579 wxWindow
* wxGetActiveWindow()
3581 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
3585 return wxFindWinFromHandle((WXHWND
)hWnd
);
3588 } // end of wxGetActiveWindow
3591 const char* wxGetMessageName(
3596 case 0x0000: return "WM_NULL";
3597 case 0x0001: return "WM_CREATE";
3598 case 0x0002: return "WM_DESTROY";
3599 case 0x0004: return "WM_ENABLE";
3600 case 0x0005: return "WM_SHOW";
3601 case 0x0006: return "WM_MOVE";
3602 case 0x0007: return "WM_SIZE";
3603 case 0x0008: return "WM_ADJUSTWINDOWPOS";
3604 case 0x0009: return "WM_CALCVALIDRECTS";
3605 case 0x000A: return "WM_SETWINDOWPARAMS";
3606 case 0x000B: return "WM_QUERYWINDOWPARAMS";
3607 case 0x000C: return "WM_HITTEST";
3608 case 0x000D: return "WM_ACTIVATE";
3609 case 0x000F: return "WM_SETFOCUS";
3610 case 0x0010: return "WM_SETSELECTION";
3611 case 0x0011: return "WM_PPAINT";
3612 case 0x0012: return "WM_PSETFOCUS";
3613 case 0x0013: return "WM_PSYSCOLORCHANGE";
3614 case 0x0014: return "WM_PSIZE";
3615 case 0x0015: return "WM_PACTIVATE";
3616 case 0x0016: return "WM_PCONTROL";
3617 case 0x0020: return "WM_COMMAND";
3618 case 0x0021: return "WM_SYSCOMMAND";
3619 case 0x0022: return "WM_HELP";
3620 case 0x0023: return "WM_PAINT";
3621 case 0x0024: return "WM_TIMER";
3622 case 0x0025: return "WM_SEM1";
3623 case 0x0026: return "WM_SEM2";
3624 case 0x0027: return "WM_SEM3";
3625 case 0x0028: return "WM_SEM4";
3626 case 0x0029: return "WM_CLOSE";
3627 case 0x002A: return "WM_QUIT";
3628 case 0x002B: return "WM_SYSCOLORCHANGE";
3629 case 0x002D: return "WM_SYSVALUECHANGE";
3630 case 0x002E: return "WM_APPTERMINATENOTIFY";
3631 case 0x002F: return "WM_PRESPARAMCHANGED";
3632 // Control notification messages
3633 case 0x0030: return "WM_CONTROL";
3634 case 0x0031: return "WM_VSCROLL";
3635 case 0x0032: return "WM_HSCROLL";
3636 case 0x0033: return "WM_INITMENU";
3637 case 0x0034: return "WM_MENUSELECT";
3638 case 0x0035: return "WM_MENUSEND";
3639 case 0x0036: return "WM_DRAWITEM";
3640 case 0x0037: return "WM_MEASUREITEM";
3641 case 0x0038: return "WM_CONTROLPOINTER";
3642 case 0x003A: return "WM_QUERYDLGCODE";
3643 case 0x003B: return "WM_INITDLG";
3644 case 0x003C: return "WM_SUBSTITUTESTRING";
3645 case 0x003D: return "WM_MATCHMNEMONIC";
3646 case 0x003E: return "WM_SAVEAPPLICATION";
3647 case 0x0129: return "WM_CTLCOLORCHANGE";
3648 case 0x0130: return "WM_QUERYCTLTYPE";
3650 case 0x0040: return "WM_FLASHWINDOW";
3651 case 0x0041: return "WM_FORMATFRAME";
3652 case 0x0042: return "WM_UPDATEFRAME";
3653 case 0x0043: return "WM_FOCUSCHANGE";
3654 case 0x0044: return "WM_SETBORDERSIZE";
3655 case 0x0045: return "WM_TRACKFRAME";
3656 case 0x0046: return "WM_MINMAXFRAME";
3657 case 0x0047: return "WM_SETICON";
3658 case 0x0048: return "WM_QUERYICON";
3659 case 0x0049: return "WM_SETACCELTABLE";
3660 case 0x004A: return "WM_QUERYACCELTABLE";
3661 case 0x004B: return "WM_TRANSLATEACCEL";
3662 case 0x004C: return "WM_QUERYTRACKINFO";
3663 case 0x004D: return "WM_QUERYBORDERSIZE";
3664 case 0x004E: return "WM_NEXTMENU";
3665 case 0x004F: return "WM_ERASEBACKGROUND";
3666 case 0x0050: return "WM_QUERYFRAMEINFO";
3667 case 0x0051: return "WM_QUERYFOCUSCHAIN";
3668 case 0x0052: return "WM_OWNERPOSCHANGE";
3669 case 0x0053: return "WM_CACLFRAMERECT";
3670 case 0x0055: return "WM_WINDOWPOSCHANGED";
3671 case 0x0056: return "WM_ADJUSTFRAMEPOS";
3672 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
3673 case 0x005B: return "WM_QUERYHELPINFO";
3674 case 0x005C: return "WM_SETHELPINFO";
3675 case 0x005D: return "WM_ERROR";
3676 case 0x005E: return "WM_REALIZEPALETTE";
3677 // Clipboard messages
3678 case 0x0060: return "WM_RENDERFMT";
3679 case 0x0061: return "WM_RENDERALLFMTS";
3680 case 0x0062: return "WM_DESTROYCLIPBOARD";
3681 case 0x0063: return "WM_PAINTCLIPBOARD";
3682 case 0x0064: return "WM_SIZECLIPBOARD";
3683 case 0x0065: return "WM_HSCROLLCLIPBOARD";
3684 case 0x0066: return "WM_VSCROLLCLIPBOARD";
3685 case 0x0067: return "WM_DRAWCLIPBOARD";
3687 case 0x0070: return "WM_MOUSEMOVE";
3688 case 0x0071: return "WM_BUTTON1DOWN";
3689 case 0x0072: return "WM_BUTTON1UP";
3690 case 0x0073: return "WM_BUTTON1DBLCLK";
3691 case 0x0074: return "WM_BUTTON2DOWN";
3692 case 0x0075: return "WM_BUTTON2UP";
3693 case 0x0076: return "WM_BUTTON2DBLCLK";
3694 case 0x0077: return "WM_BUTTON3DOWN";
3695 case 0x0078: return "WM_BUTTON3UP";
3696 case 0x0079: return "WM_BUTTON3DBLCLK";
3697 case 0x007D: return "WM_MOUSEMAP";
3698 case 0x007E: return "WM_VRNDISABLED";
3699 case 0x007F: return "WM_VRNENABLED";
3700 case 0x0410: return "WM_CHORD";
3701 case 0x0411: return "WM_BUTTON1MOTIONSTART";
3702 case 0x0412: return "WM_BUTTON1MOTIONEND";
3703 case 0x0413: return "WM_BUTTON1CLICK";
3704 case 0x0414: return "WM_BUTTON2MOTIONSTART";
3705 case 0x0415: return "WM_BUTTON2MOTIONEND";
3706 case 0x0416: return "WM_BUTTON2CLICK";
3707 case 0x0417: return "WM_BUTTON3MOTIONSTART";
3708 case 0x0418: return "WM_BUTTON3MOTIONEND";
3709 case 0x0419: return "WM_BUTTON3CLICK";
3710 case 0x0420: return "WM_BEGINDRAG";
3711 case 0x0421: return "WM_ENDDRAG";
3712 case 0x0422: return "WM_SINGLESELECT";
3713 case 0x0423: return "WM_OPEN";
3714 case 0x0424: return "WM_CONTEXTMENU";
3715 case 0x0425: return "WM_CONTEXTHELP";
3716 case 0x0426: return "WM_TEXTEDIT";
3717 case 0x0427: return "WM_BEGINSELECT";
3718 case 0x0228: return "WM_ENDSELECT";
3719 case 0x0429: return "WM_PICKUP";
3720 case 0x04C0: return "WM_PENFIRST";
3721 case 0x04FF: return "WM_PENLAST";
3722 case 0x0500: return "WM_MMPMFIRST";
3723 case 0x05FF: return "WM_MMPMLAST";
3724 case 0x0600: return "WM_STDDLGFIRST";
3725 case 0x06FF: return "WM_STDDLGLAST";
3726 case 0x0BD0: return "WM_BIDI_FIRST";
3727 case 0x0BFF: return "WM_BIDI_LAST";
3729 case 0x007A: return "WM_CHAR";
3730 case 0x007B: return "WM_VIOCHAR";
3732 case 0x00A0: return "WM_DDE_INITIATE";
3733 case 0x00A1: return "WM_DDE_REQUEST";
3734 case 0x00A2: return "WM_DDE_ACK";
3735 case 0x00A3: return "WM_DDE_DATA";
3736 case 0x00A4: return "WM_DDE_ADVISE";
3737 case 0x00A5: return "WM_DDE_UNADVISE";
3738 case 0x00A6: return "WM_DDE_POKE";
3739 case 0x00A7: return "WM_DDE_EXECUTE";
3740 case 0x00A8: return "WM_DDE_TERMINATE";
3741 case 0x00A9: return "WM_DDE_INITIATEACK";
3742 case 0x00AF: return "WM_DDE_LAST";
3744 case 0x0120: return "BM_CLICK";
3745 case 0x0121: return "BM_QUERYCHECKINDEX";
3746 case 0x0122: return "BM_QUERYHILITE";
3747 case 0x0123: return "BM_SETHILITE";
3748 case 0x0124: return "BM_QUERYCHECK";
3749 case 0x0125: return "BM_SETCHECK";
3750 case 0x0126: return "BM_SETDEFAULT";
3751 case 0x0128: return "BM_AUTOSIZE";
3753 case 0x029A: return "CBID_LIST";
3754 case 0x029B: return "CBID_EDIT";
3755 case 0x0170: return "CBM_SHOWLIST";
3756 case 0x0171: return "CBM_HILITE";
3757 case 0x0172: return "CBM_ISLISTSHOWING";
3759 case 0x0140: return "EM_QUERYCHANGED";
3760 case 0x0141: return "EM_QUERYSEL";
3761 case 0x0142: return "EM_SETSEL";
3762 case 0x0143: return "EM_SETTEXTLIMIT";
3763 case 0x0144: return "EM_CUT";
3764 case 0x0145: return "EM_COPY";
3765 case 0x0146: return "EM_CLEAR";
3766 case 0x0147: return "EM_PASTE";
3767 case 0x0148: return "EM_QUERYFIRSTCHAR";
3768 case 0x0149: return "EM_SETFIRSTCHAR";
3769 case 0x014A: return "EM_QUERYREADONLY";
3770 case 0x014B: return "EM_SETREADONLY";
3771 case 0x014C: return "EM_SETINSERTMODE";
3773 case 0x0160: return "LM_QUERYITEMCOUNT";
3774 case 0x0161: return "LM_INSERTITEM";
3775 case 0x0162: return "LM_SETOPENINDEX";
3776 case 0x0163: return "LM_DELETEITEM";
3777 case 0x0164: return "LM_SELECTITEM";
3778 case 0x0165: return "LM_QUERYSELECTION";
3779 case 0x0166: return "LM_SETITEMTEXT";
3780 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
3781 case 0x0168: return "LM_QUERYITEMTEXT";
3782 case 0x0169: return "LM_SETITEMHANDLE";
3783 case 0x016A: return "LM_QUERYITEMHANDLE";
3784 case 0x016B: return "LM_SEARCHSTRING";
3785 case 0x016C: return "LM_SETITEMHEIGHT";
3786 case 0x016D: return "LM_QUERYTOPINDEX";
3787 case 0x016E: return "LM_DELETEALL";
3788 case 0x016F: return "LM_INSERTMULITEMS";
3789 case 0x0660: return "LM_SETITEMWIDTH";
3791 case 0x0180: return "MM_INSERTITEM";
3792 case 0x0181: return "MM_DELETEITEM";
3793 case 0x0182: return "MM_QUERYITEM";
3794 case 0x0183: return "MM_SETITEM";
3795 case 0x0184: return "MM_QUERYITEMCOUNT";
3796 case 0x0185: return "MM_STARTMENUMODE";
3797 case 0x0186: return "MM_ENDMENUMODE";
3798 case 0x0188: return "MM_REMOVEITEM";
3799 case 0x0189: return "MM_SELECTITEM";
3800 case 0x018A: return "MM_QUERYSELITEMID";
3801 case 0x018B: return "MM_QUERYITEMTEXT";
3802 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
3803 case 0x018D: return "MM_SETITEMHANDLE";
3804 case 0x018E: return "MM_SETITEMTEXT";
3805 case 0x018F: return "MM_ITEMPOSITIONFROMID";
3806 case 0x0190: return "MM_ITEMIDFROMPOSITION";
3807 case 0x0191: return "MM_QUERYITEMATTR";
3808 case 0x0192: return "MM_SETITEMATTR";
3809 case 0x0193: return "MM_ISITEMVALID";
3810 case 0x0194: return "MM_QUERYITEMRECT";
3811 case 0x0431: return "MM_QUERYDEFAULTITEMID";
3812 case 0x0432: return "MM_SETDEFAULTITEMID";
3814 case 0x01A0: return "SBM_SETSCROLLBAR";
3815 case 0x01A1: return "SBM_SETPOS";
3816 case 0x01A2: return "SBM_QUERYPOS";
3817 case 0x01A3: return "SBM_QUERYRANGE";
3818 case 0x01A6: return "SBM_SETTHUMBSIZE";
3821 case 0x0F00: return "WM_HELPBASE";
3822 case 0x0FFF: return "WM_HELPTOP";
3823 // Beginning of user defined messages
3824 case 0x1000: return "WM_USER";
3826 // wxWindows user defined types
3829 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
3830 case 0x1000 + 1: return "LVM_SETBKCOLOR";
3831 case 0x1000 + 2: return "LVM_GETIMAGELIST";
3832 case 0x1000 + 3: return "LVM_SETIMAGELIST";
3833 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
3834 case 0x1000 + 5: return "LVM_GETITEMA";
3835 case 0x1000 + 75: return "LVM_GETITEMW";
3836 case 0x1000 + 6: return "LVM_SETITEMA";
3837 case 0x1000 + 76: return "LVM_SETITEMW";
3838 case 0x1000 + 7: return "LVM_INSERTITEMA";
3839 case 0x1000 + 77: return "LVM_INSERTITEMW";
3840 case 0x1000 + 8: return "LVM_DELETEITEM";
3841 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
3842 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
3843 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
3844 case 0x1000 + 12: return "LVM_GETNEXTITEM";
3845 case 0x1000 + 13: return "LVM_FINDITEMA";
3846 case 0x1000 + 83: return "LVM_FINDITEMW";
3847 case 0x1000 + 14: return "LVM_GETITEMRECT";
3848 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
3849 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
3850 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
3851 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
3852 case 0x1000 + 18: return "LVM_HITTEST";
3853 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
3854 case 0x1000 + 20: return "LVM_SCROLL";
3855 case 0x1000 + 21: return "LVM_REDRAWITEMS";
3856 case 0x1000 + 22: return "LVM_ARRANGE";
3857 case 0x1000 + 23: return "LVM_EDITLABELA";
3858 case 0x1000 + 118: return "LVM_EDITLABELW";
3859 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
3860 case 0x1000 + 25: return "LVM_GETCOLUMNA";
3861 case 0x1000 + 95: return "LVM_GETCOLUMNW";
3862 case 0x1000 + 26: return "LVM_SETCOLUMNA";
3863 case 0x1000 + 96: return "LVM_SETCOLUMNW";
3864 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
3865 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
3866 case 0x1000 + 28: return "LVM_DELETECOLUMN";
3867 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
3868 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
3869 case 0x1000 + 31: return "LVM_GETHEADER";
3870 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
3871 case 0x1000 + 34: return "LVM_GETVIEWRECT";
3872 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
3873 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
3874 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
3875 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
3876 case 0x1000 + 39: return "LVM_GETTOPINDEX";
3877 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
3878 case 0x1000 + 41: return "LVM_GETORIGIN";
3879 case 0x1000 + 42: return "LVM_UPDATE";
3880 case 0x1000 + 43: return "LVM_SETITEMSTATE";
3881 case 0x1000 + 44: return "LVM_GETITEMSTATE";
3882 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
3883 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
3884 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
3885 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
3886 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
3887 case 0x1000 + 48: return "LVM_SORTITEMS";
3888 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
3889 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
3890 case 0x1000 + 51: return "LVM_GETITEMSPACING";
3891 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
3892 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
3893 case 0x1000 + 53: return "LVM_SETICONSPACING";
3894 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
3895 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
3896 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
3897 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
3898 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
3899 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
3900 case 0x1000 + 60: return "LVM_SETHOTITEM";
3901 case 0x1000 + 61: return "LVM_GETHOTITEM";
3902 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
3903 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
3904 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
3905 case 0x1000 + 65: return "LVM_SETWORKAREA";
3908 case 0x1100 + 0: return "TVM_INSERTITEMA";
3909 case 0x1100 + 50: return "TVM_INSERTITEMW";
3910 case 0x1100 + 1: return "TVM_DELETEITEM";
3911 case 0x1100 + 2: return "TVM_EXPAND";
3912 case 0x1100 + 4: return "TVM_GETITEMRECT";
3913 case 0x1100 + 5: return "TVM_GETCOUNT";
3914 case 0x1100 + 6: return "TVM_GETINDENT";
3915 case 0x1100 + 7: return "TVM_SETINDENT";
3916 case 0x1100 + 8: return "TVM_GETIMAGELIST";
3917 case 0x1100 + 9: return "TVM_SETIMAGELIST";
3918 case 0x1100 + 10: return "TVM_GETNEXTITEM";
3919 case 0x1100 + 11: return "TVM_SELECTITEM";
3920 case 0x1100 + 12: return "TVM_GETITEMA";
3921 case 0x1100 + 62: return "TVM_GETITEMW";
3922 case 0x1100 + 13: return "TVM_SETITEMA";
3923 case 0x1100 + 63: return "TVM_SETITEMW";
3924 case 0x1100 + 14: return "TVM_EDITLABELA";
3925 case 0x1100 + 65: return "TVM_EDITLABELW";
3926 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
3927 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
3928 case 0x1100 + 17: return "TVM_HITTEST";
3929 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
3930 case 0x1100 + 19: return "TVM_SORTCHILDREN";
3931 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
3932 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
3933 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
3934 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
3935 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
3936 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
3937 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
3940 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
3941 case 0x1200 + 1: return "HDM_INSERTITEMA";
3942 case 0x1200 + 10: return "HDM_INSERTITEMW";
3943 case 0x1200 + 2: return "HDM_DELETEITEM";
3944 case 0x1200 + 3: return "HDM_GETITEMA";
3945 case 0x1200 + 11: return "HDM_GETITEMW";
3946 case 0x1200 + 4: return "HDM_SETITEMA";
3947 case 0x1200 + 12: return "HDM_SETITEMW";
3948 case 0x1200 + 5: return "HDM_LAYOUT";
3949 case 0x1200 + 6: return "HDM_HITTEST";
3950 case 0x1200 + 7: return "HDM_GETITEMRECT";
3951 case 0x1200 + 8: return "HDM_SETIMAGELIST";
3952 case 0x1200 + 9: return "HDM_GETIMAGELIST";
3953 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
3954 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
3955 case 0x1200 + 17: return "HDM_GETORDERARRAY";
3956 case 0x1200 + 18: return "HDM_SETORDERARRAY";
3957 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
3960 case 0x1300 + 2: return "TCM_GETIMAGELIST";
3961 case 0x1300 + 3: return "TCM_SETIMAGELIST";
3962 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
3963 case 0x1300 + 5: return "TCM_GETITEMA";
3964 case 0x1300 + 60: return "TCM_GETITEMW";
3965 case 0x1300 + 6: return "TCM_SETITEMA";
3966 case 0x1300 + 61: return "TCM_SETITEMW";
3967 case 0x1300 + 7: return "TCM_INSERTITEMA";
3968 case 0x1300 + 62: return "TCM_INSERTITEMW";
3969 case 0x1300 + 8: return "TCM_DELETEITEM";
3970 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
3971 case 0x1300 + 10: return "TCM_GETITEMRECT";
3972 case 0x1300 + 11: return "TCM_GETCURSEL";
3973 case 0x1300 + 12: return "TCM_SETCURSEL";
3974 case 0x1300 + 13: return "TCM_HITTEST";
3975 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
3976 case 0x1300 + 40: return "TCM_ADJUSTRECT";
3977 case 0x1300 + 41: return "TCM_SETITEMSIZE";
3978 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
3979 case 0x1300 + 43: return "TCM_SETPADDING";
3980 case 0x1300 + 44: return "TCM_GETROWCOUNT";
3981 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
3982 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
3983 case 0x1300 + 47: return "TCM_GETCURFOCUS";
3984 case 0x1300 + 48: return "TCM_SETCURFOCUS";
3985 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
3986 case 0x1300 + 50: return "TCM_DESELECTALL";
3989 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
3990 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
3991 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
3992 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
3993 case WM_USER
+1000+5: return "TB_INDETERMINATE";
3994 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
3995 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
3996 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
3997 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
3998 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
3999 case WM_USER
+1000+17: return "TB_SETSTATE";
4000 case WM_USER
+1000+18: return "TB_GETSTATE";
4001 case WM_USER
+1000+19: return "TB_ADDBITMAP";
4002 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
4003 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
4004 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
4005 case WM_USER
+1000+23: return "TB_GETBUTTON";
4006 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
4007 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
4008 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
4009 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
4010 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
4011 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
4012 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
4013 case WM_USER
+1000+29: return "TB_GETITEMRECT";
4014 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
4015 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
4016 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
4017 case WM_USER
+1000+33: return "TB_AUTOSIZE";
4018 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
4019 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
4020 case WM_USER
+1000+37: return "TB_SETPARENT";
4021 case WM_USER
+1000+39: return "TB_SETROWS";
4022 case WM_USER
+1000+40: return "TB_GETROWS";
4023 case WM_USER
+1000+42: return "TB_SETCMDID";
4024 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
4025 case WM_USER
+1000+44: return "TB_GETBITMAP";
4026 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
4027 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
4028 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
4029 case WM_USER
+1000+47: return "TB_SETINDENT";
4030 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
4031 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
4032 case WM_USER
+1000+50: return "TB_LOADIMAGES";
4033 case WM_USER
+1000+51: return "TB_GETRECT";
4034 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
4035 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
4036 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
4037 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
4038 case WM_USER
+1000+56: return "TB_SETSTYLE";
4039 case WM_USER
+1000+57: return "TB_GETSTYLE";
4040 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
4041 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
4042 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
4043 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
4044 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
4047 static char s_szBuf
[128];
4048 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
4052 } // end of wxGetMessageName
4054 #endif // __WXDEBUG__
4056 static void TranslateKbdEventToMouse(
4064 // Construct the key mask
4065 ULONG
& fwKeys
= *pFlags
;
4067 fwKeys
= VK_BUTTON2
;
4068 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4070 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4074 // Simulate right mouse button click
4078 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4082 pWin
->ScreenToClient(pX
, pY
);
4083 } // end of TranslateKbdEventToMouse
4085 // Find the wxWindow at the current mouse position, returning the mouse
4087 wxWindow
* wxFindWindowAtPointer(
4091 return wxFindWindowAtPoint(wxGetMousePosition());
4094 wxWindow
* wxFindWindowAtPoint(
4103 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4104 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4105 HWND hWnd
= hWndHit
;
4108 // Try to find a window with a wxWindow associated with it
4110 while (!pWin
&& (hWnd
!= 0))
4112 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4113 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4118 // Get the current mouse position.
4119 wxPoint
wxGetMousePosition()
4123 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4124 return wxPoint(vPt
.x
, vPt
.y
);