1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
5 // Modified by: VZ on 13.05.99: no more Default(), MSWOnXXX() reorganisation
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
21 #pragma implementation "window.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/dcclient.h"
39 #include "wx/layout.h"
40 #include "wx/dialog.h"
42 #include "wx/listbox.h"
43 #include "wx/button.h"
44 #include "wx/msgdlg.h"
50 #include "wx/ownerdrw.h"
53 #if wxUSE_DRAG_AND_DROP
54 #include "wx/msw/ole/droptgt.h"
57 #include "wx/menuitem.h"
61 #include "wx/tooltip.h"
67 #include "wx/msw/private.h"
69 #include "wx/textctrl.h"
82 #if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ )
88 #include <wx/msw/gnuwin32/extra.h>
108 // ---------------------------------------------------------------------------
110 // ---------------------------------------------------------------------------
112 // standard macros missing from some compilers headers
114 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
115 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
116 #endif // GET_X_LPARAM
118 // ---------------------------------------------------------------------------
119 // ---------------------------------------------------------------------------
121 const char *wxGetMessageName(int message
);
124 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
126 wxMenu
*wxCurrentPopupMenu
= NULL
;
127 extern wxList WXDLLEXPORT wxPendingDelete
;
129 void wxRemoveHandleAssociation(wxWindow
*win
);
130 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
131 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
133 #if !USE_SHARED_LIBRARY
134 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
137 // ---------------------------------------------------------------------------
139 // ---------------------------------------------------------------------------
141 BEGIN_EVENT_TABLE(wxWindow
, wxWindowBase
)
142 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
143 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
144 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
145 EVT_IDLE(wxWindow::OnIdle
)
148 // ===========================================================================
150 // ===========================================================================
152 // Find an item given the MS Windows id
153 wxWindow
*wxWindow::FindItem(int id
) const
155 // if ( !GetChildren() )
157 wxNode
*current
= GetChildren().First();
160 wxWindow
*childWin
= (wxWindow
*)current
->Data();
162 wxWindow
*wnd
= childWin
->FindItem(id
) ;
166 if ( childWin
->IsKindOf(CLASSINFO(wxControl
)) )
168 wxControl
*item
= (wxControl
*)childWin
;
169 if ( item
->GetId() == id
)
173 // In case it's a 'virtual' control (e.g. radiobox)
174 if ( item
->GetSubcontrols().Member((wxObject
*)id
) )
178 current
= current
->Next();
183 // Find an item given the MS Windows handle
184 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
186 // if ( !GetChildren() )
188 wxNode
*current
= GetChildren().First();
191 wxObject
*obj
= (wxObject
*)current
->Data() ;
192 // Do a recursive search.
193 wxWindow
*parent
= (wxWindow
*)obj
;
194 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
198 if ( (!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)) )
200 wxWindow
*item
= (wxWindow
*)current
->Data();
201 if ( (HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
205 if ( item
->ContainsHWND(hWnd
) )
209 current
= current
->Next();
214 // Default command handler
215 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
221 // FIXME: VZ: I'm not sure at all that the order of processing is correct
222 bool wxWindow::HandleNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
224 LPNMHDR hdr
= (LPNMHDR
)lParam
;
225 HWND hWnd
= hdr
->hwndFrom
;
226 wxWindow
*win
= wxFindWinFromHandle((WXHWND
)hWnd
);
228 // is this one of our windows?
231 return win
->MSWOnNotify(idCtrl
, lParam
, result
);
234 // try all our children
235 wxWindowList::Node
*node
= GetChildren().GetFirst();
238 wxWindow
*child
= node
->GetData();
239 if ( child
->MSWOnNotify(idCtrl
, lParam
, result
) )
246 node
= node
->GetNext();
249 // finally try this window too (catches toolbar case)
250 return MSWOnNotify(idCtrl
, lParam
, result
);
253 bool wxWindow::MSWOnNotify(int WXUNUSED(idCtrl
),
255 WXLPARAM
* WXUNUSED(result
))
258 NMHDR
* hdr
= (NMHDR
*)lParam
;
259 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
261 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
262 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
267 #endif // wxUSE_TOOLTIPS
273 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
277 // ----------------------------------------------------------------------------
278 // constructors and such
279 // ----------------------------------------------------------------------------
281 void wxWindow::Init()
287 m_doubleClickAllowed
= 0 ;
288 m_winCaptured
= FALSE
;
290 // caret stuff: initially there is no caret at all
294 m_caretShown
= FALSE
;
298 m_isBeingDeleted
= FALSE
;
301 m_mouseInWindow
= FALSE
;
308 m_backgroundTransparent
= FALSE
;
310 #if wxUSE_MOUSEEVENT_HACK
313 m_lastMouseEvent
= -1;
314 #endif // wxUSE_MOUSEEVENT_HACK
318 wxWindow::~wxWindow()
320 m_isBeingDeleted
= TRUE
;
322 MSWDetachWindowMenu();
325 m_parent
->RemoveChild(this);
330 ::DestroyWindow((HWND
)m_hWnd
);
332 wxRemoveHandleAssociation(this);
335 // Restore old Window proc, if required and remove hWnd <-> wxWindow
340 extern char wxCanvasClassName
[];
342 // real construction (Init() must have been called before!)
343 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
347 const wxString
& name
)
349 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
351 parent
->AddChild(this);
354 if ( style
& wxBORDER
)
355 msflags
|= WS_BORDER
;
356 if ( style
& wxTHICK_FRAME
)
357 msflags
|= WS_THICKFRAME
;
359 msflags
|= WS_CHILD
| WS_VISIBLE
;
360 if ( style
& wxCLIP_CHILDREN
)
361 msflags
|= WS_CLIPCHILDREN
;
364 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
366 // Even with extended styles, need to combine with WS_BORDER
367 // for them to look right.
368 if ( want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
369 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
371 msflags
|= WS_BORDER
;
374 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
376 WidthDefault(size
.x
), HeightDefault(size
.y
),
377 msflags
, NULL
, exStyle
);
382 void wxWindow::SetFocus()
384 HWND hWnd
= GetHwnd();
389 bool wxWindow::Enable(bool enable
)
391 if ( !wxWindowBase::Enable(enable
) )
394 HWND hWnd
= GetHwnd();
396 ::EnableWindow(hWnd
, (BOOL
)enable
);
401 void wxWindow::CaptureMouse()
403 HWND hWnd
= GetHwnd();
404 if ( hWnd
&& !m_winCaptured
)
407 m_winCaptured
= TRUE
;
411 void wxWindow::ReleaseMouse()
416 m_winCaptured
= FALSE
;
420 #if wxUSE_DRAG_AND_DROP
422 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
424 if ( m_dropTarget
!= 0 ) {
425 m_dropTarget
->Revoke(m_hWnd
);
429 m_dropTarget
= pDropTarget
;
430 if ( m_dropTarget
!= 0 )
431 m_dropTarget
->Register(m_hWnd
);
434 #endif // wxUSE_DRAG_AND_DROP
437 //old style file-manager drag&drop support
438 // I think we should retain the old-style
439 // DragAcceptFiles in parallel with SetDropTarget.
441 void wxWindow::DragAcceptFiles(bool accept
)
443 HWND hWnd
= GetHwnd();
445 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
448 // ----------------------------------------------------------------------------
450 // ----------------------------------------------------------------------------
454 void wxWindow::DoSetToolTip(wxToolTip
*tooltip
)
456 wxWindowBase::DoSetToolTip(tooltip
);
459 m_tooltip
->SetWindow(this);
462 #endif // wxUSE_TOOLTIPS
465 void wxWindow::DoGetSize(int *x
, int *y
) const
467 HWND hWnd
= GetHwnd();
469 GetWindowRect(hWnd
, &rect
);
472 *x
= rect
.right
- rect
.left
;
474 *y
= rect
.bottom
- rect
.top
;
477 void wxWindow::DoGetPosition(int *x
, int *y
) const
479 HWND hWnd
= GetHwnd();
482 hParentWnd
= (HWND
) GetParent()->GetHWND();
485 GetWindowRect(hWnd
, &rect
);
487 // Since we now have the absolute screen coords, if there's a parent we
488 // must subtract its top left corner
494 ::ScreenToClient(hParentWnd
, &point
);
497 // We may be faking the client origin. So a window that's really at (0,
498 // 30) may appear (to wxWin apps) to be at (0, 0).
501 wxPoint
pt(GetParent()->GetClientAreaOrigin());
512 void wxWindow::ScreenToClient(int *x
, int *y
) const
520 HWND hWnd
= GetHwnd();
521 ::ScreenToClient(hWnd
, &pt
);
529 void wxWindow::ClientToScreen(int *x
, int *y
) const
537 HWND hWnd
= GetHwnd();
538 ::ClientToScreen(hWnd
, &pt
);
546 bool wxWindow::SetCursor(const wxCursor
& cursor
)
548 if ( !wxWindowBase::SetCursor(cursor
) )
554 wxASSERT_MSG( m_cursor
.Ok(),
555 _T("cursor must be valid after call to the base version"));
557 HWND hWnd
= GetHwnd();
559 // Change the cursor NOW if we're within the correct window
561 ::GetCursorPos(&point
);
564 ::GetWindowRect(hWnd
, &rect
);
566 if ( ::PtInRect(&rect
, point
) && !wxIsBusy() )
567 ::SetCursor((HCURSOR
)m_cursor
.GetHCURSOR());
572 // Get size *available for subwindows* i.e. excluding menu bar etc.
573 void wxWindow::DoGetClientSize(int *x
, int *y
) const
575 HWND hWnd
= GetHwnd();
577 ::GetClientRect(hWnd
, &rect
);
584 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
586 int currentX
, currentY
;
587 GetPosition(¤tX
, ¤tY
);
588 int currentW
,currentH
;
589 GetSize(¤tW
, ¤tH
);
591 if ( x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
594 int actualWidth
= width
;
595 int actualHeight
= height
;
598 if ( x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
600 if ( y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
603 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
606 actualWidth
= currentW
;
608 actualHeight
= currentH
;
610 HWND hWnd
= GetHwnd();
612 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
615 void wxWindow::DoSetClientSize(int width
, int height
)
617 wxWindow
*parent
= GetParent();
618 HWND hWnd
= GetHwnd();
619 HWND hParentWnd
= (HWND
) 0;
621 hParentWnd
= (HWND
) parent
->GetHWND();
624 ::GetClientRect(hWnd
, &rect
);
627 GetWindowRect(hWnd
, &rect2
);
629 // Find the difference between the entire window (title bar and all)
630 // and the client area; add this to the new client size to move the
632 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
633 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
635 // If there's a parent, must subtract the parent's top left corner
636 // since MoveWindow moves relative to the parent
639 point
.x
= rect2
.left
;
643 ::ScreenToClient(hParentWnd
, &point
);
646 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
648 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
649 event
.SetEventObject(this);
650 GetEventHandler()->ProcessEvent(event
);
653 // For implementation purposes - sometimes decorations make the client area
655 wxPoint
wxWindow::GetClientAreaOrigin() const
657 return wxPoint(0, 0);
660 // Makes an adjustment to the window position (for example, a frame that has
661 // a toolbar that it manages itself).
662 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
664 if ( ((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent() )
666 wxPoint
pt(GetParent()->GetClientAreaOrigin());
667 x
+= pt
.x
; y
+= pt
.y
;
671 bool wxWindow::Show(bool show
)
673 if ( !wxWindowBase::Show(show
) )
676 HWND hWnd
= GetHwnd();
677 int cshow
= show
? SW_SHOW
: SW_HIDE
;
678 ::ShowWindow(hWnd
, cshow
);
682 BringWindowToTop(hWnd
);
688 int wxWindow::GetCharHeight(void) const
690 TEXTMETRIC lpTextMetric
;
691 HWND hWnd
= GetHwnd();
692 HDC dc
= ::GetDC(hWnd
);
694 GetTextMetrics(dc
, &lpTextMetric
);
695 ::ReleaseDC(hWnd
, dc
);
697 return lpTextMetric
.tmHeight
;
700 int wxWindow::GetCharWidth(void) const
702 TEXTMETRIC lpTextMetric
;
703 HWND hWnd
= GetHwnd();
704 HDC dc
= ::GetDC(hWnd
);
706 GetTextMetrics(dc
, &lpTextMetric
);
707 ::ReleaseDC(hWnd
, dc
);
709 return lpTextMetric
.tmAveCharWidth
;
712 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
713 int *descent
, int *externalLeading
, const wxFont
*theFont
) const
715 wxFont
*fontToUse
= (wxFont
*)theFont
;
717 fontToUse
= (wxFont
*) & m_font
;
719 HWND hWnd
= GetHwnd();
720 HDC dc
= ::GetDC(hWnd
);
724 if ( fontToUse
&& fontToUse
->Ok() )
726 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
728 was
= (HFONT
) SelectObject(dc
,fnt
) ;
733 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
734 GetTextMetrics(dc
, &tm
);
736 if ( fontToUse
&& fnt
&& was
)
737 SelectObject(dc
,was
) ;
743 if ( descent
) *descent
= tm
.tmDescent
;
744 if ( externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
747 // fontToUse->ReleaseResource();
750 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
752 HWND hWnd
= GetHwnd();
758 mswRect
.left
= rect
->x
;
759 mswRect
.top
= rect
->y
;
760 mswRect
.right
= rect
->x
+ rect
->width
;
761 mswRect
.bottom
= rect
->y
+ rect
->height
;
763 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
766 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
770 // ---------------------------------------------------------------------------
771 // Main wxWindows window proc and the window proc for wxWindow
772 // ---------------------------------------------------------------------------
774 // Hook for new window just as it's being created, when the window isn't yet
775 // associated with the handle
776 wxWindow
*wxWndHook
= NULL
;
779 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
781 // trace all messages - useful for the debugging
783 wxLogTrace(wxTraceMessages
, "Processing %s(wParam=%8lx, lParam=%8lx)",
784 wxGetMessageName(message
), wParam
, lParam
);
785 #endif // __WXDEBUG__
787 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
789 // when we get the first message for the HWND we just created, we associate
790 // it with wxWindow stored in wxWndHook
791 if ( !wnd
&& wxWndHook
)
793 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
796 wnd
->SetHWND((WXHWND
)hWnd
);
801 // Stop right here if we don't have a valid handle in our wxWindow object.
802 if ( wnd
&& !wnd
->GetHWND() )
804 // FIXME: why do we do this?
805 wnd
->SetHWND((WXHWND
) hWnd
);
806 rc
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
812 rc
= wnd
->MSWWindowProc(message
, wParam
, lParam
);
814 rc
= DefWindowProc( hWnd
, message
, wParam
, lParam
);
820 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
822 // did we process the message?
823 bool processed
= FALSE
;
834 // for most messages we should return 0 when we do process the message
837 HWND hWnd
= GetHwnd();
844 WORD state
= LOWORD(wParam
);
845 WORD minimized
= HIWORD(wParam
);
846 HWND hwnd
= (HWND
)lParam
;
848 WORD state
= (WORD
)wParam
;
849 WORD minimized
= LOWORD(lParam
);
850 HWND hwnd
= (HWND
)HIWORD(lParam
);
852 processed
= MSWOnActivate(state
, minimized
!= 0, (WXHWND
)hwnd
);
857 // process this message for any toplevel window
860 // if we can't close, tell the system that we processed the
861 // message - otherwise it would close us
862 processed
= !Close();
867 processed
= MSWOnSetFocus((WXHWND
)(HWND
)wParam
);
871 processed
= MSWOnKillFocus((WXHWND
)(HWND
)wParam
);
877 processed
= MSWOnCreate((WXLPCREATESTRUCT
)lParam
, &allow
);
879 // we should return 0 to allow window creation
885 processed
= MSWOnShow(wParam
!= 0, (int)lParam
);
889 processed
= MSWOnPaint();
892 case WM_QUERYDRAGICON
:
893 processed
= MSWOnQueryDragIcon(&rc
.hIcon
);
897 processed
= MSWOnSize(LOWORD(lParam
), HIWORD(lParam
), wParam
);
901 processed
= HandleMove(LOWORD(lParam
), HIWORD(lParam
));
904 case WM_WINDOWPOSCHANGING
:
905 processed
= MSWOnWindowPosChanging((void *)lParam
);
911 case WM_LBUTTONDBLCLK
:
914 case WM_RBUTTONDBLCLK
:
917 case WM_MBUTTONDBLCLK
:
919 int x
= LOWORD(lParam
);
920 int y
= HIWORD(lParam
);
922 processed
= MSWOnMouseEvent(message
, x
, y
, wParam
);
930 case MM_JOY1BUTTONDOWN
:
931 case MM_JOY2BUTTONDOWN
:
932 case MM_JOY1BUTTONUP
:
933 case MM_JOY2BUTTONUP
:
935 int x
= LOWORD(lParam
);
936 int y
= HIWORD(lParam
);
938 processed
= HandleJoystickEvent(message
, x
, y
, wParam
);
943 processed
= MSWOnDestroy();
947 processed
= MSWOnSysCommand(wParam
, lParam
);
953 WORD id
= LOWORD(wParam
);
954 HWND hwnd
= (HWND
)lParam
;
955 WORD cmd
= HIWORD(wParam
);
957 WORD id
= (WORD
)wParam
;
958 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
959 WORD cmd
= HIWORD(lParam
);
961 processed
= MSWOnCommand(id
, cmd
, (WXHWND
)hwnd
);
967 processed
= HandleNotify((int)wParam
, lParam
, &rc
.result
);
971 // for these messages we must return TRUE if process the message
975 int idCtrl
= (UINT
)wParam
;
976 if ( message
== WM_DRAWITEM
)
978 processed
= MSWOnDrawItem(idCtrl
,
979 (WXDRAWITEMSTRUCT
*)lParam
);
983 processed
= MSWOnMeasureItem(idCtrl
,
984 (WXMEASUREITEMSTRUCT
*)lParam
);
993 // If this has been processed by an event handler,
994 // return 0 now (we've handled it).
995 if ( MSWOnKeyDown((WORD
) wParam
, lParam
) )
1002 // we consider these message "not interesting" to OnChar
1003 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1010 // avoid duplicate messages to OnChar for these ASCII keys: they
1011 // will be translated by TranslateMessage() and received in WM_CHAR
1020 // special case of VK_APPS: treat it the same as right mouse
1021 // click because both usually pop up a context menu
1024 // construct the key mask
1025 WPARAM fwKeys
= MK_RBUTTON
;
1026 if ( (::GetKeyState(VK_CONTROL
) & 0x100) != 0 )
1027 fwKeys
|= MK_CONTROL
;
1028 if ( (::GetKeyState(VK_SHIFT
) & 0x100) != 0 )
1031 // simulate right mouse button click
1032 DWORD dwPos
= ::GetMessagePos();
1033 int x
= GET_X_LPARAM(dwPos
),
1034 y
= GET_Y_LPARAM(dwPos
);
1036 ScreenToClient(&x
, &y
);
1037 processed
= MSWOnMouseEvent(WM_RBUTTONDOWN
, x
, y
, fwKeys
);
1047 processed
= MSWOnChar((WORD
)wParam
, lParam
);
1052 processed
= MSWOnKeyUp((WORD
) wParam
, lParam
);
1055 case WM_CHAR
: // Always an ASCII character
1056 processed
= MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1063 WORD code
= LOWORD(wParam
);
1064 WORD pos
= HIWORD(wParam
);
1065 HWND control
= (HWND
)lParam
;
1067 WORD code
= (WORD
)wParam
;
1068 WORD pos
= LOWORD(lParam
);
1069 HWND control
= (HWND
)HIWORD(lParam
);
1071 processed
= MSWOnScroll(message
== WM_HSCROLL
? wxHORIZONTAL
1073 code
, pos
, (WXHWND
)control
);
1077 // CTLCOLOR messages are sent by children to query the parent for their
1080 case WM_CTLCOLORMSGBOX
:
1081 case WM_CTLCOLOREDIT
:
1082 case WM_CTLCOLORLISTBOX
:
1083 case WM_CTLCOLORBTN
:
1084 case WM_CTLCOLORDLG
:
1085 case WM_CTLCOLORSCROLLBAR
:
1086 case WM_CTLCOLORSTATIC
:
1088 int nCtlColor
= CTLCOLOR_BTN
;
1089 HWND control
= (HWND
)lParam
;
1090 HDC hdc
= (HDC
)wParam
;
1092 processed
= MSWOnCtlColor(&rc
.hBrush
, (WXHDC
)hdc
, (WXHWND
)control
,
1093 nCtlColor
, message
, wParam
, lParam
);
1099 HWND control
= (HWND
)LOWORD(lParam
);
1100 int nCtlColor
= (int)HIWORD(lParam
);
1101 HDC hdc
= (HDC
)wParam
;
1103 processed
= MSWOnCtlColor(&rc
.hBrush
, (WXHDC
)hdc
, (WXHWND
)control
,
1104 nCtlColor
, message
, wParam
, lParam
);
1109 // the return value for this message is ignored
1110 case WM_SYSCOLORCHANGE
:
1112 wxSysColourChangedEvent event
;
1113 event
.SetEventObject(this);
1115 processed
= GetEventHandler()->ProcessEvent(event
);
1119 case WM_PALETTECHANGED
:
1120 processed
= MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1123 case WM_QUERYNEWPALETTE
:
1124 processed
= MSWOnQueryNewPalette();
1127 // return TRUE if we erase the background
1129 // Prevents flicker when dragging
1130 if ( IsIconic(hWnd
) ) return 1;
1132 if ( !MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
) )
1137 case WM_MDIACTIVATE
:
1140 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1141 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1142 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1143 processed
= MSWOnMDIActivate((long)activate
,
1144 (WXHWND
)hWndActivate
,
1145 (WXHWND
)hWndDeactivate
);
1147 processed
= MSWOnMDIActivate((BOOL
)wParam
,
1148 (HWND
)LOWORD(lParam
),
1149 (HWND
)HIWORD(lParam
));
1155 processed
= MSWOnDropFiles(wParam
);
1159 wxFAIL_MSG("to fix");
1161 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1163 // we never set focus from here
1167 case WM_QUERYENDSESSION
:
1168 processed
= MSWOnQueryEndSession(lParam
, &rc
.allow
);
1172 processed
= MSWOnEndSession(wParam
!= 0, lParam
);
1175 case WM_GETMINMAXINFO
:
1177 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1178 if ( m_minWidth
!= -1 )
1179 info
->ptMinTrackSize
.x
= m_minWidth
;
1180 if ( m_minHeight
!= -1 )
1181 info
->ptMinTrackSize
.y
= m_minHeight
;
1182 if ( m_maxWidth
!= -1 )
1183 info
->ptMaxTrackSize
.x
= m_maxWidth
;
1184 if ( m_maxHeight
!= -1 )
1185 info
->ptMaxTrackSize
.y
= m_maxHeight
;
1190 // don't set cursor for other windows, only for this one: this
1191 // prevents children of this window from getting the same cursor as
1192 // the parent has (don't forget that this message is propagated by
1193 // default up the window parent-child hierarchy)
1194 if ( (HWND
)wParam
== hWnd
)
1196 // don't set cursor when the mouse is not in the client part
1197 short nHitTest
= LOWORD(lParam
);
1198 if ( nHitTest
== HTCLIENT
|| nHitTest
== HTERROR
)
1200 HCURSOR hcursor
= 0;
1203 // from msw\utils.cpp
1204 extern HCURSOR gs_wxBusyCursor
;
1206 hcursor
= gs_wxBusyCursor
;
1210 wxCursor
*cursor
= NULL
;
1212 if ( m_cursor
.Ok() )
1218 // from msw\data.cpp
1219 extern wxCursor
*g_globalCursor
;
1221 if ( g_globalCursor
&& g_globalCursor
->Ok() )
1222 cursor
= g_globalCursor
;
1226 hcursor
= (HCURSOR
)cursor
->GetHCURSOR();
1231 ::SetCursor(hcursor
);
1233 // returning TRUE stops the DefWindowProc() from
1234 // further processing this message - exactly what we
1235 // need because we've just set the cursor.
1246 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1247 wxGetMessageName(message
));
1248 #endif // __WXDEBUG__
1249 rc
.result
= MSWDefWindowProc(message
, wParam
, lParam
);
1255 // Dialog window proc
1256 LONG APIENTRY _EXPORT
1257 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1262 wxList
*wxWinHandleList
= NULL
;
1263 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1265 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1268 return (wxWindow
*)node
->Data();
1271 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1273 // adding NULL hWnd is (first) surely a result of an error and
1274 // (secondly) breaks menu command processing
1275 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1277 if ( !wxWinHandleList
->Find((long)hWnd
) )
1278 wxWinHandleList
->Append((long)hWnd
, win
);
1281 void wxRemoveHandleAssociation(wxWindow
*win
)
1283 wxWinHandleList
->DeleteObject(win
);
1286 // Default destroyer - override if you destroy it in some other way
1287 // (e.g. with MDI child windows)
1288 void wxWindow::MSWDestroyWindow()
1292 bool wxWindow::MSWCreate(int id
,
1302 const char *dialog_template
,
1303 WXDWORD extendedStyle
)
1305 int x1
= CW_USEDEFAULT
;
1307 int width1
= CW_USEDEFAULT
;
1310 // Find parent's size, if it exists, to set up a possible default
1311 // panel size the size of the parent window
1315 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1317 width1
= parent_rect
.right
- parent_rect
.left
;
1318 height1
= parent_rect
.bottom
- parent_rect
.top
;
1321 if ( x
> -1 ) x1
= x
;
1322 if ( y
> -1 ) y1
= y
;
1323 if ( width
> -1 ) width1
= width
;
1324 if ( height
> -1 ) height1
= height
;
1326 HWND hParent
= NULL
;
1328 hParent
= (HWND
) parent
->GetHWND();
1332 if ( dialog_template
)
1334 m_hWnd
= (WXHWND
)::CreateDialog(wxGetInstance(),
1337 (DLGPROC
)wxDlgProc
);
1341 wxLogError(_("Can't find dummy dialog template!\n"
1342 "Check resource include path for finding wx.rc."));
1347 ::MoveWindow(GetHwnd(), x1
, y1
, width1
, height1
, FALSE
);
1352 if ( style
& WS_CHILD
)
1355 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
,
1361 hParent
, (HMENU
)controlId
,
1367 wxLogError(_("Can't create window of class %s!\n"
1368 "Possible Windows 3.x compatibility problem?"),
1376 wxWinHandleList
->Append((long)m_hWnd
, this);
1381 bool wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
), bool *mayCreate
)
1388 bool wxWindow::MSWOnQueryEndSession(long logOff
, bool *mayEnd
)
1390 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1391 event
.SetEventObject(wxTheApp
);
1392 event
.SetCanVeto(TRUE
);
1393 event
.SetLoggingOff(logOff
== ENDSESSION_LOGOFF
);
1395 bool rc
= wxTheApp
->ProcessEvent(event
);
1399 // we may end only if the app didn't veto session closing (double
1401 *mayEnd
= !event
.GetVeto();
1407 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1409 // do nothing if the session isn't ending
1413 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1414 event
.SetEventObject(wxTheApp
);
1415 event
.SetCanVeto(FALSE
);
1416 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1417 if ( (this == wxTheApp
->GetTopWindow()) && // Only send once
1418 wxTheApp
->ProcessEvent(event
))
1424 bool wxWindow::MSWOnDestroy()
1426 // delete our drop target if we've got one
1427 #if wxUSE_DRAG_AND_DROP
1428 if ( m_dropTarget
!= NULL
) {
1429 m_dropTarget
->Revoke(m_hWnd
);
1431 delete m_dropTarget
;
1432 m_dropTarget
= NULL
;
1439 bool wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
),
1440 WXHWND
WXUNUSED(activate
),
1441 WXHWND
WXUNUSED(deactivate
))
1446 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1448 wxActivateEvent
event(wxEVT_ACTIVATE
,
1449 (state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
),
1451 event
.SetEventObject(this);
1453 return GetEventHandler()->ProcessEvent(event
);
1456 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1459 if ( m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0) )
1461 ::CreateCaret(GetHwnd(), NULL
, m_caretWidth
, m_caretHeight
);
1463 ::ShowCaret(GetHwnd());
1466 // panel wants to track the window which was the last to have focus in it
1467 wxWindow
*parent
= GetParent();
1468 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1470 ((wxPanel
*)parent
)->SetLastFocus(GetId());
1473 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1474 event
.SetEventObject(this);
1475 return GetEventHandler()->ProcessEvent(event
);
1478 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1481 if ( m_caretEnabled
)
1486 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1487 event
.SetEventObject(this);
1488 return GetEventHandler()->ProcessEvent(event
);
1491 bool wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1494 HDROP hFilesInfo
= (HDROP
) wParam
;
1496 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1498 // Get the total number of files dropped
1499 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1504 wxString
*files
= new wxString
[gwFilesDropped
];
1506 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1508 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1509 files
[wIndex
] = wxBuffer
;
1511 DragFinish (hFilesInfo
);
1513 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1514 event
.m_eventObject
= this;
1515 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1517 bool rc
= GetEventHandler()->ProcessEvent(event
);
1524 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1526 #if wxUSE_OWNER_DRAWN
1527 if ( id
== 0 ) { // is it a menu item?
1528 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1529 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1530 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1532 // prepare to call OnDrawItem()
1534 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1535 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1536 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1537 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1538 return pMenuItem
->OnDrawItem(
1540 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1541 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1544 #endif // owner-drawn menus
1546 wxWindow
*item
= FindItem(id
);
1547 #if wxUSE_DYNAMIC_CLASSES
1548 if ( item
&& item
->IsKindOf(CLASSINFO(wxControl
)) )
1550 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1557 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1559 #if wxUSE_OWNER_DRAWN
1560 if ( id
== 0 ) { // is it a menu item?
1561 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1562 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1563 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1565 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1566 &pMeasureStruct
->itemHeight
);
1568 #endif // owner-drawn menus
1570 wxWindow
*item
= FindItem(id
);
1571 #if wxUSE_DYNAMIC_CLASSES
1572 if ( item
&& item
->IsKindOf(CLASSINFO(wxControl
)) )
1574 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1581 bool wxWindow::MSWOnCtlColor(WXHBRUSH
*brush
,
1589 WXHBRUSH hBrush
= 0;
1591 if ( nCtlColor
== CTLCOLOR_DLG
)
1593 hBrush
= OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1597 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1599 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1608 // Define for each class of dialog and control
1609 WXHBRUSH
wxWindow::OnCtlColor(WXHDC hDC
,
1619 bool wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1621 wxPaletteChangedEvent
event(GetId());
1622 event
.SetEventObject(this);
1623 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1625 return GetEventHandler()->ProcessEvent(event
);
1628 bool wxWindow::MSWOnQueryNewPalette()
1630 wxQueryNewPaletteEvent
event(GetId());
1631 event
.SetEventObject(this);
1633 return GetEventHandler()->ProcessEvent(event
) && event
.GetPaletteRealized();
1636 // Responds to colour changes: passes event on to children.
1637 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1639 wxNode
*node
= GetChildren().First();
1642 // Only propagate to non-top-level windows
1643 wxWindow
*win
= (wxWindow
*)node
->Data();
1644 if ( win
->GetParent() )
1646 wxSysColourChangedEvent event2
;
1647 event
.m_eventObject
= win
;
1648 win
->GetEventHandler()->ProcessEvent(event2
);
1651 node
= node
->Next();
1655 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1658 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, GetHwnd(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1660 return ::DefWindowProc(GetHwnd(), nMsg
, wParam
, lParam
);
1663 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1665 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) )
1667 // intercept dialog navigation keys
1668 MSG
*msg
= (MSG
*)pMsg
;
1669 bool bProcess
= TRUE
;
1670 if ( msg
->message
!= WM_KEYDOWN
)
1673 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1678 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1680 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1681 // don't process it if it's the case (except for Ctrl-Tab/Enter
1682 // combinations which are always processed)
1686 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1689 bool bForward
= TRUE
,
1690 bWindowChange
= FALSE
;
1692 switch ( msg
->wParam
)
1695 if ( lDlgCode
& DLGC_WANTTAB
) {
1699 // Ctrl-Tab cycles thru notebook pages
1700 bWindowChange
= bCtrlDown
;
1701 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1707 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1715 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1721 if ( lDlgCode
& DLGC_WANTMESSAGE
)
1723 // control wants to process Enter itself, don't
1724 // call IsDialogMessage() which would interpret
1729 wxButton
*btnDefault
= GetDefaultItem();
1730 if ( btnDefault
&& !bCtrlDown
)
1732 // if there is a default button, Enter should
1734 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
1738 // else: but if there is not it makes sense to make it
1739 // work like a TAB - and that's what we do.
1740 // Note that Ctrl-Enter always works this way.
1751 wxNavigationKeyEvent event
;
1752 event
.SetDirection(bForward
);
1753 event
.SetWindowChange(bWindowChange
);
1754 event
.SetEventObject(this);
1756 if ( GetEventHandler()->ProcessEvent(event
) )
1761 if ( ::IsDialogMessage(GetHwnd(), msg
) )
1768 // relay mouse move events to the tooltip control
1769 MSG
*msg
= (MSG
*)pMsg
;
1770 if ( msg
->message
== WM_MOUSEMOVE
)
1771 m_tooltip
->RelayEvent(pMsg
);
1773 #endif // wxUSE_TOOLTIPS
1775 /* This code manages to disable character input completely. Nice one!
1776 * Probably because the dialog is requesting all char input. Or,
1777 * it gets called by non-dialog windows.
1779 // In case we don't have wxTAB_TRAVERSAL style on.
1780 // If we don't call this, we may never process Enter correctly.
1781 if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) == 0 )
1783 MSG *msg = (MSG *)pMsg;
1784 if ( ::IsDialogMessage(GetHwnd(), msg) )
1791 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
1793 if ( m_acceleratorTable
.Ok( ) &&
1794 ::TranslateAccelerator(GetHwnd(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
1800 void wxWindow::MSWDetachWindowMenu()
1804 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
1806 for (i
= 0; i
< N
; i
++)
1809 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
1810 if ( (chars
> 0) && (strcmp(buf
, "&Window") == 0) )
1812 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
1819 bool wxWindow::MSWOnPaint()
1822 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
1823 ::GetUpdateRgn(GetHwnd(), hRegion
, FALSE
);
1825 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
1828 ::GetUpdateRect(GetHwnd(), & updateRect
, FALSE
);
1830 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
1831 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
1834 wxPaintEvent
event(m_windowId
);
1835 event
.SetEventObject(this);
1836 return GetEventHandler()->ProcessEvent(event
);
1839 bool wxWindow::HandleMove(int x
, int y
)
1841 wxMoveEvent
event(wxPoint(x
, y
), m_windowId
);
1842 event
.SetEventObject(this);
1844 return GetEventHandler()->ProcessEvent(event
);
1847 bool wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
1849 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
1850 event
.SetEventObject(this);
1852 return GetEventHandler()->ProcessEvent(event
);
1855 bool wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
1860 // Deal with child commands from buttons etc.
1861 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
1863 if ( wxCurrentPopupMenu
)
1865 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
1866 wxCurrentPopupMenu
= NULL
;
1867 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
1871 wxWindow
*item
= FindItem(id
);
1874 bool value
= item
->MSWCommand(cmd
, id
);
1879 wxWindow
*win
= wxFindWinFromHandle(control
);
1881 return win
->MSWCommand(cmd
, id
);
1886 bool wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
1888 // 4 bits are reserved
1889 switch (wParam
& 0xFFFFFFF0)
1893 wxMaximizeEvent
event(m_windowId
);
1894 event
.SetEventObject(this);
1896 return GetEventHandler()->ProcessEvent(event
);
1901 wxIconizeEvent
event(m_windowId
);
1902 event
.SetEventObject(this);
1904 return GetEventHandler()->ProcessEvent(event
);
1911 // ---------------------------------------------------------------------------
1913 // ---------------------------------------------------------------------------
1915 void wxWindow::InitMouseEvent(wxMouseEvent
& event
, int x
, int y
, WXUINT flags
)
1919 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
1920 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
1921 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
1922 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
1923 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
1924 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
1925 event
.m_eventObject
= this;
1927 #if wxUSE_MOUSEEVENT_HACK
1930 m_lastMouseEvent
= event
.GetEventType();
1931 #endif // wxUSE_MOUSEEVENT_HACK
1935 bool wxWindow::MSWOnMouseEvent(WXUINT msg
, int x
, int y
, WXUINT flags
)
1937 // the mouse events take consecutive IDs from WM_MOUSEFIRST to
1938 // WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
1939 // from the message id and take the value in the table to get wxWin event
1941 static const wxEventType eventsMouse
[] =
1955 wxMouseEvent
event(eventsMouse
[msg
- WM_MOUSEMOVE
]);
1956 InitMouseEvent(event
, x
, y
, flags
);
1958 return GetEventHandler()->ProcessEvent(event
);
1961 bool wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
1963 if ( !m_mouseInWindow
)
1965 // Generate an ENTER event
1966 m_mouseInWindow
= TRUE
;
1968 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
1969 InitMouseEvent(event
, x
, y
, flags
);
1971 (void)GetEventHandler()->ProcessEvent(event
);
1974 #if wxUSE_MOUSEEVENT_HACK
1975 // Window gets a click down message followed by a mouse move message even
1976 // if position isn't changed! We want to discard the trailing move event
1977 // if x and y are the same.
1978 if ( (m_lastMouseEvent
== wxEVT_RIGHT_DOWN
||
1979 m_lastMouseEvent
== wxEVT_LEFT_DOWN
||
1980 m_lastMouseEvent
== wxEVT_MIDDLE_DOWN
) &&
1981 (m_lastMouseX
== event
.m_x
&& m_lastMouseY
== event
.m_y
) )
1983 m_lastMouseEvent
= wxEVT_MOTION
;
1987 #endif // wxUSE_MOUSEEVENT_HACK
1989 return MSWOnMouseEvent(WM_MOUSEMOVE
, x
, y
, flags
);
1992 // ---------------------------------------------------------------------------
1993 // keyboard handling
1994 // ---------------------------------------------------------------------------
1996 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
1998 bool wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2001 bool tempControlDown
= FALSE
;
2004 // If 1 -> 26, translate to CTRL plus a letter.
2006 if ( (id
> 0) && (id
< 27) )
2027 tempControlDown
= TRUE
;
2033 else if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2034 // it's ASCII and will be processed here only when called from
2035 // WM_CHAR (i.e. when isASCII = TRUE)
2041 wxKeyEvent
event(wxEVT_CHAR
);
2042 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2043 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2044 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2045 event
.m_altDown
= TRUE
;
2047 event
.m_eventObject
= this;
2048 event
.m_keyCode
= id
;
2049 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2054 GetWindowRect(GetHwnd(),&rect
) ;
2058 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2060 if ( GetEventHandler()->ProcessEvent(event
) )
2069 bool wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
)
2073 if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2079 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2080 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2081 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2082 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2083 event
.m_altDown
= TRUE
;
2085 event
.m_eventObject
= this;
2086 event
.m_keyCode
= id
;
2087 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2092 GetWindowRect(GetHwnd(),&rect
) ;
2096 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2098 if ( GetEventHandler()->ProcessEvent(event
) )
2110 bool wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
)
2114 if ( (id
= wxCharCodeMSWToWX(wParam
)) == 0 ) {
2120 wxKeyEvent
event(wxEVT_KEY_UP
);
2121 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2122 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2123 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2124 event
.m_altDown
= TRUE
;
2126 event
.m_eventObject
= this;
2127 event
.m_keyCode
= id
;
2128 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2133 GetWindowRect(GetHwnd(),&rect
) ;
2137 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2139 if ( GetEventHandler()->ProcessEvent(event
) )
2148 // ---------------------------------------------------------------------------
2150 // ---------------------------------------------------------------------------
2152 bool wxWindow::HandleJoystickEvent(WXUINT msg
, int x
, int y
, WXUINT flags
)
2155 if ( flags
& JOY_BUTTON1CHG
)
2156 change
= wxJOY_BUTTON1
;
2157 if ( flags
& JOY_BUTTON2CHG
)
2158 change
= wxJOY_BUTTON2
;
2159 if ( flags
& JOY_BUTTON3CHG
)
2160 change
= wxJOY_BUTTON3
;
2161 if ( flags
& JOY_BUTTON4CHG
)
2162 change
= wxJOY_BUTTON4
;
2165 if ( flags
& JOY_BUTTON1
)
2166 buttons
|= wxJOY_BUTTON1
;
2167 if ( flags
& JOY_BUTTON2
)
2168 buttons
|= wxJOY_BUTTON2
;
2169 if ( flags
& JOY_BUTTON3
)
2170 buttons
|= wxJOY_BUTTON3
;
2171 if ( flags
& JOY_BUTTON4
)
2172 buttons
|= wxJOY_BUTTON4
;
2174 // the event ids aren't consecutive so we can't use table based lookup
2176 wxEventType eventType
;
2181 eventType
= wxEVT_JOY_MOVE
;
2186 eventType
= wxEVT_JOY_MOVE
;
2191 eventType
= wxEVT_JOY_ZMOVE
;
2196 eventType
= wxEVT_JOY_ZMOVE
;
2199 case MM_JOY1BUTTONDOWN
:
2201 eventType
= wxEVT_JOY_BUTTON_DOWN
;
2204 case MM_JOY2BUTTONDOWN
:
2206 eventType
= wxEVT_JOY_BUTTON_DOWN
;
2209 case MM_JOY1BUTTONUP
:
2211 eventType
= wxEVT_JOY_BUTTON_UP
;
2214 case MM_JOY2BUTTONUP
:
2216 eventType
= wxEVT_JOY_BUTTON_UP
;
2220 wxFAIL_MSG("no such joystick event");
2225 wxJoystickEvent
event(eventType
, buttons
, joystick
, change
);
2226 event
.SetPosition(wxPoint(x
, y
));
2227 event
.SetEventObject(this);
2229 return GetEventHandler()->ProcessEvent(event
);
2232 bool wxWindow::MSWOnScroll(int orientation
, WXWORD wParam
,
2233 WXWORD pos
, WXHWND control
)
2237 wxWindow
*child
= wxFindWinFromHandle(control
);
2239 return child
->MSWOnScroll(orientation
, wParam
, pos
, control
);
2242 wxScrollEvent event
;
2243 event
.SetPosition(pos
);
2244 event
.SetOrientation(orientation
);
2245 event
.m_eventObject
= this;
2250 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2254 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2258 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2262 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2266 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2270 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2274 case SB_THUMBPOSITION
:
2275 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2282 return GetEventHandler()->ProcessEvent(event
);
2285 bool wxWindow::MSWOnShow(bool show
, int status
)
2287 wxShowEvent
event(GetId(), show
);
2288 event
.m_eventObject
= this;
2290 return GetEventHandler()->ProcessEvent(event
);
2293 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2295 wxInitDialogEvent
event(GetId());
2296 event
.m_eventObject
= this;
2298 return GetEventHandler()->ProcessEvent(event
);
2301 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2304 HDC dc
= ::GetDC((HWND
) wnd
);
2309 // the_font->UseResource();
2310 // the_font->RealizeResource();
2311 fnt
= (HFONT
)the_font
->GetResourceHandle();
2313 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2315 GetTextMetrics(dc
, &tm
);
2316 if ( the_font
&& fnt
&& was
)
2318 SelectObject(dc
,was
) ;
2320 ReleaseDC((HWND
)wnd
, dc
);
2321 *x
= tm
.tmAveCharWidth
;
2322 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2325 // the_font->ReleaseResource();
2328 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2329 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2330 int wxCharCodeMSWToWX(int keySym
)
2335 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2336 case VK_BACK
: id
= WXK_BACK
; break;
2337 case VK_TAB
: id
= WXK_TAB
; break;
2338 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2339 case VK_RETURN
: id
= WXK_RETURN
; break;
2340 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2341 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2342 case VK_MENU
: id
= WXK_MENU
; break;
2343 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2344 case VK_SPACE
: id
= WXK_SPACE
; break;
2345 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2346 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2347 case VK_NEXT
: id
= WXK_NEXT
; break;
2348 case VK_END
: id
= WXK_END
; break;
2349 case VK_HOME
: id
= WXK_HOME
; break;
2350 case VK_LEFT
: id
= WXK_LEFT
; break;
2351 case VK_UP
: id
= WXK_UP
; break;
2352 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2353 case VK_DOWN
: id
= WXK_DOWN
; break;
2354 case VK_SELECT
: id
= WXK_SELECT
; break;
2355 case VK_PRINT
: id
= WXK_PRINT
; break;
2356 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2357 case VK_INSERT
: id
= WXK_INSERT
; break;
2358 case VK_DELETE
: id
= WXK_DELETE
; break;
2359 case VK_HELP
: id
= WXK_HELP
; break;
2360 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2361 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2362 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2363 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2364 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2365 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2366 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2367 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2368 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2369 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2370 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2371 case VK_ADD
: id
= WXK_ADD
; break;
2372 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2373 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2374 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2375 case VK_F1
: id
= WXK_F1
; break;
2376 case VK_F2
: id
= WXK_F2
; break;
2377 case VK_F3
: id
= WXK_F3
; break;
2378 case VK_F4
: id
= WXK_F4
; break;
2379 case VK_F5
: id
= WXK_F5
; break;
2380 case VK_F6
: id
= WXK_F6
; break;
2381 case VK_F7
: id
= WXK_F7
; break;
2382 case VK_F8
: id
= WXK_F8
; break;
2383 case VK_F9
: id
= WXK_F9
; break;
2384 case VK_F10
: id
= WXK_F10
; break;
2385 case VK_F11
: id
= WXK_F11
; break;
2386 case VK_F12
: id
= WXK_F12
; break;
2387 case VK_F13
: id
= WXK_F13
; break;
2388 case VK_F14
: id
= WXK_F14
; break;
2389 case VK_F15
: id
= WXK_F15
; break;
2390 case VK_F16
: id
= WXK_F16
; break;
2391 case VK_F17
: id
= WXK_F17
; break;
2392 case VK_F18
: id
= WXK_F18
; break;
2393 case VK_F19
: id
= WXK_F19
; break;
2394 case VK_F20
: id
= WXK_F20
; break;
2395 case VK_F21
: id
= WXK_F21
; break;
2396 case VK_F22
: id
= WXK_F22
; break;
2397 case VK_F23
: id
= WXK_F23
; break;
2398 case VK_F24
: id
= WXK_F24
; break;
2399 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2400 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2409 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2415 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2416 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2417 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2418 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2419 case WXK_MENU
: keySym
= VK_MENU
; break;
2420 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2421 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2422 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2423 case WXK_END
: keySym
= VK_END
; break;
2424 case WXK_HOME
: keySym
= VK_HOME
; break;
2425 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2426 case WXK_UP
: keySym
= VK_UP
; break;
2427 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2428 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2429 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2430 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2431 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2432 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2433 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2434 case WXK_HELP
: keySym
= VK_HELP
; break;
2435 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2436 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2437 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2438 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2439 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2440 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2441 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2442 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2443 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2444 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2445 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2446 case WXK_ADD
: keySym
= VK_ADD
; break;
2447 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2448 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2449 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2450 case WXK_F1
: keySym
= VK_F1
; break;
2451 case WXK_F2
: keySym
= VK_F2
; break;
2452 case WXK_F3
: keySym
= VK_F3
; break;
2453 case WXK_F4
: keySym
= VK_F4
; break;
2454 case WXK_F5
: keySym
= VK_F5
; break;
2455 case WXK_F6
: keySym
= VK_F6
; break;
2456 case WXK_F7
: keySym
= VK_F7
; break;
2457 case WXK_F8
: keySym
= VK_F8
; break;
2458 case WXK_F9
: keySym
= VK_F9
; break;
2459 case WXK_F10
: keySym
= VK_F10
; break;
2460 case WXK_F11
: keySym
= VK_F11
; break;
2461 case WXK_F12
: keySym
= VK_F12
; break;
2462 case WXK_F13
: keySym
= VK_F13
; break;
2463 case WXK_F14
: keySym
= VK_F14
; break;
2464 case WXK_F15
: keySym
= VK_F15
; break;
2465 case WXK_F16
: keySym
= VK_F16
; break;
2466 case WXK_F17
: keySym
= VK_F17
; break;
2467 case WXK_F18
: keySym
= VK_F18
; break;
2468 case WXK_F19
: keySym
= VK_F19
; break;
2469 case WXK_F20
: keySym
= VK_F20
; break;
2470 case WXK_F21
: keySym
= VK_F21
; break;
2471 case WXK_F22
: keySym
= VK_F22
; break;
2472 case WXK_F23
: keySym
= VK_F23
; break;
2473 case WXK_F24
: keySym
= VK_F24
; break;
2474 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2475 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2486 // Caret manipulation
2487 void wxWindow::CreateCaret(int w
, int h
)
2491 m_caretEnabled
= TRUE
;
2494 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2499 void wxWindow::ShowCaret(bool show
)
2501 if ( m_caretEnabled
)
2504 ::ShowCaret(GetHwnd());
2506 ::HideCaret(GetHwnd());
2507 m_caretShown
= show
;
2511 void wxWindow::DestroyCaret()
2513 m_caretEnabled
= FALSE
;
2516 void wxWindow::SetCaretPos(int x
, int y
)
2518 ::SetCaretPos(x
, y
);
2521 void wxWindow::GetCaretPos(int *x
, int *y
) const
2524 ::GetCaretPos(&point
);
2529 wxWindow
*wxGetActiveWindow()
2531 HWND hWnd
= GetActiveWindow();
2534 return wxFindWinFromHandle((WXHWND
) hWnd
);
2539 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2540 // in active frames and dialogs, regardless of where the focus is.
2541 static HHOOK wxTheKeyboardHook
= 0;
2542 static FARPROC wxTheKeyboardHookProc
= 0;
2543 int APIENTRY _EXPORT
2544 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2546 void wxSetKeyboardHook(bool doIt
)
2550 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
2551 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
2552 #if defined(__WIN32__) && !defined(__TWIN32__)
2553 GetCurrentThreadId());
2554 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2561 UnhookWindowsHookEx(wxTheKeyboardHook
);
2562 FreeProcInstance(wxTheKeyboardHookProc
);
2566 int APIENTRY _EXPORT
2567 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
2569 DWORD hiWord
= HIWORD(lParam
);
2570 if ( nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0) )
2573 if ( (id
= wxCharCodeMSWToWX(wParam
)) != 0 )
2575 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
2576 if ( (HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2577 event
.m_altDown
= TRUE
;
2579 event
.m_eventObject
= NULL
;
2580 event
.m_keyCode
= id
;
2581 /* begin Albert's fix for control and shift key 26.5 */
2582 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2583 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2584 /* end Albert's fix for control and shift key 26.5 */
2585 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2587 wxWindow
*win
= wxGetActiveWindow();
2590 if ( win
->GetEventHandler()->ProcessEvent(event
) )
2595 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
2600 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
2603 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
2605 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
2606 // pixel coordinates, relatives to the canvas -- So, we first need to
2607 // substract origin of the window, then convert to screen position
2609 int x
= x_pos
; int y
= y_pos
;
2611 GetWindowRect (GetHwnd(), &rect
);
2616 SetCursorPos (x
, y
);
2619 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
2623 bool wxWindow::MSWOnQueryDragIcon(WXHICON
* WXUNUSED(hIcon
))
2628 bool wxWindow::MSWOnEraseBkgnd(WXHDC hdc
)
2636 wxEraseEvent
event(m_windowId
, &dc
);
2637 event
.m_eventObject
= this;
2638 bool rc
= GetEventHandler()->ProcessEvent(event
);
2641 dc
.SelectOldObjects(hdc
);
2642 dc
.SetHDC((WXHDC
) NULL
);
2647 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
2653 ::GetClientRect(GetHwnd(), &rect
);
2655 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
2656 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
2657 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
2659 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
2660 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
2661 ::DeleteObject(hBrush
);
2662 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
2664 // Less efficient version (and doesn't account for scrolling)
2666 GetClientSize(& w, & h);
2667 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
2668 event.GetDC()->SetBrush(brush);
2669 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
2671 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
2675 #if WXWIN_COMPATIBILITY
2676 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
2678 #if defined(__WIN95__)
2682 // Try to adjust the range to cope with page size > 1
2683 // - a Windows API quirk
2684 int pageSize
= GetScrollPage(orient
);
2685 if ( pageSize
> 1 && range
> 0)
2687 range1
+= (pageSize
- 1);
2693 if ( orient
== wxHORIZONTAL
) {
2699 info
.cbSize
= sizeof(SCROLLINFO
);
2700 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
2704 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
2706 HWND hWnd
= GetHwnd();
2708 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
2711 if ( orient
== wxHORIZONTAL
)
2716 HWND hWnd
= GetHwnd();
2718 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
2722 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
2724 #if defined(__WIN95__)
2728 if ( orient
== wxHORIZONTAL
) {
2730 m_xThumbSize
= page
;
2733 m_yThumbSize
= page
;
2736 info
.cbSize
= sizeof(SCROLLINFO
);
2739 info
.fMask
= SIF_PAGE
;
2741 HWND hWnd
= GetHwnd();
2743 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
2745 if ( orient
== wxHORIZONTAL
)
2746 m_xThumbSize
= page
;
2748 m_yThumbSize
= page
;
2752 int wxWindow::OldGetScrollRange(int orient
) const
2755 if ( orient
== wxHORIZONTAL
)
2760 #if __WATCOMC__ && defined(__WINDOWS_386__)
2761 short minPos
, maxPos
;
2765 HWND hWnd
= GetHwnd();
2768 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
2769 #if defined(__WIN95__)
2770 // Try to adjust the range to cope with page size > 1
2771 // - a Windows API quirk
2772 int pageSize
= GetScrollPage(orient
);
2775 maxPos
-= (pageSize
- 1);
2784 int wxWindow::GetScrollPage(int orient
) const
2786 if ( orient
== wxHORIZONTAL
)
2787 return m_xThumbSize
;
2789 return m_yThumbSize
;
2793 int wxWindow::GetScrollPos(int orient
) const
2796 if ( orient
== wxHORIZONTAL
)
2800 HWND hWnd
= GetHwnd();
2803 return ::GetScrollPos(hWnd
, wOrient
);
2809 // This now returns the whole range, not just the number
2810 // of positions that we can scroll.
2811 int wxWindow::GetScrollRange(int orient
) const
2814 if ( orient
== wxHORIZONTAL
)
2819 #if __WATCOMC__ && defined(__WINDOWS_386__)
2820 short minPos
, maxPos
;
2824 HWND hWnd
= GetHwnd();
2827 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
2828 #if defined(__WIN95__)
2829 // Try to adjust the range to cope with page size > 1
2830 // - a Windows API quirk
2831 int pageSize
= GetScrollThumb(orient
);
2834 maxPos
-= (pageSize
- 1);
2836 // October 10th: new range concept.
2846 int wxWindow::GetScrollThumb(int orient
) const
2848 if ( orient
== wxHORIZONTAL
)
2849 return m_xThumbSize
;
2851 return m_yThumbSize
;
2854 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
2856 #if defined(__WIN95__)
2860 if ( orient
== wxHORIZONTAL
) {
2866 info
.cbSize
= sizeof(SCROLLINFO
);
2870 info
.fMask
= SIF_POS
;
2872 HWND hWnd
= GetHwnd();
2874 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
2877 if ( orient
== wxHORIZONTAL
)
2882 HWND hWnd
= GetHwnd();
2884 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
2888 // New function that will replace some of the above.
2889 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
2890 int range
, bool refresh
)
2893 SetScrollPage(orient, thumbVisible, FALSE);
2895 int oldRange = range - thumbVisible ;
2896 SetScrollRange(orient, oldRange, FALSE);
2898 SetScrollPos(orient, pos, refresh);
2900 #if defined(__WIN95__)
2901 int oldRange
= range
- thumbVisible
;
2903 int range1
= oldRange
;
2905 // Try to adjust the range to cope with page size > 1
2906 // - a Windows API quirk
2907 int pageSize
= thumbVisible
;
2908 if ( pageSize
> 1 && range
> 0)
2910 range1
+= (pageSize
- 1);
2916 if ( orient
== wxHORIZONTAL
) {
2922 info
.cbSize
= sizeof(SCROLLINFO
);
2923 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
2927 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
2929 HWND hWnd
= GetHwnd();
2931 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
2934 if ( orient
== wxHORIZONTAL
)
2939 HWND hWnd
= GetHwnd();
2942 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
2943 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
2946 if ( orient
== wxHORIZONTAL
) {
2947 m_xThumbSize
= thumbVisible
;
2949 m_yThumbSize
= thumbVisible
;
2953 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
2958 rect2
.left
= rect
->x
;
2959 rect2
.top
= rect
->y
;
2960 rect2
.right
= rect
->x
+ rect
->width
;
2961 rect2
.bottom
= rect
->y
+ rect
->height
;
2965 ::ScrollWindow(GetHwnd(), dx
, dy
, &rect2
, NULL
);
2967 ::ScrollWindow(GetHwnd(), dx
, dy
, NULL
, NULL
);
2970 bool wxWindow::SetFont(const wxFont
& font
)
2972 if ( !wxWindowBase::SetFont(font
) )
2978 HWND hWnd
= GetHwnd();
2981 WXHANDLE hFont
= m_font
.GetResourceHandle();
2983 wxASSERT_MSG( hFont
, _T("should have valid font") );
2985 ::SendMessage(hWnd
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
2991 void wxWindow::SubclassWin(WXHWND hWnd
)
2993 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
2995 wxAssociateWinWithHandle((HWND
)hWnd
, this);
2997 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
2998 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3001 void wxWindow::UnsubclassWin()
3003 wxRemoveHandleAssociation(this);
3005 // Restore old Window proc
3008 FARPROC farProc
= (FARPROC
) GetWindowLong(GetHwnd(), GWL_WNDPROC
);
3009 if ( (m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
) )
3011 SetWindowLong(GetHwnd(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3017 // Make a Windows extended style from the given wxWindows window style
3018 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3020 WXDWORD exStyle
= 0;
3021 if ( style
& wxTRANSPARENT_WINDOW
)
3022 exStyle
|= WS_EX_TRANSPARENT
;
3024 if ( !eliminateBorders
)
3026 if ( style
& wxSUNKEN_BORDER
)
3027 exStyle
|= WS_EX_CLIENTEDGE
;
3028 if ( style
& wxDOUBLE_BORDER
)
3029 exStyle
|= WS_EX_DLGMODALFRAME
;
3030 #if defined(__WIN95__)
3031 if ( style
& wxRAISED_BORDER
)
3032 exStyle
|= WS_EX_WINDOWEDGE
;
3033 if ( style
& wxSTATIC_BORDER
)
3034 exStyle
|= WS_EX_STATICEDGE
;
3040 // Determines whether native 3D effects or CTL3D should be used,
3041 // applying a default border style if required, and returning an extended
3042 // style to pass to CreateWindowEx.
3043 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3045 // If matches certain criteria, then assume no 3D effects
3046 // unless specifically requested (dealt with in MakeExtendedStyle)
3047 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3050 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3053 // Determine whether we should be using 3D effects or not.
3054 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3056 // 1) App can specify global 3D effects
3057 *want3D
= wxTheApp
->GetAuto3D();
3059 // 2) If the parent is being drawn with user colours, or simple border specified,
3060 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3061 if ( GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
) )
3064 // 3) Control can override this global setting by defining
3065 // a border style, e.g. wxSUNKEN_BORDER
3066 if ( m_windowStyle
& wxSUNKEN_BORDER
)
3069 // 4) If it's a special border, CTL3D can't cope so we want a native border
3070 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3071 (m_windowStyle
& wxSTATIC_BORDER
) )
3074 nativeBorder
= TRUE
;
3077 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3078 // effects from extended style
3081 nativeBorder
= FALSE
;
3084 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3086 // If we want 3D, but haven't specified a border here,
3087 // apply the default border style specified.
3088 // TODO what about non-Win95 WIN32? Does it have borders?
3089 #if defined(__WIN95__) && !wxUSE_CTL3D
3090 if ( defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3091 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3092 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3098 // Get the window with the focus
3099 wxWindow
*wxWindowBase::FindFocus()
3101 HWND hWnd
= ::GetFocus();
3104 return wxFindWinFromHandle((WXHWND
) hWnd
);
3109 // If nothing defined for this, try the parent.
3110 // E.g. we may be a button loaded from a resource, with no callback function
3112 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3114 if ( GetEventHandler()->ProcessEvent(event
) )
3117 m_parent
->GetEventHandler()->OnCommand(win
, event
);
3120 wxObject
* wxWindow::GetChild(int number
) const
3122 // Return a pointer to the Nth object in the Panel
3123 // if ( !GetChildren() )
3125 wxNode
*node
= GetChildren().First();
3128 node
= node
->Next() ;
3131 wxObject
*obj
= (wxObject
*)node
->Data();
3138 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
3140 /* This is obsolete now; if we wish to intercept listbox double-clicks,
3141 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
3144 if ( initiatingItem->IsKindOf(CLASSINFO(wxListBox)) )
3146 wxListBox *lbox = (wxListBox *)initiatingItem;
3147 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
3148 event.m_commandInt = -1;
3149 if ( (lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0 )
3151 event.m_commandString = copystring(lbox->GetStringSelection());
3152 event.m_commandInt = lbox->GetSelection();
3153 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
3155 event.m_eventObject = lbox;
3157 lbox->ProcessCommand(event);
3159 if ( event.m_commandString )
3160 delete[] event.m_commandString;
3164 wxButton *but = GetDefaultItem();
3167 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
3168 event.SetEventObject(but);
3169 but->Command(event);
3174 void wxWindow::Clear()
3176 wxClientDC
dc(this);
3177 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
3178 dc
.SetBackground(brush
);
3183 // Default input behaviour for a scrolling canvas should be to scroll
3184 // according to the cursor keys pressed
3185 void wxWindow::OnChar(wxKeyEvent& event)
3197 GetScrollUnitsPerPage(&x_page, &y_page);
3199 GetVirtualSize(&v_width,&v_height);
3201 ViewStart(&start_x, &start_y);
3204 y_pages = (int)(v_height/vert_units) - y_page;
3212 switch (event.keyCode)
3219 if ( start_y - y_page > 0 )
3220 Scroll(start_x, start_y - y_page);
3230 if ( (y_page > 0) && (start_y <= y_pages-y-1) )
3232 if ( y_pages + y < start_y + y_page )
3233 Scroll(start_x, y_pages + y);
3235 Scroll(start_x, start_y + y_page);
3242 if ( (y_page > 0) && (start_y >= 1) )
3243 Scroll(start_x, start_y - 1);
3249 if ( (y_page > 0) && (start_y <= y_pages-y-1) )
3252 Scroll(start_x, start_y + 1);
3258 if ( (x_page > 0) && (start_x >= 1) )
3259 Scroll(start_x - 1, start_y);
3265 Scroll(start_x + 1, start_y);
3276 Scroll(start_x, y_pages+y);
3284 // Setup background and foreground colours correctly
3285 void wxWindow::SetupColours()
3288 SetBackgroundColour(GetParent()->GetBackgroundColour());
3291 void wxWindow::OnIdle(wxIdleEvent
& event
)
3293 // Check if we need to send a LEAVE event
3294 if ( m_mouseInWindow
)
3297 ::GetCursorPos(&pt
);
3298 if ( ::WindowFromPoint(pt
) != GetHwnd() )
3300 // Generate a LEAVE event
3301 m_mouseInWindow
= FALSE
;
3303 // Unfortunately the mouse button and keyboard state may have changed
3304 // by the time the OnIdle function is called, so 'state' may be
3307 if ( ::GetKeyState(VK_SHIFT
) != 0 )
3309 if ( ::GetKeyState(VK_CONTROL
) != 0 )
3310 state
|= MK_CONTROL
;
3312 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
3313 InitMouseEvent(event
, pt
.x
, pt
.y
, state
);
3315 (void)GetEventHandler()->ProcessEvent(event
);
3322 // Raise the window to the top of the Z order
3323 void wxWindow::Raise()
3325 ::BringWindowToTop(GetHwnd());
3328 // Lower the window to the bottom of the Z order
3329 void wxWindow::Lower()
3331 ::SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
3334 // Set this window to be the child of 'parent'.
3335 bool wxWindow::Reparent(wxWindow
*parent
)
3337 if ( !wxWindowBase::Reparent(parent
) )
3340 HWND hWndChild
= GetHwnd();
3341 HWND hWndParent
= GetParent() ? GetWinHwnd(GetParent()) : (HWND
)0;
3343 ::SetParent(hWndChild
, hWndParent
);
3349 const char *wxGetMessageName(int message
)
3351 switch ( message
) {
3352 case 0x0000: return "WM_NULL";
3353 case 0x0001: return "WM_CREATE";
3354 case 0x0002: return "WM_DESTROY";
3355 case 0x0003: return "WM_MOVE";
3356 case 0x0005: return "WM_SIZE";
3357 case 0x0006: return "WM_ACTIVATE";
3358 case 0x0007: return "WM_SETFOCUS";
3359 case 0x0008: return "WM_KILLFOCUS";
3360 case 0x000A: return "WM_ENABLE";
3361 case 0x000B: return "WM_SETREDRAW";
3362 case 0x000C: return "WM_SETTEXT";
3363 case 0x000D: return "WM_GETTEXT";
3364 case 0x000E: return "WM_GETTEXTLENGTH";
3365 case 0x000F: return "WM_PAINT";
3366 case 0x0010: return "WM_CLOSE";
3367 case 0x0011: return "WM_QUERYENDSESSION";
3368 case 0x0012: return "WM_QUIT";
3369 case 0x0013: return "WM_QUERYOPEN";
3370 case 0x0014: return "WM_ERASEBKGND";
3371 case 0x0015: return "WM_SYSCOLORCHANGE";
3372 case 0x0016: return "WM_ENDSESSION";
3373 case 0x0017: return "WM_SYSTEMERROR";
3374 case 0x0018: return "WM_SHOWWINDOW";
3375 case 0x0019: return "WM_CTLCOLOR";
3376 case 0x001A: return "WM_WININICHANGE";
3377 case 0x001B: return "WM_DEVMODECHANGE";
3378 case 0x001C: return "WM_ACTIVATEAPP";
3379 case 0x001D: return "WM_FONTCHANGE";
3380 case 0x001E: return "WM_TIMECHANGE";
3381 case 0x001F: return "WM_CANCELMODE";
3382 case 0x0020: return "WM_SETCURSOR";
3383 case 0x0021: return "WM_MOUSEACTIVATE";
3384 case 0x0022: return "WM_CHILDACTIVATE";
3385 case 0x0023: return "WM_QUEUESYNC";
3386 case 0x0024: return "WM_GETMINMAXINFO";
3387 case 0x0026: return "WM_PAINTICON";
3388 case 0x0027: return "WM_ICONERASEBKGND";
3389 case 0x0028: return "WM_NEXTDLGCTL";
3390 case 0x002A: return "WM_SPOOLERSTATUS";
3391 case 0x002B: return "WM_DRAWITEM";
3392 case 0x002C: return "WM_MEASUREITEM";
3393 case 0x002D: return "WM_DELETEITEM";
3394 case 0x002E: return "WM_VKEYTOITEM";
3395 case 0x002F: return "WM_CHARTOITEM";
3396 case 0x0030: return "WM_SETFONT";
3397 case 0x0031: return "WM_GETFONT";
3398 case 0x0037: return "WM_QUERYDRAGICON";
3399 case 0x0039: return "WM_COMPAREITEM";
3400 case 0x0041: return "WM_COMPACTING";
3401 case 0x0044: return "WM_COMMNOTIFY";
3402 case 0x0046: return "WM_WINDOWPOSCHANGING";
3403 case 0x0047: return "WM_WINDOWPOSCHANGED";
3404 case 0x0048: return "WM_POWER";
3407 case 0x004A: return "WM_COPYDATA";
3408 case 0x004B: return "WM_CANCELJOURNAL";
3409 case 0x004E: return "WM_NOTIFY";
3410 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
3411 case 0x0051: return "WM_INPUTLANGCHANGE";
3412 case 0x0052: return "WM_TCARD";
3413 case 0x0053: return "WM_HELP";
3414 case 0x0054: return "WM_USERCHANGED";
3415 case 0x0055: return "WM_NOTIFYFORMAT";
3416 case 0x007B: return "WM_CONTEXTMENU";
3417 case 0x007C: return "WM_STYLECHANGING";
3418 case 0x007D: return "WM_STYLECHANGED";
3419 case 0x007E: return "WM_DISPLAYCHANGE";
3420 case 0x007F: return "WM_GETICON";
3421 case 0x0080: return "WM_SETICON";
3424 case 0x0081: return "WM_NCCREATE";
3425 case 0x0082: return "WM_NCDESTROY";
3426 case 0x0083: return "WM_NCCALCSIZE";
3427 case 0x0084: return "WM_NCHITTEST";
3428 case 0x0085: return "WM_NCPAINT";
3429 case 0x0086: return "WM_NCACTIVATE";
3430 case 0x0087: return "WM_GETDLGCODE";
3431 case 0x00A0: return "WM_NCMOUSEMOVE";
3432 case 0x00A1: return "WM_NCLBUTTONDOWN";
3433 case 0x00A2: return "WM_NCLBUTTONUP";
3434 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
3435 case 0x00A4: return "WM_NCRBUTTONDOWN";
3436 case 0x00A5: return "WM_NCRBUTTONUP";
3437 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
3438 case 0x00A7: return "WM_NCMBUTTONDOWN";
3439 case 0x00A8: return "WM_NCMBUTTONUP";
3440 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
3441 case 0x0100: return "WM_KEYDOWN";
3442 case 0x0101: return "WM_KEYUP";
3443 case 0x0102: return "WM_CHAR";
3444 case 0x0103: return "WM_DEADCHAR";
3445 case 0x0104: return "WM_SYSKEYDOWN";
3446 case 0x0105: return "WM_SYSKEYUP";
3447 case 0x0106: return "WM_SYSCHAR";
3448 case 0x0107: return "WM_SYSDEADCHAR";
3449 case 0x0108: return "WM_KEYLAST";
3452 case 0x010D: return "WM_IME_STARTCOMPOSITION";
3453 case 0x010E: return "WM_IME_ENDCOMPOSITION";
3454 case 0x010F: return "WM_IME_COMPOSITION";
3457 case 0x0110: return "WM_INITDIALOG";
3458 case 0x0111: return "WM_COMMAND";
3459 case 0x0112: return "WM_SYSCOMMAND";
3460 case 0x0113: return "WM_TIMER";
3461 case 0x0114: return "WM_HSCROLL";
3462 case 0x0115: return "WM_VSCROLL";
3463 case 0x0116: return "WM_INITMENU";
3464 case 0x0117: return "WM_INITMENUPOPUP";
3465 case 0x011F: return "WM_MENUSELECT";
3466 case 0x0120: return "WM_MENUCHAR";
3467 case 0x0121: return "WM_ENTERIDLE";
3468 case 0x0200: return "WM_MOUSEMOVE";
3469 case 0x0201: return "WM_LBUTTONDOWN";
3470 case 0x0202: return "WM_LBUTTONUP";
3471 case 0x0203: return "WM_LBUTTONDBLCLK";
3472 case 0x0204: return "WM_RBUTTONDOWN";
3473 case 0x0205: return "WM_RBUTTONUP";
3474 case 0x0206: return "WM_RBUTTONDBLCLK";
3475 case 0x0207: return "WM_MBUTTONDOWN";
3476 case 0x0208: return "WM_MBUTTONUP";
3477 case 0x0209: return "WM_MBUTTONDBLCLK";
3478 case 0x0210: return "WM_PARENTNOTIFY";
3479 case 0x0211: return "WM_ENTERMENULOOP";
3480 case 0x0212: return "WM_EXITMENULOOP";
3483 case 0x0213: return "WM_NEXTMENU";
3484 case 0x0214: return "WM_SIZING";
3485 case 0x0215: return "WM_CAPTURECHANGED";
3486 case 0x0216: return "WM_MOVING";
3487 case 0x0218: return "WM_POWERBROADCAST";
3488 case 0x0219: return "WM_DEVICECHANGE";
3491 case 0x0220: return "WM_MDICREATE";
3492 case 0x0221: return "WM_MDIDESTROY";
3493 case 0x0222: return "WM_MDIACTIVATE";
3494 case 0x0223: return "WM_MDIRESTORE";
3495 case 0x0224: return "WM_MDINEXT";
3496 case 0x0225: return "WM_MDIMAXIMIZE";
3497 case 0x0226: return "WM_MDITILE";
3498 case 0x0227: return "WM_MDICASCADE";
3499 case 0x0228: return "WM_MDIICONARRANGE";
3500 case 0x0229: return "WM_MDIGETACTIVE";
3501 case 0x0230: return "WM_MDISETMENU";
3502 case 0x0233: return "WM_DROPFILES";
3505 case 0x0281: return "WM_IME_SETCONTEXT";
3506 case 0x0282: return "WM_IME_NOTIFY";
3507 case 0x0283: return "WM_IME_CONTROL";
3508 case 0x0284: return "WM_IME_COMPOSITIONFULL";
3509 case 0x0285: return "WM_IME_SELECT";
3510 case 0x0286: return "WM_IME_CHAR";
3511 case 0x0290: return "WM_IME_KEYDOWN";
3512 case 0x0291: return "WM_IME_KEYUP";
3515 case 0x0300: return "WM_CUT";
3516 case 0x0301: return "WM_COPY";
3517 case 0x0302: return "WM_PASTE";
3518 case 0x0303: return "WM_CLEAR";
3519 case 0x0304: return "WM_UNDO";
3520 case 0x0305: return "WM_RENDERFORMAT";
3521 case 0x0306: return "WM_RENDERALLFORMATS";
3522 case 0x0307: return "WM_DESTROYCLIPBOARD";
3523 case 0x0308: return "WM_DRAWCLIPBOARD";
3524 case 0x0309: return "WM_PAINTCLIPBOARD";
3525 case 0x030A: return "WM_VSCROLLCLIPBOARD";
3526 case 0x030B: return "WM_SIZECLIPBOARD";
3527 case 0x030C: return "WM_ASKCBFORMATNAME";
3528 case 0x030D: return "WM_CHANGECBCHAIN";
3529 case 0x030E: return "WM_HSCROLLCLIPBOARD";
3530 case 0x030F: return "WM_QUERYNEWPALETTE";
3531 case 0x0310: return "WM_PALETTEISCHANGING";
3532 case 0x0311: return "WM_PALETTECHANGED";
3535 // common controls messages - although they're not strictly speaking
3536 // standard, it's nice to decode them nevertheless
3539 case 0x1000 + 0: return "LVM_GETBKCOLOR";
3540 case 0x1000 + 1: return "LVM_SETBKCOLOR";
3541 case 0x1000 + 2: return "LVM_GETIMAGELIST";
3542 case 0x1000 + 3: return "LVM_SETIMAGELIST";
3543 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
3544 case 0x1000 + 5: return "LVM_GETITEMA";
3545 case 0x1000 + 75: return "LVM_GETITEMW";
3546 case 0x1000 + 6: return "LVM_SETITEMA";
3547 case 0x1000 + 76: return "LVM_SETITEMW";
3548 case 0x1000 + 7: return "LVM_INSERTITEMA";
3549 case 0x1000 + 77: return "LVM_INSERTITEMW";
3550 case 0x1000 + 8: return "LVM_DELETEITEM";
3551 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
3552 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
3553 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
3554 case 0x1000 + 12: return "LVM_GETNEXTITEM";
3555 case 0x1000 + 13: return "LVM_FINDITEMA";
3556 case 0x1000 + 83: return "LVM_FINDITEMW";
3557 case 0x1000 + 14: return "LVM_GETITEMRECT";
3558 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
3559 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
3560 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
3561 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
3562 case 0x1000 + 18: return "LVM_HITTEST";
3563 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
3564 case 0x1000 + 20: return "LVM_SCROLL";
3565 case 0x1000 + 21: return "LVM_REDRAWITEMS";
3566 case 0x1000 + 22: return "LVM_ARRANGE";
3567 case 0x1000 + 23: return "LVM_EDITLABELA";
3568 case 0x1000 + 118: return "LVM_EDITLABELW";
3569 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
3570 case 0x1000 + 25: return "LVM_GETCOLUMNA";
3571 case 0x1000 + 95: return "LVM_GETCOLUMNW";
3572 case 0x1000 + 26: return "LVM_SETCOLUMNA";
3573 case 0x1000 + 96: return "LVM_SETCOLUMNW";
3574 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
3575 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
3576 case 0x1000 + 28: return "LVM_DELETECOLUMN";
3577 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
3578 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
3579 case 0x1000 + 31: return "LVM_GETHEADER";
3580 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
3581 case 0x1000 + 34: return "LVM_GETVIEWRECT";
3582 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
3583 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
3584 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
3585 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
3586 case 0x1000 + 39: return "LVM_GETTOPINDEX";
3587 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
3588 case 0x1000 + 41: return "LVM_GETORIGIN";
3589 case 0x1000 + 42: return "LVM_UPDATE";
3590 case 0x1000 + 43: return "LVM_SETITEMSTATE";
3591 case 0x1000 + 44: return "LVM_GETITEMSTATE";
3592 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
3593 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
3594 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
3595 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
3596 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
3597 case 0x1000 + 48: return "LVM_SORTITEMS";
3598 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
3599 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
3600 case 0x1000 + 51: return "LVM_GETITEMSPACING";
3601 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
3602 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
3603 case 0x1000 + 53: return "LVM_SETICONSPACING";
3604 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
3605 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
3606 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
3607 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
3608 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
3609 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
3610 case 0x1000 + 60: return "LVM_SETHOTITEM";
3611 case 0x1000 + 61: return "LVM_GETHOTITEM";
3612 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
3613 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
3614 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
3615 case 0x1000 + 65: return "LVM_SETWORKAREA";
3618 case 0x1100 + 0: return "TVM_INSERTITEMA";
3619 case 0x1100 + 50: return "TVM_INSERTITEMW";
3620 case 0x1100 + 1: return "TVM_DELETEITEM";
3621 case 0x1100 + 2: return "TVM_EXPAND";
3622 case 0x1100 + 4: return "TVM_GETITEMRECT";
3623 case 0x1100 + 5: return "TVM_GETCOUNT";
3624 case 0x1100 + 6: return "TVM_GETINDENT";
3625 case 0x1100 + 7: return "TVM_SETINDENT";
3626 case 0x1100 + 8: return "TVM_GETIMAGELIST";
3627 case 0x1100 + 9: return "TVM_SETIMAGELIST";
3628 case 0x1100 + 10: return "TVM_GETNEXTITEM";
3629 case 0x1100 + 11: return "TVM_SELECTITEM";
3630 case 0x1100 + 12: return "TVM_GETITEMA";
3631 case 0x1100 + 62: return "TVM_GETITEMW";
3632 case 0x1100 + 13: return "TVM_SETITEMA";
3633 case 0x1100 + 63: return "TVM_SETITEMW";
3634 case 0x1100 + 14: return "TVM_EDITLABELA";
3635 case 0x1100 + 65: return "TVM_EDITLABELW";
3636 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
3637 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
3638 case 0x1100 + 17: return "TVM_HITTEST";
3639 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
3640 case 0x1100 + 19: return "TVM_SORTCHILDREN";
3641 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
3642 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
3643 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
3644 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
3645 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
3646 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
3647 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
3650 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
3651 case 0x1200 + 1: return "HDM_INSERTITEMA";
3652 case 0x1200 + 10: return "HDM_INSERTITEMW";
3653 case 0x1200 + 2: return "HDM_DELETEITEM";
3654 case 0x1200 + 3: return "HDM_GETITEMA";
3655 case 0x1200 + 11: return "HDM_GETITEMW";
3656 case 0x1200 + 4: return "HDM_SETITEMA";
3657 case 0x1200 + 12: return "HDM_SETITEMW";
3658 case 0x1200 + 5: return "HDM_LAYOUT";
3659 case 0x1200 + 6: return "HDM_HITTEST";
3660 case 0x1200 + 7: return "HDM_GETITEMRECT";
3661 case 0x1200 + 8: return "HDM_SETIMAGELIST";
3662 case 0x1200 + 9: return "HDM_GETIMAGELIST";
3663 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
3664 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
3665 case 0x1200 + 17: return "HDM_GETORDERARRAY";
3666 case 0x1200 + 18: return "HDM_SETORDERARRAY";
3667 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
3670 case 0x1300 + 2: return "TCM_GETIMAGELIST";
3671 case 0x1300 + 3: return "TCM_SETIMAGELIST";
3672 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
3673 case 0x1300 + 5: return "TCM_GETITEMA";
3674 case 0x1300 + 60: return "TCM_GETITEMW";
3675 case 0x1300 + 6: return "TCM_SETITEMA";
3676 case 0x1300 + 61: return "TCM_SETITEMW";
3677 case 0x1300 + 7: return "TCM_INSERTITEMA";
3678 case 0x1300 + 62: return "TCM_INSERTITEMW";
3679 case 0x1300 + 8: return "TCM_DELETEITEM";
3680 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
3681 case 0x1300 + 10: return "TCM_GETITEMRECT";
3682 case 0x1300 + 11: return "TCM_GETCURSEL";
3683 case 0x1300 + 12: return "TCM_SETCURSEL";
3684 case 0x1300 + 13: return "TCM_HITTEST";
3685 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
3686 case 0x1300 + 40: return "TCM_ADJUSTRECT";
3687 case 0x1300 + 41: return "TCM_SETITEMSIZE";
3688 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
3689 case 0x1300 + 43: return "TCM_SETPADDING";
3690 case 0x1300 + 44: return "TCM_GETROWCOUNT";
3691 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
3692 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
3693 case 0x1300 + 47: return "TCM_GETCURFOCUS";
3694 case 0x1300 + 48: return "TCM_SETCURFOCUS";
3695 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
3696 case 0x1300 + 50: return "TCM_DESELECTALL";
3699 case WM_USER
+1: return "TB_ENABLEBUTTON";
3700 case WM_USER
+2: return "TB_CHECKBUTTON";
3701 case WM_USER
+3: return "TB_PRESSBUTTON";
3702 case WM_USER
+4: return "TB_HIDEBUTTON";
3703 case WM_USER
+5: return "TB_INDETERMINATE";
3704 case WM_USER
+9: return "TB_ISBUTTONENABLED";
3705 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
3706 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
3707 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
3708 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
3709 case WM_USER
+17: return "TB_SETSTATE";
3710 case WM_USER
+18: return "TB_GETSTATE";
3711 case WM_USER
+19: return "TB_ADDBITMAP";
3712 case WM_USER
+20: return "TB_ADDBUTTONS";
3713 case WM_USER
+21: return "TB_INSERTBUTTON";
3714 case WM_USER
+22: return "TB_DELETEBUTTON";
3715 case WM_USER
+23: return "TB_GETBUTTON";
3716 case WM_USER
+24: return "TB_BUTTONCOUNT";
3717 case WM_USER
+25: return "TB_COMMANDTOINDEX";
3718 case WM_USER
+26: return "TB_SAVERESTOREA";
3719 case WM_USER
+76: return "TB_SAVERESTOREW";
3720 case WM_USER
+27: return "TB_CUSTOMIZE";
3721 case WM_USER
+28: return "TB_ADDSTRINGA";
3722 case WM_USER
+77: return "TB_ADDSTRINGW";
3723 case WM_USER
+29: return "TB_GETITEMRECT";
3724 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
3725 case WM_USER
+31: return "TB_SETBUTTONSIZE";
3726 case WM_USER
+32: return "TB_SETBITMAPSIZE";
3727 case WM_USER
+33: return "TB_AUTOSIZE";
3728 case WM_USER
+35: return "TB_GETTOOLTIPS";
3729 case WM_USER
+36: return "TB_SETTOOLTIPS";
3730 case WM_USER
+37: return "TB_SETPARENT";
3731 case WM_USER
+39: return "TB_SETROWS";
3732 case WM_USER
+40: return "TB_GETROWS";
3733 case WM_USER
+42: return "TB_SETCMDID";
3734 case WM_USER
+43: return "TB_CHANGEBITMAP";
3735 case WM_USER
+44: return "TB_GETBITMAP";
3736 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
3737 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
3738 case WM_USER
+46: return "TB_REPLACEBITMAP";
3739 case WM_USER
+47: return "TB_SETINDENT";
3740 case WM_USER
+48: return "TB_SETIMAGELIST";
3741 case WM_USER
+49: return "TB_GETIMAGELIST";
3742 case WM_USER
+50: return "TB_LOADIMAGES";
3743 case WM_USER
+51: return "TB_GETRECT";
3744 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
3745 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
3746 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
3747 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
3748 case WM_USER
+56: return "TB_SETSTYLE";
3749 case WM_USER
+57: return "TB_GETSTYLE";
3750 case WM_USER
+58: return "TB_GETBUTTONSIZE";
3751 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
3752 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
3753 case WM_USER
+61: return "TB_GETTEXTROWS";
3754 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
3759 static char s_szBuf
[128];
3760 sprintf(s_szBuf
, "<unknown message = %d>", message
);
3764 #endif //__WXDEBUG__