1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dcclient.h"
31 #include "wx/layout.h"
32 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/msgdlg.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
46 #include "wx/msw/ole/droptgt.h"
49 #include "wx/menuitem.h"
53 #include "wx/tooltip.h"
59 #include "wx/msw/private.h"
61 #include "wx/textctrl.h"
74 #if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ )
80 #include <wx/msw/gnuwin32/extra.h>
101 const char *wxGetMessageName(int message
);
104 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
106 wxMenu
*wxCurrentPopupMenu
= NULL
;
107 extern wxList WXDLLEXPORT wxPendingDelete
;
109 void wxRemoveHandleAssociation(wxWindow
*win
);
110 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
111 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
113 #if !USE_SHARED_LIBRARY
114 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
117 BEGIN_EVENT_TABLE(wxWindow
, wxWindowBase
)
118 EVT_CHAR(wxWindow::OnChar
)
119 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
120 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
121 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
122 EVT_IDLE(wxWindow::OnIdle
)
125 // Find an item given the MS Windows id
126 wxWindow
*wxWindow::FindItem(int id
) const
128 // if ( !GetChildren() )
130 wxNode
*current
= GetChildren().First();
133 wxWindow
*childWin
= (wxWindow
*)current
->Data();
135 wxWindow
*wnd
= childWin
->FindItem(id
) ;
139 if ( childWin
->IsKindOf(CLASSINFO(wxControl
)) )
141 wxControl
*item
= (wxControl
*)childWin
;
142 if ( item
->GetId() == id
)
146 // In case it's a 'virtual' control (e.g. radiobox)
147 if ( item
->GetSubcontrols().Member((wxObject
*)id
) )
151 current
= current
->Next();
156 // Find an item given the MS Windows handle
157 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
159 // if ( !GetChildren() )
161 wxNode
*current
= GetChildren().First();
164 wxObject
*obj
= (wxObject
*)current
->Data() ;
165 // Do a recursive search.
166 wxWindow
*parent
= (wxWindow
*)obj
;
167 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
171 if ( (!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)) )
173 wxWindow
*item
= (wxWindow
*)current
->Data();
174 if ( (HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
178 if ( item
->ContainsHWND(hWnd
) )
182 current
= current
->Next();
187 // Default command handler
188 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
193 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
195 WXLPARAM
* WXUNUSED(result
))
199 NMHDR
* hdr
= (NMHDR
*)lParam
;
200 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
202 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
203 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
214 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
218 // ----------------------------------------------------------------------------
219 // constructors and such
220 // ----------------------------------------------------------------------------
222 void wxWindow::Init()
228 m_doubleClickAllowed
= 0 ;
229 m_winCaptured
= FALSE
;
231 // caret stuff: initially there is no caret at all
235 m_caretShown
= FALSE
;
239 m_isBeingDeleted
= FALSE
;
242 m_mouseInWindow
= FALSE
;
252 m_backgroundTransparent
= FALSE
;
256 m_lastMouseEvent
= -1;
260 wxWindow::~wxWindow()
262 m_isBeingDeleted
= TRUE
;
264 MSWDetachWindowMenu();
267 ::DestroyWindow((HWND
)m_hWnd
);
269 wxRemoveHandleAssociation(this);
272 // Restore old Window proc, if required and remove hWnd <-> wxWindow
277 extern char wxCanvasClassName
[];
279 // real construction (Init() must have been called before!)
280 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
284 const wxString
& name
)
286 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
288 parent
->AddChild(this);
291 if ( style
& wxBORDER
)
292 msflags
|= WS_BORDER
;
293 if ( style
& wxTHICK_FRAME
)
294 msflags
|= WS_THICKFRAME
;
296 msflags
|= WS_CHILD
| WS_VISIBLE
;
297 if ( style
& wxCLIP_CHILDREN
)
298 msflags
|= WS_CLIPCHILDREN
;
301 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
303 // Even with extended styles, need to combine with WS_BORDER
304 // for them to look right.
305 if ( want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
306 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
308 msflags
|= WS_BORDER
;
311 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
313 WidthDefault(size
.x
), HeightDefault(size
.y
),
314 msflags
, NULL
, exStyle
);
319 void wxWindow::SetFocus()
321 HWND hWnd
= (HWND
) GetHWND();
326 bool wxWindow::Enable(bool enable
)
328 if ( !wxWindowBase::Enable(enable
) )
331 HWND hWnd
= (HWND
) GetHWND();
333 ::EnableWindow(hWnd
, (BOOL
)enable
);
338 void wxWindow::CaptureMouse()
340 HWND hWnd
= (HWND
) GetHWND();
341 if ( hWnd
&& !m_winCaptured
)
344 m_winCaptured
= TRUE
;
348 void wxWindow::ReleaseMouse()
353 m_winCaptured
= FALSE
;
357 #if wxUSE_DRAG_AND_DROP
359 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
361 if ( m_dropTarget
!= 0 ) {
362 m_dropTarget
->Revoke(m_hWnd
);
366 m_dropTarget
= pDropTarget
;
367 if ( m_dropTarget
!= 0 )
368 m_dropTarget
->Register(m_hWnd
);
371 #endif // wxUSE_DRAG_AND_DROP
374 //old style file-manager drag&drop support
375 // I think we should retain the old-style
376 // DragAcceptFiles in parallel with SetDropTarget.
378 void wxWindow::DragAcceptFiles(bool accept
)
380 HWND hWnd
= (HWND
) GetHWND();
382 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
385 // ----------------------------------------------------------------------------
387 // ----------------------------------------------------------------------------
391 void wxWindow::DoSetToolTip(wxToolTip
*tooltip
)
393 wxWindowBase::SetToolTip(tooltip
);
396 m_tooltip
->SetWindow(this);
399 #endif // wxUSE_TOOLTIPS
402 void wxWindow::DoGetSize(int *x
, int *y
) const
404 HWND hWnd
= (HWND
) GetHWND();
406 GetWindowRect(hWnd
, &rect
);
409 *x
= rect
.right
- rect
.left
;
411 *y
= rect
.bottom
- rect
.top
;
414 void wxWindow::DoGetPosition(int *x
, int *y
) const
416 HWND hWnd
= (HWND
) GetHWND();
419 hParentWnd
= (HWND
) GetParent()->GetHWND();
422 GetWindowRect(hWnd
, &rect
);
424 // Since we now have the absolute screen coords, if there's a parent we
425 // must subtract its top left corner
431 ::ScreenToClient(hParentWnd
, &point
);
434 // We may be faking the client origin. So a window that's really at (0,
435 // 30) may appear (to wxWin apps) to be at (0, 0).
438 wxPoint
pt(GetParent()->GetClientAreaOrigin());
449 void wxWindow::ScreenToClient(int *x
, int *y
) const
457 HWND hWnd
= (HWND
) GetHWND();
458 ::ScreenToClient(hWnd
, &pt
);
466 void wxWindow::ClientToScreen(int *x
, int *y
) const
474 HWND hWnd
= (HWND
) GetHWND();
475 ::ClientToScreen(hWnd
, &pt
);
483 bool wxWindow::SetCursor(const wxCursor
& cursor
)
485 if ( !wxWindowBase::SetCursor(cursor
) )
491 wxASSERT_MSG( m_cursor
.Ok(),
492 _T("cursor must be valid after call to the base version"));
494 HWND hWnd
= (HWND
)GetHWND();
496 // Change the cursor NOW if we're within the correct window
498 ::GetCursorPos(&point
);
501 ::GetWindowRect(hWnd
, &rect
);
503 if ( ::PtInRect(&rect
, point
) && !wxIsBusy() )
504 ::SetCursor((HCURSOR
)m_cursor
.GetHCURSOR());
509 // Get size *available for subwindows* i.e. excluding menu bar etc.
510 void wxWindow::DoGetClientSize(int *x
, int *y
) const
512 HWND hWnd
= (HWND
) GetHWND();
514 ::GetClientRect(hWnd
, &rect
);
521 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
523 int currentX
, currentY
;
524 GetPosition(¤tX
, ¤tY
);
525 int currentW
,currentH
;
526 GetSize(¤tW
, ¤tH
);
528 if ( x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
531 int actualWidth
= width
;
532 int actualHeight
= height
;
535 if ( x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
537 if ( y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
540 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
543 actualWidth
= currentW
;
545 actualHeight
= currentH
;
547 HWND hWnd
= (HWND
) GetHWND();
549 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
552 void wxWindow::DoSetClientSize(int width
, int height
)
554 wxWindow
*parent
= GetParent();
555 HWND hWnd
= (HWND
) GetHWND();
556 HWND hParentWnd
= (HWND
) 0;
558 hParentWnd
= (HWND
) parent
->GetHWND();
561 ::GetClientRect(hWnd
, &rect
);
564 GetWindowRect(hWnd
, &rect2
);
566 // Find the difference between the entire window (title bar and all)
567 // and the client area; add this to the new client size to move the
569 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
570 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
572 // If there's a parent, must subtract the parent's top left corner
573 // since MoveWindow moves relative to the parent
576 point
.x
= rect2
.left
;
580 ::ScreenToClient(hParentWnd
, &point
);
583 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
585 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
586 event
.SetEventObject(this);
587 GetEventHandler()->ProcessEvent(event
);
590 // For implementation purposes - sometimes decorations make the client area
592 wxPoint
wxWindow::GetClientAreaOrigin() const
594 return wxPoint(0, 0);
597 // Makes an adjustment to the window position (for example, a frame that has
598 // a toolbar that it manages itself).
599 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
601 if ( ((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent() )
603 wxPoint
pt(GetParent()->GetClientAreaOrigin());
604 x
+= pt
.x
; y
+= pt
.y
;
608 bool wxWindow::Show(bool show
)
610 if ( !wxWindowBase::Show(show
) )
613 HWND hWnd
= (HWND
) GetHWND();
614 int cshow
= show
? SW_SHOW
: SW_HIDE
;
615 ::ShowWindow(hWnd
, cshow
);
619 BringWindowToTop(hWnd
);
625 int wxWindow::GetCharHeight(void) const
627 TEXTMETRIC lpTextMetric
;
628 HWND hWnd
= (HWND
) GetHWND();
629 HDC dc
= ::GetDC(hWnd
);
631 GetTextMetrics(dc
, &lpTextMetric
);
632 ::ReleaseDC(hWnd
, dc
);
634 return lpTextMetric
.tmHeight
;
637 int wxWindow::GetCharWidth(void) const
639 TEXTMETRIC lpTextMetric
;
640 HWND hWnd
= (HWND
) GetHWND();
641 HDC dc
= ::GetDC(hWnd
);
643 GetTextMetrics(dc
, &lpTextMetric
);
644 ::ReleaseDC(hWnd
, dc
);
646 return lpTextMetric
.tmAveCharWidth
;
649 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
650 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
652 wxFont
*fontToUse
= (wxFont
*)theFont
;
654 fontToUse
= (wxFont
*) & m_font
;
656 HWND hWnd
= (HWND
) GetHWND();
657 HDC dc
= ::GetDC(hWnd
);
661 if ( fontToUse
&& fontToUse
->Ok() )
663 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
665 was
= (HFONT
) SelectObject(dc
,fnt
) ;
670 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
671 GetTextMetrics(dc
, &tm
);
673 if ( fontToUse
&& fnt
&& was
)
674 SelectObject(dc
,was
) ;
680 if ( descent
) *descent
= tm
.tmDescent
;
681 if ( externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
684 // fontToUse->ReleaseResource();
687 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
689 HWND hWnd
= (HWND
) GetHWND();
695 mswRect
.left
= rect
->x
;
696 mswRect
.top
= rect
->y
;
697 mswRect
.right
= rect
->x
+ rect
->width
;
698 mswRect
.bottom
= rect
->y
+ rect
->height
;
700 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
703 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
707 bool wxWindow::ProcessEvent(wxEvent
& event
)
709 // we save here the information about the last message because it might be
710 // overwritten if the event handler sends any messages to our window (case
711 // in point: wxNotebook::OnSize) - and then if we call Default() later
712 // (which is done quite often if the message is not processed) it will use
713 // incorrect values for m_lastXXX variables
714 WXUINT lastMsg
= m_lastMsg
;
715 WXWPARAM lastWParam
= m_lastWParam
;
716 WXLPARAM lastLParam
= m_lastLParam
;
718 // call the base version
719 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
723 m_lastWParam
= lastWParam
;
724 m_lastLParam
= lastLParam
;
729 // Hook for new window just as it's being created,
730 // when the window isn't yet associated with the handle
731 wxWindow
*wxWndHook
= NULL
;
734 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
736 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
738 if ( !wnd
&& wxWndHook
)
740 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
743 wnd
->SetHWND((WXHWND
)hWnd
);
746 // Stop right here if we don't have a valid handle in our wxWindow object.
747 if ( wnd
&& !wnd
->GetHWND() ) {
748 wnd
->SetHWND((WXHWND
) hWnd
);
749 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
755 wnd
->PushLastMessage(message
, wParam
, lParam
);
758 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
760 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
763 // Should probably have a test for 'genuine' NT
764 #if defined(__WIN32__)
765 #define DIMENSION_TYPE short
767 #define DIMENSION_TYPE int
770 // Main Windows window proc
771 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
773 wxASSERT( m_lastMsg
== message
&&
774 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
777 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
778 wxGetMessageName(message
), wParam
, lParam
);
779 #endif // __WXDEBUG__
781 HWND hWnd
= (HWND
)m_hWnd
;
788 WORD state
= LOWORD(wParam
);
789 WORD minimized
= HIWORD(wParam
);
790 HWND hwnd
= (HWND
)lParam
;
792 WORD state
= (WORD
)wParam
;
793 WORD minimized
= LOWORD(lParam
);
794 HWND hwnd
= (HWND
)HIWORD(lParam
);
796 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
802 HWND hwnd
= (HWND
)wParam
;
803 // return OnSetFocus(hwnd);
805 if ( MSWOnSetFocus((WXHWND
) hwnd
) )
807 else return MSWDefWindowProc(message
, wParam
, lParam
);
812 HWND hwnd
= (HWND
)lParam
;
813 // return OnKillFocus(hwnd);
814 if ( MSWOnKillFocus((WXHWND
) hwnd
) )
817 return MSWDefWindowProc(message
, wParam
, lParam
);
822 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
828 MSWOnShow((wParam
!= 0), (int) lParam
);
835 else return MSWDefWindowProc(message
, wParam
, lParam
);
838 case WM_QUERYDRAGICON
:
840 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
844 return MSWDefWindowProc(message
, wParam
, lParam
);
850 int width
= LOWORD(lParam
);
851 int height
= HIWORD(lParam
);
852 MSWOnSize(width
, height
, wParam
);
858 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
860 event
.SetEventObject(this);
861 if ( !GetEventHandler()->ProcessEvent(event
) )
866 case WM_WINDOWPOSCHANGING
:
868 MSWOnWindowPosChanging((void *)lParam
);
874 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
875 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
876 MSWOnRButtonDown(x
, y
, wParam
);
881 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
882 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
883 MSWOnRButtonUp(x
, y
, wParam
);
886 case WM_RBUTTONDBLCLK
:
888 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
889 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
890 MSWOnRButtonDClick(x
, y
, wParam
);
895 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
896 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
897 MSWOnMButtonDown(x
, y
, wParam
);
902 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
903 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
904 MSWOnMButtonUp(x
, y
, wParam
);
907 case WM_MBUTTONDBLCLK
:
909 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
910 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
911 MSWOnMButtonDClick(x
, y
, wParam
);
916 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
917 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
918 MSWOnLButtonDown(x
, y
, wParam
);
923 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
924 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
925 MSWOnLButtonUp(x
, y
, wParam
);
928 case WM_LBUTTONDBLCLK
:
930 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
931 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
932 MSWOnLButtonDClick(x
, y
, wParam
);
937 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
938 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
939 MSWOnMouseMove(x
, y
, wParam
);
942 case MM_JOY1BUTTONDOWN
:
944 int x
= LOWORD(lParam
);
945 int y
= HIWORD(lParam
);
946 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
949 case MM_JOY2BUTTONDOWN
:
951 int x
= LOWORD(lParam
);
952 int y
= HIWORD(lParam
);
953 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
956 case MM_JOY1BUTTONUP
:
958 int x
= LOWORD(lParam
);
959 int y
= HIWORD(lParam
);
960 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
963 case MM_JOY2BUTTONUP
:
965 int x
= LOWORD(lParam
);
966 int y
= HIWORD(lParam
);
967 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
972 int x
= LOWORD(lParam
);
973 int y
= HIWORD(lParam
);
974 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
979 int x
= LOWORD(lParam
);
980 int y
= HIWORD(lParam
);
981 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
986 int z
= LOWORD(lParam
);
987 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
992 int z
= LOWORD(lParam
);
993 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
998 if ( MSWOnDestroy() )
1000 else return MSWDefWindowProc(message
, wParam
, lParam
);
1005 return MSWOnSysCommand(wParam
, lParam
);
1012 WORD id
= LOWORD(wParam
);
1013 HWND hwnd
= (HWND
)lParam
;
1014 WORD cmd
= HIWORD(wParam
);
1016 WORD id
= (WORD
)wParam
;
1017 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1018 WORD cmd
= HIWORD(lParam
);
1020 if ( !MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
) )
1021 return MSWDefWindowProc(message
, wParam
, lParam
);
1024 #if defined(__WIN95__)
1027 // for some messages (TVN_ITEMEXPANDING for example), the return
1028 // value of WM_NOTIFY handler is important, so don't just return 0
1029 // if we processed the message
1030 return MSWOnNotify(wParam
, lParam
);
1036 WORD flags
= HIWORD(wParam
);
1037 HMENU sysmenu
= (HMENU
)lParam
;
1039 WORD flags
= LOWORD(lParam
);
1040 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1042 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1045 case WM_INITMENUPOPUP
:
1047 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1052 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1055 case WM_MEASUREITEM
:
1057 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1061 // If this has been processed by an event handler,
1062 // return 0 now (we've handled it).
1063 if ( MSWOnKeyDown((WORD
) wParam
, lParam
) )
1066 // we consider these message "not interesting" to OnChar
1067 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1074 // avoid duplicate messages to OnChar for these ASCII keys: they
1075 // will be translated by TranslateMessage() and received in WM_CHAR
1085 // normally these macros would be defined in windows.h
1086 #ifndef GET_X_LPARAM
1087 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
1088 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
1091 // special case of VK_APPS: treat it the same as right mouse click
1092 // because both usually pop up a context menu
1095 // construct the key mask
1096 WPARAM fwKeys
= MK_RBUTTON
;
1097 if ( (::GetKeyState(VK_CONTROL
) & 0x100) != 0 )
1098 fwKeys
|= MK_CONTROL
;
1099 if ( (::GetKeyState(VK_SHIFT
) & 0x100) != 0 )
1102 // simulate right mouse button click
1103 DWORD dwPos
= ::GetMessagePos();
1104 int x
= GET_X_LPARAM(dwPos
),
1105 y
= GET_Y_LPARAM(dwPos
);
1107 ScreenToClient(&x
, &y
);
1108 MSWOnRButtonDown(x
, y
, fwKeys
);
1118 if ( !MSWOnChar((WORD
)wParam
, lParam
) )
1127 if ( !MSWOnKeyUp((WORD
) wParam
, lParam
) )
1131 case WM_CHAR
: // Always an ASCII character
1132 if ( !MSWOnChar((WORD
)wParam
, lParam
, TRUE
) )
1139 WORD code
= LOWORD(wParam
);
1140 WORD pos
= HIWORD(wParam
);
1141 HWND control
= (HWND
)lParam
;
1143 WORD code
= (WORD
)wParam
;
1144 WORD pos
= LOWORD(lParam
);
1145 HWND control
= (HWND
)HIWORD(lParam
);
1147 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1153 WORD code
= LOWORD(wParam
);
1154 WORD pos
= HIWORD(wParam
);
1155 HWND control
= (HWND
)lParam
;
1157 WORD code
= (WORD
)wParam
;
1158 WORD pos
= LOWORD(lParam
);
1159 HWND control
= (HWND
)HIWORD(lParam
);
1161 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1165 case WM_CTLCOLORBTN
:
1167 int nCtlColor
= CTLCOLOR_BTN
;
1168 HWND control
= (HWND
)lParam
;
1169 HDC pDC
= (HDC
)wParam
;
1170 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1171 message
, wParam
, lParam
);
1174 case WM_CTLCOLORDLG
:
1176 int nCtlColor
= CTLCOLOR_DLG
;
1177 HWND control
= (HWND
)lParam
;
1178 HDC pDC
= (HDC
)wParam
;
1179 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1180 message
, wParam
, lParam
);\
1183 case WM_CTLCOLORLISTBOX
:
1185 int nCtlColor
= CTLCOLOR_LISTBOX
;
1186 HWND control
= (HWND
)lParam
;
1187 HDC pDC
= (HDC
)wParam
;
1188 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1189 message
, wParam
, lParam
);
1192 case WM_CTLCOLORMSGBOX
:
1194 int nCtlColor
= CTLCOLOR_MSGBOX
;
1195 HWND control
= (HWND
)lParam
;
1196 HDC pDC
= (HDC
)wParam
;
1197 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1198 message
, wParam
, lParam
);
1201 case WM_CTLCOLORSCROLLBAR
:
1203 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1204 HWND control
= (HWND
)lParam
;
1205 HDC pDC
= (HDC
)wParam
;
1206 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1207 message
, wParam
, lParam
);
1210 case WM_CTLCOLORSTATIC
:
1212 int nCtlColor
= CTLCOLOR_STATIC
;
1213 HWND control
= (HWND
)lParam
;
1214 HDC pDC
= (HDC
)wParam
;
1215 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1216 message
, wParam
, lParam
);
1219 case WM_CTLCOLOREDIT
:
1221 int nCtlColor
= CTLCOLOR_EDIT
;
1222 HWND control
= (HWND
)lParam
;
1223 HDC pDC
= (HDC
)wParam
;
1224 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1225 message
, wParam
, lParam
);
1231 HWND control
= (HWND
)LOWORD(lParam
);
1232 int nCtlColor
= (int)HIWORD(lParam
);
1233 HDC pDC
= (HDC
)wParam
;
1234 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1235 message
, wParam
, lParam
);
1239 case WM_SYSCOLORCHANGE
:
1241 // Return value of 0 means, we processed it.
1242 if ( MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0 )
1245 return MSWDefWindowProc(message
, wParam
, lParam
);
1248 case WM_PALETTECHANGED
:
1250 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1253 case WM_QUERYNEWPALETTE
:
1255 return MSWOnQueryNewPalette();
1260 // Prevents flicker when dragging
1261 if ( IsIconic(hWnd
) ) return 1;
1263 if ( !MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
) )
1264 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1268 case WM_MDIACTIVATE
:
1271 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1272 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1273 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1274 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1276 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1277 (HWND
)HIWORD(lParam
));
1282 MSWOnDropFiles(wParam
);
1287 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1290 case WM_QUERYENDSESSION
:
1292 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1293 // return MSWOnClose();
1295 return MSWOnQueryEndSession(lParam
);
1300 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1301 MSWOnEndSession((wParam
!= 0), lParam
);
1313 case WM_GETMINMAXINFO
:
1315 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1316 if ( m_minWidth
!= -1 )
1317 info
->ptMinTrackSize
.x
= m_minWidth
;
1318 if ( m_minHeight
!= -1 )
1319 info
->ptMinTrackSize
.y
= m_minHeight
;
1320 if ( m_maxWidth
!= -1 )
1321 info
->ptMaxTrackSize
.x
= m_maxWidth
;
1322 if ( m_maxHeight
!= -1 )
1323 info
->ptMaxTrackSize
.y
= m_maxHeight
;
1324 return MSWDefWindowProc(message
, wParam
, lParam
);
1329 return MSWGetDlgCode();
1333 // don't set cursor for other windows, only for this one: this
1334 // prevents children of this window from getting the same cursor
1335 // as the parent has (don't forget that this message is propagated
1336 // by default up the window parent-child hierarchy)
1337 if ( (HWND
)wParam
== hWnd
)
1339 // don't set cursor when the mouse is not in the client part
1340 short nHitTest
= LOWORD(lParam
);
1341 if ( nHitTest
== HTCLIENT
|| nHitTest
== HTERROR
)
1343 HCURSOR hcursor
= 0;
1346 // from msw\utils.cpp
1347 extern HCURSOR gs_wxBusyCursor
;
1349 hcursor
= gs_wxBusyCursor
;
1353 wxCursor
*cursor
= NULL
;
1355 if ( m_cursor
.Ok() )
1361 // from msw\data.cpp
1362 extern wxCursor
*g_globalCursor
;
1364 if ( g_globalCursor
&& g_globalCursor
->Ok() )
1365 cursor
= g_globalCursor
;
1369 hcursor
= (HCURSOR
)cursor
->GetHCURSOR();
1374 ::SetCursor(hcursor
);
1376 // returning TRUE stops the DefWindowProc() from
1377 // further processing this message - exactly what we
1378 // need because we've just set the cursor.
1384 return MSWDefWindowProc(message
, wParam
, lParam
);
1387 return MSWDefWindowProc(message
, wParam
, lParam
);
1390 return 0; // Success: we processed this command.
1393 // Dialog window proc
1394 LONG APIENTRY _EXPORT
1395 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1400 wxList
*wxWinHandleList
= NULL
;
1401 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1403 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1406 return (wxWindow
*)node
->Data();
1409 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1411 // adding NULL hWnd is (first) surely a result of an error and
1412 // (secondly) breaks menu command processing
1413 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1415 if ( !wxWinHandleList
->Find((long)hWnd
) )
1416 wxWinHandleList
->Append((long)hWnd
, win
);
1419 void wxRemoveHandleAssociation(wxWindow
*win
)
1421 wxWinHandleList
->DeleteObject(win
);
1424 // Default destroyer - override if you destroy it in some other way
1425 // (e.g. with MDI child windows)
1426 void wxWindow::MSWDestroyWindow()
1430 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1431 int x
, int y
, int width
, int height
,
1432 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1434 bool is_dialog
= (dialog_template
!= NULL
);
1435 int x1
= CW_USEDEFAULT
;
1437 int width1
= CW_USEDEFAULT
;
1440 // Find parent's size, if it exists, to set up a possible default
1441 // panel size the size of the parent window
1445 // Was GetWindowRect: JACS 5/5/95
1446 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1448 width1
= parent_rect
.right
- parent_rect
.left
;
1449 height1
= parent_rect
.bottom
- parent_rect
.top
;
1452 if ( x
> -1 ) x1
= x
;
1453 if ( y
> -1 ) y1
= y
;
1454 if ( width
> -1 ) width1
= width
;
1455 if ( height
> -1 ) height1
= height
;
1457 HWND hParent
= NULL
;
1459 hParent
= (HWND
) parent
->GetHWND();
1465 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1466 // other compilers???
1467 // VZ: it's always needed for Win16 and never for Win32
1469 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1470 (DLGPROC
)wxDlgProc
);
1472 // N.B.: if we _don't_ use this form,
1473 // then with VC++ 1.5, it crashes horribly.
1475 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1476 (DLGPROC
)wxDlgProc
);
1478 // Crashes when we use this.
1479 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1481 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1487 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1488 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1489 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1494 if ( style
& WS_CHILD
)
1499 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1504 hParent
, (HMENU
)controlId
, wxGetInstance(),
1508 wxLogError("Can't create window of class %s!\n"
1509 "Possible Windows 3.x compatibility problem?", wclass
);
1514 wxWinHandleList
->Append((long)m_hWnd
, this);
1517 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1521 bool wxWindow::MSWOnClose()
1526 // Some compilers don't define this
1527 #ifndef ENDSESSION_LOGOFF
1528 #define ENDSESSION_LOGOFF 0x80000000
1531 // Return TRUE to end session, FALSE to veto end session.
1532 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1534 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1535 event
.SetEventObject(wxTheApp
);
1536 event
.SetCanVeto(TRUE
);
1537 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1538 if ( (this == wxTheApp
->GetTopWindow() ) && // Only send once
1539 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1541 return FALSE
; // Veto!
1545 return TRUE
; // Don't veto
1549 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1551 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1552 event
.SetEventObject(wxTheApp
);
1553 event
.SetCanVeto(FALSE
);
1554 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1555 if (endSession
&& // No need to send if the session isn't ending
1556 (this == wxTheApp
->GetTopWindow()) && // Only send once
1557 wxTheApp
->ProcessEvent(event
))
1563 bool wxWindow::MSWOnDestroy()
1565 // delete our drop target if we've got one
1566 #if wxUSE_DRAG_AND_DROP
1567 if ( m_dropTarget
!= NULL
) {
1568 m_dropTarget
->Revoke(m_hWnd
);
1570 delete m_dropTarget
;
1571 m_dropTarget
= NULL
;
1578 // Deal with child commands from buttons etc.
1580 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1582 #if defined(__WIN95__)
1583 // Find a child window to send the notification to, e.g. a toolbar.
1584 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1585 // handle of the toolbar; it's probably the handle of the tooltip
1586 // window (anyway, it's parent is also the toolbar's parent).
1587 // So, since we don't know which hWnd or wxWindow originated the
1588 // WM_NOTIFY, we'll need to go through all the children of this window
1589 // trying out MSWNotify.
1590 // This won't work now, though, because any number of controls
1591 // could respond to the same generic messages :-(
1593 /* This doesn't work for toolbars, but try for other controls first.
1595 NMHDR
*hdr
= (NMHDR
*)lParam
;
1596 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1597 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1599 WXLPARAM result
= 0;
1603 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1608 // Rely on MSWNotify to check whether the message
1609 // belongs to the window or not
1610 wxNode
*node
= GetChildren().First();
1613 wxWindow
*child
= (wxWindow
*)node
->Data();
1614 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1616 node
= node
->Next();
1619 // finally try this window too (catches toolbar case)
1620 if ( MSWNotify(wParam
, lParam
, &result
) )
1629 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1633 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1637 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1639 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1641 event
.SetEventObject(this);
1642 GetEventHandler()->ProcessEvent(event
);
1646 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1649 if ( m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0) )
1651 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1653 ::ShowCaret((HWND
) GetHWND());
1656 // panel wants to track the window which was the last to have focus in it
1657 wxWindow
*parent
= GetParent();
1658 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1660 ((wxPanel
*)parent
)->SetLastFocus(GetId());
1663 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1664 event
.SetEventObject(this);
1665 if ( !GetEventHandler()->ProcessEvent(event
) )
1670 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1673 if ( m_caretEnabled
)
1678 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1679 event
.SetEventObject(this);
1680 if ( !GetEventHandler()->ProcessEvent(event
) )
1685 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1688 HDROP hFilesInfo
= (HDROP
) wParam
;
1690 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1692 // Get the total number of files dropped
1693 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1698 wxString
*files
= new wxString
[gwFilesDropped
];
1700 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1702 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1703 files
[wIndex
] = wxBuffer
;
1705 DragFinish (hFilesInfo
);
1707 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1708 event
.m_eventObject
= this;
1709 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1711 if ( !GetEventHandler()->ProcessEvent(event
) )
1717 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1719 #if wxUSE_OWNER_DRAWN
1720 if ( id
== 0 ) { // is it a menu item?
1721 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1722 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1723 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1725 // prepare to call OnDrawItem()
1727 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1728 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1729 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1730 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1731 return pMenuItem
->OnDrawItem(
1733 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1734 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1737 #endif // owner-drawn menus
1739 wxWindow
*item
= FindItem(id
);
1740 #if wxUSE_DYNAMIC_CLASSES
1741 if ( item
&& item
->IsKindOf(CLASSINFO(wxControl
)) )
1743 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1750 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1752 #if wxUSE_OWNER_DRAWN
1753 if ( id
== 0 ) { // is it a menu item?
1754 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1755 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1756 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1758 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1759 &pMeasureStruct
->itemHeight
);
1761 #endif // owner-drawn menus
1763 wxWindow
*item
= FindItem(id
);
1764 #if wxUSE_DYNAMIC_CLASSES
1765 if ( item
&& item
->IsKindOf(CLASSINFO(wxControl
)) )
1767 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1774 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1775 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1777 if ( nCtlColor
== CTLCOLOR_DLG
)
1779 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1782 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1784 WXHBRUSH hBrush
= 0;
1787 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1789 // I think that even for dialogs, we may need to call DefWindowProc (?)
1790 // Or maybe just rely on the usual default behaviour.
1792 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1797 // Define for each class of dialog and control
1798 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1799 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1801 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1804 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1806 wxSysColourChangedEvent event
;
1807 event
.SetEventObject(this);
1809 // Check if app handles this.
1810 if ( GetEventHandler()->ProcessEvent(event
) )
1813 // We didn't process it
1817 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1819 wxPaletteChangedEvent
event(GetId());
1820 event
.SetEventObject(this);
1821 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1822 GetEventHandler()->ProcessEvent(event
);
1826 long wxWindow::MSWOnQueryNewPalette()
1828 wxQueryNewPaletteEvent
event(GetId());
1829 event
.SetEventObject(this);
1830 if ( !GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized() )
1832 return (long) FALSE
;
1838 // Responds to colour changes: passes event on to children.
1839 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1841 wxNode
*node
= GetChildren().First();
1844 // Only propagate to non-top-level windows
1845 wxWindow
*win
= (wxWindow
*)node
->Data();
1846 if ( win
->GetParent() )
1848 wxSysColourChangedEvent event2
;
1849 event
.m_eventObject
= win
;
1850 win
->GetEventHandler()->ProcessEvent(event2
);
1853 node
= node
->Next();
1857 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1860 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1862 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1865 long wxWindow::Default()
1867 // Ignore 'fake' events (perhaps generated as a result of a separate real
1869 if ( m_lastMsg
== 0 )
1873 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1874 wxGetMessageName(m_lastMsg
));
1875 #endif // __WXDEBUG__
1877 return MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1880 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1882 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) )
1884 // intercept dialog navigation keys
1885 MSG
*msg
= (MSG
*)pMsg
;
1886 bool bProcess
= TRUE
;
1887 if ( msg
->message
!= WM_KEYDOWN
)
1890 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1895 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1897 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1898 // don't process it if it's the case (except for Ctrl-Tab/Enter
1899 // combinations which are always processed)
1903 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1906 bool bForward
= TRUE
,
1907 bWindowChange
= FALSE
;
1909 switch ( msg
->wParam
)
1912 if ( lDlgCode
& DLGC_WANTTAB
) {
1916 // Ctrl-Tab cycles thru notebook pages
1917 bWindowChange
= bCtrlDown
;
1918 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1924 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1932 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1938 if ( lDlgCode
& DLGC_WANTMESSAGE
)
1940 // control wants to process Enter itself, don't
1941 // call IsDialogMessage() which would interpret
1946 wxButton
*btnDefault
= GetDefaultItem();
1947 if ( btnDefault
&& !bCtrlDown
)
1949 // if there is a default button, Enter should
1951 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
1955 // else: but if there is not it makes sense to make it
1956 // work like a TAB - and that's what we do.
1957 // Note that Ctrl-Enter always works this way.
1968 wxNavigationKeyEvent event
;
1969 event
.SetDirection(bForward
);
1970 event
.SetWindowChange(bWindowChange
);
1971 event
.SetEventObject(this);
1973 if ( GetEventHandler()->ProcessEvent(event
) )
1978 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
1985 // relay mouse move events to the tooltip control
1986 MSG
*msg
= (MSG
*)pMsg
;
1987 if ( msg
->message
== WM_MOUSEMOVE
)
1988 m_tooltip
->RelayEvent(pMsg
);
1990 #endif // wxUSE_TOOLTIPS
1992 /* This code manages to disable character input completely. Nice one!
1993 * Probably because the dialog is requesting all char input. Or,
1994 * it gets called by non-dialog windows.
1996 // In case we don't have wxTAB_TRAVERSAL style on.
1997 // If we don't call this, we may never process Enter correctly.
1998 if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) == 0 )
2000 MSG *msg = (MSG *)pMsg;
2001 if ( ::IsDialogMessage((HWND)GetHWND(), msg) )
2008 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2010 if ( m_acceleratorTable
.Ok( ) &&
2011 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2017 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2022 void wxWindow::MSWDetachWindowMenu()
2026 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2028 for (i
= 0; i
< N
; i
++)
2031 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2032 if ( (chars
> 0) && (strcmp(buf
, "&Window") == 0) )
2034 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2041 bool wxWindow::MSWOnPaint()
2044 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2045 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2047 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2050 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2052 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2053 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2056 wxPaintEvent
event(m_windowId
);
2057 event
.SetEventObject(this);
2058 if ( !GetEventHandler()->ProcessEvent(event
) )
2063 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2073 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2074 event
.SetEventObject(this);
2075 if ( !GetEventHandler()->ProcessEvent(event
) )
2081 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2086 // Deal with child commands from buttons etc.
2087 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2089 if ( wxCurrentPopupMenu
)
2091 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2092 wxCurrentPopupMenu
= NULL
;
2093 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2097 wxWindow
*item
= FindItem(id
);
2100 bool value
= item
->MSWCommand(cmd
, id
);
2105 wxWindow
*win
= wxFindWinFromHandle(control
);
2107 return win
->MSWCommand(cmd
, id
);
2112 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2114 switch (wParam
& 0xFFFFFFF0)
2118 wxMaximizeEvent
event(m_windowId
);
2119 event
.SetEventObject(this);
2120 if ( !GetEventHandler()->ProcessEvent(event
) )
2128 wxIconizeEvent
event(m_windowId
);
2129 event
.SetEventObject(this);
2130 if ( !GetEventHandler()->ProcessEvent(event
) )
2142 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2144 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2146 event
.m_x
= x
; event
.m_y
= y
;
2147 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2148 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2149 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2150 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2151 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2152 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2153 event
.m_eventObject
= this;
2155 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_LEFT_DOWN
;
2157 if ( !GetEventHandler()->ProcessEvent(event
) )
2161 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2163 wxMouseEvent
event(wxEVT_LEFT_UP
);
2165 event
.m_x
= x
; event
.m_y
= y
;
2166 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2167 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2168 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2169 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2170 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2171 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2172 event
.m_eventObject
= this;
2174 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_LEFT_UP
;
2176 if ( !GetEventHandler()->ProcessEvent(event
) )
2180 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2182 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2184 event
.m_x
= x
; event
.m_y
= y
;
2185 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2186 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2187 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2188 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2189 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2190 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2191 event
.m_eventObject
= this;
2193 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_LEFT_DCLICK
;
2195 if ( !GetEventHandler()->ProcessEvent(event
) )
2199 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2201 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2203 event
.m_x
= x
; event
.m_y
= y
;
2204 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2205 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2206 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2207 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2208 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2209 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2210 event
.m_eventObject
= this;
2212 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_MIDDLE_DOWN
;
2214 if ( !GetEventHandler()->ProcessEvent(event
) )
2218 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2220 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2222 event
.m_x
= x
; event
.m_y
= y
;
2223 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2224 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2225 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2226 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2227 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2228 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2229 event
.m_eventObject
= this;
2231 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_MIDDLE_UP
;
2233 if ( !GetEventHandler()->ProcessEvent(event
) )
2237 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2239 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2241 event
.m_x
= x
; event
.m_y
= y
;
2242 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2243 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2244 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2245 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2246 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2247 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2248 event
.m_eventObject
= this;
2250 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_MIDDLE_DCLICK
;
2252 if ( !GetEventHandler()->ProcessEvent(event
) )
2256 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2258 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2260 event
.m_x
= x
; event
.m_y
= y
;
2261 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2262 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2263 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2264 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2265 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2266 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2267 event
.m_eventObject
= this;
2269 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_RIGHT_DOWN
;
2271 if ( !GetEventHandler()->ProcessEvent(event
) )
2275 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2277 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2279 event
.m_x
= x
; event
.m_y
= y
;
2280 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2281 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2282 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2283 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2284 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2285 event
.m_eventObject
= this;
2286 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2288 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_RIGHT_UP
;
2290 if ( !GetEventHandler()->ProcessEvent(event
) )
2294 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2296 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2298 event
.m_x
= x
; event
.m_y
= y
;
2299 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2300 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2301 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2302 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2303 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2304 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2305 event
.m_eventObject
= this;
2307 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
; m_lastMouseEvent
= wxEVT_RIGHT_DCLICK
;
2309 if ( !GetEventHandler()->ProcessEvent(event
) )
2313 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2315 // 'normal' move event...
2317 if ( !m_mouseInWindow
)
2319 // Generate an ENTER event
2320 m_mouseInWindow
= TRUE
;
2321 MSWOnMouseEnter(x
, y
, flags
);
2324 wxMouseEvent
event(wxEVT_MOTION
);
2326 event
.m_x
= x
; event
.m_y
= y
;
2327 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2328 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2329 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2330 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2331 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2332 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2333 event
.m_eventObject
= this;
2335 // Window gets a click down message followed by a mouse move
2336 // message even if position isn't changed! We want to discard
2337 // the trailing move event if x and y are the same.
2338 if ((m_lastMouseEvent
== wxEVT_RIGHT_DOWN
|| m_lastMouseEvent
== wxEVT_LEFT_DOWN
||
2339 m_lastMouseEvent
== wxEVT_MIDDLE_DOWN
) &&
2340 (m_lastMouseX
== event
.m_x
&& m_lastMouseY
== event
.m_y
))
2342 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
;
2343 m_lastMouseEvent
= wxEVT_MOTION
;
2347 m_lastMouseEvent
= wxEVT_MOTION
;
2348 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
;
2350 if ( !GetEventHandler()->ProcessEvent(event
) )
2354 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2356 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2358 event
.m_x
= x
; event
.m_y
= y
;
2359 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2360 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2361 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2362 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2363 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2364 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2365 event
.m_eventObject
= this;
2367 m_lastMouseEvent
= wxEVT_ENTER_WINDOW
;
2368 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
;
2369 // No message - ensure we don't try to call the default behaviour accidentally.
2371 GetEventHandler()->ProcessEvent(event
);
2374 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2376 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2378 event
.m_x
= x
; event
.m_y
= y
;
2379 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2380 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2381 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2382 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2383 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2384 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2385 event
.m_eventObject
= this;
2387 m_lastMouseEvent
= wxEVT_LEAVE_WINDOW
;
2388 m_lastMouseX
= event
.m_x
; m_lastMouseY
= event
.m_y
;
2389 // No message - ensure we don't try to call the default behaviour accidentally.
2391 GetEventHandler()->ProcessEvent(event
);
2394 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
2396 bool wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2399 bool tempControlDown
= FALSE
;
2402 // If 1 -> 26, translate to CTRL plus a letter.
2404 if ( (id
> 0) && (id
< 27) )
2425 tempControlDown
= TRUE
;
2431 else if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2432 // it's ASCII and will be processed here only when called from
2433 // WM_CHAR (i.e. when isASCII = TRUE)
2439 wxKeyEvent
event(wxEVT_CHAR
);
2440 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2441 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2442 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2443 event
.m_altDown
= TRUE
;
2445 event
.m_eventObject
= this;
2446 event
.m_keyCode
= id
;
2447 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2452 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2456 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2458 if ( GetEventHandler()->ProcessEvent(event
) )
2467 bool wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
)
2471 if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2477 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2478 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2479 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2480 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2481 event
.m_altDown
= TRUE
;
2483 event
.m_eventObject
= this;
2484 event
.m_keyCode
= id
;
2485 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2490 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2494 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2496 if ( GetEventHandler()->ProcessEvent(event
) )
2508 bool wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
)
2512 if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2518 wxKeyEvent
event(wxEVT_KEY_UP
);
2519 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2520 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2521 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2522 event
.m_altDown
= TRUE
;
2524 event
.m_eventObject
= this;
2525 event
.m_keyCode
= id
;
2526 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2531 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2535 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2537 if ( GetEventHandler()->ProcessEvent(event
) )
2546 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2550 if ( flags
& JOY_BUTTON1CHG
)
2551 change
= wxJOY_BUTTON1
;
2552 if ( flags
& JOY_BUTTON2CHG
)
2553 change
= wxJOY_BUTTON2
;
2554 if ( flags
& JOY_BUTTON3CHG
)
2555 change
= wxJOY_BUTTON3
;
2556 if ( flags
& JOY_BUTTON4CHG
)
2557 change
= wxJOY_BUTTON4
;
2559 if ( flags
& JOY_BUTTON1
)
2560 buttons
|= wxJOY_BUTTON1
;
2561 if ( flags
& JOY_BUTTON2
)
2562 buttons
|= wxJOY_BUTTON2
;
2563 if ( flags
& JOY_BUTTON3
)
2564 buttons
|= wxJOY_BUTTON3
;
2565 if ( flags
& JOY_BUTTON4
)
2566 buttons
|= wxJOY_BUTTON4
;
2568 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2569 event
.SetPosition(wxPoint(x
, y
));
2570 event
.SetEventObject(this);
2572 GetEventHandler()->ProcessEvent(event
);
2575 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2579 if ( flags
& JOY_BUTTON1CHG
)
2580 change
= wxJOY_BUTTON1
;
2581 if ( flags
& JOY_BUTTON2CHG
)
2582 change
= wxJOY_BUTTON2
;
2583 if ( flags
& JOY_BUTTON3CHG
)
2584 change
= wxJOY_BUTTON3
;
2585 if ( flags
& JOY_BUTTON4CHG
)
2586 change
= wxJOY_BUTTON4
;
2588 if ( flags
& JOY_BUTTON1
)
2589 buttons
|= wxJOY_BUTTON1
;
2590 if ( flags
& JOY_BUTTON2
)
2591 buttons
|= wxJOY_BUTTON2
;
2592 if ( flags
& JOY_BUTTON3
)
2593 buttons
|= wxJOY_BUTTON3
;
2594 if ( flags
& JOY_BUTTON4
)
2595 buttons
|= wxJOY_BUTTON4
;
2597 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2598 event
.SetPosition(wxPoint(x
, y
));
2599 event
.SetEventObject(this);
2601 GetEventHandler()->ProcessEvent(event
);
2604 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2607 if ( flags
& JOY_BUTTON1
)
2608 buttons
|= wxJOY_BUTTON1
;
2609 if ( flags
& JOY_BUTTON2
)
2610 buttons
|= wxJOY_BUTTON2
;
2611 if ( flags
& JOY_BUTTON3
)
2612 buttons
|= wxJOY_BUTTON3
;
2613 if ( flags
& JOY_BUTTON4
)
2614 buttons
|= wxJOY_BUTTON4
;
2616 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2617 event
.SetPosition(wxPoint(x
, y
));
2618 event
.SetEventObject(this);
2620 GetEventHandler()->ProcessEvent(event
);
2623 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2626 if ( flags
& JOY_BUTTON1
)
2627 buttons
|= wxJOY_BUTTON1
;
2628 if ( flags
& JOY_BUTTON2
)
2629 buttons
|= wxJOY_BUTTON2
;
2630 if ( flags
& JOY_BUTTON3
)
2631 buttons
|= wxJOY_BUTTON3
;
2632 if ( flags
& JOY_BUTTON4
)
2633 buttons
|= wxJOY_BUTTON4
;
2635 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2636 event
.SetZPosition(z
);
2637 event
.SetEventObject(this);
2639 GetEventHandler()->ProcessEvent(event
);
2642 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2646 wxWindow
*child
= wxFindWinFromHandle(control
);
2648 child
->MSWOnVScroll(wParam
, pos
, control
);
2652 wxScrollEvent event
;
2653 event
.SetPosition(pos
);
2654 event
.SetOrientation(wxVERTICAL
);
2655 event
.m_eventObject
= this;
2660 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2664 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2668 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2672 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2676 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2680 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2684 case SB_THUMBPOSITION
:
2685 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2693 if ( !GetEventHandler()->ProcessEvent(event
) )
2697 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2701 wxWindow
*child
= wxFindWinFromHandle(control
);
2703 child
->MSWOnHScroll(wParam
, pos
, control
);
2709 wxScrollEvent event
;
2710 event
.SetPosition(pos
);
2711 event
.SetOrientation(wxHORIZONTAL
);
2712 event
.m_eventObject
= this;
2717 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2721 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2725 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2729 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2733 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2737 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2741 case SB_THUMBPOSITION
:
2742 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2749 if ( GetEventHandler()->ProcessEvent(event
) )
2753 // call the default WM_HSCROLL handler: it's non trivial in some common
2754 // controls (up-down control for example)
2758 void wxWindow::MSWOnShow(bool show
, int status
)
2760 wxShowEvent
event(GetId(), show
);
2761 event
.m_eventObject
= this;
2762 GetEventHandler()->ProcessEvent(event
);
2765 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2767 wxInitDialogEvent
event(GetId());
2768 event
.m_eventObject
= this;
2769 GetEventHandler()->ProcessEvent(event
);
2773 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2776 HDC dc
= ::GetDC((HWND
) wnd
);
2781 // the_font->UseResource();
2782 // the_font->RealizeResource();
2783 fnt
= (HFONT
)the_font
->GetResourceHandle();
2785 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2787 GetTextMetrics(dc
, &tm
);
2788 if ( the_font
&& fnt
&& was
)
2790 SelectObject(dc
,was
) ;
2792 ReleaseDC((HWND
)wnd
, dc
);
2793 *x
= tm
.tmAveCharWidth
;
2794 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2797 // the_font->ReleaseResource();
2800 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2801 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2802 int wxCharCodeMSWToWX(int keySym
)
2807 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2808 case VK_BACK
: id
= WXK_BACK
; break;
2809 case VK_TAB
: id
= WXK_TAB
; break;
2810 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2811 case VK_RETURN
: id
= WXK_RETURN
; break;
2812 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2813 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2814 case VK_MENU
: id
= WXK_MENU
; break;
2815 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2816 case VK_SPACE
: id
= WXK_SPACE
; break;
2817 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2818 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2819 case VK_NEXT
: id
= WXK_NEXT
; break;
2820 case VK_END
: id
= WXK_END
; break;
2821 case VK_HOME
: id
= WXK_HOME
; break;
2822 case VK_LEFT
: id
= WXK_LEFT
; break;
2823 case VK_UP
: id
= WXK_UP
; break;
2824 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2825 case VK_DOWN
: id
= WXK_DOWN
; break;
2826 case VK_SELECT
: id
= WXK_SELECT
; break;
2827 case VK_PRINT
: id
= WXK_PRINT
; break;
2828 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2829 case VK_INSERT
: id
= WXK_INSERT
; break;
2830 case VK_DELETE
: id
= WXK_DELETE
; break;
2831 case VK_HELP
: id
= WXK_HELP
; break;
2832 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2833 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2834 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2835 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2836 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2837 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2838 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2839 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2840 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2841 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2842 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2843 case VK_ADD
: id
= WXK_ADD
; break;
2844 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2845 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2846 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2847 case VK_F1
: id
= WXK_F1
; break;
2848 case VK_F2
: id
= WXK_F2
; break;
2849 case VK_F3
: id
= WXK_F3
; break;
2850 case VK_F4
: id
= WXK_F4
; break;
2851 case VK_F5
: id
= WXK_F5
; break;
2852 case VK_F6
: id
= WXK_F6
; break;
2853 case VK_F7
: id
= WXK_F7
; break;
2854 case VK_F8
: id
= WXK_F8
; break;
2855 case VK_F9
: id
= WXK_F9
; break;
2856 case VK_F10
: id
= WXK_F10
; break;
2857 case VK_F11
: id
= WXK_F11
; break;
2858 case VK_F12
: id
= WXK_F12
; break;
2859 case VK_F13
: id
= WXK_F13
; break;
2860 case VK_F14
: id
= WXK_F14
; break;
2861 case VK_F15
: id
= WXK_F15
; break;
2862 case VK_F16
: id
= WXK_F16
; break;
2863 case VK_F17
: id
= WXK_F17
; break;
2864 case VK_F18
: id
= WXK_F18
; break;
2865 case VK_F19
: id
= WXK_F19
; break;
2866 case VK_F20
: id
= WXK_F20
; break;
2867 case VK_F21
: id
= WXK_F21
; break;
2868 case VK_F22
: id
= WXK_F22
; break;
2869 case VK_F23
: id
= WXK_F23
; break;
2870 case VK_F24
: id
= WXK_F24
; break;
2871 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2872 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2881 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2887 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2888 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2889 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2890 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2891 case WXK_MENU
: keySym
= VK_MENU
; break;
2892 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2893 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2894 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2895 case WXK_END
: keySym
= VK_END
; break;
2896 case WXK_HOME
: keySym
= VK_HOME
; break;
2897 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2898 case WXK_UP
: keySym
= VK_UP
; break;
2899 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2900 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2901 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2902 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2903 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2904 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2905 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2906 case WXK_HELP
: keySym
= VK_HELP
; break;
2907 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2908 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2909 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2910 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2911 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2912 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2913 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2914 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2915 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2916 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2917 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2918 case WXK_ADD
: keySym
= VK_ADD
; break;
2919 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2920 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2921 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2922 case WXK_F1
: keySym
= VK_F1
; break;
2923 case WXK_F2
: keySym
= VK_F2
; break;
2924 case WXK_F3
: keySym
= VK_F3
; break;
2925 case WXK_F4
: keySym
= VK_F4
; break;
2926 case WXK_F5
: keySym
= VK_F5
; break;
2927 case WXK_F6
: keySym
= VK_F6
; break;
2928 case WXK_F7
: keySym
= VK_F7
; break;
2929 case WXK_F8
: keySym
= VK_F8
; break;
2930 case WXK_F9
: keySym
= VK_F9
; break;
2931 case WXK_F10
: keySym
= VK_F10
; break;
2932 case WXK_F11
: keySym
= VK_F11
; break;
2933 case WXK_F12
: keySym
= VK_F12
; break;
2934 case WXK_F13
: keySym
= VK_F13
; break;
2935 case WXK_F14
: keySym
= VK_F14
; break;
2936 case WXK_F15
: keySym
= VK_F15
; break;
2937 case WXK_F16
: keySym
= VK_F16
; break;
2938 case WXK_F17
: keySym
= VK_F17
; break;
2939 case WXK_F18
: keySym
= VK_F18
; break;
2940 case WXK_F19
: keySym
= VK_F19
; break;
2941 case WXK_F20
: keySym
= VK_F20
; break;
2942 case WXK_F21
: keySym
= VK_F21
; break;
2943 case WXK_F22
: keySym
= VK_F22
; break;
2944 case WXK_F23
: keySym
= VK_F23
; break;
2945 case WXK_F24
: keySym
= VK_F24
; break;
2946 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2947 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2958 // Caret manipulation
2959 void wxWindow::CreateCaret(int w
, int h
)
2963 m_caretEnabled
= TRUE
;
2966 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2971 void wxWindow::ShowCaret(bool show
)
2973 if ( m_caretEnabled
)
2976 ::ShowCaret((HWND
) GetHWND());
2978 ::HideCaret((HWND
) GetHWND());
2979 m_caretShown
= show
;
2983 void wxWindow::DestroyCaret()
2985 m_caretEnabled
= FALSE
;
2988 void wxWindow::SetCaretPos(int x
, int y
)
2990 ::SetCaretPos(x
, y
);
2993 void wxWindow::GetCaretPos(int *x
, int *y
) const
2996 ::GetCaretPos(&point
);
3001 wxWindow
*wxGetActiveWindow()
3003 HWND hWnd
= GetActiveWindow();
3006 return wxFindWinFromHandle((WXHWND
) hWnd
);
3011 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3012 // in active frames and dialogs, regardless of where the focus is.
3013 static HHOOK wxTheKeyboardHook
= 0;
3014 static FARPROC wxTheKeyboardHookProc
= 0;
3015 int APIENTRY _EXPORT
3016 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3018 void wxSetKeyboardHook(bool doIt
)
3022 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3023 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3024 #if defined(__WIN32__) && !defined(__TWIN32__)
3025 GetCurrentThreadId());
3026 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3033 UnhookWindowsHookEx(wxTheKeyboardHook
);
3034 FreeProcInstance(wxTheKeyboardHookProc
);
3038 int APIENTRY _EXPORT
3039 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3041 DWORD hiWord
= HIWORD(lParam
);
3042 if ( nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0) )
3045 if ( (id
= wxCharCodeMSWToWX(wParam
)) != 0 )
3047 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3048 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3049 event
.m_altDown
= TRUE
;
3051 event
.m_eventObject
= NULL
;
3052 event
.m_keyCode
= id
;
3053 /* begin Albert's fix for control and shift key 26.5 */
3054 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3055 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3056 /* end Albert's fix for control and shift key 26.5 */
3057 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3059 wxWindow
*win
= wxGetActiveWindow();
3062 if ( win
->GetEventHandler()->ProcessEvent(event
) )
3067 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3072 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3075 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3077 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3078 // pixel coordinates, relatives to the canvas -- So, we first need to
3079 // substract origin of the window, then convert to screen position
3081 int x
= x_pos
; int y
= y_pos
;
3083 GetWindowRect ((HWND
) GetHWND(), &rect
);
3088 SetCursorPos (x
, y
);
3091 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3095 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3103 wxEraseEvent
event(m_windowId
, &dc
);
3104 event
.m_eventObject
= this;
3105 if ( !GetEventHandler()->ProcessEvent(event
) )
3108 dc
.SelectOldObjects(pDC
);
3114 dc
.SelectOldObjects(pDC
);
3117 dc
.SetHDC((WXHDC
) NULL
);
3121 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3127 ::GetClientRect((HWND
) GetHWND(), &rect
);
3129 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3130 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3131 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3133 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3134 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3135 ::DeleteObject(hBrush
);
3136 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3138 // Less efficient version (and doesn't account for scrolling)
3140 GetClientSize(& w, & h);
3141 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3142 event.GetDC()->SetBrush(brush);
3143 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3145 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3149 #if WXWIN_COMPATIBILITY
3150 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3152 #if defined(__WIN95__)
3156 // Try to adjust the range to cope with page size > 1
3157 // - a Windows API quirk
3158 int pageSize
= GetScrollPage(orient
);
3159 if ( pageSize
> 1 && range
> 0)
3161 range1
+= (pageSize
- 1);
3167 if ( orient
== wxHORIZONTAL
) {
3173 info
.cbSize
= sizeof(SCROLLINFO
);
3174 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3178 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3180 HWND hWnd
= (HWND
) GetHWND();
3182 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3185 if ( orient
== wxHORIZONTAL
)
3190 HWND hWnd
= (HWND
) GetHWND();
3192 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3196 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3198 #if defined(__WIN95__)
3202 if ( orient
== wxHORIZONTAL
) {
3204 m_xThumbSize
= page
;
3207 m_yThumbSize
= page
;
3210 info
.cbSize
= sizeof(SCROLLINFO
);
3213 info
.fMask
= SIF_PAGE
;
3215 HWND hWnd
= (HWND
) GetHWND();
3217 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3219 if ( orient
== wxHORIZONTAL
)
3220 m_xThumbSize
= page
;
3222 m_yThumbSize
= page
;
3226 int wxWindow::OldGetScrollRange(int orient
) const
3229 if ( orient
== wxHORIZONTAL
)
3234 #if __WATCOMC__ && defined(__WINDOWS_386__)
3235 short minPos
, maxPos
;
3239 HWND hWnd
= (HWND
) GetHWND();
3242 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3243 #if defined(__WIN95__)
3244 // Try to adjust the range to cope with page size > 1
3245 // - a Windows API quirk
3246 int pageSize
= GetScrollPage(orient
);
3249 maxPos
-= (pageSize
- 1);
3258 int wxWindow::GetScrollPage(int orient
) const
3260 if ( orient
== wxHORIZONTAL
)
3261 return m_xThumbSize
;
3263 return m_yThumbSize
;
3267 int wxWindow::GetScrollPos(int orient
) const
3270 if ( orient
== wxHORIZONTAL
)
3274 HWND hWnd
= (HWND
) GetHWND();
3277 return ::GetScrollPos(hWnd
, wOrient
);
3283 // This now returns the whole range, not just the number
3284 // of positions that we can scroll.
3285 int wxWindow::GetScrollRange(int orient
) const
3288 if ( orient
== wxHORIZONTAL
)
3293 #if __WATCOMC__ && defined(__WINDOWS_386__)
3294 short minPos
, maxPos
;
3298 HWND hWnd
= (HWND
) GetHWND();
3301 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3302 #if defined(__WIN95__)
3303 // Try to adjust the range to cope with page size > 1
3304 // - a Windows API quirk
3305 int pageSize
= GetScrollThumb(orient
);
3308 maxPos
-= (pageSize
- 1);
3310 // October 10th: new range concept.
3320 int wxWindow::GetScrollThumb(int orient
) const
3322 if ( orient
== wxHORIZONTAL
)
3323 return m_xThumbSize
;
3325 return m_yThumbSize
;
3328 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3330 #if defined(__WIN95__)
3334 if ( orient
== wxHORIZONTAL
) {
3340 info
.cbSize
= sizeof(SCROLLINFO
);
3344 info
.fMask
= SIF_POS
;
3346 HWND hWnd
= (HWND
) GetHWND();
3348 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3351 if ( orient
== wxHORIZONTAL
)
3356 HWND hWnd
= (HWND
) GetHWND();
3358 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3362 // New function that will replace some of the above.
3363 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3364 int range
, bool refresh
)
3367 SetScrollPage(orient, thumbVisible, FALSE);
3369 int oldRange = range - thumbVisible ;
3370 SetScrollRange(orient, oldRange, FALSE);
3372 SetScrollPos(orient, pos, refresh);
3374 #if defined(__WIN95__)
3375 int oldRange
= range
- thumbVisible
;
3377 int range1
= oldRange
;
3379 // Try to adjust the range to cope with page size > 1
3380 // - a Windows API quirk
3381 int pageSize
= thumbVisible
;
3382 if ( pageSize
> 1 && range
> 0)
3384 range1
+= (pageSize
- 1);
3390 if ( orient
== wxHORIZONTAL
) {
3396 info
.cbSize
= sizeof(SCROLLINFO
);
3397 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3401 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3403 HWND hWnd
= (HWND
) GetHWND();
3405 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3408 if ( orient
== wxHORIZONTAL
)
3413 HWND hWnd
= (HWND
) GetHWND();
3416 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3417 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3420 if ( orient
== wxHORIZONTAL
) {
3421 m_xThumbSize
= thumbVisible
;
3423 m_yThumbSize
= thumbVisible
;
3427 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3432 rect2
.left
= rect
->x
;
3433 rect2
.top
= rect
->y
;
3434 rect2
.right
= rect
->x
+ rect
->width
;
3435 rect2
.bottom
= rect
->y
+ rect
->height
;
3439 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3441 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3444 bool wxWindow::SetFont(const wxFont
& font
)
3446 if ( !wxWindowBase::SetFont(font
) )
3452 HWND hWnd
= (HWND
) GetHWND();
3455 WXHANDLE hFont
= m_font
.GetResourceHandle();
3457 wxASSERT_MSG( hFont
, _T("should have valid font") );
3459 ::SendMessage(hWnd
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
3465 void wxWindow::SubclassWin(WXHWND hWnd
)
3467 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3469 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3471 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3472 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3475 void wxWindow::UnsubclassWin()
3477 wxRemoveHandleAssociation(this);
3479 // Restore old Window proc
3480 if ( (HWND
) GetHWND() )
3482 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3483 if ( (m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
) )
3485 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3491 // Make a Windows extended style from the given wxWindows window style
3492 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3494 WXDWORD exStyle
= 0;
3495 if ( style
& wxTRANSPARENT_WINDOW
)
3496 exStyle
|= WS_EX_TRANSPARENT
;
3498 if ( !eliminateBorders
)
3500 if ( style
& wxSUNKEN_BORDER
)
3501 exStyle
|= WS_EX_CLIENTEDGE
;
3502 if ( style
& wxDOUBLE_BORDER
)
3503 exStyle
|= WS_EX_DLGMODALFRAME
;
3504 #if defined(__WIN95__)
3505 if ( style
& wxRAISED_BORDER
)
3506 exStyle
|= WS_EX_WINDOWEDGE
;
3507 if ( style
& wxSTATIC_BORDER
)
3508 exStyle
|= WS_EX_STATICEDGE
;
3514 // Determines whether native 3D effects or CTL3D should be used,
3515 // applying a default border style if required, and returning an extended
3516 // style to pass to CreateWindowEx.
3517 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3519 // If matches certain criteria, then assume no 3D effects
3520 // unless specifically requested (dealt with in MakeExtendedStyle)
3521 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3524 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3527 // Determine whether we should be using 3D effects or not.
3528 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3530 // 1) App can specify global 3D effects
3531 *want3D
= wxTheApp
->GetAuto3D();
3533 // 2) If the parent is being drawn with user colours, or simple border specified,
3534 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3535 if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
) )
3538 // 3) Control can override this global setting by defining
3539 // a border style, e.g. wxSUNKEN_BORDER
3540 if ( m_windowStyle
& wxSUNKEN_BORDER
)
3543 // 4) If it's a special border, CTL3D can't cope so we want a native border
3544 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3545 (m_windowStyle
& wxSTATIC_BORDER
) )
3548 nativeBorder
= TRUE
;
3551 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3552 // effects from extended style
3555 nativeBorder
= FALSE
;
3558 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3560 // If we want 3D, but haven't specified a border here,
3561 // apply the default border style specified.
3562 // TODO what about non-Win95 WIN32? Does it have borders?
3563 #if defined(__WIN95__) && !wxUSE_CTL3D
3564 if ( defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3565 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3566 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3572 void wxWindow::OnChar(wxKeyEvent
& event
)
3577 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3582 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3587 void wxWindow::OnPaint(wxPaintEvent
& event
)
3592 // Get the window with the focus
3593 wxWindow
*wxWindowBase::FindFocus()
3595 HWND hWnd
= ::GetFocus();
3598 return wxFindWinFromHandle((WXHWND
) hWnd
);
3603 // If nothing defined for this, try the parent.
3604 // E.g. we may be a button loaded from a resource, with no callback function
3606 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3608 if ( GetEventHandler()->ProcessEvent(event
) )
3611 m_parent
->GetEventHandler()->OnCommand(win
, event
);
3614 wxObject
* wxWindow::GetChild(int number
) const
3616 // Return a pointer to the Nth object in the Panel
3617 // if ( !GetChildren() )
3619 wxNode
*node
= GetChildren().First();
3622 node
= node
->Next() ;
3625 wxObject
*obj
= (wxObject
*)node
->Data();
3632 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
3634 /* This is obsolete now; if we wish to intercept listbox double-clicks,
3635 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
3638 if ( initiatingItem->IsKindOf(CLASSINFO(wxListBox)) )
3640 wxListBox *lbox = (wxListBox *)initiatingItem;
3641 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
3642 event.m_commandInt = -1;
3643 if ( (lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0 )
3645 event.m_commandString = copystring(lbox->GetStringSelection());
3646 event.m_commandInt = lbox->GetSelection();
3647 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
3649 event.m_eventObject = lbox;
3651 lbox->ProcessCommand(event);
3653 if ( event.m_commandString )
3654 delete[] event.m_commandString;
3658 wxButton *but = GetDefaultItem();
3661 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
3662 event.SetEventObject(but);
3663 but->Command(event);
3668 void wxWindow::Clear()
3670 wxClientDC
dc(this);
3671 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
3672 dc
.SetBackground(brush
);
3677 // Default input behaviour for a scrolling canvas should be to scroll
3678 // according to the cursor keys pressed
3679 void wxWindow::OnChar(wxKeyEvent& event)
3691 GetScrollUnitsPerPage(&x_page, &y_page);
3693 GetVirtualSize(&v_width,&v_height);
3695 ViewStart(&start_x, &start_y);
3698 y_pages = (int)(v_height/vert_units) - y_page;
3706 switch (event.keyCode)
3713 if ( start_y - y_page > 0 )
3714 Scroll(start_x, start_y - y_page);
3724 if ( (y_page > 0) && (start_y <= y_pages-y-1) )
3726 if ( y_pages + y < start_y + y_page )
3727 Scroll(start_x, y_pages + y);
3729 Scroll(start_x, start_y + y_page);
3736 if ( (y_page > 0) && (start_y >= 1) )
3737 Scroll(start_x, start_y - 1);
3743 if ( (y_page > 0) && (start_y <= y_pages-y-1) )
3746 Scroll(start_x, start_y + 1);
3752 if ( (x_page > 0) && (start_x >= 1) )
3753 Scroll(start_x - 1, start_y);
3759 Scroll(start_x + 1, start_y);
3770 Scroll(start_x, y_pages+y);
3778 // Setup background and foreground colours correctly
3779 void wxWindow::SetupColours()
3782 SetBackgroundColour(GetParent()->GetBackgroundColour());
3785 void wxWindow::OnIdle(wxIdleEvent
& event
)
3787 // Check if we need to send a LEAVE event
3788 if ( m_mouseInWindow
)
3791 ::GetCursorPos(&pt
);
3792 if ( ::WindowFromPoint(pt
) != (HWND
) GetHWND() )
3794 // Generate a LEAVE event
3795 m_mouseInWindow
= FALSE
;
3798 if ( ::GetKeyState(VK_SHIFT
) != 0 )
3800 if ( ::GetKeyState(VK_CONTROL
) != 0 )
3801 state
|= MK_CONTROL
;
3803 // Unfortunately the mouse button and keyboard state may have changed
3804 // by the time the OnIdle function is called, so 'state' may be
3807 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
3813 // Raise the window to the top of the Z order
3814 void wxWindow::Raise()
3816 ::BringWindowToTop((HWND
) GetHWND());
3819 // Lower the window to the bottom of the Z order
3820 void wxWindow::Lower()
3822 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3825 long wxWindow::MSWGetDlgCode()
3827 // default: just forward to def window proc (the msg has no parameters)
3828 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
3831 // Set this window to be the child of 'parent'.
3832 bool wxWindow::Reparent(wxWindow
*parent
)
3834 if ( !wxWindowBase::Reparent(parent
) )
3837 HWND hWndChild
= (HWND
)GetHWND();
3838 HWND hWndParent
= (HWND
)(GetParent() ? GetParent()->GetHWND() : NULL
);
3840 ::SetParent(hWndChild
, hWndParent
);
3846 const char *wxGetMessageName(int message
)
3848 switch ( message
) {
3849 case 0x0000: return "WM_NULL";
3850 case 0x0001: return "WM_CREATE";
3851 case 0x0002: return "WM_DESTROY";
3852 case 0x0003: return "WM_MOVE";
3853 case 0x0005: return "WM_SIZE";
3854 case 0x0006: return "WM_ACTIVATE";
3855 case 0x0007: return "WM_SETFOCUS";
3856 case 0x0008: return "WM_KILLFOCUS";
3857 case 0x000A: return "WM_ENABLE";
3858 case 0x000B: return "WM_SETREDRAW";
3859 case 0x000C: return "WM_SETTEXT";
3860 case 0x000D: return "WM_GETTEXT";
3861 case 0x000E: return "WM_GETTEXTLENGTH";
3862 case 0x000F: return "WM_PAINT";
3863 case 0x0010: return "WM_CLOSE";
3864 case 0x0011: return "WM_QUERYENDSESSION";
3865 case 0x0012: return "WM_QUIT";
3866 case 0x0013: return "WM_QUERYOPEN";
3867 case 0x0014: return "WM_ERASEBKGND";
3868 case 0x0015: return "WM_SYSCOLORCHANGE";
3869 case 0x0016: return "WM_ENDSESSION";
3870 case 0x0017: return "WM_SYSTEMERROR";
3871 case 0x0018: return "WM_SHOWWINDOW";
3872 case 0x0019: return "WM_CTLCOLOR";
3873 case 0x001A: return "WM_WININICHANGE";
3874 case 0x001B: return "WM_DEVMODECHANGE";
3875 case 0x001C: return "WM_ACTIVATEAPP";
3876 case 0x001D: return "WM_FONTCHANGE";
3877 case 0x001E: return "WM_TIMECHANGE";
3878 case 0x001F: return "WM_CANCELMODE";
3879 case 0x0020: return "WM_SETCURSOR";
3880 case 0x0021: return "WM_MOUSEACTIVATE";
3881 case 0x0022: return "WM_CHILDACTIVATE";
3882 case 0x0023: return "WM_QUEUESYNC";
3883 case 0x0024: return "WM_GETMINMAXINFO";
3884 case 0x0026: return "WM_PAINTICON";
3885 case 0x0027: return "WM_ICONERASEBKGND";
3886 case 0x0028: return "WM_NEXTDLGCTL";
3887 case 0x002A: return "WM_SPOOLERSTATUS";
3888 case 0x002B: return "WM_DRAWITEM";
3889 case 0x002C: return "WM_MEASUREITEM";
3890 case 0x002D: return "WM_DELETEITEM";
3891 case 0x002E: return "WM_VKEYTOITEM";
3892 case 0x002F: return "WM_CHARTOITEM";
3893 case 0x0030: return "WM_SETFONT";
3894 case 0x0031: return "WM_GETFONT";
3895 case 0x0037: return "WM_QUERYDRAGICON";
3896 case 0x0039: return "WM_COMPAREITEM";
3897 case 0x0041: return "WM_COMPACTING";
3898 case 0x0044: return "WM_COMMNOTIFY";
3899 case 0x0046: return "WM_WINDOWPOSCHANGING";
3900 case 0x0047: return "WM_WINDOWPOSCHANGED";
3901 case 0x0048: return "WM_POWER";
3904 case 0x004A: return "WM_COPYDATA";
3905 case 0x004B: return "WM_CANCELJOURNAL";
3906 case 0x004E: return "WM_NOTIFY";
3907 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
3908 case 0x0051: return "WM_INPUTLANGCHANGE";
3909 case 0x0052: return "WM_TCARD";
3910 case 0x0053: return "WM_HELP";
3911 case 0x0054: return "WM_USERCHANGED";
3912 case 0x0055: return "WM_NOTIFYFORMAT";
3913 case 0x007B: return "WM_CONTEXTMENU";
3914 case 0x007C: return "WM_STYLECHANGING";
3915 case 0x007D: return "WM_STYLECHANGED";
3916 case 0x007E: return "WM_DISPLAYCHANGE";
3917 case 0x007F: return "WM_GETICON";
3918 case 0x0080: return "WM_SETICON";
3921 case 0x0081: return "WM_NCCREATE";
3922 case 0x0082: return "WM_NCDESTROY";
3923 case 0x0083: return "WM_NCCALCSIZE";
3924 case 0x0084: return "WM_NCHITTEST";
3925 case 0x0085: return "WM_NCPAINT";
3926 case 0x0086: return "WM_NCACTIVATE";
3927 case 0x0087: return "WM_GETDLGCODE";
3928 case 0x00A0: return "WM_NCMOUSEMOVE";
3929 case 0x00A1: return "WM_NCLBUTTONDOWN";
3930 case 0x00A2: return "WM_NCLBUTTONUP";
3931 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
3932 case 0x00A4: return "WM_NCRBUTTONDOWN";
3933 case 0x00A5: return "WM_NCRBUTTONUP";
3934 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
3935 case 0x00A7: return "WM_NCMBUTTONDOWN";
3936 case 0x00A8: return "WM_NCMBUTTONUP";
3937 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
3938 case 0x0100: return "WM_KEYDOWN";
3939 case 0x0101: return "WM_KEYUP";
3940 case 0x0102: return "WM_CHAR";
3941 case 0x0103: return "WM_DEADCHAR";
3942 case 0x0104: return "WM_SYSKEYDOWN";
3943 case 0x0105: return "WM_SYSKEYUP";
3944 case 0x0106: return "WM_SYSCHAR";
3945 case 0x0107: return "WM_SYSDEADCHAR";
3946 case 0x0108: return "WM_KEYLAST";
3949 case 0x010D: return "WM_IME_STARTCOMPOSITION";
3950 case 0x010E: return "WM_IME_ENDCOMPOSITION";
3951 case 0x010F: return "WM_IME_COMPOSITION";
3954 case 0x0110: return "WM_INITDIALOG";
3955 case 0x0111: return "WM_COMMAND";
3956 case 0x0112: return "WM_SYSCOMMAND";
3957 case 0x0113: return "WM_TIMER";
3958 case 0x0114: return "WM_HSCROLL";
3959 case 0x0115: return "WM_VSCROLL";
3960 case 0x0116: return "WM_INITMENU";
3961 case 0x0117: return "WM_INITMENUPOPUP";
3962 case 0x011F: return "WM_MENUSELECT";
3963 case 0x0120: return "WM_MENUCHAR";
3964 case 0x0121: return "WM_ENTERIDLE";
3965 case 0x0200: return "WM_MOUSEMOVE";
3966 case 0x0201: return "WM_LBUTTONDOWN";
3967 case 0x0202: return "WM_LBUTTONUP";
3968 case 0x0203: return "WM_LBUTTONDBLCLK";
3969 case 0x0204: return "WM_RBUTTONDOWN";
3970 case 0x0205: return "WM_RBUTTONUP";
3971 case 0x0206: return "WM_RBUTTONDBLCLK";
3972 case 0x0207: return "WM_MBUTTONDOWN";
3973 case 0x0208: return "WM_MBUTTONUP";
3974 case 0x0209: return "WM_MBUTTONDBLCLK";
3975 case 0x0210: return "WM_PARENTNOTIFY";
3976 case 0x0211: return "WM_ENTERMENULOOP";
3977 case 0x0212: return "WM_EXITMENULOOP";
3980 case 0x0213: return "WM_NEXTMENU";
3981 case 0x0214: return "WM_SIZING";
3982 case 0x0215: return "WM_CAPTURECHANGED";
3983 case 0x0216: return "WM_MOVING";
3984 case 0x0218: return "WM_POWERBROADCAST";
3985 case 0x0219: return "WM_DEVICECHANGE";
3988 case 0x0220: return "WM_MDICREATE";
3989 case 0x0221: return "WM_MDIDESTROY";
3990 case 0x0222: return "WM_MDIACTIVATE";
3991 case 0x0223: return "WM_MDIRESTORE";
3992 case 0x0224: return "WM_MDINEXT";
3993 case 0x0225: return "WM_MDIMAXIMIZE";
3994 case 0x0226: return "WM_MDITILE";
3995 case 0x0227: return "WM_MDICASCADE";
3996 case 0x0228: return "WM_MDIICONARRANGE";
3997 case 0x0229: return "WM_MDIGETACTIVE";
3998 case 0x0230: return "WM_MDISETMENU";
3999 case 0x0233: return "WM_DROPFILES";
4002 case 0x0281: return "WM_IME_SETCONTEXT";
4003 case 0x0282: return "WM_IME_NOTIFY";
4004 case 0x0283: return "WM_IME_CONTROL";
4005 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4006 case 0x0285: return "WM_IME_SELECT";
4007 case 0x0286: return "WM_IME_CHAR";
4008 case 0x0290: return "WM_IME_KEYDOWN";
4009 case 0x0291: return "WM_IME_KEYUP";
4012 case 0x0300: return "WM_CUT";
4013 case 0x0301: return "WM_COPY";
4014 case 0x0302: return "WM_PASTE";
4015 case 0x0303: return "WM_CLEAR";
4016 case 0x0304: return "WM_UNDO";
4017 case 0x0305: return "WM_RENDERFORMAT";
4018 case 0x0306: return "WM_RENDERALLFORMATS";
4019 case 0x0307: return "WM_DESTROYCLIPBOARD";
4020 case 0x0308: return "WM_DRAWCLIPBOARD";
4021 case 0x0309: return "WM_PAINTCLIPBOARD";
4022 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4023 case 0x030B: return "WM_SIZECLIPBOARD";
4024 case 0x030C: return "WM_ASKCBFORMATNAME";
4025 case 0x030D: return "WM_CHANGECBCHAIN";
4026 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4027 case 0x030F: return "WM_QUERYNEWPALETTE";
4028 case 0x0310: return "WM_PALETTEISCHANGING";
4029 case 0x0311: return "WM_PALETTECHANGED";
4032 // common controls messages - although they're not strictly speaking
4033 // standard, it's nice to decode them nevertheless
4036 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4037 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4038 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4039 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4040 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4041 case 0x1000 + 5: return "LVM_GETITEMA";
4042 case 0x1000 + 75: return "LVM_GETITEMW";
4043 case 0x1000 + 6: return "LVM_SETITEMA";
4044 case 0x1000 + 76: return "LVM_SETITEMW";
4045 case 0x1000 + 7: return "LVM_INSERTITEMA";
4046 case 0x1000 + 77: return "LVM_INSERTITEMW";
4047 case 0x1000 + 8: return "LVM_DELETEITEM";
4048 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4049 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4050 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4051 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4052 case 0x1000 + 13: return "LVM_FINDITEMA";
4053 case 0x1000 + 83: return "LVM_FINDITEMW";
4054 case 0x1000 + 14: return "LVM_GETITEMRECT";
4055 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4056 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4057 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4058 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4059 case 0x1000 + 18: return "LVM_HITTEST";
4060 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4061 case 0x1000 + 20: return "LVM_SCROLL";
4062 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4063 case 0x1000 + 22: return "LVM_ARRANGE";
4064 case 0x1000 + 23: return "LVM_EDITLABELA";
4065 case 0x1000 + 118: return "LVM_EDITLABELW";
4066 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4067 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4068 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4069 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4070 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4071 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4072 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4073 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4074 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4075 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4076 case 0x1000 + 31: return "LVM_GETHEADER";
4077 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4078 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4079 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4080 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4081 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4082 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4083 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4084 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4085 case 0x1000 + 41: return "LVM_GETORIGIN";
4086 case 0x1000 + 42: return "LVM_UPDATE";
4087 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4088 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4089 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4090 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4091 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4092 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4093 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4094 case 0x1000 + 48: return "LVM_SORTITEMS";
4095 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4096 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4097 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4098 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4099 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4100 case 0x1000 + 53: return "LVM_SETICONSPACING";
4101 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4102 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4103 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4104 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4105 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4106 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4107 case 0x1000 + 60: return "LVM_SETHOTITEM";
4108 case 0x1000 + 61: return "LVM_GETHOTITEM";
4109 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4110 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4111 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4112 case 0x1000 + 65: return "LVM_SETWORKAREA";
4115 case 0x1100 + 0: return "TVM_INSERTITEMA";
4116 case 0x1100 + 50: return "TVM_INSERTITEMW";
4117 case 0x1100 + 1: return "TVM_DELETEITEM";
4118 case 0x1100 + 2: return "TVM_EXPAND";
4119 case 0x1100 + 4: return "TVM_GETITEMRECT";
4120 case 0x1100 + 5: return "TVM_GETCOUNT";
4121 case 0x1100 + 6: return "TVM_GETINDENT";
4122 case 0x1100 + 7: return "TVM_SETINDENT";
4123 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4124 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4125 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4126 case 0x1100 + 11: return "TVM_SELECTITEM";
4127 case 0x1100 + 12: return "TVM_GETITEMA";
4128 case 0x1100 + 62: return "TVM_GETITEMW";
4129 case 0x1100 + 13: return "TVM_SETITEMA";
4130 case 0x1100 + 63: return "TVM_SETITEMW";
4131 case 0x1100 + 14: return "TVM_EDITLABELA";
4132 case 0x1100 + 65: return "TVM_EDITLABELW";
4133 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4134 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4135 case 0x1100 + 17: return "TVM_HITTEST";
4136 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4137 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4138 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4139 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4140 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4141 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4142 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4143 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4144 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4147 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4148 case 0x1200 + 1: return "HDM_INSERTITEMA";
4149 case 0x1200 + 10: return "HDM_INSERTITEMW";
4150 case 0x1200 + 2: return "HDM_DELETEITEM";
4151 case 0x1200 + 3: return "HDM_GETITEMA";
4152 case 0x1200 + 11: return "HDM_GETITEMW";
4153 case 0x1200 + 4: return "HDM_SETITEMA";
4154 case 0x1200 + 12: return "HDM_SETITEMW";
4155 case 0x1200 + 5: return "HDM_LAYOUT";
4156 case 0x1200 + 6: return "HDM_HITTEST";
4157 case 0x1200 + 7: return "HDM_GETITEMRECT";
4158 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4159 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4160 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4161 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4162 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4163 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4164 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4167 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4168 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4169 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4170 case 0x1300 + 5: return "TCM_GETITEMA";
4171 case 0x1300 + 60: return "TCM_GETITEMW";
4172 case 0x1300 + 6: return "TCM_SETITEMA";
4173 case 0x1300 + 61: return "TCM_SETITEMW";
4174 case 0x1300 + 7: return "TCM_INSERTITEMA";
4175 case 0x1300 + 62: return "TCM_INSERTITEMW";
4176 case 0x1300 + 8: return "TCM_DELETEITEM";
4177 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4178 case 0x1300 + 10: return "TCM_GETITEMRECT";
4179 case 0x1300 + 11: return "TCM_GETCURSEL";
4180 case 0x1300 + 12: return "TCM_SETCURSEL";
4181 case 0x1300 + 13: return "TCM_HITTEST";
4182 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4183 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4184 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4185 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4186 case 0x1300 + 43: return "TCM_SETPADDING";
4187 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4188 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4189 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4190 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4191 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4192 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4193 case 0x1300 + 50: return "TCM_DESELECTALL";
4196 case WM_USER
+1: return "TB_ENABLEBUTTON";
4197 case WM_USER
+2: return "TB_CHECKBUTTON";
4198 case WM_USER
+3: return "TB_PRESSBUTTON";
4199 case WM_USER
+4: return "TB_HIDEBUTTON";
4200 case WM_USER
+5: return "TB_INDETERMINATE";
4201 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4202 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4203 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4204 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4205 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4206 case WM_USER
+17: return "TB_SETSTATE";
4207 case WM_USER
+18: return "TB_GETSTATE";
4208 case WM_USER
+19: return "TB_ADDBITMAP";
4209 case WM_USER
+20: return "TB_ADDBUTTONS";
4210 case WM_USER
+21: return "TB_INSERTBUTTON";
4211 case WM_USER
+22: return "TB_DELETEBUTTON";
4212 case WM_USER
+23: return "TB_GETBUTTON";
4213 case WM_USER
+24: return "TB_BUTTONCOUNT";
4214 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4215 case WM_USER
+26: return "TB_SAVERESTOREA";
4216 case WM_USER
+76: return "TB_SAVERESTOREW";
4217 case WM_USER
+27: return "TB_CUSTOMIZE";
4218 case WM_USER
+28: return "TB_ADDSTRINGA";
4219 case WM_USER
+77: return "TB_ADDSTRINGW";
4220 case WM_USER
+29: return "TB_GETITEMRECT";
4221 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4222 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4223 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4224 case WM_USER
+33: return "TB_AUTOSIZE";
4225 case WM_USER
+35: return "TB_GETTOOLTIPS";
4226 case WM_USER
+36: return "TB_SETTOOLTIPS";
4227 case WM_USER
+37: return "TB_SETPARENT";
4228 case WM_USER
+39: return "TB_SETROWS";
4229 case WM_USER
+40: return "TB_GETROWS";
4230 case WM_USER
+42: return "TB_SETCMDID";
4231 case WM_USER
+43: return "TB_CHANGEBITMAP";
4232 case WM_USER
+44: return "TB_GETBITMAP";
4233 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4234 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4235 case WM_USER
+46: return "TB_REPLACEBITMAP";
4236 case WM_USER
+47: return "TB_SETINDENT";
4237 case WM_USER
+48: return "TB_SETIMAGELIST";
4238 case WM_USER
+49: return "TB_GETIMAGELIST";
4239 case WM_USER
+50: return "TB_LOADIMAGES";
4240 case WM_USER
+51: return "TB_GETRECT";
4241 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4242 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4243 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4244 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4245 case WM_USER
+56: return "TB_SETSTYLE";
4246 case WM_USER
+57: return "TB_GETSTYLE";
4247 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4248 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4249 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4250 case WM_USER
+61: return "TB_GETTEXTROWS";
4251 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4256 static char s_szBuf
[128];
4257 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4261 #endif //__WXDEBUG__