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
;
278 m_hWndScrollBarHorz
= 0L;
279 m_hWndScrollBarVert
= 0L;
282 // Pass WM_GETDLGCODE to DefWindowProc()
287 m_bBackgroundTransparent
= FALSE
;
290 // As all windows are created with WS_VISIBLE style...
294 #if wxUSE_MOUSEEVENT_HACK
297 m_nLastMouseEvent
= -1;
298 #endif // wxUSE_MOUSEEVENT_HACK
304 wxWindow::~wxWindow()
306 m_isBeingDeleted
= TRUE
;
308 OS2DetachWindowMenu();
310 m_parent
->RemoveChild(this);
315 if(!::WinDestroyWindow(GetHWND()))
316 wxLogLastError(wxT("DestroyWindow"));
318 // remove hWnd <-> wxWindow association
320 wxRemoveHandleAssociation(this);
322 } // end of wxWindow::~wxWindow
324 bool wxWindow::Create(
327 , const wxPoint
& rPos
328 , const wxSize
& rSize
330 , const wxString
& rName
333 HWND hParent
= NULLHANDLE
;
334 wxPoint vPos
= rPos
; // The OS/2 position
336 wxCHECK_MSG(pParent
, FALSE
, wxT("can't create wxWindow without parent"));
338 if ( !CreateBase( pParent
352 pParent
->AddChild(this);
353 hParent
= GetWinHwnd(pParent
);
355 // OS2 uses normal coordinates, no bassackwards Windows ones
357 nTempy
= pParent
->GetSize().y
- (vPos
.y
+ rSize
.y
);
361 nTempy
= pParent
->GetSize().y
+ (vPos
.y
+ rSize
.y
);
362 pParent
->SetSize(0, 0, pParent
->GetSize().x
, nTempy
);
371 ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
);
372 hParent
= HWND_DESKTOP
;
373 vPos
.y
= vRect
.yTop
- (vPos
.y
+ rSize
.y
);
376 ULONG ulCreateFlags
= 0L;
380 // Most wxSTYLES are really PM Class specific styles and will be
381 // set in those class create procs. PM's basic windows styles are
384 ulCreateFlags
|= WS_VISIBLE
;
387 if ( lStyle
& wxCLIP_SIBLINGS
)
388 ulCreateFlags
|= WS_CLIPSIBLINGS
;
390 if (lStyle
& wxCLIP_CHILDREN
)
391 ulCreateFlags
|= WS_CLIPCHILDREN
;
394 // Empty stuff for now since PM has no custome 3D effects
395 // Doesn't mean someone cannot make some up though
398 WXDWORD dwExStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &bWant3D
);
401 // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
402 // and no presentation parameters
405 ,(PSZ
)wxCanvasClassName
410 ,WidthDefault(rSize
.x
)
411 ,HeightDefault(rSize
.y
)
418 } // end of wxWindow::Create
420 // ---------------------------------------------------------------------------
422 // ---------------------------------------------------------------------------
424 void wxWindow::SetFocus()
426 HWND hWnd
= GetHwnd();
429 ::WinSetFocus(HWND_DESKTOP
, hWnd
);
430 } // end of wxWindow::SetFocus
432 wxWindow
* wxWindowBase::FindFocus()
434 HWND hWnd
= ::WinQueryFocus(HWND_DESKTOP
);
438 return wxFindWinFromHandle((WXHWND
)hWnd
);
441 } // wxWindowBase::FindFocus
443 bool wxWindow::Enable(
447 if (!wxWindowBase::Enable(bEnable
))
450 HWND hWnd
= GetHwnd();
453 ::WinEnableWindow(hWnd
, (BOOL
)bEnable
);
455 wxWindowList::Node
* pNode
= GetChildren().GetFirst();
459 wxWindow
* pChild
= pNode
->GetData();
461 pChild
->Enable(bEnable
);
462 pNode
= pNode
->GetNext();
465 } // end of wxWindow::Enable
471 if (!wxWindowBase::Show(bShow
))
474 HWND hWnd
= GetHwnd();
476 ::WinShowWindow(hWnd
, bShow
);
480 ::WinSetWindowPos(hWnd
, HWND_TOP
, 0, 0, 0, 0, SWP_ACTIVATE
| SWP_ZORDER
);
483 } // end of wxWindow::Show
485 void wxWindow::Raise()
487 ::WinSetWindowPos(GetHwnd(), HWND_TOP
, 0, 0, 0, 0, SWP_ZORDER
| SWP_ACTIVATE
);
488 } // end of wxWindow::Raise
490 void wxWindow::Lower()
492 ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_ZORDER
| SWP_DEACTIVATE
);
493 } // end of wxWindow::Lower
495 void wxWindow::SetTitle(
496 const wxString
& rTitle
499 ::WinSetWindowText(GetHwnd(), rTitle
.c_str());
500 } // end of wxWindow::SetTitle
502 wxString
wxWindow::GetTitle() const
504 return wxGetWindowText(GetHWND());
505 } // end of wxWindow::GetTitle
507 void wxWindow::CaptureMouse()
509 HWND hWnd
= GetHwnd();
511 if (hWnd
&& !m_bWinCaptured
)
513 ::WinSetCapture(HWND_DESKTOP
, hWnd
);
514 m_bWinCaptured
= TRUE
;
516 } // end of wxWindow::GetTitle
518 void wxWindow::ReleaseMouse()
522 ::WinSetCapture(HWND_DESKTOP
, NULLHANDLE
);
523 m_bWinCaptured
= FALSE
;
525 } // end of wxWindow::ReleaseMouse
527 bool wxWindow::SetFont(
531 if (!wxWindowBase::SetFont(rFont
))
537 HWND hWnd
= GetHwnd();
543 sprintf(zFont
, "%d.%s", rFont
.GetPointSize(), rFont
.GetFaceName().c_str());
544 return(::WinSetPresParam(hWnd
, PP_FONTNAMESIZE
, strlen(zFont
), (PVOID
)zFont
));
549 bool wxWindow::SetCursor(
550 const wxCursor
& rCursor
551 ) // check if base implementation is OK
553 if ( !wxWindowBase::SetCursor(rCursor
))
559 wxASSERT_MSG( m_cursor
.Ok(),
560 wxT("cursor must be valid after call to the base version"));
562 HWND hWnd
= GetHwnd();
568 hPS
= ::WinGetPS(hWnd
);
570 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
571 ::WinQueryWindowRect(hWnd
, &vRect
);
573 hRGN
= ::GpiCreateRegion(hPS
, 1L, &vRect
);
575 if ((::GpiPtInRegion(hPS
, hRGN
, &vPoint
) == PRGN_INSIDE
) && !wxIsBusy())
577 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)m_cursor
.GetHCURSOR());
580 } // end of wxWindow::SetCursor
582 void wxWindow::WarpPointer(
591 ::WinQueryWindowRect(GetHwnd(), &vRect
);
595 ::WinSetPointerPos(HWND_DESKTOP
, (LONG
)nX
, (LONG
)(nY
));
596 } // end of wxWindow::WarpPointer
598 #if WXWIN_COMPATIBILITY
599 void wxWindow::OS2DeviceToLogical (float *x
, float *y
) const
602 #endif // WXWIN_COMPATIBILITY
604 // ---------------------------------------------------------------------------
606 // ---------------------------------------------------------------------------
608 #if WXWIN_COMPATIBILITY
609 void wxWindow::SetScrollRange(
615 int nRange1
= nRange
;
616 int nPageSize
= GetScrollPage(nOrient
);
618 if (nPpageSize
> 1 && nRange
> 0)
620 nRange1
+= (nPageSize
- 1);
623 if (nOrient
== wxHORIZONTAL
)
625 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
626 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
630 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)0, MPFROM2SHORT(0, (SHORT
)nRange1
));
631 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
633 } // end of wxWindow::SetScrollRange
635 void wxWindow::SetScrollPage(
641 if (nOrient
== wxHORIZONTAL
)
642 m_nXThumbSize
= nPage
;
644 m_nYThumbSize
= nPage
;
645 } // end of wxWindow::SetScrollPage
647 int wxWindow::OldGetScrollRange(
652 HWND hWnd
= GetHwnd();
656 mRc
= WinSendMsg(hWnd
, SBM_QUERYRANGE
, (MPARAM
)0L, (MPARAM
)0L);
657 return(SHORT2FROMMR(mRc
));
660 } // end of wxWindow::OldGetScrollRange
662 int wxWindow::GetScrollPage(
666 if (nOrient
== wxHORIZONTAL
)
667 return m_nXThumbSize
;
669 return m_nYThumbSize
;
670 } // end of wxWindow::GetScrollPage
671 #endif // WXWIN_COMPATIBILITY
673 int wxWindow::GetScrollPos(
677 if (nOrient
== wxHORIZONTAL
)
678 return((int)::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
680 return((int)::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYPOS
, (MPARAM
)NULL
, (MPARAM
)NULL
));
681 } // end of wxWindow::GetScrollPos
683 int wxWindow::GetScrollRange(
689 if (nOrient
== wxHORIZONTAL
)
690 mr
= ::WinSendMsg(m_hWndScrollBarHorz
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
692 mr
= ::WinSendMsg(m_hWndScrollBarVert
, SBM_QUERYRANGE
, (MPARAM
)NULL
, (MPARAM
)NULL
);
693 return((int)SHORT2FROMMR(mr
));
694 } // end of wxWindow::GetScrollRange
696 int wxWindow::GetScrollThumb(
700 if (nOrient
== wxHORIZONTAL
)
701 return m_nXThumbSize
;
703 return m_nYThumbSize
;
704 } // end of wxWindow::GetScrollThumb
706 void wxWindow::SetScrollPos(
712 if (nOrient
== wxHORIZONTAL
)
713 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
715 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETPOS
, (MPARAM
)nPos
, (MPARAM
)NULL
);
716 } // end of wxWindow::SetScrollPos(
718 void wxWindow::SetScrollbar(
726 int nOldRange
= nRange
- nThumbVisible
;
727 int nRange1
= nOldRange
;
728 int nPageSize
= nThumbVisible
;
730 HWND hWnd
= GetHwnd();
731 ULONG ulStyle
= WS_VISIBLE
;
734 ::WinQueryWindowRect(hWnd
, &vRect
);
735 if (nPageSize
> 1 && nRange
> 0)
737 nRange1
+= (nPageSize
- 1);
740 vInfo
.cb
= sizeof(SBCDATA
);
742 vInfo
.posLast
= (SHORT
)nRange1
;
743 vInfo
.posThumb
= nPos
;
745 if (nOrient
== wxHORIZONTAL
)
748 if (m_hWndScrollBarHorz
== 0L)
751 // We create the scrollbars with the desktop so that they are not
752 // registered as child windows of the window in order that child
753 // windows may be scrolled without scrolling the scrollbars themselves!
755 m_hWndScrollBarHorz
= ::WinCreateWindow( HWND_DESKTOP
761 ,vRect
.xRight
- vRect
.xLeft
775 // Only want to resize the scrollbar if it changes, otherwise
776 // we'd probably end up in a recursive loop until we crash the call stack
777 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
778 // generates those events.
780 ::WinQueryWindowRect(m_hWndScrollBarHorz
, &vRect2
);
781 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
782 vRect2
.xRight
== vRect
.xRight
&&
783 vRect2
.yBottom
== vRect
.yBottom
&&
784 vRect2
.yTop
== vRect
.yTop
787 ::WinSetWindowPos( m_hWndScrollBarHorz
791 ,vRect
.xRight
- vRect
.xLeft
793 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
796 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
797 ::WinSendMsg(m_hWndScrollBarHorz
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
803 if (m_hWndScrollBarVert
== 0L)
805 m_hWndScrollBarVert
= ::WinCreateWindow( HWND_DESKTOP
812 ,vRect
.yTop
- vRect
.yBottom
825 // Only want to resize the scrollbar if it changes, otherwise
826 // we'd probably end up in a recursive loop until we crash the call stack
827 // because this method is called in a ScrolledWindow OnSize event and SWP_MOVE | SWP_SIZE
828 // generates those events.
830 ::WinQueryWindowRect(m_hWndScrollBarVert
, &vRect2
);
831 if (!(vRect2
.xLeft
== vRect
.xLeft
&&
832 vRect2
.xRight
== vRect
.xRight
&&
833 vRect2
.yBottom
== vRect
.yBottom
&&
834 vRect2
.yTop
== vRect
.yTop
837 ::WinSetWindowPos( m_hWndScrollBarVert
842 ,vRect
.yTop
- vRect
.yBottom
843 ,SWP_ACTIVATE
| SWP_MOVE
| SWP_SIZE
| SWP_SHOW
846 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETSCROLLBAR
, (MPARAM
)nPos
, MPFROM2SHORT(0, (SHORT
)nRange1
));
847 ::WinSendMsg(m_hWndScrollBarVert
, SBM_SETTHUMBSIZE
, MPFROM2SHORT((SHORT
)nThumbVisible
, (SHORT
)nRange1
), (MPARAM
)0);
849 m_nYThumbSize
= nThumbVisible
;
851 } // end of wxWindow::SetScrollbar
853 void wxWindow::ScrollWindow(
856 , const wxRect
* pRect
862 nDy
*= -1; // flip the sign of Dy as OS/2 is opposite wxWin.
865 vRect2
.xLeft
= pRect
->x
;
866 vRect2
.yTop
= pRect
->y
+ pRect
->height
;
867 vRect2
.xRight
= pRect
->x
+ pRect
->width
;
868 vRect2
.yBottom
= pRect
->y
;
872 ::WinScrollWindow( GetHwnd()
879 ,SW_SCROLLCHILDREN
| SW_INVALIDATERGN
882 ::WinScrollWindow( GetHwnd()
889 ,SW_SCROLLCHILDREN
| SW_INVALIDATERGN
891 } // end of wxWindow::ScrollWindow
893 // ---------------------------------------------------------------------------
895 // ---------------------------------------------------------------------------
897 void wxWindow::SubclassWin(
901 HWND hwnd
= (HWND
)hWnd
;
903 wxASSERT_MSG( !m_fnOldWndProc
, wxT("subclassing window twice?") );
904 wxCHECK_RET(::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in SubclassWin") );
905 m_fnOldWndProc
= (WXFARPROC
) ::WinSubclassWindow(hwnd
, (PFNWP
)wxWndProc
);
906 } // end of wxWindow::SubclassWin
908 void wxWindow::UnsubclassWin()
911 // Restore old Window proc
913 HWND hwnd
= GetHWND();
917 wxCHECK_RET( ::WinIsWindow(vHabmain
, hwnd
), wxT("invalid HWND in UnsubclassWin") );
919 PFNWP fnProc
= (PFNWP
)::WinQueryWindowPtr(hwnd
, QWP_PFNWP
);
921 if ( (m_fnOldWndProc
!= 0) && (fnProc
!= (PFNWP
) m_fnOldWndProc
))
923 WinSubclassWindow(hwnd
, (PFNWP
)m_fnOldWndProc
);
927 } // end of wxWindow::UnsubclassWin
930 // Make a Windows extended style from the given wxWindows window style
932 WXDWORD
wxWindow::MakeExtendedStyle(
934 , bool bEliminateBorders
938 // PM does not support extended style
942 } // end of wxWindow::MakeExtendedStyle
945 // Determines whether native 3D effects or CTL3D should be used,
946 // applying a default border style if required, and returning an extended
947 // style to pass to CreateWindowEx.
949 WXDWORD
wxWindow::Determine3DEffects(
950 WXDWORD dwDefaultBorderStyle
954 WXDWORD dwStyle
= 0L;
957 // Native PM does not have any specialize 3D effects like WIN32 does
961 } // end of wxWindow::Determine3DEffects
963 #if WXWIN_COMPATIBILITY
964 void wxWindow::OnCommand(
966 , wxCommandEvent
& rEvent
969 if (GetEventHandler()->ProcessEvent(rEvent
))
972 m_parent
->GetEventHandler()->OnCommand( rWin
975 } // end of wxWindow::OnCommand
977 wxObject
* wxWindow::GetChild(
982 // Return a pointer to the Nth object in the Panel
984 wxNode
* pNode
= GetChildren().First();
988 pNode
= pNode
->Next();
991 wxObject
* pObj
= (wxObject
*)pNode
->Data();
996 } // end of wxWindow::GetChild
998 #endif // WXWIN_COMPATIBILITY
1001 // Setup background and foreground colours correctly
1003 void wxWindow::SetupColours()
1006 SetBackgroundColour(GetParent()->GetBackgroundColour());
1007 } // end of wxWindow::SetupColours
1009 void wxWindow::OnIdle(
1014 // Check if we need to send a LEAVE event
1016 if (m_bMouseInWindow
)
1020 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
1021 if (::WinWindowFromPoint(HWND_DESKTOP
, &vPoint
, FALSE
) != (HWND
)GetHwnd())
1024 // Generate a LEAVE event
1026 m_bMouseInWindow
= FALSE
;
1029 // Unfortunately the mouse button and keyboard state may have changed
1030 // by the time the OnIdle function is called, so 'state' may be
1035 if (::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) != 0)
1037 if (::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) != 0);
1040 wxMouseEvent
rEvent(wxEVT_LEAVE_WINDOW
);
1042 InitMouseEvent( rEvent
1047 (void)GetEventHandler()->ProcessEvent(rEvent
);
1051 } // end of wxWindow::OnIdle
1054 // Set this window to be the child of 'parent'.
1056 bool wxWindow::Reparent(
1060 if (!wxWindowBase::Reparent(pParent
))
1063 HWND hWndChild
= GetHwnd();
1064 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1066 ::WinSetParent(hWndChild
, hWndParent
, TRUE
);
1068 } // end of wxWindow::Reparent
1070 void wxWindow::Clear()
1072 wxClientDC
vDc(this);
1073 wxBrush
vBrush( GetBackgroundColour()
1077 vDc
.SetBackground(vBrush
);
1079 } // end of wxWindow::Clear
1081 void wxWindow::Refresh(
1083 , const wxRect
* pRect
1086 HWND hWnd
= GetHwnd();
1094 vOs2Rect
.xLeft
= pRect
->x
;
1095 vOs2Rect
.yTop
= pRect
->y
;
1096 vOs2Rect
.xRight
= pRect
->x
+ pRect
->width
;
1097 vOs2Rect
.yBottom
= pRect
->y
+ pRect
->height
;
1099 ::WinInvalidateRect(hWnd
, &vOs2Rect
, bEraseBack
);
1102 ::WinInvalidateRect(hWnd
, NULL
, bEraseBack
);
1104 } // end of wxWindow::Refresh
1106 // ---------------------------------------------------------------------------
1108 // ---------------------------------------------------------------------------
1110 #if wxUSE_DRAG_AND_DROP
1111 void wxWindow::SetDropTarget(
1112 wxDropTarget
* pDropTarget
1115 if (m_dropTarget
!= 0)
1117 m_dropTarget
->Revoke(m_hWnd
);
1118 delete m_dropTarget
;
1120 m_dropTarget
= pDropTarget
;
1121 if (m_dropTarget
!= 0)
1122 m_dropTarget
->Register(m_hWnd
);
1123 } // end of wxWindow::SetDropTarget
1127 // old style file-manager drag&drop support: we retain the old-style
1128 // DragAcceptFiles in parallel with SetDropTarget.
1130 void wxWindow::DragAcceptFiles(
1134 HWND hWnd
= GetHwnd();
1136 if (hWnd
&& bAccept
)
1137 ::DrgAcceptDroppedFiles(hWnd
, NULL
, NULL
, DO_COPY
, 0L);
1138 } // end of wxWindow::DragAcceptFiles
1140 // ----------------------------------------------------------------------------
1142 // ----------------------------------------------------------------------------
1146 void wxWindow::DoSetToolTip(
1150 wxWindowBase::DoSetToolTip(pTooltip
);
1153 m_tooltip
->SetWindow(this);
1154 } // end of wxWindow::DoSetToolTip
1156 #endif // wxUSE_TOOLTIPS
1158 // ---------------------------------------------------------------------------
1159 // moving and resizing
1160 // ---------------------------------------------------------------------------
1163 void wxWindow::DoGetSize(
1168 HWND hWnd
= GetHwnd();
1171 ::WinQueryWindowRect(hWnd
, &vRect
);
1174 *pWidth
= vRect
.xRight
- vRect
.xLeft
;
1176 // OS/2 PM is backwards from windows
1177 *pHeight
= vRect
.yTop
- vRect
.yBottom
;
1178 } // end of wxWindow::DoGetSize
1180 void wxWindow::DoGetPosition(
1185 HWND hWnd
= GetHwnd();
1189 ::WinQueryWindowRect(hWnd
, &vRect
);
1191 vPoint
.x
= vRect
.xLeft
;
1192 vPoint
.y
= vRect
.yBottom
;
1195 // We do the adjustments with respect to the parent only for the "real"
1196 // children, not for the dialogs/frames
1200 HWND hParentWnd
= 0;
1201 wxWindow
* pParent
= GetParent();
1204 hParentWnd
= GetWinHwnd(pParent
);
1207 // Since we now have the absolute screen coords, if there's a parent we
1208 // must subtract its bottom left corner
1214 ::WinQueryWindowRect(hParentWnd
, &vRect2
);
1215 vPoint
.x
-= vRect
.xLeft
;
1216 vPoint
.y
-= vRect
.yBottom
;
1220 // We may be faking the client origin. So a window that's really at (0,
1221 // 30) may appear (to wxWin apps) to be at (0, 0).
1223 wxPoint
vPt(pParent
->GetClientAreaOrigin());
1233 } // end of wxWindow::DoGetPosition
1235 void wxWindow::DoScreenToClient(
1240 HWND hWnd
= GetHwnd();
1243 ::WinQueryWindowPos(hWnd
, &vSwp
);
1249 } // end of wxWindow::DoScreenToClient
1251 void wxWindow::DoClientToScreen(
1256 HWND hWnd
= GetHwnd();
1259 ::WinQueryWindowPos(hWnd
, &vSwp
);
1265 } // end of wxWindow::DoClientToScreen
1268 // Get size *available for subwindows* i.e. excluding menu bar etc.
1269 // Must be a frame type window
1271 void wxWindow::DoGetClientSize(
1276 HWND hWnd
= GetHwnd();
1280 hWndClient
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1281 if( hWndClient
== NULLHANDLE
)
1282 ::WinQueryWindowRect(GetHwnd(), &vRect
);
1284 ::WinQueryWindowRect(hWndClient
, &vRect
);
1287 *pWidth
= vRect
.xRight
;
1289 *pHeight
= vRect
.yTop
;
1290 } // end of wxWindow::DoGetClientSize
1292 void wxWindow::DoMoveWindow(
1299 if ( !::WinSetWindowPos( GetHwnd()
1305 ,SWP_SIZE
| SWP_MOVE
1308 wxLogLastError("MoveWindow");
1310 } // end of wxWindow::DoMoveWindow
1313 // Set the size of the window: if the dimensions are positive, just use them,
1314 // but if any of them is equal to -1, it means that we must find the value for
1315 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
1316 // which case -1 is a valid value for x and y)
1318 // If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
1319 // the width/height to best suit our contents, otherwise we reuse the current
1322 void wxWindow::DoSetSize(
1331 // Get the current size and position...
1337 wxSize
vSize(-1, -1);
1339 GetPosition( &nCurrentX
1342 GetSize( &nCurrentWidth
1347 // ... and don't do anything (avoiding flicker) if it's already ok
1349 if ( nX
== nCurrentX
&&
1351 nWidth
== nCurrentWidth
&&
1352 nHeight
== nCurrentHeight
1358 if (nX
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1360 if (nY
== -1 && !(nSizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1363 AdjustForParentClientOrigin( nX
1370 if (nSizeFlags
& wxSIZE_AUTO_WIDTH
)
1372 vSize
= DoGetBestSize();
1378 // Just take the current one
1380 nWidth
= nCurrentWidth
;
1386 if (nSizeFlags
& wxSIZE_AUTO_HEIGHT
)
1390 vSize
= DoGetBestSize();
1396 // just take the current one
1397 nHeight
= nCurrentHeight
;
1406 } // end of wxWindow::DoSetSize
1408 void wxWindow::DoSetClientSize(
1413 wxWindow
* pParent
= GetParent();
1414 HWND hWnd
= GetHwnd();
1415 HWND hParentWnd
= (HWND
)0;
1416 HWND hClientWnd
= (HWND
)0;
1421 hClientWnd
= ::WinWindowFromID(GetHwnd(), FID_CLIENT
);
1422 ::WinQueryWindowRect(hClientWnd
, &vRect2
);
1425 hParentWnd
= (HWND
) pParent
->GetHWND();
1427 ::WinQueryWindowRect(hWnd
, &vRect
);
1428 ::WinQueryWindowRect(hParentWnd
, &vRect3
);
1430 // Find the difference between the entire window (title bar and all)
1431 // and the client area; add this to the new client size to move the
1432 // window. OS/2 is backward from windows on height
1434 int nActualWidth
= vRect2
.xRight
- vRect2
.xLeft
- vRect
.xRight
+ nWidth
;
1435 int nActualHeight
= vRect2
.yTop
- vRect2
.yBottom
- vRect
.yTop
+ nHeight
;
1438 // If there's a parent, must subtract the parent's bottom left corner
1439 // since MoveWindow moves relative to the parent
1443 vPoint
.x
= vRect2
.xLeft
;
1444 vPoint
.y
= vRect2
.yBottom
;
1447 vPoint
.x
-= vRect3
.xLeft
;
1448 vPoint
.y
-= vRect3
.yBottom
;
1451 DoMoveWindow( vPoint
.x
1457 wxSizeEvent
vEvent( wxSize( nWidth
1463 vEvent
.SetEventObject(this);
1464 GetEventHandler()->ProcessEvent(vEvent
);
1465 } // end of wxWindow::DoSetClientSize
1467 wxPoint
wxWindow::GetClientAreaOrigin() const
1469 return wxPoint(0, 0);
1470 } // end of wxWindow::GetClientAreaOrigin
1472 void wxWindow::AdjustForParentClientOrigin(
1479 // Don't do it for the dialogs/frames - they float independently of their
1484 wxWindow
* pParent
= GetParent();
1486 if (!(nSizeFlags
& wxSIZE_NO_ADJUSTMENTS
) && pParent
)
1488 wxPoint
vPoint(pParent
->GetClientAreaOrigin());
1493 } // end of wxWindow::AdjustForParentClientOrigin
1495 // ---------------------------------------------------------------------------
1497 // ---------------------------------------------------------------------------
1499 int wxWindow::GetCharHeight() const
1502 FONTMETRICS vFontMetrics
;
1505 hPs
= ::WinGetPS(GetHwnd());
1507 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1509 ::WinReleasePS(hPs
);
1512 ::WinReleasePS(hPs
);
1513 return(vFontMetrics
.lMaxAscender
+ vFontMetrics
.lMaxDescender
);
1514 } // end of wxWindow::GetCharHeight
1516 int wxWindow::GetCharWidth() const
1519 FONTMETRICS vFontMetrics
;
1521 hPs
= ::WinGetPS(GetHwnd());
1523 if(!GpiQueryFontMetrics(hPs
, sizeof(FONTMETRICS
), &vFontMetrics
))
1525 ::WinReleasePS(hPs
);
1528 ::WinReleasePS(hPs
);
1529 return(vFontMetrics
.lAveCharWidth
);
1530 } // end of wxWindow::GetCharWidth
1532 void wxWindow::GetTextExtent(
1533 const wxString
& rString
1537 , int* pExternalLeading
1538 , const wxFont
* pTheFont
1541 const wxFont
* pFontToUse
= pTheFont
;
1544 hPs
= ::WinGetPS(GetHwnd());
1546 // TODO: Will have to play with fonts later
1549 pFontToUse = &m_font;
1552 HFONT hFfontOld = 0;
1554 if (pFontToUse && pFontToUse->Ok())
1557 hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
1559 hFontOld = (HFONT)SelectObject(dc,fnt);
1564 GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
1565 GetTextMetrics(dc, &tm);
1567 if ( fontToUse && fnt && hfontOld )
1568 SelectObject(dc, hfontOld);
1570 ReleaseDC(hWnd, dc);
1577 *descent = tm.tmDescent;
1578 if ( externalLeading )
1579 *externalLeading = tm.tmExternalLeading;
1581 ::WinReleasePS(hPs
);
1584 #if wxUSE_CARET && WXWIN_COMPATIBILITY
1585 // ---------------------------------------------------------------------------
1586 // Caret manipulation
1587 // ---------------------------------------------------------------------------
1589 void wxWindow::CreateCaret(
1594 SetCaret(new wxCaret( this
1598 } // end of wxWindow::CreateCaret
1600 void wxWindow::CreateCaret(
1601 const wxBitmap
* pBitmap
1604 wxFAIL_MSG("not implemented");
1605 } // end of wxWindow::CreateCaret
1607 void wxWindow::ShowCaret(
1611 wxCHECK_RET( m_caret
, "no caret to show" );
1613 m_caret
->Show(bShow
);
1614 } // end of wxWindow::ShowCaret
1616 void wxWindow::DestroyCaret()
1619 } // end of wxWindow::DestroyCaret
1621 void wxWindow::SetCaretPos(
1625 wxCHECK_RET( m_caret
, "no caret to move" );
1630 } // end of wxWindow::SetCaretPos
1632 void wxWindow::GetCaretPos(
1637 wxCHECK_RET( m_caret
, "no caret to get position of" );
1639 m_caret
->GetPosition( pX
1642 } // end of wxWindow::GetCaretPos
1644 #endif //wxUSE_CARET
1646 // ---------------------------------------------------------------------------
1648 // ---------------------------------------------------------------------------
1650 bool wxWindow::DoPopupMenu(
1656 HWND hWnd
= GetHwnd();
1657 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
1658 HWND hMenu
= GetHmenuOf(pMenu
);
1660 pMenu
->SetInvokingWindow(this);
1663 DoClientToScreen( &nX
1666 wxCurrentPopupMenu
= pMenu
;
1668 ::WinPopupMenu( hWndParent
1674 ,PU_MOUSEBUTTON2DOWN
| PU_MOUSEBUTTON2
| PU_KEYBOARD
1677 wxCurrentPopupMenu
= NULL
;
1679 pMenu
->SetInvokingWindow(NULL
);
1681 } // end of wxWindow::DoPopupMenu
1683 // ===========================================================================
1684 // pre/post message processing
1685 // ===========================================================================
1687 MRESULT
wxWindow::OS2DefWindowProc(
1694 return (MRESULT
)m_fnOldWndProc(GetHWND(), (ULONG
)uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1696 return ::WinDefWindowProc(GetHWND(), (ULONG
)uMsg
, (MPARAM
)wParam
, (MPARAM
)lParam
);
1697 } // end of wxWindow::OS2DefWindowProc
1699 bool wxWindow::OS2ProcessMessage(
1703 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1705 if (m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
))
1708 // Intercept dialog navigation keys
1710 bool bProcess
= TRUE
;
1711 USHORT uKeyFlags
= SHORT1FROMMP(pQMsg
->mp1
);
1713 if (uKeyFlags
& KC_KEYUP
)
1716 if (uKeyFlags
& KC_ALT
)
1719 if (!(uKeyFlags
& KC_VIRTUALKEY
))
1724 bool bCtrlDown
= IsCtrlDown();
1725 bool bShiftDown
= IsShiftDown();
1728 // WM_QUERYDLGCODE: ask the control if it wants the key for itself,
1729 // don't process it if it's the case (except for Ctrl-Tab/Enter
1730 // combinations which are always processed)
1732 ULONG ulDlgCode
= 0;
1736 ulDlgCode
= (ULONG
)::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0);
1739 bool bForward
= TRUE
;
1740 bool bWindowChange
= FALSE
;
1742 switch (SHORT2FROMMP(pQMsg
->mp2
))
1745 // Going to make certain assumptions about specific types of controls
1746 // here, so we may have to alter some things later if they prove invalid
1750 // Shift tabl will always be a nav-key but tabs may be wanted
1759 // Entry Fields want tabs for themselve usually
1763 case DLGC_ENTRYFIELD
:
1773 // Ctrl-Tab cycles thru notebook pages
1775 bWindowChange
= bCtrlDown
;
1776 bForward
= !bShiftDown
;
1799 // ctrl-enter is not processed
1803 else if (ulDlgCode
& DLGC_BUTTON
)
1806 // buttons want process Enter themselevs
1812 wxPanel
* pPanel
= wxDynamicCast(this, wxPanel
);
1813 wxButton
* pBtn
= NULL
;
1818 // Panel may have a default button which should
1819 // be activated by Enter
1821 pBtn
= pPanel
->GetDefaultItem();
1824 if (pBtn
&& pBtn
->IsEnabled())
1827 // If we do have a default button, do press it
1829 pBtn
->OS2Command(BN_CLICKED
, 0 /* unused */);
1832 // else: but if it does not it makes sense to make
1833 // it work like a TAB - and that's what we do.
1834 // Note that Ctrl-Enter always works this way.
1845 wxNavigationKeyEvent vEvent
;
1847 vEvent
.SetDirection(bForward
);
1848 vEvent
.SetWindowChange(bWindowChange
);
1849 vEvent
.SetEventObject(this);
1851 if (GetEventHandler()->ProcessEvent(vEvent
))
1853 wxButton
* pBtn
= wxDynamicCast(FindFocus(), wxButton
);
1858 // The button which has focus should be default
1867 // Let Dialogs process
1869 if (::WinSendMsg(pQMsg
->hwnd
, WM_QUERYDLGCODE
, pQMsg
, 0));
1876 // relay mouse move events to the tooltip control
1877 QMSG
* pQMsg
= (QMSG
*)pMsg
;
1879 if (pQMsg
->msg
== WM_MOUSEMOVE
)
1880 m_tooltip
->RelayEvent(pMsg
);
1882 #endif // wxUSE_TOOLTIPS
1885 } // end of wxWindow::OS2ProcessMessage
1887 bool wxWindow::OS2TranslateMessage(
1892 return m_acceleratorTable
.Translate(m_hWnd
, pMsg
);
1895 #endif //wxUSE_ACCEL
1896 } // end of wxWindow::OS2TranslateMessage
1898 // ---------------------------------------------------------------------------
1899 // message params unpackers
1900 // ---------------------------------------------------------------------------
1902 void wxWindow::UnpackCommand(
1910 *pId
= LOWORD(wParam
);
1911 *phWnd
= NULL
; // or may be GetHWND() ?
1912 *pCmd
= LOWORD(lParam
);
1913 } // end of wxWindow::UnpackCommand
1915 void wxWindow::UnpackActivate(
1922 *pState
= LOWORD(wParam
);
1923 *phWnd
= (WXHWND
)lParam
;
1924 } // end of wxWindow::UnpackActivate
1926 void wxWindow::UnpackScroll(
1937 ulId
= (ULONG
)LONGFROMMP(wParam
);
1938 hWnd
= ::WinWindowFromID(GetHwnd(), ulId
);
1939 if (hWnd
== m_hWndScrollBarHorz
|| hWnd
== m_hWndScrollBarVert
)
1940 *phWnd
= NULLHANDLE
;
1944 *pPos
= SHORT1FROMMP(lParam
);
1945 *pCode
= SHORT2FROMMP(lParam
);
1946 } // end of wxWindow::UnpackScroll
1948 void wxWindow::UnpackMenuSelect(
1956 *pItem
= (WXWORD
)LOWORD(wParam
);
1957 *pFlags
= HIWORD(wParam
);
1958 *phMenu
= (WXHMENU
)lParam
;
1959 } // end of wxWindow::UnpackMenuSelect
1961 // ---------------------------------------------------------------------------
1962 // Main wxWindows window proc and the window proc for wxWindow
1963 // ---------------------------------------------------------------------------
1966 // Hook for new window just as it's being created, when the window isn't yet
1967 // associated with the handle
1969 wxWindow
* wxWndHook
= NULL
;
1974 MRESULT EXPENTRY
wxWndProc(
1982 // Trace all ulMsgs - useful for the debugging
1985 wxLogTrace(wxTraceMessages
, wxT("Processing %s(wParam=%8lx, lParam=%8lx)"),
1986 wxGetMessageName(ulMsg
), wParam
, lParam
);
1987 #endif // __WXDEBUG__
1989 wxWindow
* pWnd
= wxFindWinFromHandle((WXHWND
)hWnd
);
1992 // When we get the first message for the HWND we just created, we associate
1993 // it with wxWindow stored in wxWndHook
1995 if (!pWnd
&& wxWndHook
)
1997 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
2000 pWnd
->SetHWND((WXHWND
)hWnd
);
2003 MRESULT rc
= (MRESULT
)0;
2007 // Stop right here if we don't have a valid handle in our wxWindow object.
2009 if (pWnd
&& !pWnd
->GetHWND())
2011 pWnd
->SetHWND((WXHWND
) hWnd
);
2012 rc
= pWnd
->OS2DefWindowProc(ulMsg
, wParam
, lParam
);
2018 rc
= pWnd
->OS2WindowProc(ulMsg
, wParam
, lParam
);
2020 rc
= ::WinDefWindowProc(hWnd
, ulMsg
, wParam
, lParam
);
2024 } // end of wxWndProc
2027 // We will add (or delete) messages we need to handle at this default
2030 MRESULT
wxWindow::OS2WindowProc(
2037 // Did we process the uMsg?
2039 bool bProcessed
= FALSE
;
2046 // For most messages we should return 0 when we do process the message
2048 mResult
= (MRESULT
)0;
2056 bProcessed
= HandleCreate( (WXLPCREATESTRUCT
)lParam
2062 // Return 0 to bAllow window creation
2064 mResult
= (MRESULT
)(bMayCreate
? 0 : -1);
2075 bProcessed
= HandleMove( LOWORD(lParam
)
2081 bProcessed
= HandleSize( LOWORD(lParam
)
2092 UnpackActivate( wParam
2098 bProcessed
= HandleActivate( wState
2106 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
2107 bProcessed
= HandleSetFocus((WXHWND
)(HWND
)wParam
);
2109 bProcessed
= HandleKillFocus((WXHWND
)(HWND
)wParam
);
2113 bProcessed
= HandlePaint();
2118 // Don't let the DefWindowProc() destroy our window - we'll do it
2119 // ourselves in ~wxWindow
2122 mResult
= (MRESULT
)TRUE
;
2126 bProcessed
= HandleShow(wParam
!= 0, (int)lParam
);
2130 // Under OS2 PM Joysticks are treated just like mouse events
2131 // The "Motion" events will be prevelent in joysticks
2134 case WM_BUTTON1DOWN
:
2136 case WM_BUTTON1DBLCLK
:
2137 case WM_BUTTON1MOTIONEND
:
2138 case WM_BUTTON1MOTIONSTART
:
2139 case WM_BUTTON2DOWN
:
2141 case WM_BUTTON2DBLCLK
:
2142 case WM_BUTTON2MOTIONEND
:
2143 case WM_BUTTON2MOTIONSTART
:
2144 case WM_BUTTON3DOWN
:
2146 case WM_BUTTON3DBLCLK
:
2147 case WM_BUTTON3MOTIONEND
:
2148 case WM_BUTTON3MOTIONSTART
:
2150 short x
= LOWORD(lParam
);
2151 short y
= HIWORD(lParam
);
2153 bProcessed
= HandleMouseEvent(uMsg
, x
, y
, (WXUINT
)wParam
);
2157 bProcessed
= HandleSysCommand(wParam
, lParam
);
2164 UnpackCommand(wParam
, lParam
, &id
, &hwnd
, &cmd
);
2166 bProcessed
= HandleCommand(id
, cmd
, hwnd
);
2171 // For these messages we must return TRUE if process the message
2174 case WM_MEASUREITEM
:
2176 int nIdCtrl
= (UINT
)wParam
;
2178 if ( uMsg
== WM_DRAWITEM
)
2180 bProcessed
= OS2OnDrawItem(nIdCtrl
,
2181 (WXDRAWITEMSTRUCT
*)lParam
);
2185 bProcessed
= OS2OnMeasureItem(nIdCtrl
,
2186 (WXMEASUREITEMSTRUCT
*)lParam
);
2190 mResult
= (MRESULT
)TRUE
;
2194 case WM_QUERYDLGCODE
:
2197 mResult
= (MRESULT
)m_lDlgCode
;
2201 //else: get the dlg code from the DefWindowProc()
2206 // In OS/2 PM all keyboard events are of the WM_CHAR type. Virtual key and key-up
2207 // and key-down events are obtained from the WM_CHAR params.
2211 USHORT uKeyFlags
= SHORT1FROMMP((MPARAM
)wParam
);
2213 if (uKeyFlags
& KC_KEYUP
)
2215 bProcessed
= HandleKeyUp((WXDWORD
)wParam
, lParam
);
2218 else // keydown event
2221 // If this has been processed by an event handler,
2222 // return 0 now (we've handled it). DON't RETURN
2223 // we still need to process further
2225 HandleKeyDown((WXDWORD
)wParam
, lParam
);
2226 if (uKeyFlags
& KC_VIRTUALKEY
)
2228 USHORT uVk
= SHORT2FROMMP((MPARAM
)lParam
);
2231 // We consider these message "not interesting" to OnChar
2233 if (uVk
== VK_SHIFT
|| uVk
== VK_CTRL
)
2241 // Avoid duplicate messages to OnChar for these ASCII keys: they
2242 // will be translated by TranslateMessage() and received in WM_CHAR
2248 // But set processed to FALSE, not TRUE to still pass them to
2249 // the control's default window proc - otherwise built-in
2250 // keyboard handling won't work
2259 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
);
2263 else // WM_CHAR -- Always an ASCII character
2265 bProcessed
= HandleChar((WXDWORD
)wParam
, lParam
, TRUE
);
2277 UnpackScroll( wParam
2284 bProcessed
= OS2OnScroll( uMsg
== WM_HSCROLL
? wxHORIZONTAL
2293 #if defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
2294 case WM_CTLCOLORCHANGE
:
2296 bProcessed
= HandleCtlColor(&hBrush
);
2300 case WM_ERASEBACKGROUND
:
2302 // Returning TRUE to requestw PM to paint the window background
2303 // in SYSCLR_WINDOW. We don't really want that
2305 bProcessed
= HandleEraseBkgnd((WXHDC
)(HPS
)wParam
);
2306 mResult
= (MRESULT
)(FALSE
);
2310 // Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
2311 // things such as colors and fonts and such
2313 case WM_QUERYWINDOWPARAMS
:
2315 PWNDPARAMS pWndParams
= (PWNDPARAMS
)wParam
;
2317 bProcessed
= HandleWindowParams( pWndParams
2323 // the return value for this message is ignored
2324 case WM_SYSCOLORCHANGE
:
2325 bProcessed
= HandleSysColorChange();
2328 case WM_REALIZEPALETTE
:
2329 bProcessed
= HandlePaletteChanged();
2332 case WM_PRESPARAMCHANGED
:
2333 bProcessed
= HandlePresParamChanged(wParam
);
2337 // move all drag and drops to wxDrg
2339 bProcessed
= HandleEndDrag(wParam
);
2343 bProcessed
= HandleInitDialog((WXHWND
)(HWND
)wParam
);
2347 // we never set focus from here
2352 // wxFrame specific message
2353 case WM_MINMAXFRAME
:
2354 bProcessed
= HandleGetMinMaxInfo((PSWP
)wParam
);
2357 case WM_SYSVALUECHANGED
:
2358 // TODO: do something
2359 mResult
= (MRESULT
)TRUE
;
2363 // Comparable to WM_SETPOINTER for windows, only for just controls
2365 case WM_CONTROLPOINTER
:
2366 bProcessed
= HandleSetCursor( SHORT1FROMMP(wParam
) // Control ID
2367 ,(HWND
)lParam
// Cursor Handle
2372 // Returning TRUE stops the DefWindowProc() from further
2373 // processing this message - exactly what we need because we've
2374 // just set the cursor.
2376 mResult
= (MRESULT
)TRUE
;
2383 wxLogTrace(wxTraceMessages
, wxT("Forwarding %s to DefWindowProc."),
2384 wxGetMessageName(uMsg
));
2385 #endif // __WXDEBUG__
2386 if (IsKindOf(CLASSINFO(wxFrame
)))
2387 mResult
= ::WinDefWindowProc(m_hWnd
, uMsg
, wParam
, lParam
);
2389 mResult
= OS2DefWindowProc(uMsg
, wParam
, lParam
);
2392 } // end of wxWindow::OS2WindowProc
2395 // Dialog window proc
2403 if (uMsg
== WM_INITDLG
)
2406 // For this message, returning TRUE tells system to set focus to the
2407 // first control in the dialog box
2409 return (MRESULT
)TRUE
;
2414 // For all the other ones, FALSE means that we didn't process the
2419 } // end of wxDlgProc
2421 wxWindow
* wxFindWinFromHandle(
2425 wxNode
* pNode
= wxWinHandleList
->Find((long)hWnd
);
2429 return (wxWindow
*)pNode
->Data();
2430 } // end of wxFindWinFromHandle
2432 void wxAssociateWinWithHandle(
2438 // Adding NULL hWnd is (first) surely a result of an error and
2439 // (secondly) breaks menu command processing
2441 wxCHECK_RET( hWnd
!= (HWND
)NULL
,
2442 wxT("attempt to add a NULL hWnd to window list ignored") );
2445 wxWindow
* pOldWin
= wxFindWinFromHandle((WXHWND
) hWnd
);
2447 if (pOldWin
&& (pOldWin
!= pWin
))
2449 wxString
str(pWin
->GetClassInfo()->GetClassName());
2450 wxLogError( "Bug! Found existing HWND %X for new window of class %s"
2457 wxWinHandleList
->Append( (long)hWnd
2461 } // end of wxAssociateWinWithHandle
2463 void wxRemoveHandleAssociation(
2467 wxWinHandleList
->DeleteObject(pWin
);
2468 } // end of wxRemoveHandleAssociation
2471 // Default destroyer - override if you destroy it in some other way
2472 // (e.g. with MDI child windows)
2474 void wxWindow::OS2DestroyWindow()
2478 void wxWindow::OS2DetachWindowMenu()
2482 HMENU hMenu
= (HMENU
)m_hMenu
;
2484 int nN
= (int)::WinSendMsg(hMenu
, MM_QUERYITEMCOUNT
, 0, 0);
2487 for (i
= 0; i
< nN
; i
++)
2490 int nChars
= (int)::WinSendMsg( hMenu
2492 ,MPFROM2SHORT(i
, nN
)
2497 wxLogLastError(wxT("GetMenuString"));
2501 if (wxStrcmp(zBuf
, wxT("&Window")) == 0)
2503 ::WinSendMsg(hMenu
, MM_DELETEITEM
, MPFROM2SHORT(i
, TRUE
), 0);
2508 } // end of wxWindow::OS2DetachWindowMenu
2510 bool wxWindow::OS2Create(
2513 , const wxChar
* zTitle
2521 , unsigned long ulId
2531 long lHeight1
= 20L;
2533 int nNeedsubclass
= 0;
2534 PCSZ pszClass
= zClass
;
2537 // Find parent's size, if it exists, to set up a possible default
2538 // panel size the size of the parent window
2555 // check to see if the new window is a standard control
2557 if ((ULONG
)zClass
== (ULONG
)WC_BUTTON
||
2558 (ULONG
)zClass
== (ULONG
)WC_COMBOBOX
||
2559 (ULONG
)zClass
== (ULONG
)WC_CONTAINER
||
2560 (ULONG
)zClass
== (ULONG
)WC_ENTRYFIELD
||
2561 (ULONG
)zClass
== (ULONG
)WC_FRAME
||
2562 (ULONG
)zClass
== (ULONG
)WC_LISTBOX
||
2563 (ULONG
)zClass
== (ULONG
)WC_MENU
||
2564 (ULONG
)zClass
== (ULONG
)WC_NOTEBOOK
||
2565 (ULONG
)zClass
== (ULONG
)WC_SCROLLBAR
||
2566 (ULONG
)zClass
== (ULONG
)WC_SPINBUTTON
||
2567 (ULONG
)zClass
== (ULONG
)WC_STATIC
||
2568 (ULONG
)zClass
== (ULONG
)WC_TITLEBAR
||
2569 (ULONG
)zClass
== (ULONG
)WC_VALUESET
2576 // no standard controls
2577 if(wxString (wxT("wxFrameClass")) == wxString(zClass
) )
2579 pszClass
= WC_FRAME
;
2586 nControlId
= FID_CLIENT
;
2591 // We will either have a registered class via string name or a standard PM Class via a long
2593 m_hWnd
= (WXHWND
)::WinCreateWindow( (HWND
)hParent
2595 ,(PSZ
)zTitle
? zTitle
: wxT("")
2609 vError
= ::WinGetLastError(vHabmain
);
2610 sError
= wxPMErrorToStr(vError
);
2611 wxLogError("Can't create window of class %s!. Error: %s\n", zClass
, sError
);
2614 ::WinSetWindowULong(m_hWnd
, QWL_USER
, (ULONG
) this);
2618 wxNode
* pNode
= wxWinHandleList
->Member(this);
2622 HWND hWnd
= (HWND
)pNode
->GetKeyInteger();
2624 if (hWnd
!= (HWND
)m_hWnd
)
2627 wxLogError("A second HWND association is being added for the same window!");
2631 wxAssociateWinWithHandle((HWND
)m_hWnd
2635 // Now need to subclass window.
2639 wxAssociateWinWithHandle((HWND
)m_hWnd
,this);
2643 SubclassWin(GetHWND());
2646 } // end of wxWindow::OS2Create
2648 // ===========================================================================
2649 // OS2 PM message handlers
2650 // ===========================================================================
2652 // ---------------------------------------------------------------------------
2653 // window creation/destruction
2654 // ---------------------------------------------------------------------------
2656 bool wxWindow::HandleCreate(
2657 WXLPCREATESTRUCT vCs
2661 wxWindowCreateEvent
vEvent(this);
2663 (void)GetEventHandler()->ProcessEvent(vEvent
);
2664 *pbMayCreate
= TRUE
;
2666 } // end of wxWindow::HandleCreate
2668 bool wxWindow::HandleDestroy()
2670 wxWindowDestroyEvent
vEvent(this);
2672 (void)GetEventHandler()->ProcessEvent(vEvent
);
2675 // Delete our drop target if we've got one
2677 #if wxUSE_DRAG_AND_DROP
2678 if (m_dropTarget
!= NULL
)
2680 m_dropTarget
->Revoke(m_hWnd
);
2681 delete m_dropTarget
;
2682 m_dropTarget
= NULL
;
2684 #endif // wxUSE_DRAG_AND_DROP
2687 // WM_DESTROY handled
2690 } // end of wxWindow::HandleDestroy
2692 // ---------------------------------------------------------------------------
2694 // ---------------------------------------------------------------------------
2695 void wxWindow::OnSetFocus(
2696 wxFocusEvent
& rEvent
2700 // Panel wants to track the window which was the last to have focus in it,
2701 // so we want to set ourselves as the window which last had focus
2703 // Notice that it's also important to do it upwards the tree becaus
2704 // otherwise when the top level panel gets focus, it won't set it back to
2705 // us, but to some other sibling
2707 wxWindow
* pWin
= this;
2711 wxWindow
* pParent
= pWin
->GetParent();
2712 wxPanel
* pPanel
= wxDynamicCast( pParent
2717 pPanel
->SetLastFocus(pWin
);
2722 wxLogTrace(_T("focus"), _T("%s (0x%08x) gets focus"),
2723 GetClassInfo()->GetClassName(), GetHandle());
2726 } // end of wxWindow::OnSetFocus
2728 bool wxWindow::HandleActivate(
2730 , WXHWND
WXUNUSED(hActivate
)
2733 wxActivateEvent
vEvent( wxEVT_ACTIVATE
2737 vEvent
.SetEventObject(this);
2738 return GetEventHandler()->ProcessEvent(vEvent
);
2739 } // end of wxWindow::HandleActivate
2741 bool wxWindow::HandleSetFocus(
2742 WXHWND
WXUNUSED(hWnd
)
2751 m_caret
->OnSetFocus();
2753 #endif // wxUSE_CARET
2756 // Panel wants to track the window which was the last to have focus in it
2758 wxPanel
* pPanel
= wxDynamicCast( GetParent()
2763 pPanel
->SetLastFocus(this);
2766 wxFocusEvent
vEvent(wxEVT_SET_FOCUS
, m_windowId
);
2768 vEvent
.SetEventObject(this);
2769 return GetEventHandler()->ProcessEvent(vEvent
);
2770 } // end of wxWindow::HandleSetFocus
2772 bool wxWindow::HandleKillFocus(
2773 WXHWND
WXUNUSED(hWnd
)
2782 m_caret
->OnKillFocus();
2784 #endif // wxUSE_CARET
2786 wxFocusEvent
vEvent( wxEVT_KILL_FOCUS
2790 vEvent
.SetEventObject(this);
2791 return GetEventHandler()->ProcessEvent(vEvent
);
2792 } // end of wxWindow::HandleKillFocus
2794 // ---------------------------------------------------------------------------
2796 // ---------------------------------------------------------------------------
2798 bool wxWindow::HandleShow(
2803 wxShowEvent
vEvent( GetId()
2807 vEvent
.m_eventObject
= this;
2808 return GetEventHandler()->ProcessEvent(vEvent
);
2809 } // end of wxWindow::HandleShow
2811 bool wxWindow::HandleInitDialog(
2812 WXHWND
WXUNUSED(hWndFocus
)
2815 wxInitDialogEvent
vEvent(GetId());
2817 vEvent
.m_eventObject
= this;
2818 return GetEventHandler()->ProcessEvent(vEvent
);
2819 } // end of wxWindow::HandleInitDialog
2821 bool wxWindow::HandleEndDrag(WXWPARAM wParam
)
2823 // TODO: We'll handle drag and drop later
2827 bool wxWindow::HandleSetCursor(
2833 // Under OS/2 PM this allows the pointer to be changed
2834 // as it passes over a control
2836 ::WinSetPointer(HWND_DESKTOP
, (HPOINTER
)hPointer
);
2838 } // end of wxWindow::HandleSetCursor
2840 // ---------------------------------------------------------------------------
2841 // owner drawn stuff
2842 // ---------------------------------------------------------------------------
2843 bool wxWindow::OS2OnDrawItem(
2845 , WXDRAWITEMSTRUCT
* pItemStruct
2850 #if wxUSE_OWNER_DRAWN
2852 // Is it a menu item?
2858 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
2859 wxFrame
* pFrame
= (wxFrame
*)this;
2860 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
2861 HDC hDC
= ::GpiQueryDevice(pMeasureStruct
->hps
);
2862 wxRect
vRect( pMeasureStruct
->rclItem
.xLeft
2863 ,pMeasureStruct
->rclItem
.yBottom
2864 ,pMeasureStruct
->rclItem
.xRight
- pMeasureStruct
->rclItem
.xLeft
2865 ,pMeasureStruct
->rclItem
.yTop
- pMeasureStruct
->rclItem
.yBottom
2870 vDc
.SetHPS(pMeasureStruct
->hps
);
2872 // Load the wxWindows Pallete and set to RGB mode
2874 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
2878 ,(LONG
)wxTheColourDatabase
->m_nSize
2879 ,(PLONG
)wxTheColourDatabase
->m_palTable
2882 vError
= ::WinGetLastError(vHabmain
);
2883 sError
= wxPMErrorToStr(vError
);
2884 wxLogError("Unable to set current color table. Error: %s\n", sError
);
2887 // Set the color table to RGB mode
2889 if (!::GpiCreateLogColorTable( pMeasureStruct
->hps
2897 vError
= ::WinGetLastError(vHabmain
);
2898 sError
= wxPMErrorToStr(vError
);
2899 wxLogError("Unable to set current color table. Error: %s\n", sError
);
2902 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
2908 if (pMeasureStruct
->fsAttribute
== pMeasureStruct
->fsAttributeOld
)
2911 // Entire Item needs to be redrawn (either it has reappeared from
2912 // behind another window or is being displayed for the first time
2914 eAction
= wxOwnerDrawn::wxODDrawAll
;
2916 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
2919 // If it is currently selected we let the system handle it
2921 eStatus
|= wxOwnerDrawn::wxODSelected
;
2923 if (pMeasureStruct
->fsAttribute
& MIA_CHECKED
)
2926 // If it is currently checked we draw our own
2928 eStatus
|= wxOwnerDrawn::wxODChecked
;
2929 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_CHECKED
;
2931 if (pMeasureStruct
->fsAttribute
& MIA_DISABLED
)
2934 // If it is currently disabled we let the system handle it
2936 eStatus
|= wxOwnerDrawn::wxODDisabled
;
2939 // Don't really care about framed (indicationg focus) or NoDismiss
2944 if (pMeasureStruct
->fsAttribute
& MIA_HILITED
)
2946 eAction
= wxOwnerDrawn::wxODDrawAll
;
2947 eStatus
|= wxOwnerDrawn::wxODSelected
;
2949 // Keep the system from trying to highlight with its bogus colors
2951 pMeasureStruct
->fsAttributeOld
= pMeasureStruct
->fsAttribute
&= ~MIA_HILITED
;
2953 else if (!(pMeasureStruct
->fsAttribute
& MIA_HILITED
))
2955 eAction
= wxOwnerDrawn::wxODDrawAll
;
2958 // Keep the system from trying to highlight with its bogus colors
2960 pMeasureStruct
->fsAttribute
= pMeasureStruct
->fsAttributeOld
&= ~MIA_HILITED
;
2965 // For now we don't care about anything else
2966 // just ignore the entire message!
2972 // Now redraw the item
2974 return(pMenuItem
->OnDrawItem( vDc
2976 ,(wxOwnerDrawn::wxODAction
)eAction
2977 ,(wxOwnerDrawn::wxODStatus
)eStatus
2980 // leave the fsAttribute and fsOldAttribute unchanged. If different,
2981 // the system will do the highlight or fraeming or disabling for us,
2982 // otherwise, we'd have to do it ourselves.
2986 wxWindow
* pItem
= FindItem(vId
);
2988 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
2990 return ((wxControl
*)pItem
)->OS2OnDraw(pItemStruct
);
2994 } // end of wxWindow::OS2OnDrawItem
2996 bool wxWindow::OS2OnMeasureItem(
2998 , WXMEASUREITEMSTRUCT
* pItemStruct
3002 // Is it a menu item?
3004 if (lId
== 65536) // I really don't like this...has to be a better indicator
3006 if (IsKindOf(CLASSINFO(wxFrame
))) // we'll assume if Frame then a menu
3010 POWNERITEM pMeasureStruct
= (POWNERITEM
)pItemStruct
;
3011 wxFrame
* pFrame
= (wxFrame
*)this;
3012 wxMenuItem
* pMenuItem
= pFrame
->GetMenuBar()->FindItem(pMeasureStruct
->idItem
, pMeasureStruct
->hItem
);
3014 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
3017 if (pMenuItem
->OnMeasureItem( &nWidth
3021 pMeasureStruct
->rclItem
.xRight
= nWidth
;
3022 pMeasureStruct
->rclItem
.xLeft
= 0L;
3023 pMeasureStruct
->rclItem
.yTop
= nHeight
;
3024 pMeasureStruct
->rclItem
.yBottom
= 0L;
3030 wxWindow
* pItem
= FindItem(lId
);
3032 if (pItem
&& pItem
->IsKindOf(CLASSINFO(wxControl
)))
3034 return ((wxControl
*)pItem
)->OS2OnMeasure(pItemStruct
);
3039 // ---------------------------------------------------------------------------
3040 // colours and palettes
3041 // ---------------------------------------------------------------------------
3043 bool wxWindow::HandleSysColorChange()
3045 wxSysColourChangedEvent vEvent
;
3047 vEvent
.SetEventObject(this);
3048 return GetEventHandler()->ProcessEvent(vEvent
);
3049 } // end of wxWindow::HandleSysColorChange
3051 bool wxWindow::HandleCtlColor(
3056 // Not much provided with message. So not sure I can do anything with it
3059 } // end of wxWindow::HandleCtlColor
3061 bool wxWindow::HandleWindowParams(
3062 PWNDPARAMS pWndParams
3066 // TODO: I'll do something here, just not sure what yet
3070 // Define for each class of dialog and control
3071 WXHBRUSH
wxWindow::OnCtlColor(WXHDC hDC
,
3081 bool wxWindow::HandlePaletteChanged()
3083 // need to set this to something first
3084 WXHWND hWndPalChange
= NULLHANDLE
;
3086 wxPaletteChangedEvent
vEvent(GetId());
3088 vEvent
.SetEventObject(this);
3089 vEvent
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
3091 return GetEventHandler()->ProcessEvent(vEvent
);
3092 } // end of wxWindow::HandlePaletteChanged
3094 bool wxWindow::HandlePresParamChanged(
3099 // TODO: Once again I'll do something here when I need it
3101 //wxQueryNewPaletteEvent event(GetId());
3102 //event.SetEventObject(this);
3103 // if the background is erased
3104 // bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
3106 return FALSE
; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
3110 // Responds to colour changes: passes event on to children.
3112 void wxWindow::OnSysColourChanged(
3113 wxSysColourChangedEvent
& rEvent
3116 wxNode
* pNode
= GetChildren().First();
3121 // Only propagate to non-top-level windows
3123 wxWindow
* pWin
= (wxWindow
*)pNode
->Data();
3125 if (pWin
->GetParent())
3127 wxSysColourChangedEvent vEvent
;
3129 rEvent
.m_eventObject
= pWin
;
3130 pWin
->GetEventHandler()->ProcessEvent(vEvent
);
3132 pNode
= pNode
->Next();
3134 } // end of wxWindow::OnSysColourChanged
3136 // ---------------------------------------------------------------------------
3138 // ---------------------------------------------------------------------------
3140 bool wxWindow::HandlePaint()
3142 HRGN hRgn
= NULLHANDLE
;
3143 wxPaintEvent vEvent
;
3147 if (::WinQueryUpdateRegion(GetHwnd(), hRgn
) == RGN_NULL
)
3149 wxLogLastError("CreateRectRgn");
3153 m_updateRegion
= wxRegion(hRgn
);
3154 vEvent
.SetEventObject(this);
3155 if (!GetEventHandler()->ProcessEvent(vEvent
))
3159 hPS
= ::WinBeginPaint( GetHwnd()
3165 ::GpiCreateLogColorTable( hPS
3169 ,(LONG
)wxTheColourDatabase
->m_nSize
3170 ,(PLONG
)wxTheColourDatabase
->m_palTable
3172 ::GpiCreateLogColorTable( hPS
3180 ::WinFillRect(hPS
, &vRect
, GetBackgroundColour().GetPixel());
3184 return (GetEventHandler()->ProcessEvent(vEvent
));
3185 } // end of wxWindow::HandlePaint
3187 bool wxWindow::HandleEraseBkgnd(
3193 ::WinQueryWindowPos(GetHwnd(), &vSwp
);
3194 if (vSwp
.fl
& SWP_MINIMIZE
)
3199 vDC
.m_hPS
= (HPS
)hDC
; // this is really a PS
3200 vDC
.SetWindow(this);
3203 wxEraseEvent
vEvent(m_windowId
, &vDC
);
3205 vEvent
.SetEventObject(this);
3207 bool rc
= GetEventHandler()->ProcessEvent(vEvent
);
3210 vDC
.m_hPS
= NULLHANDLE
;
3212 } // end of wxWindow::HandleEraseBkgnd
3214 void wxWindow::OnEraseBackground(
3215 wxEraseEvent
& rEvent
3219 HPS hPS
= rEvent
.m_dc
->m_hPS
;
3221 ::WinQueryWindowRect(GetHwnd(), &vRect
);
3222 ::WinFillRect(hPS
, &vRect
, m_backgroundColour
.GetPixel());
3223 } // end of wxWindow::OnEraseBackground
3225 // ---------------------------------------------------------------------------
3226 // moving and resizing
3227 // ---------------------------------------------------------------------------
3229 bool wxWindow::HandleMinimize()
3231 wxIconizeEvent
vEvent(m_windowId
);
3233 vEvent
.SetEventObject(this);
3234 return GetEventHandler()->ProcessEvent(vEvent
);
3235 } // end of wxWindow::HandleMinimize
3237 bool wxWindow::HandleMaximize()
3239 wxMaximizeEvent
vEvent(m_windowId
);
3241 vEvent
.SetEventObject(this);
3242 return GetEventHandler()->ProcessEvent(vEvent
);
3243 } // end of wxWindow::HandleMaximize
3245 bool wxWindow::HandleMove(
3250 wxMoveEvent
vEvent( wxPoint( nX
3256 vEvent
.SetEventObject(this);
3257 return GetEventHandler()->ProcessEvent(vEvent
);
3258 } // end of wxWindow::HandleMove
3260 bool wxWindow::HandleSize(
3263 , WXUINT
WXUNUSED(nFlag
)
3266 wxSizeEvent
vEvent( wxSize( nWidth
3272 vEvent
.SetEventObject(this);
3273 return GetEventHandler()->ProcessEvent(vEvent
);
3274 } // end of wxWindow::HandleSize
3276 bool wxWindow::HandleGetMinMaxInfo(
3286 ::WinGetMaxPosition(GetHwnd(), pSwp
);
3287 m_maxWidth
= pSwp
->cx
;
3288 m_maxHeight
= pSwp
->cy
;
3292 ::WinGetMinPosition(GetHwnd(), pSwp
, &vPoint
);
3293 m_minWidth
= pSwp
->cx
;
3294 m_minHeight
= pSwp
->cy
;
3301 } // end of wxWindow::HandleGetMinMaxInfo
3303 // ---------------------------------------------------------------------------
3305 // ---------------------------------------------------------------------------
3306 bool wxWindow::HandleCommand(
3312 if (wxCurrentPopupMenu
)
3314 wxMenu
* pPopupMenu
= wxCurrentPopupMenu
;
3316 wxCurrentPopupMenu
= NULL
;
3317 return pPopupMenu
->OS2Command(wCmd
, wId
);
3320 wxWindow
* pWin
= FindItem(wId
);
3324 pWin
= wxFindWinFromHandle(hControl
);
3328 return pWin
->OS2Command( wCmd
3332 } // end of wxWindow::HandleCommand
3334 bool wxWindow::HandleSysCommand(
3340 // 4 bits are reserved
3342 switch (SHORT1FROMMP(wParam
))
3345 return HandleMaximize();
3348 return HandleMinimize();
3351 } // end of wxWindow::HandleSysCommand
3353 // ---------------------------------------------------------------------------
3355 // ---------------------------------------------------------------------------
3357 void wxWindow::InitMouseEvent(
3358 wxMouseEvent
& rEvent
3366 rEvent
.m_shiftDown
= ((uFlags
& VK_SHIFT
) != 0);
3367 rEvent
.m_controlDown
= ((uFlags
& VK_CTRL
) != 0);
3368 rEvent
.m_leftDown
= ((uFlags
& VK_BUTTON1
) != 0);
3369 rEvent
.m_middleDown
= ((uFlags
& VK_BUTTON3
) != 0);
3370 rEvent
.m_rightDown
= ((uFlags
& VK_BUTTON2
) != 0);
3371 rEvent
.SetTimestamp(s_currentMsg
.time
);
3372 rEvent
.m_eventObject
= this;
3374 #if wxUSE_MOUSEEVENT_HACK
3377 m_lastMouseEvent
= rEvent
.GetEventType();
3378 #endif // wxUSE_MOUSEEVENT_HACK
3379 } // end of wxWindow::InitMouseEvent
3381 bool wxWindow::HandleMouseEvent(
3389 // The mouse events take consecutive IDs from WM_MOUSEFIRST to
3390 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
3391 // from the message id and take the value in the table to get wxWin event
3394 static const wxEventType eventsMouse
[] =
3408 wxMouseEvent
vEvent(eventsMouse
[uMsg
- WM_MOUSEMOVE
]);
3410 InitMouseEvent( vEvent
3416 return GetEventHandler()->ProcessEvent(vEvent
);
3417 } // end of wxWindow::HandleMouseEvent
3419 bool wxWindow::HandleMouseMove(
3425 if (!m_bMouseInWindow
)
3428 // Generate an ENTER event
3430 m_bMouseInWindow
= TRUE
;
3432 wxMouseEvent
vEvent(wxEVT_ENTER_WINDOW
);
3434 InitMouseEvent( vEvent
3440 (void)GetEventHandler()->ProcessEvent(vEvent
);
3442 return HandleMouseEvent( WM_MOUSEMOVE
3447 } // end of wxWindow::HandleMouseMove
3449 // ---------------------------------------------------------------------------
3450 // keyboard handling
3451 // ---------------------------------------------------------------------------
3454 // Create the key event of the given type for the given key - used by
3455 // HandleChar and HandleKeyDown/Up
3457 wxKeyEvent
wxWindow::CreateKeyEvent(
3463 wxKeyEvent
vEvent(eType
);
3465 vEvent
.SetId(GetId());
3466 vEvent
.m_shiftDown
= IsShiftDown();
3467 vEvent
.m_controlDown
= IsCtrlDown();
3468 vEvent
.m_altDown
= (HIWORD(lParam
) & KC_ALT
) == KC_ALT
;
3470 vEvent
.m_eventObject
= (wxWindow
*)this; // const_cast
3471 vEvent
.m_keyCode
= nId
;
3472 vEvent
.SetTimestamp(s_currentMsg
.time
);
3475 // Translate the position to client coords
3480 ::WinQueryPointerPos(HWND_DESKTOP
, &vPoint
);
3481 ::WinQueryWindowRect( GetHwnd()
3485 vPoint
.x
-= vRect
.xLeft
;
3486 vPoint
.y
-= vRect
.yBottom
;
3488 vEvent
.m_x
= vPoint
.x
;
3489 vEvent
.m_y
= vPoint
.y
;
3492 } // end of wxWindow::CreateKeyEvent
3495 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
3498 bool wxWindow::HandleChar(
3504 bool bCtrlDown
= FALSE
;
3510 // If 1 -> 26, translate to CTRL plus a letter.
3513 if ((vId
> 0) && (vId
< 27))
3535 else if ( (vId
= wxCharCodeOS2ToWX(wParam
)) == 0)
3538 // It's ASCII and will be processed here only when called from
3539 // WM_CHAR (i.e. when isASCII = TRUE), don't process it now
3546 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_CHAR
3553 vEvent
.m_controlDown
= TRUE
;
3556 if (GetEventHandler()->ProcessEvent(vEvent
))
3562 bool wxWindow::HandleKeyDown(
3567 int nId
= wxCharCodeOS2ToWX(wParam
);
3572 // Normal ASCII char
3579 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
3584 if (GetEventHandler()->ProcessEvent(vEvent
))
3590 } // end of wxWindow::HandleKeyDown
3592 bool wxWindow::HandleKeyUp(
3597 int nId
= wxCharCodeOS2ToWX(wParam
);
3602 // Normal ASCII char
3609 wxKeyEvent
vEvent(CreateKeyEvent( wxEVT_KEY_UP
3614 if (GetEventHandler()->ProcessEvent(vEvent
))
3618 } // end of wxWindow::HandleKeyUp
3620 // ---------------------------------------------------------------------------
3622 // ---------------------------------------------------------------------------
3624 // ---------------------------------------------------------------------------
3626 // ---------------------------------------------------------------------------
3628 bool wxWindow::OS2OnScroll(
3637 wxWindow
* pChild
= wxFindWinFromHandle(hControl
);
3640 return pChild
->OS2OnScroll( nOrientation
3647 wxScrollWinEvent vEvent
;
3649 vEvent
.SetPosition(wPos
);
3650 vEvent
.SetOrientation(nOrientation
);
3651 vEvent
.m_eventObject
= this;
3656 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEUP
;
3660 vEvent
.m_eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
3664 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEUP
;
3668 vEvent
.m_eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
3671 case SB_SLIDERPOSITION
:
3672 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
3675 case SB_SLIDERTRACK
:
3676 vEvent
.m_eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
3682 return GetEventHandler()->ProcessEvent(vEvent
);
3683 } // end of wxWindow::OS2OnScroll
3685 // ===========================================================================
3687 // ===========================================================================
3696 // TODO: we'll do this later
3697 } // end of wxGetCharSize
3700 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
3701 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
3703 int wxCharCodeOS2ToWX(
3711 case VK_BACKTAB
: nId
= WXK_BACK
; break;
3712 case VK_TAB
: nId
= WXK_TAB
; break;
3713 case VK_CLEAR
: nId
= WXK_CLEAR
; break;
3714 case VK_ENTER
: nId
= WXK_RETURN
; break;
3715 case VK_SHIFT
: nId
= WXK_SHIFT
; break;
3716 case VK_CTRL
: nId
= WXK_CONTROL
; break;
3717 case VK_PAUSE
: nId
= WXK_PAUSE
; break;
3718 case VK_SPACE
: nId
= WXK_SPACE
; break;
3719 case VK_ESC
: nId
= WXK_ESCAPE
; break;
3720 case VK_END
: nId
= WXK_END
; break;
3721 case VK_HOME
: nId
= WXK_HOME
; break;
3722 case VK_LEFT
: nId
= WXK_LEFT
; break;
3723 case VK_UP
: nId
= WXK_UP
; break;
3724 case VK_RIGHT
: nId
= WXK_RIGHT
; break;
3725 case VK_DOWN
: nId
= WXK_DOWN
; break;
3726 case VK_PRINTSCRN
: nId
= WXK_PRINT
; break;
3727 case VK_INSERT
: nId
= WXK_INSERT
; break;
3728 case VK_DELETE
: nId
= WXK_DELETE
; break;
3729 case VK_F1
: nId
= WXK_F1
; break;
3730 case VK_F2
: nId
= WXK_F2
; break;
3731 case VK_F3
: nId
= WXK_F3
; break;
3732 case VK_F4
: nId
= WXK_F4
; break;
3733 case VK_F5
: nId
= WXK_F5
; break;
3734 case VK_F6
: nId
= WXK_F6
; break;
3735 case VK_F7
: nId
= WXK_F7
; break;
3736 case VK_F8
: nId
= WXK_F8
; break;
3737 case VK_F9
: nId
= WXK_F9
; break;
3738 case VK_F10
: nId
= WXK_F10
; break;
3739 case VK_F11
: nId
= WXK_F11
; break;
3740 case VK_F12
: nId
= WXK_F12
; break;
3741 case VK_F13
: nId
= WXK_F13
; break;
3742 case VK_F14
: nId
= WXK_F14
; break;
3743 case VK_F15
: nId
= WXK_F15
; break;
3744 case VK_F16
: nId
= WXK_F16
; break;
3745 case VK_F17
: nId
= WXK_F17
; break;
3746 case VK_F18
: nId
= WXK_F18
; break;
3747 case VK_F19
: nId
= WXK_F19
; break;
3748 case VK_F20
: nId
= WXK_F20
; break;
3749 case VK_F21
: nId
= WXK_F21
; break;
3750 case VK_F22
: nId
= WXK_F22
; break;
3751 case VK_F23
: nId
= WXK_F23
; break;
3752 case VK_F24
: nId
= WXK_F24
; break;
3753 case VK_NUMLOCK
: nId
= WXK_NUMLOCK
; break;
3754 case VK_SCRLLOCK
: nId
= WXK_SCROLL
; break;
3761 } // end of wxCharCodeOS2ToWX
3763 int wxCharCodeWXToOS2(
3773 case WXK_CLEAR
: nKeySym
= VK_CLEAR
; break;
3774 case WXK_SHIFT
: nKeySym
= VK_SHIFT
; break;
3775 case WXK_CONTROL
: nKeySym
= VK_CTRL
; break;
3776 case WXK_PAUSE
: nKeySym
= VK_PAUSE
; break;
3777 case WXK_END
: nKeySym
= VK_END
; break;
3778 case WXK_HOME
: nKeySym
= VK_HOME
; break;
3779 case WXK_LEFT
: nKeySym
= VK_LEFT
; break;
3780 case WXK_UP
: nKeySym
= VK_UP
; break;
3781 case WXK_RIGHT
: nKeySym
= VK_RIGHT
; break;
3782 case WXK_DOWN
: nKeySym
= VK_DOWN
; break;
3783 case WXK_PRINT
: nKeySym
= VK_PRINTSCRN
; break;
3784 case WXK_INSERT
: nKeySym
= VK_INSERT
; break;
3785 case WXK_DELETE
: nKeySym
= VK_DELETE
; break;
3786 case WXK_F1
: nKeySym
= VK_F1
; break;
3787 case WXK_F2
: nKeySym
= VK_F2
; break;
3788 case WXK_F3
: nKeySym
= VK_F3
; break;
3789 case WXK_F4
: nKeySym
= VK_F4
; break;
3790 case WXK_F5
: nKeySym
= VK_F5
; break;
3791 case WXK_F6
: nKeySym
= VK_F6
; break;
3792 case WXK_F7
: nKeySym
= VK_F7
; break;
3793 case WXK_F8
: nKeySym
= VK_F8
; break;
3794 case WXK_F9
: nKeySym
= VK_F9
; break;
3795 case WXK_F10
: nKeySym
= VK_F10
; break;
3796 case WXK_F11
: nKeySym
= VK_F11
; break;
3797 case WXK_F12
: nKeySym
= VK_F12
; break;
3798 case WXK_F13
: nKeySym
= VK_F13
; break;
3799 case WXK_F14
: nKeySym
= VK_F14
; break;
3800 case WXK_F15
: nKeySym
= VK_F15
; break;
3801 case WXK_F16
: nKeySym
= VK_F16
; break;
3802 case WXK_F17
: nKeySym
= VK_F17
; break;
3803 case WXK_F18
: nKeySym
= VK_F18
; break;
3804 case WXK_F19
: nKeySym
= VK_F19
; break;
3805 case WXK_F20
: nKeySym
= VK_F20
; break;
3806 case WXK_F21
: nKeySym
= VK_F21
; break;
3807 case WXK_F22
: nKeySym
= VK_F22
; break;
3808 case WXK_F23
: nKeySym
= VK_F23
; break;
3809 case WXK_F24
: nKeySym
= VK_F24
; break;
3810 case WXK_NUMLOCK
: nKeySym
= VK_NUMLOCK
; break;
3811 case WXK_SCROLL
: nKeySym
= VK_SCRLLOCK
; break;
3814 *bIsVirtual
= FALSE
;
3820 } // end of wxCharCodeWXToOS2
3822 wxWindow
* wxGetActiveWindow()
3824 HWND hWnd
= ::WinQueryActiveWindow(HWND_DESKTOP
);
3828 return wxFindWinFromHandle((WXHWND
)hWnd
);
3831 } // end of wxGetActiveWindow
3834 const char* wxGetMessageName(
3839 case 0x0000: return "WM_NULL";
3840 case 0x0001: return "WM_CREATE";
3841 case 0x0002: return "WM_DESTROY";
3842 case 0x0004: return "WM_ENABLE";
3843 case 0x0005: return "WM_SHOW";
3844 case 0x0006: return "WM_MOVE";
3845 case 0x0007: return "WM_SIZE";
3846 case 0x0008: return "WM_ADJUSTWINDOWPOS";
3847 case 0x0009: return "WM_CALCVALIDRECTS";
3848 case 0x000A: return "WM_SETWINDOWPARAMS";
3849 case 0x000B: return "WM_QUERYWINDOWPARAMS";
3850 case 0x000C: return "WM_HITTEST";
3851 case 0x000D: return "WM_ACTIVATE";
3852 case 0x000F: return "WM_SETFOCUS";
3853 case 0x0010: return "WM_SETSELECTION";
3854 case 0x0011: return "WM_PPAINT";
3855 case 0x0012: return "WM_PSETFOCUS";
3856 case 0x0013: return "WM_PSYSCOLORCHANGE";
3857 case 0x0014: return "WM_PSIZE";
3858 case 0x0015: return "WM_PACTIVATE";
3859 case 0x0016: return "WM_PCONTROL";
3860 case 0x0020: return "WM_COMMAND";
3861 case 0x0021: return "WM_SYSCOMMAND";
3862 case 0x0022: return "WM_HELP";
3863 case 0x0023: return "WM_PAINT";
3864 case 0x0024: return "WM_TIMER";
3865 case 0x0025: return "WM_SEM1";
3866 case 0x0026: return "WM_SEM2";
3867 case 0x0027: return "WM_SEM3";
3868 case 0x0028: return "WM_SEM4";
3869 case 0x0029: return "WM_CLOSE";
3870 case 0x002A: return "WM_QUIT";
3871 case 0x002B: return "WM_SYSCOLORCHANGE";
3872 case 0x002D: return "WM_SYSVALUECHANGE";
3873 case 0x002E: return "WM_APPTERMINATENOTIFY";
3874 case 0x002F: return "WM_PRESPARAMCHANGED";
3875 // Control notification messages
3876 case 0x0030: return "WM_CONTROL";
3877 case 0x0031: return "WM_VSCROLL";
3878 case 0x0032: return "WM_HSCROLL";
3879 case 0x0033: return "WM_INITMENU";
3880 case 0x0034: return "WM_MENUSELECT";
3881 case 0x0035: return "WM_MENUSEND";
3882 case 0x0036: return "WM_DRAWITEM";
3883 case 0x0037: return "WM_MEASUREITEM";
3884 case 0x0038: return "WM_CONTROLPOINTER";
3885 case 0x003A: return "WM_QUERYDLGCODE";
3886 case 0x003B: return "WM_INITDLG";
3887 case 0x003C: return "WM_SUBSTITUTESTRING";
3888 case 0x003D: return "WM_MATCHMNEMONIC";
3889 case 0x003E: return "WM_SAVEAPPLICATION";
3890 case 0x0129: return "WM_CTLCOLORCHANGE";
3891 case 0x0130: return "WM_QUERYCTLTYPE";
3893 case 0x0040: return "WM_FLASHWINDOW";
3894 case 0x0041: return "WM_FORMATFRAME";
3895 case 0x0042: return "WM_UPDATEFRAME";
3896 case 0x0043: return "WM_FOCUSCHANGE";
3897 case 0x0044: return "WM_SETBORDERSIZE";
3898 case 0x0045: return "WM_TRACKFRAME";
3899 case 0x0046: return "WM_MINMAXFRAME";
3900 case 0x0047: return "WM_SETICON";
3901 case 0x0048: return "WM_QUERYICON";
3902 case 0x0049: return "WM_SETACCELTABLE";
3903 case 0x004A: return "WM_QUERYACCELTABLE";
3904 case 0x004B: return "WM_TRANSLATEACCEL";
3905 case 0x004C: return "WM_QUERYTRACKINFO";
3906 case 0x004D: return "WM_QUERYBORDERSIZE";
3907 case 0x004E: return "WM_NEXTMENU";
3908 case 0x004F: return "WM_ERASEBACKGROUND";
3909 case 0x0050: return "WM_QUERYFRAMEINFO";
3910 case 0x0051: return "WM_QUERYFOCUSCHAIN";
3911 case 0x0052: return "WM_OWNERPOSCHANGE";
3912 case 0x0053: return "WM_CACLFRAMERECT";
3913 case 0x0055: return "WM_WINDOWPOSCHANGED";
3914 case 0x0056: return "WM_ADJUSTFRAMEPOS";
3915 case 0x0059: return "WM_QUERYFRAMECTLCOUNT";
3916 case 0x005B: return "WM_QUERYHELPINFO";
3917 case 0x005C: return "WM_SETHELPINFO";
3918 case 0x005D: return "WM_ERROR";
3919 case 0x005E: return "WM_REALIZEPALETTE";
3920 // Clipboard messages
3921 case 0x0060: return "WM_RENDERFMT";
3922 case 0x0061: return "WM_RENDERALLFMTS";
3923 case 0x0062: return "WM_DESTROYCLIPBOARD";
3924 case 0x0063: return "WM_PAINTCLIPBOARD";
3925 case 0x0064: return "WM_SIZECLIPBOARD";
3926 case 0x0065: return "WM_HSCROLLCLIPBOARD";
3927 case 0x0066: return "WM_VSCROLLCLIPBOARD";
3928 case 0x0067: return "WM_DRAWCLIPBOARD";
3930 case 0x0070: return "WM_MOUSEMOVE";
3931 case 0x0071: return "WM_BUTTON1DOWN";
3932 case 0x0072: return "WM_BUTTON1UP";
3933 case 0x0073: return "WM_BUTTON1DBLCLK";
3934 case 0x0074: return "WM_BUTTON2DOWN";
3935 case 0x0075: return "WM_BUTTON2UP";
3936 case 0x0076: return "WM_BUTTON2DBLCLK";
3937 case 0x0077: return "WM_BUTTON3DOWN";
3938 case 0x0078: return "WM_BUTTON3UP";
3939 case 0x0079: return "WM_BUTTON3DBLCLK";
3940 case 0x007D: return "WM_MOUSEMAP";
3941 case 0x007E: return "WM_VRNDISABLED";
3942 case 0x007F: return "WM_VRNENABLED";
3943 case 0x0410: return "WM_CHORD";
3944 case 0x0411: return "WM_BUTTON1MOTIONSTART";
3945 case 0x0412: return "WM_BUTTON1MOTIONEND";
3946 case 0x0413: return "WM_BUTTON1CLICK";
3947 case 0x0414: return "WM_BUTTON2MOTIONSTART";
3948 case 0x0415: return "WM_BUTTON2MOTIONEND";
3949 case 0x0416: return "WM_BUTTON2CLICK";
3950 case 0x0417: return "WM_BUTTON3MOTIONSTART";
3951 case 0x0418: return "WM_BUTTON3MOTIONEND";
3952 case 0x0419: return "WM_BUTTON3CLICK";
3953 case 0x0420: return "WM_BEGINDRAG";
3954 case 0x0421: return "WM_ENDDRAG";
3955 case 0x0422: return "WM_SINGLESELECT";
3956 case 0x0423: return "WM_OPEN";
3957 case 0x0424: return "WM_CONTEXTMENU";
3958 case 0x0425: return "WM_CONTEXTHELP";
3959 case 0x0426: return "WM_TEXTEDIT";
3960 case 0x0427: return "WM_BEGINSELECT";
3961 case 0x0228: return "WM_ENDSELECT";
3962 case 0x0429: return "WM_PICKUP";
3963 case 0x04C0: return "WM_PENFIRST";
3964 case 0x04FF: return "WM_PENLAST";
3965 case 0x0500: return "WM_MMPMFIRST";
3966 case 0x05FF: return "WM_MMPMLAST";
3967 case 0x0600: return "WM_STDDLGFIRST";
3968 case 0x06FF: return "WM_STDDLGLAST";
3969 case 0x0BD0: return "WM_BIDI_FIRST";
3970 case 0x0BFF: return "WM_BIDI_LAST";
3972 case 0x007A: return "WM_CHAR";
3973 case 0x007B: return "WM_VIOCHAR";
3975 case 0x00A0: return "WM_DDE_INITIATE";
3976 case 0x00A1: return "WM_DDE_REQUEST";
3977 case 0x00A2: return "WM_DDE_ACK";
3978 case 0x00A3: return "WM_DDE_DATA";
3979 case 0x00A4: return "WM_DDE_ADVISE";
3980 case 0x00A5: return "WM_DDE_UNADVISE";
3981 case 0x00A6: return "WM_DDE_POKE";
3982 case 0x00A7: return "WM_DDE_EXECUTE";
3983 case 0x00A8: return "WM_DDE_TERMINATE";
3984 case 0x00A9: return "WM_DDE_INITIATEACK";
3985 case 0x00AF: return "WM_DDE_LAST";
3987 case 0x0120: return "BM_CLICK";
3988 case 0x0121: return "BM_QUERYCHECKINDEX";
3989 case 0x0122: return "BM_QUERYHILITE";
3990 case 0x0123: return "BM_SETHILITE";
3991 case 0x0124: return "BM_QUERYCHECK";
3992 case 0x0125: return "BM_SETCHECK";
3993 case 0x0126: return "BM_SETDEFAULT";
3994 case 0x0128: return "BM_AUTOSIZE";
3996 case 0x029A: return "CBID_LIST";
3997 case 0x029B: return "CBID_EDIT";
3998 case 0x0170: return "CBM_SHOWLIST";
3999 case 0x0171: return "CBM_HILITE";
4000 case 0x0172: return "CBM_ISLISTSHOWING";
4002 case 0x0140: return "EM_QUERYCHANGED";
4003 case 0x0141: return "EM_QUERYSEL";
4004 case 0x0142: return "EM_SETSEL";
4005 case 0x0143: return "EM_SETTEXTLIMIT";
4006 case 0x0144: return "EM_CUT";
4007 case 0x0145: return "EM_COPY";
4008 case 0x0146: return "EM_CLEAR";
4009 case 0x0147: return "EM_PASTE";
4010 case 0x0148: return "EM_QUERYFIRSTCHAR";
4011 case 0x0149: return "EM_SETFIRSTCHAR";
4012 case 0x014A: return "EM_QUERYREADONLY";
4013 case 0x014B: return "EM_SETREADONLY";
4014 case 0x014C: return "EM_SETINSERTMODE";
4016 case 0x0160: return "LM_QUERYITEMCOUNT";
4017 case 0x0161: return "LM_INSERTITEM";
4018 case 0x0162: return "LM_SETOPENINDEX";
4019 case 0x0163: return "LM_DELETEITEM";
4020 case 0x0164: return "LM_SELECTITEM";
4021 case 0x0165: return "LM_QUERYSELECTION";
4022 case 0x0166: return "LM_SETITEMTEXT";
4023 case 0x0167: return "LM_QUERYITEMTEXTLENGTH";
4024 case 0x0168: return "LM_QUERYITEMTEXT";
4025 case 0x0169: return "LM_SETITEMHANDLE";
4026 case 0x016A: return "LM_QUERYITEMHANDLE";
4027 case 0x016B: return "LM_SEARCHSTRING";
4028 case 0x016C: return "LM_SETITEMHEIGHT";
4029 case 0x016D: return "LM_QUERYTOPINDEX";
4030 case 0x016E: return "LM_DELETEALL";
4031 case 0x016F: return "LM_INSERTMULITEMS";
4032 case 0x0660: return "LM_SETITEMWIDTH";
4034 case 0x0180: return "MM_INSERTITEM";
4035 case 0x0181: return "MM_DELETEITEM";
4036 case 0x0182: return "MM_QUERYITEM";
4037 case 0x0183: return "MM_SETITEM";
4038 case 0x0184: return "MM_QUERYITEMCOUNT";
4039 case 0x0185: return "MM_STARTMENUMODE";
4040 case 0x0186: return "MM_ENDMENUMODE";
4041 case 0x0188: return "MM_REMOVEITEM";
4042 case 0x0189: return "MM_SELECTITEM";
4043 case 0x018A: return "MM_QUERYSELITEMID";
4044 case 0x018B: return "MM_QUERYITEMTEXT";
4045 case 0x018C: return "MM_QUERYITEMTEXTLENGTH";
4046 case 0x018D: return "MM_SETITEMHANDLE";
4047 case 0x018E: return "MM_SETITEMTEXT";
4048 case 0x018F: return "MM_ITEMPOSITIONFROMID";
4049 case 0x0190: return "MM_ITEMIDFROMPOSITION";
4050 case 0x0191: return "MM_QUERYITEMATTR";
4051 case 0x0192: return "MM_SETITEMATTR";
4052 case 0x0193: return "MM_ISITEMVALID";
4053 case 0x0194: return "MM_QUERYITEMRECT";
4054 case 0x0431: return "MM_QUERYDEFAULTITEMID";
4055 case 0x0432: return "MM_SETDEFAULTITEMID";
4057 case 0x01A0: return "SBM_SETSCROLLBAR";
4058 case 0x01A1: return "SBM_SETPOS";
4059 case 0x01A2: return "SBM_QUERYPOS";
4060 case 0x01A3: return "SBM_QUERYRANGE";
4061 case 0x01A6: return "SBM_SETTHUMBSIZE";
4064 case 0x0F00: return "WM_HELPBASE";
4065 case 0x0FFF: return "WM_HELPTOP";
4066 // Beginning of user defined messages
4067 case 0x1000: return "WM_USER";
4069 // wxWindows user defined types
4072 // case 0x1000 + 0: return "LVM_GETBKCOLOR";
4073 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4074 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4075 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4076 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4077 case 0x1000 + 5: return "LVM_GETITEMA";
4078 case 0x1000 + 75: return "LVM_GETITEMW";
4079 case 0x1000 + 6: return "LVM_SETITEMA";
4080 case 0x1000 + 76: return "LVM_SETITEMW";
4081 case 0x1000 + 7: return "LVM_INSERTITEMA";
4082 case 0x1000 + 77: return "LVM_INSERTITEMW";
4083 case 0x1000 + 8: return "LVM_DELETEITEM";
4084 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4085 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4086 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4087 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4088 case 0x1000 + 13: return "LVM_FINDITEMA";
4089 case 0x1000 + 83: return "LVM_FINDITEMW";
4090 case 0x1000 + 14: return "LVM_GETITEMRECT";
4091 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4092 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4093 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4094 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4095 case 0x1000 + 18: return "LVM_HITTEST";
4096 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4097 case 0x1000 + 20: return "LVM_SCROLL";
4098 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4099 case 0x1000 + 22: return "LVM_ARRANGE";
4100 case 0x1000 + 23: return "LVM_EDITLABELA";
4101 case 0x1000 + 118: return "LVM_EDITLABELW";
4102 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4103 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4104 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4105 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4106 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4107 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4108 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4109 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4110 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4111 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4112 case 0x1000 + 31: return "LVM_GETHEADER";
4113 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4114 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4115 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4116 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4117 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4118 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4119 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4120 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4121 case 0x1000 + 41: return "LVM_GETORIGIN";
4122 case 0x1000 + 42: return "LVM_UPDATE";
4123 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4124 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4125 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4126 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4127 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4128 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4129 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4130 case 0x1000 + 48: return "LVM_SORTITEMS";
4131 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4132 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4133 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4134 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4135 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4136 case 0x1000 + 53: return "LVM_SETICONSPACING";
4137 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4138 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4139 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4140 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4141 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4142 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4143 case 0x1000 + 60: return "LVM_SETHOTITEM";
4144 case 0x1000 + 61: return "LVM_GETHOTITEM";
4145 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4146 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4147 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4148 case 0x1000 + 65: return "LVM_SETWORKAREA";
4151 case 0x1100 + 0: return "TVM_INSERTITEMA";
4152 case 0x1100 + 50: return "TVM_INSERTITEMW";
4153 case 0x1100 + 1: return "TVM_DELETEITEM";
4154 case 0x1100 + 2: return "TVM_EXPAND";
4155 case 0x1100 + 4: return "TVM_GETITEMRECT";
4156 case 0x1100 + 5: return "TVM_GETCOUNT";
4157 case 0x1100 + 6: return "TVM_GETINDENT";
4158 case 0x1100 + 7: return "TVM_SETINDENT";
4159 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4160 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4161 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4162 case 0x1100 + 11: return "TVM_SELECTITEM";
4163 case 0x1100 + 12: return "TVM_GETITEMA";
4164 case 0x1100 + 62: return "TVM_GETITEMW";
4165 case 0x1100 + 13: return "TVM_SETITEMA";
4166 case 0x1100 + 63: return "TVM_SETITEMW";
4167 case 0x1100 + 14: return "TVM_EDITLABELA";
4168 case 0x1100 + 65: return "TVM_EDITLABELW";
4169 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4170 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4171 case 0x1100 + 17: return "TVM_HITTEST";
4172 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4173 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4174 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4175 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4176 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4177 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4178 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4179 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4180 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4183 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4184 case 0x1200 + 1: return "HDM_INSERTITEMA";
4185 case 0x1200 + 10: return "HDM_INSERTITEMW";
4186 case 0x1200 + 2: return "HDM_DELETEITEM";
4187 case 0x1200 + 3: return "HDM_GETITEMA";
4188 case 0x1200 + 11: return "HDM_GETITEMW";
4189 case 0x1200 + 4: return "HDM_SETITEMA";
4190 case 0x1200 + 12: return "HDM_SETITEMW";
4191 case 0x1200 + 5: return "HDM_LAYOUT";
4192 case 0x1200 + 6: return "HDM_HITTEST";
4193 case 0x1200 + 7: return "HDM_GETITEMRECT";
4194 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4195 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4196 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4197 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4198 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4199 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4200 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4203 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4204 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4205 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4206 case 0x1300 + 5: return "TCM_GETITEMA";
4207 case 0x1300 + 60: return "TCM_GETITEMW";
4208 case 0x1300 + 6: return "TCM_SETITEMA";
4209 case 0x1300 + 61: return "TCM_SETITEMW";
4210 case 0x1300 + 7: return "TCM_INSERTITEMA";
4211 case 0x1300 + 62: return "TCM_INSERTITEMW";
4212 case 0x1300 + 8: return "TCM_DELETEITEM";
4213 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4214 case 0x1300 + 10: return "TCM_GETITEMRECT";
4215 case 0x1300 + 11: return "TCM_GETCURSEL";
4216 case 0x1300 + 12: return "TCM_SETCURSEL";
4217 case 0x1300 + 13: return "TCM_HITTEST";
4218 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4219 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4220 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4221 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4222 case 0x1300 + 43: return "TCM_SETPADDING";
4223 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4224 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4225 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4226 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4227 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4228 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4229 case 0x1300 + 50: return "TCM_DESELECTALL";
4232 case WM_USER
+1000+1: return "TB_ENABLEBUTTON";
4233 case WM_USER
+1000+2: return "TB_CHECKBUTTON";
4234 case WM_USER
+1000+3: return "TB_PRESSBUTTON";
4235 case WM_USER
+1000+4: return "TB_HIDEBUTTON";
4236 case WM_USER
+1000+5: return "TB_INDETERMINATE";
4237 case WM_USER
+1000+9: return "TB_ISBUTTONENABLED";
4238 case WM_USER
+1000+10: return "TB_ISBUTTONCHECKED";
4239 case WM_USER
+1000+11: return "TB_ISBUTTONPRESSED";
4240 case WM_USER
+1000+12: return "TB_ISBUTTONHIDDEN";
4241 case WM_USER
+1000+13: return "TB_ISBUTTONINDETERMINATE";
4242 case WM_USER
+1000+17: return "TB_SETSTATE";
4243 case WM_USER
+1000+18: return "TB_GETSTATE";
4244 case WM_USER
+1000+19: return "TB_ADDBITMAP";
4245 case WM_USER
+1000+20: return "TB_ADDBUTTONS";
4246 case WM_USER
+1000+21: return "TB_INSERTBUTTON";
4247 case WM_USER
+1000+22: return "TB_DELETEBUTTON";
4248 case WM_USER
+1000+23: return "TB_GETBUTTON";
4249 case WM_USER
+1000+24: return "TB_BUTTONCOUNT";
4250 case WM_USER
+1000+25: return "TB_COMMANDTOINDEX";
4251 case WM_USER
+1000+26: return "TB_SAVERESTOREA";
4252 case WM_USER
+1000+76: return "TB_SAVERESTOREW";
4253 case WM_USER
+1000+27: return "TB_CUSTOMIZE";
4254 case WM_USER
+1000+28: return "TB_ADDSTRINGA";
4255 case WM_USER
+1000+77: return "TB_ADDSTRINGW";
4256 case WM_USER
+1000+29: return "TB_GETITEMRECT";
4257 case WM_USER
+1000+30: return "TB_BUTTONSTRUCTSIZE";
4258 case WM_USER
+1000+31: return "TB_SETBUTTONSIZE";
4259 case WM_USER
+1000+32: return "TB_SETBITMAPSIZE";
4260 case WM_USER
+1000+33: return "TB_AUTOSIZE";
4261 case WM_USER
+1000+35: return "TB_GETTOOLTIPS";
4262 case WM_USER
+1000+36: return "TB_SETTOOLTIPS";
4263 case WM_USER
+1000+37: return "TB_SETPARENT";
4264 case WM_USER
+1000+39: return "TB_SETROWS";
4265 case WM_USER
+1000+40: return "TB_GETROWS";
4266 case WM_USER
+1000+42: return "TB_SETCMDID";
4267 case WM_USER
+1000+43: return "TB_CHANGEBITMAP";
4268 case WM_USER
+1000+44: return "TB_GETBITMAP";
4269 case WM_USER
+1000+45: return "TB_GETBUTTONTEXTA";
4270 case WM_USER
+1000+75: return "TB_GETBUTTONTEXTW";
4271 case WM_USER
+1000+46: return "TB_REPLACEBITMAP";
4272 case WM_USER
+1000+47: return "TB_SETINDENT";
4273 case WM_USER
+1000+48: return "TB_SETIMAGELIST";
4274 case WM_USER
+1000+49: return "TB_GETIMAGELIST";
4275 case WM_USER
+1000+50: return "TB_LOADIMAGES";
4276 case WM_USER
+1000+51: return "TB_GETRECT";
4277 case WM_USER
+1000+52: return "TB_SETHOTIMAGELIST";
4278 case WM_USER
+1000+53: return "TB_GETHOTIMAGELIST";
4279 case WM_USER
+1000+54: return "TB_SETDISABLEDIMAGELIST";
4280 case WM_USER
+1000+55: return "TB_GETDISABLEDIMAGELIST";
4281 case WM_USER
+1000+56: return "TB_SETSTYLE";
4282 case WM_USER
+1000+57: return "TB_GETSTYLE";
4283 case WM_USER
+1000+58: return "TB_GETBUTTONSIZE";
4284 case WM_USER
+1000+59: return "TB_SETBUTTONWIDTH";
4285 case WM_USER
+1000+60: return "TB_SETMAXTEXTROWS";
4286 case WM_USER
+1000+61: return "TB_GETTEXTROWS";
4287 case WM_USER
+1000+41: return "TB_GETBITMAPFLAGS";
4290 static char s_szBuf
[128];
4291 sprintf(s_szBuf
, "<unknown message = %d>", nMessage
);
4295 } // end of wxGetMessageName
4297 #endif // __WXDEBUG__
4299 static void TranslateKbdEventToMouse(
4307 // Construct the key mask
4308 ULONG
& fwKeys
= *pFlags
;
4310 fwKeys
= VK_BUTTON2
;
4311 if ((::WinGetKeyState(HWND_DESKTOP
, VK_CTRL
) & 0x100) != 0)
4313 if ((::WinGetKeyState(HWND_DESKTOP
, VK_SHIFT
) & 0x100) != 0)
4317 // Simulate right mouse button click
4321 ::WinQueryMsgPos(vHabmain
, &vPoint
);
4325 pWin
->ScreenToClient(pX
, pY
);
4326 } // end of TranslateKbdEventToMouse
4328 // Find the wxWindow at the current mouse position, returning the mouse
4330 wxWindow
* wxFindWindowAtPointer(
4334 return wxFindWindowAtPoint(wxGetMousePosition());
4337 wxWindow
* wxFindWindowAtPoint(
4346 HWND hWndHit
= ::WinWindowFromPoint(HWND_DESKTOP
, &vPt2
, FALSE
);
4347 wxWindow
* pWin
= wxFindWinFromHandle((WXHWND
)hWndHit
) ;
4348 HWND hWnd
= hWndHit
;
4351 // Try to find a window with a wxWindow associated with it
4353 while (!pWin
&& (hWnd
!= 0))
4355 hWnd
= ::WinQueryWindow(hWnd
, QW_PARENT
);
4356 pWin
= wxFindWinFromHandle((WXHWND
)hWnd
) ;
4361 // Get the current mouse position.
4362 wxPoint
wxGetMousePosition()
4366 ::WinQueryPointerPos(HWND_DESKTOP
, &vPt
);
4367 return wxPoint(vPt
.x
, vPt
.y
);