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/settings.h"
37 #include "wx/msgdlg.h"
43 #include "wx/ownerdrw.h"
46 #if wxUSE_DRAG_AND_DROP
47 #include "wx/msw/ole/droptgt.h"
50 #include "wx/menuitem.h"
54 #include "wx/tooltip.h"
60 #include "wx/msw/private.h"
73 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
79 #include <wx/msw/gnuwin32/extra.h>
83 // all these are defined in <windows.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
, wxEvtHandler
)
117 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
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 WXHWND
wxWindow::GetHWND(void) const
220 return (WXHWND
) m_hWnd
;
223 void wxWindow::SetHWND(WXHWND hWnd
)
228 // ----------------------------------------------------------------------------
229 // constructors and such
230 // ----------------------------------------------------------------------------
232 void wxWindow::Init()
240 m_windowParent
= NULL
;
241 m_windowEventHandler
= this;
242 m_children
= new wxList
;
243 m_doubleClickAllowed
= 0 ;
244 m_winCaptured
= FALSE
;
245 m_constraints
= NULL
;
246 m_constraintsInvolvedIn
= NULL
;
247 m_windowSizer
= NULL
;
248 m_sizerParent
= NULL
;
249 m_autoLayout
= FALSE
;
250 m_windowValidator
= NULL
;
255 m_caretWidth
= m_caretHeight
= 0;
257 m_caretShown
= FALSE
;
264 m_isBeingDeleted
= FALSE
;
270 m_mouseInWindow
= FALSE
;
272 m_windowParent
= NULL
;
273 m_defaultItem
= NULL
;
275 wxSystemSettings settings
;
277 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
278 m_foregroundColour
= *wxBLACK
;
288 m_backgroundTransparent
= FALSE
;
290 m_lastXPos
= (float)-1.0;
291 m_lastYPos
= (float)-1.0;
295 #if wxUSE_DRAG_AND_DROP
296 m_pDropTarget
= NULL
;
310 wxWindow::~wxWindow()
312 m_isBeingDeleted
= TRUE
;
314 // first of all, delete the things on which nothing else depends
320 // JACS - if behaviour is odd, restore this
321 // to the start of ~wxWindow. Vadim has changed
322 // it to nearer the end. Unsure of side-effects
323 // e.g. when deleting associated global data.
324 // Restore old Window proc, if required
327 // Have to delete constraints/sizer FIRST otherwise
328 // sizers may try to look at deleted windows as they
329 // delete themselves.
330 #if wxUSE_CONSTRAINTS
331 DeleteRelatedConstraints();
335 // This removes any dangling pointers to this window
336 // in other windows' constraintsInvolvedIn lists.
337 UnsetConstraints(m_constraints
);
338 delete m_constraints
;
339 m_constraints
= NULL
;
342 wxDELETE(m_windowSizer
);
344 // If this is a child of a sizer, remove self from parent
346 m_sizerParent
->RemoveChild((wxWindow
*)this);
350 MSWDetachWindowMenu();
353 m_windowParent
->RemoveChild(this);
358 ::DestroyWindow((HWND
)m_hWnd
);
360 wxRemoveHandleAssociation(this);
365 GlobalFree((HGLOBAL
) m_globalHandle
);
373 // Just in case the window has been Closed, but
374 // we're then deleting immediately: don't leave
375 // dangling pointers.
376 wxPendingDelete
.DeleteObject(this);
378 // Just in case we've loaded a top-level window via
379 // wxWindow::LoadNativeDialog but we weren't a dialog
381 wxTopLevelWindows
.DeleteObject(this);
383 if ( m_windowValidator
)
384 delete m_windowValidator
;
386 // Restore old Window proc, if required
387 // and remove hWnd <-> wxWindow association
391 // Destroy the window (delayed, if a managed window)
392 bool wxWindow::Destroy()
398 extern char wxCanvasClassName
[];
400 // real construction (Init() must have been called before!)
401 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
405 const wxString
& name
)
407 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
409 parent
->AddChild(this);
414 m_windowId
= (int)NewControlId();
423 // To be consistent with wxGTK
429 wxSystemSettings settings
;
431 m_windowStyle
= style
;
434 if (style
& wxBORDER
)
435 msflags
|= WS_BORDER
;
436 if (style
& wxTHICK_FRAME
)
437 msflags
|= WS_THICKFRAME
;
439 msflags
|= WS_CHILD
| WS_VISIBLE
;
440 if (style
& wxCLIP_CHILDREN
)
441 msflags
|= WS_CLIPCHILDREN
;
444 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
446 // Even with extended styles, need to combine with WS_BORDER
447 // for them to look right.
448 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
449 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
450 msflags
|= WS_BORDER
;
452 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
453 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
458 void wxWindow::SetFocus()
460 HWND hWnd
= (HWND
) GetHWND();
465 void wxWindow::Enable(bool enable
)
467 m_winEnabled
= enable
;
468 HWND hWnd
= (HWND
) GetHWND();
470 ::EnableWindow(hWnd
, (BOOL
)enable
);
473 void wxWindow::CaptureMouse()
475 HWND hWnd
= (HWND
) GetHWND();
476 if (hWnd
&& !m_winCaptured
)
479 m_winCaptured
= TRUE
;
483 void wxWindow::ReleaseMouse()
488 m_winCaptured
= FALSE
;
492 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
494 m_acceleratorTable
= accel
;
498 // Push/pop event handler (i.e. allow a chain of event handlers
500 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
502 handler
->SetNextHandler(GetEventHandler());
503 SetEventHandler(handler
);
506 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
508 if ( GetEventHandler() )
510 wxEvtHandler
*handlerA
= GetEventHandler();
511 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
512 handlerA
->SetNextHandler(NULL
);
513 SetEventHandler(handlerB
);
526 #if wxUSE_DRAG_AND_DROP
528 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
530 if ( m_pDropTarget
!= 0 ) {
531 m_pDropTarget
->Revoke(m_hWnd
);
532 delete m_pDropTarget
;
535 m_pDropTarget
= pDropTarget
;
536 if ( m_pDropTarget
!= 0 )
537 m_pDropTarget
->Register(m_hWnd
);
540 #endif // wxUSE_DRAG_AND_DROP
543 //old style file-manager drag&drop support
544 // I think we should retain the old-style
545 // DragAcceptFiles in parallel with SetDropTarget.
547 void wxWindow::DragAcceptFiles(bool accept
)
549 HWND hWnd
= (HWND
) GetHWND();
551 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
554 // ----------------------------------------------------------------------------
556 // ----------------------------------------------------------------------------
560 void wxWindow::SetToolTip(const wxString
&tip
)
562 SetToolTip(new wxToolTip(tip
));
565 void wxWindow::SetToolTip(wxToolTip
*tooltip
)
571 m_tooltip
->SetWindow(this);
574 #endif // wxUSE_TOOLTIPS
577 void wxWindow::GetSize(int *x
, int *y
) const
579 HWND hWnd
= (HWND
) GetHWND();
581 GetWindowRect(hWnd
, &rect
);
582 *x
= rect
.right
- rect
.left
;
583 *y
= rect
.bottom
- rect
.top
;
586 void wxWindow::GetPosition(int *x
, int *y
) const
588 HWND hWnd
= (HWND
) GetHWND();
591 hParentWnd
= (HWND
) GetParent()->GetHWND();
594 GetWindowRect(hWnd
, &rect
);
596 // Since we now have the absolute screen coords,
597 // if there's a parent we must subtract its top left corner
603 ::ScreenToClient(hParentWnd
, &point
);
606 // We may be faking the client origin.
607 // So a window that's really at (0, 30) may appear
608 // (to wxWin apps) to be at (0, 0).
611 wxPoint
pt(GetParent()->GetClientAreaOrigin());
619 void wxWindow::ScreenToClient(int *x
, int *y
) const
621 HWND hWnd
= (HWND
) GetHWND();
626 ::ScreenToClient(hWnd
, &pt
);
632 void wxWindow::ClientToScreen(int *x
, int *y
) const
634 HWND hWnd
= (HWND
) GetHWND();
639 ::ClientToScreen(hWnd
, &pt
);
645 void wxWindow::SetCursor(const wxCursor
& cursor
)
647 m_windowCursor
= cursor
;
648 if (m_windowCursor
.Ok())
650 HWND hWnd
= (HWND
) GetHWND();
652 // Change the cursor NOW if we're within the correct window
654 ::GetCursorPos(&point
);
657 ::GetWindowRect(hWnd
, &rect
);
659 if (::PtInRect(&rect
, point
) && !wxIsBusy())
660 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
663 // This will cause big reentrancy problems if wxFlushEvents is implemented.
665 // return old_cursor;
669 // Get size *available for subwindows* i.e. excluding menu bar etc.
670 void wxWindow::GetClientSize(int *x
, int *y
) const
672 HWND hWnd
= (HWND
) GetHWND();
674 ::GetClientRect(hWnd
, &rect
);
679 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
681 int currentX
, currentY
;
682 GetPosition(¤tX
, ¤tY
);
683 int currentW
,currentH
;
684 GetSize(¤tW
, ¤tH
);
686 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
689 int actualWidth
= width
;
690 int actualHeight
= height
;
693 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
695 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
698 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
701 actualWidth
= currentW
;
703 actualHeight
= currentH
;
705 HWND hWnd
= (HWND
) GetHWND();
707 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
710 void wxWindow::DoSetClientSize(int width
, int height
)
712 wxWindow
*parent
= GetParent();
713 HWND hWnd
= (HWND
) GetHWND();
714 HWND hParentWnd
= (HWND
) 0;
716 hParentWnd
= (HWND
) parent
->GetHWND();
719 ::GetClientRect(hWnd
, &rect
);
722 GetWindowRect(hWnd
, &rect2
);
724 // Find the difference between the entire window (title bar and all)
725 // and the client area; add this to the new client size to move the
727 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
728 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
730 // If there's a parent, must subtract the parent's top left corner
731 // since MoveWindow moves relative to the parent
734 point
.x
= rect2
.left
;
738 ::ScreenToClient(hParentWnd
, &point
);
741 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
743 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
744 event
.SetEventObject(this);
745 GetEventHandler()->ProcessEvent(event
);
748 // For implementation purposes - sometimes decorations make the client area
750 wxPoint
wxWindow::GetClientAreaOrigin() const
752 return wxPoint(0, 0);
755 // Makes an adjustment to the window position (for example, a frame that has
756 // a toolbar that it manages itself).
757 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
759 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
761 wxPoint
pt(GetParent()->GetClientAreaOrigin());
762 x
+= pt
.x
; y
+= pt
.y
;
766 bool wxWindow::Show(bool show
)
769 HWND hWnd
= (HWND
) GetHWND();
775 ShowWindow(hWnd
, cshow
);
778 BringWindowToTop(hWnd
);
779 // Next line causes a crash on NT, apparently.
780 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
785 bool wxWindow::IsShown(void) const
787 // Can't rely on IsWindowVisible, since it will return FALSE
788 // if the parent is not visible.
790 // int ret = ::IsWindowVisible((HWND) GetHWND()) ;
791 // return (ret != 0);
794 int wxWindow::GetCharHeight(void) const
796 TEXTMETRIC lpTextMetric
;
797 HWND hWnd
= (HWND
) GetHWND();
798 HDC dc
= ::GetDC(hWnd
);
800 GetTextMetrics(dc
, &lpTextMetric
);
801 ::ReleaseDC(hWnd
, dc
);
803 return lpTextMetric
.tmHeight
;
806 int wxWindow::GetCharWidth(void) const
808 TEXTMETRIC lpTextMetric
;
809 HWND hWnd
= (HWND
) GetHWND();
810 HDC dc
= ::GetDC(hWnd
);
812 GetTextMetrics(dc
, &lpTextMetric
);
813 ::ReleaseDC(hWnd
, dc
);
815 return lpTextMetric
.tmAveCharWidth
;
818 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
819 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
821 wxFont
*fontToUse
= (wxFont
*)theFont
;
823 fontToUse
= (wxFont
*) & m_windowFont
;
825 HWND hWnd
= (HWND
) GetHWND();
826 HDC dc
= ::GetDC(hWnd
);
830 if (fontToUse
&& fontToUse
->Ok())
832 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
834 was
= (HFONT
) SelectObject(dc
,fnt
) ;
839 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
840 GetTextMetrics(dc
, &tm
);
842 if (fontToUse
&& fnt
&& was
)
843 SelectObject(dc
,was
) ;
849 if (descent
) *descent
= tm
.tmDescent
;
850 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
853 // fontToUse->ReleaseResource();
856 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
858 HWND hWnd
= (HWND
) GetHWND();
864 mswRect
.left
= rect
->x
;
865 mswRect
.top
= rect
->y
;
866 mswRect
.right
= rect
->x
+ rect
->width
;
867 mswRect
.bottom
= rect
->y
+ rect
->height
;
869 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
872 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
876 bool wxWindow::ProcessEvent(wxEvent
& event
)
878 // we save here the information about the last message because it might be
879 // overwritten if the event handler sends any messages to our window (case
880 // in point: wxNotebook::OnSize) - and then if we call Default() later
881 // (which is done quite often if the message is not processed) it will use
882 // incorrect values for m_lastXXX variables
883 WXUINT lastMsg
= m_lastMsg
;
884 WXWPARAM lastWParam
= m_lastWParam
;
885 WXLPARAM lastLParam
= m_lastLParam
;
887 // call the base version
888 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
892 m_lastWParam
= lastWParam
;
893 m_lastLParam
= lastLParam
;
898 // Hook for new window just as it's being created,
899 // when the window isn't yet associated with the handle
900 wxWindow
*wxWndHook
= NULL
;
903 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
905 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
907 if (!wnd
&& wxWndHook
)
909 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
912 wnd
->m_hWnd
= (WXHWND
) hWnd
;
915 // Stop right here if we don't have a valid handle in our wxWindow object.
916 if (wnd
&& !wnd
->m_hWnd
) {
917 wnd
->m_hWnd
= (WXHWND
) hWnd
;
918 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
924 wnd
->m_lastMsg
= message
;
925 wnd
->m_lastWParam
= wParam
;
926 wnd
->m_lastLParam
= lParam
;
929 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
931 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
934 // Should probably have a test for 'genuine' NT
935 #if defined(__WIN32__)
936 #define DIMENSION_TYPE short
938 #define DIMENSION_TYPE int
941 // Main Windows 3 window proc
942 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
944 wxASSERT( m_lastMsg
== message
&&
945 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
948 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
949 wxGetMessageName(message
), wParam
, lParam
);
950 #endif // __WXDEBUG__
952 HWND hWnd
= (HWND
)m_hWnd
;
959 WORD state
= LOWORD(wParam
);
960 WORD minimized
= HIWORD(wParam
);
961 HWND hwnd
= (HWND
)lParam
;
963 WORD state
= (WORD
)wParam
;
964 WORD minimized
= LOWORD(lParam
);
965 HWND hwnd
= (HWND
)HIWORD(lParam
);
967 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
973 HWND hwnd
= (HWND
)wParam
;
974 // return OnSetFocus(hwnd);
976 if (MSWOnSetFocus((WXHWND
) hwnd
))
978 else return MSWDefWindowProc(message
, wParam
, lParam
);
983 HWND hwnd
= (HWND
)lParam
;
984 // return OnKillFocus(hwnd);
985 if (MSWOnKillFocus((WXHWND
) hwnd
))
988 return MSWDefWindowProc(message
, wParam
, lParam
);
993 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
999 MSWOnShow((wParam
!= 0), (int) lParam
);
1006 else return MSWDefWindowProc(message
, wParam
, lParam
);
1009 case WM_QUERYDRAGICON
:
1011 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
1015 return MSWDefWindowProc(message
, wParam
, lParam
);
1021 int width
= LOWORD(lParam
);
1022 int height
= HIWORD(lParam
);
1023 MSWOnSize(width
, height
, wParam
);
1029 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1031 event
.SetEventObject(this);
1032 if ( !GetEventHandler()->ProcessEvent(event
) )
1037 case WM_WINDOWPOSCHANGING
:
1039 MSWOnWindowPosChanging((void *)lParam
);
1043 case WM_RBUTTONDOWN
:
1045 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1046 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1047 MSWOnRButtonDown(x
, y
, wParam
);
1052 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1053 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1054 MSWOnRButtonUp(x
, y
, wParam
);
1057 case WM_RBUTTONDBLCLK
:
1059 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1060 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1061 MSWOnRButtonDClick(x
, y
, wParam
);
1064 case WM_MBUTTONDOWN
:
1066 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1067 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1068 MSWOnMButtonDown(x
, y
, wParam
);
1073 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1074 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1075 MSWOnMButtonUp(x
, y
, wParam
);
1078 case WM_MBUTTONDBLCLK
:
1080 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1081 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1082 MSWOnMButtonDClick(x
, y
, wParam
);
1085 case WM_LBUTTONDOWN
:
1087 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1088 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1089 MSWOnLButtonDown(x
, y
, wParam
);
1094 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1095 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1096 MSWOnLButtonUp(x
, y
, wParam
);
1099 case WM_LBUTTONDBLCLK
:
1101 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1102 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1103 MSWOnLButtonDClick(x
, y
, wParam
);
1108 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1109 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1110 MSWOnMouseMove(x
, y
, wParam
);
1113 case MM_JOY1BUTTONDOWN
:
1115 int x
= LOWORD(lParam
);
1116 int y
= HIWORD(lParam
);
1117 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1120 case MM_JOY2BUTTONDOWN
:
1122 int x
= LOWORD(lParam
);
1123 int y
= HIWORD(lParam
);
1124 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1127 case MM_JOY1BUTTONUP
:
1129 int x
= LOWORD(lParam
);
1130 int y
= HIWORD(lParam
);
1131 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1134 case MM_JOY2BUTTONUP
:
1136 int x
= LOWORD(lParam
);
1137 int y
= HIWORD(lParam
);
1138 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1143 int x
= LOWORD(lParam
);
1144 int y
= HIWORD(lParam
);
1145 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1150 int x
= LOWORD(lParam
);
1151 int y
= HIWORD(lParam
);
1152 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1157 int z
= LOWORD(lParam
);
1158 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1163 int z
= LOWORD(lParam
);
1164 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1171 else return MSWDefWindowProc(message
, wParam
, lParam
);
1176 return MSWOnSysCommand(wParam
, lParam
);
1182 WORD id
= LOWORD(wParam
);
1183 HWND hwnd
= (HWND
)lParam
;
1184 WORD cmd
= HIWORD(wParam
);
1186 WORD id
= (WORD
)wParam
;
1187 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1188 WORD cmd
= HIWORD(lParam
);
1190 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1191 return MSWDefWindowProc(message
, wParam
, lParam
);
1194 #if defined(__WIN95__)
1197 // for some messages (TVN_ITEMEXPANDING for example), the return
1198 // value of WM_NOTIFY handler is important, so don't just return 0
1199 // if we processed the message
1200 return MSWOnNotify(wParam
, lParam
);
1206 WORD flags
= HIWORD(wParam
);
1207 HMENU sysmenu
= (HMENU
)lParam
;
1209 WORD flags
= LOWORD(lParam
);
1210 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1212 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1215 case WM_INITMENUPOPUP
:
1217 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1222 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1225 case WM_MEASUREITEM
:
1227 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1233 // If this has been processed by an event handler,
1234 // return 0 now (we've handled it).
1235 if (MSWOnKeyDown((WORD
) wParam
, lParam
))
1240 // we consider these message "not interesting" to OnChar
1241 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1246 // Avoid duplicate messages to OnChar for these special keys
1263 if (!MSWOnChar((WORD
)wParam
, lParam
))
1268 if ( ::GetKeyState(VK_CONTROL) & 0x100 )
1278 if (!MSWOnKeyUp((WORD
) wParam
, lParam
))
1282 case WM_CHAR
: // Always an ASCII character
1284 if (!MSWOnChar((WORD
)wParam
, lParam
, TRUE
))
1292 WORD code
= LOWORD(wParam
);
1293 WORD pos
= HIWORD(wParam
);
1294 HWND control
= (HWND
)lParam
;
1296 WORD code
= (WORD
)wParam
;
1297 WORD pos
= LOWORD(lParam
);
1298 HWND control
= (HWND
)HIWORD(lParam
);
1300 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1306 WORD code
= LOWORD(wParam
);
1307 WORD pos
= HIWORD(wParam
);
1308 HWND control
= (HWND
)lParam
;
1310 WORD code
= (WORD
)wParam
;
1311 WORD pos
= LOWORD(lParam
);
1312 HWND control
= (HWND
)HIWORD(lParam
);
1314 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1318 case WM_CTLCOLORBTN
:
1320 int nCtlColor
= CTLCOLOR_BTN
;
1321 HWND control
= (HWND
)lParam
;
1322 HDC pDC
= (HDC
)wParam
;
1323 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1324 message
, wParam
, lParam
);
1327 case WM_CTLCOLORDLG
:
1329 int nCtlColor
= CTLCOLOR_DLG
;
1330 HWND control
= (HWND
)lParam
;
1331 HDC pDC
= (HDC
)wParam
;
1332 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1333 message
, wParam
, lParam
);\
1336 case WM_CTLCOLORLISTBOX
:
1338 int nCtlColor
= CTLCOLOR_LISTBOX
;
1339 HWND control
= (HWND
)lParam
;
1340 HDC pDC
= (HDC
)wParam
;
1341 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1342 message
, wParam
, lParam
);
1345 case WM_CTLCOLORMSGBOX
:
1347 int nCtlColor
= CTLCOLOR_MSGBOX
;
1348 HWND control
= (HWND
)lParam
;
1349 HDC pDC
= (HDC
)wParam
;
1350 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1351 message
, wParam
, lParam
);
1354 case WM_CTLCOLORSCROLLBAR
:
1356 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1357 HWND control
= (HWND
)lParam
;
1358 HDC pDC
= (HDC
)wParam
;
1359 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1360 message
, wParam
, lParam
);
1363 case WM_CTLCOLORSTATIC
:
1365 int nCtlColor
= CTLCOLOR_STATIC
;
1366 HWND control
= (HWND
)lParam
;
1367 HDC pDC
= (HDC
)wParam
;
1368 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1369 message
, wParam
, lParam
);
1372 case WM_CTLCOLOREDIT
:
1374 int nCtlColor
= CTLCOLOR_EDIT
;
1375 HWND control
= (HWND
)lParam
;
1376 HDC pDC
= (HDC
)wParam
;
1377 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1378 message
, wParam
, lParam
);
1384 HWND control
= (HWND
)LOWORD(lParam
);
1385 int nCtlColor
= (int)HIWORD(lParam
);
1386 HDC pDC
= (HDC
)wParam
;
1387 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1388 message
, wParam
, lParam
);
1392 case WM_SYSCOLORCHANGE
:
1394 // Return value of 0 means, we processed it.
1395 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1398 return MSWDefWindowProc(message
, wParam
, lParam
);
1401 case WM_PALETTECHANGED
:
1403 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1406 case WM_QUERYNEWPALETTE
:
1408 return MSWOnQueryNewPalette();
1413 // Prevents flicker when dragging
1414 if (IsIconic(hWnd
)) return 1;
1416 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1417 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1421 case WM_MDIACTIVATE
:
1424 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1425 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1426 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1427 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1429 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1430 (HWND
)HIWORD(lParam
));
1435 MSWOnDropFiles(wParam
);
1440 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1443 case WM_QUERYENDSESSION
:
1445 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1446 // return MSWOnClose();
1448 return MSWOnQueryEndSession(lParam
);
1453 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1454 MSWOnEndSession((wParam
!= 0), lParam
);
1467 case WM_GETMINMAXINFO
:
1469 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1470 if (m_minSizeX
!= -1)
1471 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1472 if (m_minSizeY
!= -1)
1473 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1474 if (m_maxSizeX
!= -1)
1475 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1476 if (m_maxSizeY
!= -1)
1477 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1478 return MSWDefWindowProc(message
, wParam
, lParam
);
1483 return MSWGetDlgCode();
1487 // don't set cursor when the mouse is not in the client part
1488 short nHitTest
= LOWORD(lParam
);
1489 if ( nHitTest
== HTCLIENT
|| nHitTest
== HTERROR
)
1491 HCURSOR hcursor
= 0;
1494 extern HCURSOR gs_wxBusyCursor
; // from msw\utils.cpp
1496 hcursor
= gs_wxBusyCursor
;
1498 else if ( m_windowCursor
.Ok() )
1500 hcursor
= (HCURSOR
)m_windowCursor
.GetHCURSOR();
1504 extern wxCursor
*g_globalCursor
; // from msw\data.cpp
1506 if ( g_globalCursor
&& g_globalCursor
->Ok() )
1507 hcursor
= (HCURSOR
)g_globalCursor
->GetHCURSOR();
1512 ::SetCursor(hcursor
);
1514 // returning TRUE stops the DefWindowProc() from further
1515 // processing this message - exactly what we need because
1516 // we've just set the cursor
1522 return MSWDefWindowProc(message
, wParam
, lParam
);
1525 return MSWDefWindowProc(message
, wParam
, lParam
);
1528 return 0; // Success: we processed this command.
1531 // Dialog window proc
1532 LONG APIENTRY _EXPORT
1533 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1538 wxList
*wxWinHandleList
= NULL
;
1539 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1541 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1544 return (wxWindow
*)node
->Data();
1547 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1549 // adding NULL hWnd is (first) surely a result of an error and
1550 // (secondly) breaks menu command processing
1551 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1553 if ( !wxWinHandleList
->Find((long)hWnd
) )
1554 wxWinHandleList
->Append((long)hWnd
, win
);
1557 void wxRemoveHandleAssociation(wxWindow
*win
)
1559 wxWinHandleList
->DeleteObject(win
);
1562 // Default destroyer - override if you destroy it in some other way
1563 // (e.g. with MDI child windows)
1564 void wxWindow::MSWDestroyWindow()
1568 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1569 int x
, int y
, int width
, int height
,
1570 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1572 bool is_dialog
= (dialog_template
!= NULL
);
1573 int x1
= CW_USEDEFAULT
;
1575 int width1
= CW_USEDEFAULT
;
1578 // Find parent's size, if it exists, to set up a possible default
1579 // panel size the size of the parent window
1583 // Was GetWindowRect: JACS 5/5/95
1584 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1586 width1
= parent_rect
.right
- parent_rect
.left
;
1587 height1
= parent_rect
.bottom
- parent_rect
.top
;
1592 if (width
> -1) width1
= width
;
1593 if (height
> -1) height1
= height
;
1595 HWND hParent
= NULL
;
1597 hParent
= (HWND
) parent
->GetHWND();
1603 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1604 // other compilers???
1605 // VZ: it's always needed for Win16 and never for Win32
1607 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1608 (DLGPROC
)wxDlgProc
);
1610 // N.B.: if we _don't_ use this form,
1611 // then with VC++ 1.5, it crashes horribly.
1613 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1614 (DLGPROC
)wxDlgProc
);
1616 // Crashes when we use this.
1617 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1619 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1625 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1626 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1627 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1632 if (style
& WS_CHILD
)
1637 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1642 hParent
, (HMENU
)controlId
, wxGetInstance(),
1646 wxLogError("Can't create window of class %s!\n"
1647 "Possible Windows 3.x compatibility problem?", wclass
);
1652 wxWinHandleList
->Append((long)m_hWnd
, this);
1655 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1659 bool wxWindow::MSWOnClose()
1664 // Some compilers don't define this
1665 #ifndef ENDSESSION_LOGOFF
1666 #define ENDSESSION_LOGOFF 0x80000000
1669 // Return TRUE to end session, FALSE to veto end session.
1670 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1672 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1673 event
.SetEventObject(wxTheApp
);
1674 event
.SetCanVeto(TRUE
);
1675 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1676 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1677 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1679 return FALSE
; // Veto!
1683 return TRUE
; // Don't veto
1687 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1689 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1690 event
.SetEventObject(wxTheApp
);
1691 event
.SetCanVeto(FALSE
);
1692 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1693 if (endSession
&& // No need to send if the session isn't ending
1694 (this == wxTheApp
->GetTopWindow()) && // Only send once
1695 wxTheApp
->ProcessEvent(event
))
1701 bool wxWindow::MSWOnDestroy()
1703 // delete our drop target if we've got one
1704 #if wxUSE_DRAG_AND_DROP
1705 if ( m_pDropTarget
!= NULL
) {
1706 m_pDropTarget
->Revoke(m_hWnd
);
1708 delete m_pDropTarget
;
1709 m_pDropTarget
= NULL
;
1716 // Deal with child commands from buttons etc.
1718 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1720 #if defined(__WIN95__)
1721 // Find a child window to send the notification to, e.g. a toolbar.
1722 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1723 // handle of the toolbar; it's probably the handle of the tooltip
1724 // window (anyway, it's parent is also the toolbar's parent).
1725 // So, since we don't know which hWnd or wxWindow originated the
1726 // WM_NOTIFY, we'll need to go through all the children of this window
1727 // trying out MSWNotify.
1728 // This won't work now, though, because any number of controls
1729 // could respond to the same generic messages :-(
1731 /* This doesn't work for toolbars, but try for other controls first.
1733 NMHDR
*hdr
= (NMHDR
*)lParam
;
1734 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1735 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1737 WXLPARAM result
= 0;
1741 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1746 // Rely on MSWNotify to check whether the message
1747 // belongs to the window or not
1748 wxNode
*node
= GetChildren().First();
1751 wxWindow
*child
= (wxWindow
*)node
->Data();
1752 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1754 node
= node
->Next();
1757 // finally try this window too (catches toolbar case)
1758 if ( MSWNotify(wParam
, lParam
, &result
) )
1767 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1771 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1775 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1777 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1779 event
.SetEventObject(this);
1780 GetEventHandler()->ProcessEvent(event
);
1784 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1787 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1789 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1791 ::ShowCaret((HWND
) GetHWND());
1794 // panel wants to track the window which was the last to have focus in it
1795 wxWindow
*parent
= GetParent();
1796 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1798 ((wxPanel
*)parent
)->SetLastFocus(GetId());
1801 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1802 event
.SetEventObject(this);
1803 if (!GetEventHandler()->ProcessEvent(event
))
1808 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1816 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1817 event
.SetEventObject(this);
1818 if (!GetEventHandler()->ProcessEvent(event
))
1823 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1826 HDROP hFilesInfo
= (HDROP
) wParam
;
1828 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1830 // Get the total number of files dropped
1831 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1836 wxString
*files
= new wxString
[gwFilesDropped
];
1838 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1840 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1841 files
[wIndex
] = wxBuffer
;
1843 DragFinish (hFilesInfo
);
1845 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1846 event
.m_eventObject
= this;
1847 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1849 if (!GetEventHandler()->ProcessEvent(event
))
1855 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1857 #if wxUSE_OWNER_DRAWN
1858 if ( id
== 0 ) { // is it a menu item?
1859 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1860 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1861 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1863 // prepare to call OnDrawItem()
1865 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1866 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1867 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1868 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1869 return pMenuItem
->OnDrawItem(
1871 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1872 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1875 #endif // owner-drawn menus
1877 wxWindow
*item
= FindItem(id
);
1878 #if wxUSE_DYNAMIC_CLASSES
1879 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1881 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1888 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1890 #if wxUSE_OWNER_DRAWN
1891 if ( id
== 0 ) { // is it a menu item?
1892 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1893 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1894 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1896 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1897 &pMeasureStruct
->itemHeight
);
1899 #endif // owner-drawn menus
1901 wxWindow
*item
= FindItem(id
);
1902 #if wxUSE_DYNAMIC_CLASSES
1903 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1905 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1912 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1913 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1915 if (nCtlColor
== CTLCOLOR_DLG
)
1917 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1920 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1922 WXHBRUSH hBrush
= 0;
1925 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1927 // I think that even for dialogs, we may need to call DefWindowProc (?)
1928 // Or maybe just rely on the usual default behaviour.
1930 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1935 // Define for each class of dialog and control
1936 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1937 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1939 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1942 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1944 wxSysColourChangedEvent event
;
1945 event
.SetEventObject(this);
1947 // Check if app handles this.
1948 if (GetEventHandler()->ProcessEvent(event
))
1951 // We didn't process it
1955 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1957 wxPaletteChangedEvent
event(GetId());
1958 event
.SetEventObject(this);
1959 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1960 GetEventHandler()->ProcessEvent(event
);
1964 long wxWindow::MSWOnQueryNewPalette()
1966 wxQueryNewPaletteEvent
event(GetId());
1967 event
.SetEventObject(this);
1968 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1970 return (long) FALSE
;
1976 // Responds to colour changes: passes event on to children.
1977 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1979 wxNode
*node
= GetChildren().First();
1982 // Only propagate to non-top-level windows
1983 wxWindow
*win
= (wxWindow
*)node
->Data();
1984 if ( win
->GetParent() )
1986 wxSysColourChangedEvent event2
;
1987 event
.m_eventObject
= win
;
1988 win
->GetEventHandler()->ProcessEvent(event2
);
1991 node
= node
->Next();
1995 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1998 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
2000 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
2003 long wxWindow::Default()
2005 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
2010 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
2011 wxGetMessageName(m_lastMsg
));
2012 #endif // __WXDEBUG__
2014 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
2017 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
2019 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
2020 // intercept dialog navigation keys
2021 MSG
*msg
= (MSG
*)pMsg
;
2022 bool bProcess
= TRUE
;
2023 if ( msg
->message
!= WM_KEYDOWN
)
2026 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2031 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
2033 // WM_GETDLGCODE: ask the control if it wants the key for itself,
2034 // don't process it if it's the case (except for Ctrl-Tab/Enter
2035 // combinations which are always processed)
2039 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
2042 bool bForward
= TRUE
,
2043 bWindowChange
= FALSE
;
2045 switch ( msg
->wParam
)
2048 if ( lDlgCode
& DLGC_WANTTAB
) {
2052 // Ctrl-Tab cycles thru notebook pages
2053 bWindowChange
= bCtrlDown
;
2054 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
2060 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2068 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2074 if ( lDlgCode
& DLGC_WANTMESSAGE
)
2076 // control wants to process Enter itself, don't
2077 // call IsDialogMessage() which would interpret
2082 wxButton
*btnDefault
= GetDefaultItem();
2083 if ( btnDefault
&& !bCtrlDown
)
2085 // if there is a default button, Enter should
2087 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
2091 // else: but if there is not it makes sense to make it
2092 // work like a TAB - and that's what we do.
2093 // Note that Ctrl-Enter always works this way.
2104 wxNavigationKeyEvent event
;
2105 event
.SetDirection(bForward
);
2106 event
.SetWindowChange(bWindowChange
);
2107 event
.SetEventObject(this);
2109 if ( GetEventHandler()->ProcessEvent(event
) )
2114 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
2120 // relay mouse move events to the tooltip control
2121 MSG
*msg
= (MSG
*)pMsg
;
2122 if ( msg
->message
== WM_MOUSEMOVE
)
2123 m_tooltip
->RelayEvent(pMsg
);
2125 #endif // wxUSE_TOOLTIPS
2130 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2132 if (m_acceleratorTable
.Ok() &&
2133 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2139 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2144 void wxWindow::MSWDetachWindowMenu()
2148 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2150 for (i
= 0; i
< N
; i
++)
2153 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2154 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2156 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2163 bool wxWindow::MSWOnPaint()
2166 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2167 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2169 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2172 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2174 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2175 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2178 wxPaintEvent
event(m_windowId
);
2179 event
.SetEventObject(this);
2180 if (!GetEventHandler()->ProcessEvent(event
))
2185 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2195 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2196 event
.SetEventObject(this);
2197 if (!GetEventHandler()->ProcessEvent(event
))
2203 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2208 // Deal with child commands from buttons etc.
2209 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2211 if (wxCurrentPopupMenu
)
2213 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2214 wxCurrentPopupMenu
= NULL
;
2215 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2219 wxWindow
*item
= FindItem(id
);
2222 bool value
= item
->MSWCommand(cmd
, id
);
2227 wxWindow
*win
= wxFindWinFromHandle(control
);
2229 return win
->MSWCommand(cmd
, id
);
2234 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2236 switch (wParam
& 0xFFFFFFF0)
2240 wxMaximizeEvent
event(m_windowId
);
2241 event
.SetEventObject(this);
2242 if (!GetEventHandler()->ProcessEvent(event
))
2250 wxIconizeEvent
event(m_windowId
);
2251 event
.SetEventObject(this);
2252 if (!GetEventHandler()->ProcessEvent(event
))
2264 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2266 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2268 event
.m_x
= x
; event
.m_y
= y
;
2269 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2270 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2271 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2272 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2273 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2274 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2275 event
.m_eventObject
= this;
2277 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2279 if (!GetEventHandler()->ProcessEvent(event
))
2283 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2285 wxMouseEvent
event(wxEVT_LEFT_UP
);
2287 event
.m_x
= x
; event
.m_y
= y
;
2288 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2289 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2290 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2291 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2292 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2293 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2294 event
.m_eventObject
= this;
2296 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2298 if (!GetEventHandler()->ProcessEvent(event
))
2302 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2304 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2306 event
.m_x
= x
; event
.m_y
= y
;
2307 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2308 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2309 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2310 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2311 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2312 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2313 event
.m_eventObject
= this;
2315 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2317 if (!GetEventHandler()->ProcessEvent(event
))
2321 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2323 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2325 event
.m_x
= x
; event
.m_y
= y
;
2326 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2327 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2328 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2329 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2330 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2331 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2332 event
.m_eventObject
= this;
2334 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2336 if (!GetEventHandler()->ProcessEvent(event
))
2340 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2342 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2344 event
.m_x
= x
; event
.m_y
= y
;
2345 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2346 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2347 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2348 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2349 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2350 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2351 event
.m_eventObject
= this;
2353 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2355 if (!GetEventHandler()->ProcessEvent(event
))
2359 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2361 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2363 event
.m_x
= x
; event
.m_y
= y
;
2364 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2365 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2366 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2367 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2368 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2369 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2370 event
.m_eventObject
= this;
2372 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2374 if (!GetEventHandler()->ProcessEvent(event
))
2378 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2380 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2382 event
.m_x
= x
; event
.m_y
= y
;
2383 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2384 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2385 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2386 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2387 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2388 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2389 event
.m_eventObject
= this;
2391 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2393 if (!GetEventHandler()->ProcessEvent(event
))
2397 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2399 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2401 event
.m_x
= x
; event
.m_y
= y
;
2402 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2403 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2404 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2405 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2406 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2407 event
.m_eventObject
= this;
2408 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2410 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2412 if (!GetEventHandler()->ProcessEvent(event
))
2416 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2418 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2420 event
.m_x
= x
; event
.m_y
= y
;
2421 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2422 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2423 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2424 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2425 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2426 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2427 event
.m_eventObject
= this;
2429 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2431 if (!GetEventHandler()->ProcessEvent(event
))
2435 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2437 // 'normal' move event...
2439 if (!m_mouseInWindow
)
2441 // Generate an ENTER event
2442 m_mouseInWindow
= TRUE
;
2443 MSWOnMouseEnter(x
, y
, flags
);
2446 wxMouseEvent
event(wxEVT_MOTION
);
2448 event
.m_x
= x
; event
.m_y
= y
;
2449 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2450 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2451 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2452 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2453 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2454 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2455 event
.m_eventObject
= this;
2457 // Window gets a click down message followed by a mouse move
2458 // message even if position isn't changed! We want to discard
2459 // the trailing move event if x and y are the same.
2460 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2461 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2462 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2464 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2465 m_lastEvent
= wxEVT_MOTION
;
2469 m_lastEvent
= wxEVT_MOTION
;
2470 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2472 if (!GetEventHandler()->ProcessEvent(event
))
2476 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2478 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2480 event
.m_x
= x
; event
.m_y
= y
;
2481 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2482 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2483 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2484 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2485 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2486 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2487 event
.m_eventObject
= this;
2489 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2490 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2491 // No message - ensure we don't try to call the default behaviour accidentally.
2493 GetEventHandler()->ProcessEvent(event
);
2496 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2498 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2500 event
.m_x
= x
; event
.m_y
= y
;
2501 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2502 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2503 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2504 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2505 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2506 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2507 event
.m_eventObject
= this;
2509 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2510 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2511 // No message - ensure we don't try to call the default behaviour accidentally.
2513 GetEventHandler()->ProcessEvent(event
);
2516 bool wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2519 bool tempControlDown
= FALSE
;
2522 // If 1 -> 26, translate to CTRL plus a letter.
2524 if ((id
> 0) && (id
< 27))
2545 tempControlDown
= TRUE
;
2551 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2552 // it's ASCII and will be processed here only when called from
2553 // WM_CHAR (i.e. when isASCII = TRUE)
2559 wxKeyEvent
event(wxEVT_CHAR
);
2560 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2561 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2562 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2563 event
.m_altDown
= TRUE
;
2565 event
.m_eventObject
= this;
2566 event
.m_keyCode
= id
;
2567 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2572 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2576 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2578 if (GetEventHandler()->ProcessEvent(event
))
2587 bool wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2591 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2597 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2598 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2599 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2600 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2601 event
.m_altDown
= TRUE
;
2603 event
.m_eventObject
= this;
2604 event
.m_keyCode
= id
;
2605 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2610 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2614 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2616 if (GetEventHandler()->ProcessEvent(event
))
2628 bool wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2632 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2638 wxKeyEvent
event(wxEVT_KEY_UP
);
2639 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2640 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2641 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2642 event
.m_altDown
= TRUE
;
2644 event
.m_eventObject
= this;
2645 event
.m_keyCode
= id
;
2646 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2651 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2655 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2657 if (GetEventHandler()->ProcessEvent(event
))
2666 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2670 if (flags
& JOY_BUTTON1CHG
)
2671 change
= wxJOY_BUTTON1
;
2672 if (flags
& JOY_BUTTON2CHG
)
2673 change
= wxJOY_BUTTON2
;
2674 if (flags
& JOY_BUTTON3CHG
)
2675 change
= wxJOY_BUTTON3
;
2676 if (flags
& JOY_BUTTON4CHG
)
2677 change
= wxJOY_BUTTON4
;
2679 if (flags
& JOY_BUTTON1
)
2680 buttons
|= wxJOY_BUTTON1
;
2681 if (flags
& JOY_BUTTON2
)
2682 buttons
|= wxJOY_BUTTON2
;
2683 if (flags
& JOY_BUTTON3
)
2684 buttons
|= wxJOY_BUTTON3
;
2685 if (flags
& JOY_BUTTON4
)
2686 buttons
|= wxJOY_BUTTON4
;
2688 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2689 event
.SetPosition(wxPoint(x
, y
));
2690 event
.SetEventObject(this);
2692 GetEventHandler()->ProcessEvent(event
);
2695 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2699 if (flags
& JOY_BUTTON1CHG
)
2700 change
= wxJOY_BUTTON1
;
2701 if (flags
& JOY_BUTTON2CHG
)
2702 change
= wxJOY_BUTTON2
;
2703 if (flags
& JOY_BUTTON3CHG
)
2704 change
= wxJOY_BUTTON3
;
2705 if (flags
& JOY_BUTTON4CHG
)
2706 change
= wxJOY_BUTTON4
;
2708 if (flags
& JOY_BUTTON1
)
2709 buttons
|= wxJOY_BUTTON1
;
2710 if (flags
& JOY_BUTTON2
)
2711 buttons
|= wxJOY_BUTTON2
;
2712 if (flags
& JOY_BUTTON3
)
2713 buttons
|= wxJOY_BUTTON3
;
2714 if (flags
& JOY_BUTTON4
)
2715 buttons
|= wxJOY_BUTTON4
;
2717 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2718 event
.SetPosition(wxPoint(x
, y
));
2719 event
.SetEventObject(this);
2721 GetEventHandler()->ProcessEvent(event
);
2724 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2727 if (flags
& JOY_BUTTON1
)
2728 buttons
|= wxJOY_BUTTON1
;
2729 if (flags
& JOY_BUTTON2
)
2730 buttons
|= wxJOY_BUTTON2
;
2731 if (flags
& JOY_BUTTON3
)
2732 buttons
|= wxJOY_BUTTON3
;
2733 if (flags
& JOY_BUTTON4
)
2734 buttons
|= wxJOY_BUTTON4
;
2736 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2737 event
.SetPosition(wxPoint(x
, y
));
2738 event
.SetEventObject(this);
2740 GetEventHandler()->ProcessEvent(event
);
2743 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2746 if (flags
& JOY_BUTTON1
)
2747 buttons
|= wxJOY_BUTTON1
;
2748 if (flags
& JOY_BUTTON2
)
2749 buttons
|= wxJOY_BUTTON2
;
2750 if (flags
& JOY_BUTTON3
)
2751 buttons
|= wxJOY_BUTTON3
;
2752 if (flags
& JOY_BUTTON4
)
2753 buttons
|= wxJOY_BUTTON4
;
2755 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2756 event
.SetZPosition(z
);
2757 event
.SetEventObject(this);
2759 GetEventHandler()->ProcessEvent(event
);
2762 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2766 wxWindow
*child
= wxFindWinFromHandle(control
);
2768 child
->MSWOnVScroll(wParam
, pos
, control
);
2772 wxScrollEvent event
;
2773 event
.SetPosition(pos
);
2774 event
.SetOrientation(wxVERTICAL
);
2775 event
.m_eventObject
= this;
2780 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2784 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2788 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2792 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2796 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2800 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2804 case SB_THUMBPOSITION
:
2805 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2813 if (!GetEventHandler()->ProcessEvent(event
))
2817 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2821 wxWindow
*child
= wxFindWinFromHandle(control
);
2823 child
->MSWOnHScroll(wParam
, pos
, control
);
2829 wxScrollEvent event
;
2830 event
.SetPosition(pos
);
2831 event
.SetOrientation(wxHORIZONTAL
);
2832 event
.m_eventObject
= this;
2837 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2841 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2845 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2849 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2853 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2857 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2861 case SB_THUMBPOSITION
:
2862 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2869 if ( GetEventHandler()->ProcessEvent(event
) )
2873 // call the default WM_HSCROLL handler: it's non trivial in some common
2874 // controls (up-down control for example)
2878 void wxWindow::MSWOnShow(bool show
, int status
)
2880 wxShowEvent
event(GetId(), show
);
2881 event
.m_eventObject
= this;
2882 GetEventHandler()->ProcessEvent(event
);
2885 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2887 wxInitDialogEvent
event(GetId());
2888 event
.m_eventObject
= this;
2889 GetEventHandler()->ProcessEvent(event
);
2893 void wxWindow::InitDialog()
2895 wxInitDialogEvent
event(GetId());
2896 event
.SetEventObject( this );
2897 GetEventHandler()->ProcessEvent(event
);
2900 // Default init dialog behaviour is to transfer data to window
2901 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2903 TransferDataToWindow();
2906 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2909 HDC dc
= ::GetDC((HWND
) wnd
);
2914 // the_font->UseResource();
2915 // the_font->RealizeResource();
2916 fnt
= (HFONT
)the_font
->GetResourceHandle();
2918 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2920 GetTextMetrics(dc
, &tm
);
2921 if (the_font
&& fnt
&& was
)
2923 SelectObject(dc
,was
) ;
2925 ReleaseDC((HWND
)wnd
, dc
);
2926 *x
= tm
.tmAveCharWidth
;
2927 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2930 // the_font->ReleaseResource();
2933 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2934 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2935 int wxCharCodeMSWToWX(int keySym
)
2940 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2941 case VK_BACK
: id
= WXK_BACK
; break;
2942 case VK_TAB
: id
= WXK_TAB
; break;
2943 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2944 case VK_RETURN
: id
= WXK_RETURN
; break;
2945 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2946 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2947 case VK_MENU
: id
= WXK_MENU
; break;
2948 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2949 case VK_SPACE
: id
= WXK_SPACE
; break;
2950 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2951 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2952 case VK_NEXT
: id
= WXK_NEXT
; break;
2953 case VK_END
: id
= WXK_END
; break;
2954 case VK_HOME
: id
= WXK_HOME
; break;
2955 case VK_LEFT
: id
= WXK_LEFT
; break;
2956 case VK_UP
: id
= WXK_UP
; break;
2957 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2958 case VK_DOWN
: id
= WXK_DOWN
; break;
2959 case VK_SELECT
: id
= WXK_SELECT
; break;
2960 case VK_PRINT
: id
= WXK_PRINT
; break;
2961 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2962 case VK_INSERT
: id
= WXK_INSERT
; break;
2963 case VK_DELETE
: id
= WXK_DELETE
; break;
2964 case VK_HELP
: id
= WXK_HELP
; break;
2965 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2966 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2967 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2968 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2969 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2970 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2971 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2972 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2973 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2974 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2975 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2976 case VK_ADD
: id
= WXK_ADD
; break;
2977 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2978 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2979 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2980 case VK_F1
: id
= WXK_F1
; break;
2981 case VK_F2
: id
= WXK_F2
; break;
2982 case VK_F3
: id
= WXK_F3
; break;
2983 case VK_F4
: id
= WXK_F4
; break;
2984 case VK_F5
: id
= WXK_F5
; break;
2985 case VK_F6
: id
= WXK_F6
; break;
2986 case VK_F7
: id
= WXK_F7
; break;
2987 case VK_F8
: id
= WXK_F8
; break;
2988 case VK_F9
: id
= WXK_F9
; break;
2989 case VK_F10
: id
= WXK_F10
; break;
2990 case VK_F11
: id
= WXK_F11
; break;
2991 case VK_F12
: id
= WXK_F12
; break;
2992 case VK_F13
: id
= WXK_F13
; break;
2993 case VK_F14
: id
= WXK_F14
; break;
2994 case VK_F15
: id
= WXK_F15
; break;
2995 case VK_F16
: id
= WXK_F16
; break;
2996 case VK_F17
: id
= WXK_F17
; break;
2997 case VK_F18
: id
= WXK_F18
; break;
2998 case VK_F19
: id
= WXK_F19
; break;
2999 case VK_F20
: id
= WXK_F20
; break;
3000 case VK_F21
: id
= WXK_F21
; break;
3001 case VK_F22
: id
= WXK_F22
; break;
3002 case VK_F23
: id
= WXK_F23
; break;
3003 case VK_F24
: id
= WXK_F24
; break;
3004 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
3005 case VK_SCROLL
: id
= WXK_SCROLL
; break;
3014 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
3020 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
3021 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
3022 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
3023 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
3024 case WXK_MENU
: keySym
= VK_MENU
; break;
3025 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
3026 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
3027 case WXK_NEXT
: keySym
= VK_NEXT
; break;
3028 case WXK_END
: keySym
= VK_END
; break;
3029 case WXK_HOME
: keySym
= VK_HOME
; break;
3030 case WXK_LEFT
: keySym
= VK_LEFT
; break;
3031 case WXK_UP
: keySym
= VK_UP
; break;
3032 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
3033 case WXK_DOWN
: keySym
= VK_DOWN
; break;
3034 case WXK_SELECT
: keySym
= VK_SELECT
; break;
3035 case WXK_PRINT
: keySym
= VK_PRINT
; break;
3036 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
3037 case WXK_INSERT
: keySym
= VK_INSERT
; break;
3038 case WXK_DELETE
: keySym
= VK_DELETE
; break;
3039 case WXK_HELP
: keySym
= VK_HELP
; break;
3040 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
3041 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
3042 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
3043 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
3044 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
3045 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
3046 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
3047 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
3048 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
3049 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
3050 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
3051 case WXK_ADD
: keySym
= VK_ADD
; break;
3052 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
3053 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
3054 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
3055 case WXK_F1
: keySym
= VK_F1
; break;
3056 case WXK_F2
: keySym
= VK_F2
; break;
3057 case WXK_F3
: keySym
= VK_F3
; break;
3058 case WXK_F4
: keySym
= VK_F4
; break;
3059 case WXK_F5
: keySym
= VK_F5
; break;
3060 case WXK_F6
: keySym
= VK_F6
; break;
3061 case WXK_F7
: keySym
= VK_F7
; break;
3062 case WXK_F8
: keySym
= VK_F8
; break;
3063 case WXK_F9
: keySym
= VK_F9
; break;
3064 case WXK_F10
: keySym
= VK_F10
; break;
3065 case WXK_F11
: keySym
= VK_F11
; break;
3066 case WXK_F12
: keySym
= VK_F12
; break;
3067 case WXK_F13
: keySym
= VK_F13
; break;
3068 case WXK_F14
: keySym
= VK_F14
; break;
3069 case WXK_F15
: keySym
= VK_F15
; break;
3070 case WXK_F16
: keySym
= VK_F16
; break;
3071 case WXK_F17
: keySym
= VK_F17
; break;
3072 case WXK_F18
: keySym
= VK_F18
; break;
3073 case WXK_F19
: keySym
= VK_F19
; break;
3074 case WXK_F20
: keySym
= VK_F20
; break;
3075 case WXK_F21
: keySym
= VK_F21
; break;
3076 case WXK_F22
: keySym
= VK_F22
; break;
3077 case WXK_F23
: keySym
= VK_F23
; break;
3078 case WXK_F24
: keySym
= VK_F24
; break;
3079 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
3080 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
3091 // Caret manipulation
3092 void wxWindow::CreateCaret(int w
, int h
)
3096 m_caretEnabled
= TRUE
;
3099 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
3104 void wxWindow::ShowCaret(bool show
)
3109 ::ShowCaret((HWND
) GetHWND());
3111 ::HideCaret((HWND
) GetHWND());
3112 m_caretShown
= show
;
3116 void wxWindow::DestroyCaret()
3118 m_caretEnabled
= FALSE
;
3121 void wxWindow::SetCaretPos(int x
, int y
)
3123 ::SetCaretPos(x
, y
);
3126 void wxWindow::GetCaretPos(int *x
, int *y
) const
3129 ::GetCaretPos(&point
);
3134 wxWindow
*wxGetActiveWindow()
3136 HWND hWnd
= GetActiveWindow();
3139 return wxFindWinFromHandle((WXHWND
) hWnd
);
3144 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3145 // in active frames and dialogs, regardless of where the focus is.
3146 static HHOOK wxTheKeyboardHook
= 0;
3147 static FARPROC wxTheKeyboardHookProc
= 0;
3148 int APIENTRY _EXPORT
3149 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3151 void wxSetKeyboardHook(bool doIt
)
3155 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3156 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3157 #if defined(__WIN32__) && !defined(__TWIN32__)
3158 GetCurrentThreadId());
3159 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3166 UnhookWindowsHookEx(wxTheKeyboardHook
);
3167 FreeProcInstance(wxTheKeyboardHookProc
);
3171 int APIENTRY _EXPORT
3172 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3174 DWORD hiWord
= HIWORD(lParam
);
3175 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3178 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3180 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3181 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3182 event
.m_altDown
= TRUE
;
3184 event
.m_eventObject
= NULL
;
3185 event
.m_keyCode
= id
;
3186 /* begin Albert's fix for control and shift key 26.5 */
3187 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3188 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3189 /* end Albert's fix for control and shift key 26.5 */
3190 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3192 wxWindow
*win
= wxGetActiveWindow();
3195 if (win
->GetEventHandler()->ProcessEvent(event
))
3200 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3205 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3208 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3216 void wxWindow::Centre(int direction
)
3218 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3220 wxWindow
*father
= (wxWindow
*)GetParent();
3224 father
->GetClientSize(&panel_width
, &panel_height
);
3225 GetSize(&width
, &height
);
3226 GetPosition(&x
, &y
);
3231 if (direction
& wxHORIZONTAL
)
3232 new_x
= (int)((panel_width
- width
)/2);
3234 if (direction
& wxVERTICAL
)
3235 new_y
= (int)((panel_height
- height
)/2);
3237 SetSize(new_x
, new_y
, -1, -1);
3241 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3243 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3244 // pixel coordinates, relatives to the canvas -- So, we first need to
3245 // substract origin of the window, then convert to screen position
3247 int x
= x_pos
; int y
= y_pos
;
3249 GetWindowRect ((HWND
) GetHWND(), &rect
);
3254 SetCursorPos (x
, y
);
3257 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3261 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3269 wxEraseEvent
event(m_windowId
, &dc
);
3270 event
.m_eventObject
= this;
3271 if (!GetEventHandler()->ProcessEvent(event
))
3274 dc
.SelectOldObjects(pDC
);
3280 dc
.SelectOldObjects(pDC
);
3283 dc
.SetHDC((WXHDC
) NULL
);
3287 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3293 ::GetClientRect((HWND
) GetHWND(), &rect
);
3295 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3296 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3297 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3299 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3300 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3301 ::DeleteObject(hBrush
);
3302 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3304 // Less efficient version (and doesn't account for scrolling)
3306 GetClientSize(& w, & h);
3307 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3308 event.GetDC()->SetBrush(brush);
3309 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3311 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3315 #if WXWIN_COMPATIBILITY
3316 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3318 #if defined(__WIN95__)
3322 // Try to adjust the range to cope with page size > 1
3323 // - a Windows API quirk
3324 int pageSize
= GetScrollPage(orient
);
3325 if ( pageSize
> 1 && range
> 0)
3327 range1
+= (pageSize
- 1);
3333 if (orient
== wxHORIZONTAL
) {
3339 info
.cbSize
= sizeof(SCROLLINFO
);
3340 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3344 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3346 HWND hWnd
= (HWND
) GetHWND();
3348 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3351 if (orient
== wxHORIZONTAL
)
3356 HWND hWnd
= (HWND
) GetHWND();
3358 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3362 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3364 #if defined(__WIN95__)
3368 if (orient
== wxHORIZONTAL
) {
3370 m_xThumbSize
= page
;
3373 m_yThumbSize
= page
;
3376 info
.cbSize
= sizeof(SCROLLINFO
);
3379 info
.fMask
= SIF_PAGE
;
3381 HWND hWnd
= (HWND
) GetHWND();
3383 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3385 if (orient
== wxHORIZONTAL
)
3386 m_xThumbSize
= page
;
3388 m_yThumbSize
= page
;
3392 int wxWindow::OldGetScrollRange(int orient
) const
3395 if (orient
== wxHORIZONTAL
)
3400 #if __WATCOMC__ && defined(__WINDOWS_386__)
3401 short minPos
, maxPos
;
3405 HWND hWnd
= (HWND
) GetHWND();
3408 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3409 #if defined(__WIN95__)
3410 // Try to adjust the range to cope with page size > 1
3411 // - a Windows API quirk
3412 int pageSize
= GetScrollPage(orient
);
3415 maxPos
-= (pageSize
- 1);
3424 int wxWindow::GetScrollPage(int orient
) const
3426 if (orient
== wxHORIZONTAL
)
3427 return m_xThumbSize
;
3429 return m_yThumbSize
;
3433 int wxWindow::GetScrollPos(int orient
) const
3436 if (orient
== wxHORIZONTAL
)
3440 HWND hWnd
= (HWND
) GetHWND();
3443 return ::GetScrollPos(hWnd
, wOrient
);
3449 // This now returns the whole range, not just the number
3450 // of positions that we can scroll.
3451 int wxWindow::GetScrollRange(int orient
) const
3454 if (orient
== wxHORIZONTAL
)
3459 #if __WATCOMC__ && defined(__WINDOWS_386__)
3460 short minPos
, maxPos
;
3464 HWND hWnd
= (HWND
) GetHWND();
3467 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3468 #if defined(__WIN95__)
3469 // Try to adjust the range to cope with page size > 1
3470 // - a Windows API quirk
3471 int pageSize
= GetScrollThumb(orient
);
3474 maxPos
-= (pageSize
- 1);
3476 // October 10th: new range concept.
3486 int wxWindow::GetScrollThumb(int orient
) const
3488 if (orient
== wxHORIZONTAL
)
3489 return m_xThumbSize
;
3491 return m_yThumbSize
;
3494 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3496 #if defined(__WIN95__)
3500 if (orient
== wxHORIZONTAL
) {
3506 info
.cbSize
= sizeof(SCROLLINFO
);
3510 info
.fMask
= SIF_POS
;
3512 HWND hWnd
= (HWND
) GetHWND();
3514 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3517 if (orient
== wxHORIZONTAL
)
3522 HWND hWnd
= (HWND
) GetHWND();
3524 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3528 // New function that will replace some of the above.
3529 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3530 int range
, bool refresh
)
3533 SetScrollPage(orient, thumbVisible, FALSE);
3535 int oldRange = range - thumbVisible ;
3536 SetScrollRange(orient, oldRange, FALSE);
3538 SetScrollPos(orient, pos, refresh);
3540 #if defined(__WIN95__)
3541 int oldRange
= range
- thumbVisible
;
3543 int range1
= oldRange
;
3545 // Try to adjust the range to cope with page size > 1
3546 // - a Windows API quirk
3547 int pageSize
= thumbVisible
;
3548 if ( pageSize
> 1 && range
> 0)
3550 range1
+= (pageSize
- 1);
3556 if (orient
== wxHORIZONTAL
) {
3562 info
.cbSize
= sizeof(SCROLLINFO
);
3563 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3567 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3569 HWND hWnd
= (HWND
) GetHWND();
3571 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3574 if (orient
== wxHORIZONTAL
)
3579 HWND hWnd
= (HWND
) GetHWND();
3582 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3583 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3586 if (orient
== wxHORIZONTAL
) {
3587 m_xThumbSize
= thumbVisible
;
3589 m_yThumbSize
= thumbVisible
;
3593 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3598 rect2
.left
= rect
->x
;
3599 rect2
.top
= rect
->y
;
3600 rect2
.right
= rect
->x
+ rect
->width
;
3601 rect2
.bottom
= rect
->y
+ rect
->height
;
3605 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3607 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3610 void wxWindow::SetFont(const wxFont
& font
)
3612 m_windowFont
= font
;
3614 if (!m_windowFont
.Ok())
3617 HWND hWnd
= (HWND
) GetHWND();
3620 if (m_windowFont
.GetResourceHandle())
3621 SendMessage(hWnd
, WM_SETFONT
,
3622 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3626 void wxWindow::SubclassWin(WXHWND hWnd
)
3628 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3630 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3632 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3633 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3636 void wxWindow::UnsubclassWin()
3638 wxRemoveHandleAssociation(this);
3640 // Restore old Window proc
3641 if ((HWND
) GetHWND())
3643 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3644 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3646 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3652 // Make a Windows extended style from the given wxWindows window style
3653 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3655 WXDWORD exStyle
= 0;
3656 if ( style
& wxTRANSPARENT_WINDOW
)
3657 exStyle
|= WS_EX_TRANSPARENT
;
3659 if ( !eliminateBorders
)
3661 if ( style
& wxSUNKEN_BORDER
)
3662 exStyle
|= WS_EX_CLIENTEDGE
;
3663 if ( style
& wxDOUBLE_BORDER
)
3664 exStyle
|= WS_EX_DLGMODALFRAME
;
3665 #if defined(__WIN95__)
3666 if ( style
& wxRAISED_BORDER
)
3667 exStyle
|= WS_EX_WINDOWEDGE
;
3668 if ( style
& wxSTATIC_BORDER
)
3669 exStyle
|= WS_EX_STATICEDGE
;
3675 // Determines whether native 3D effects or CTL3D should be used,
3676 // applying a default border style if required, and returning an extended
3677 // style to pass to CreateWindowEx.
3678 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3680 // If matches certain criteria, then assume no 3D effects
3681 // unless specifically requested (dealt with in MakeExtendedStyle)
3682 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3685 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3688 // Determine whether we should be using 3D effects or not.
3689 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3691 // 1) App can specify global 3D effects
3692 *want3D
= wxTheApp
->GetAuto3D();
3694 // 2) If the parent is being drawn with user colours, or simple border specified,
3695 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3696 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3699 // 3) Control can override this global setting by defining
3700 // a border style, e.g. wxSUNKEN_BORDER
3701 if (m_windowStyle
& wxSUNKEN_BORDER
)
3704 // 4) If it's a special border, CTL3D can't cope so we want a native border
3705 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3706 (m_windowStyle
& wxSTATIC_BORDER
) )
3709 nativeBorder
= TRUE
;
3712 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3713 // effects from extended style
3716 nativeBorder
= FALSE
;
3719 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3721 // If we want 3D, but haven't specified a border here,
3722 // apply the default border style specified.
3723 // TODO what about non-Win95 WIN32? Does it have borders?
3724 #if defined(__WIN95__) && !wxUSE_CTL3D
3725 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3726 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3727 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3733 void wxWindow::OnChar(wxKeyEvent
& event
)
3736 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3741 if ( !event
.ControlDown() ) // Why this test?
3742 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3745 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3750 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3755 void wxWindow::OnPaint(wxPaintEvent
& event
)
3760 bool wxWindow::IsEnabled(void) const
3762 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3765 // Dialog support: override these and call
3766 // base class members to add functionality
3767 // that can't be done using validators.
3768 // NOTE: these functions assume that controls
3769 // are direct children of this window, not grandchildren
3770 // or other levels of descendant.
3772 // Transfer values to controls. If returns FALSE,
3773 // it's an application error (pops up a dialog)
3774 bool wxWindow::TransferDataToWindow()
3776 wxNode
*node
= GetChildren().First();
3779 wxWindow
*child
= (wxWindow
*)node
->Data();
3780 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3781 !child
->GetValidator()->TransferToWindow() )
3783 wxLogError(_("Could not transfer data to window"));
3787 node
= node
->Next();
3792 // Transfer values from controls. If returns FALSE,
3793 // validation failed: don't quit
3794 bool wxWindow::TransferDataFromWindow()
3796 wxNode
*node
= GetChildren().First();
3799 wxWindow
*child
= (wxWindow
*)node
->Data();
3800 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3805 node
= node
->Next();
3810 bool wxWindow::Validate()
3812 wxNode
*node
= GetChildren().First();
3815 wxWindow
*child
= (wxWindow
*)node
->Data();
3816 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3821 node
= node
->Next();
3826 // Get the window with the focus
3827 wxWindow
*wxWindow::FindFocus()
3829 HWND hWnd
= ::GetFocus();
3832 return wxFindWinFromHandle((WXHWND
) hWnd
);
3837 void wxWindow::AddChild(wxWindow
*child
)
3839 GetChildren().Append(child
);
3840 child
->m_windowParent
= this;
3843 void wxWindow::RemoveChild(wxWindow
*child
)
3845 // if (GetChildren())
3846 GetChildren().DeleteObject(child
);
3847 child
->m_windowParent
= NULL
;
3850 void wxWindow::DestroyChildren()
3853 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3855 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3857 if ( GetChildren().Member(child
) )
3863 void wxWindow::MakeModal(bool modal
)
3865 // Disable all other windows
3866 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3868 wxNode
*node
= wxTopLevelWindows
.First();
3871 wxWindow
*win
= (wxWindow
*)node
->Data();
3873 win
->Enable(!modal
);
3875 node
= node
->Next();
3880 // If nothing defined for this, try the parent.
3881 // E.g. we may be a button loaded from a resource, with no callback function
3883 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3885 if (GetEventHandler()->ProcessEvent(event
) )
3888 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3891 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3895 UnsetConstraints(m_constraints
);
3896 delete m_constraints
;
3901 // Make sure other windows know they're part of a 'meaningful relationship'
3902 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3903 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3904 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3905 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3906 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3907 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3908 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3909 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3910 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3911 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3912 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3913 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3914 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3915 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3916 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3917 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3921 // This removes any dangling pointers to this window
3922 // in other windows' constraintsInvolvedIn lists.
3923 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3927 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3928 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3929 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3930 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3931 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3932 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3933 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3934 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3935 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3936 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3937 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3938 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3939 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3940 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3941 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3942 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3946 // Back-pointer to other windows we're involved with, so if we delete
3947 // this window, we must delete any constraints we're involved with.
3948 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3950 if (!m_constraintsInvolvedIn
)
3951 m_constraintsInvolvedIn
= new wxList
;
3952 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3953 m_constraintsInvolvedIn
->Append(otherWin
);
3956 // REMOVE back-pointer to other windows we're involved with.
3957 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3959 if (m_constraintsInvolvedIn
)
3960 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3963 // Reset any constraints that mention this window
3964 void wxWindow::DeleteRelatedConstraints()
3966 if (m_constraintsInvolvedIn
)
3968 wxNode
*node
= m_constraintsInvolvedIn
->First();
3971 wxWindow
*win
= (wxWindow
*)node
->Data();
3972 wxNode
*next
= node
->Next();
3973 wxLayoutConstraints
*constr
= win
->GetConstraints();
3975 // Reset any constraints involving this window
3978 constr
->left
.ResetIfWin((wxWindow
*)this);
3979 constr
->top
.ResetIfWin((wxWindow
*)this);
3980 constr
->right
.ResetIfWin((wxWindow
*)this);
3981 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3982 constr
->width
.ResetIfWin((wxWindow
*)this);
3983 constr
->height
.ResetIfWin((wxWindow
*)this);
3984 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3985 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3990 delete m_constraintsInvolvedIn
;
3991 m_constraintsInvolvedIn
= NULL
;
3995 void wxWindow::SetSizer(wxSizer
*sizer
)
3997 m_windowSizer
= sizer
;
3999 sizer
->SetSizerParent((wxWindow
*)this);
4006 bool wxWindow::Layout()
4008 if (GetConstraints())
4011 GetClientSize(&w
, &h
);
4012 GetConstraints()->width
.SetValue(w
);
4013 GetConstraints()->height
.SetValue(h
);
4016 // If top level (one sizer), evaluate the sizer's constraints.
4020 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
4021 GetSizer()->LayoutPhase1(&noChanges
);
4022 GetSizer()->LayoutPhase2(&noChanges
);
4023 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
4028 // Otherwise, evaluate child constraints
4029 ResetConstraints(); // Mark all constraints as unevaluated
4030 DoPhase(1); // Just one phase need if no sizers involved
4032 SetConstraintSizes(); // Recursively set the real window sizes
4038 // Do a phase of evaluating constraints:
4039 // the default behaviour. wxSizers may do a similar
4040 // thing, but also impose their own 'constraints'
4041 // and order the evaluation differently.
4042 bool wxWindow::LayoutPhase1(int *noChanges
)
4044 wxLayoutConstraints
*constr
= GetConstraints();
4047 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
4053 bool wxWindow::LayoutPhase2(int *noChanges
)
4063 // Do a phase of evaluating child constraints
4064 bool wxWindow::DoPhase(int phase
)
4066 int noIterations
= 0;
4067 int maxIterations
= 500;
4071 while ((noChanges
> 0) && (noIterations
< maxIterations
))
4075 wxNode
*node
= GetChildren().First();
4078 wxWindow
*child
= (wxWindow
*)node
->Data();
4079 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
4081 wxLayoutConstraints
*constr
= child
->GetConstraints();
4084 if (succeeded
.Member(child
))
4089 int tempNoChanges
= 0;
4090 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
4091 noChanges
+= tempNoChanges
;
4094 succeeded
.Append(child
);
4099 node
= node
->Next();
4106 void wxWindow::ResetConstraints()
4108 wxLayoutConstraints
*constr
= GetConstraints();
4111 constr
->left
.SetDone(FALSE
);
4112 constr
->top
.SetDone(FALSE
);
4113 constr
->right
.SetDone(FALSE
);
4114 constr
->bottom
.SetDone(FALSE
);
4115 constr
->width
.SetDone(FALSE
);
4116 constr
->height
.SetDone(FALSE
);
4117 constr
->centreX
.SetDone(FALSE
);
4118 constr
->centreY
.SetDone(FALSE
);
4120 wxNode
*node
= GetChildren().First();
4123 wxWindow
*win
= (wxWindow
*)node
->Data();
4124 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4125 win
->ResetConstraints();
4126 node
= node
->Next();
4130 // Need to distinguish between setting the 'fake' size for
4131 // windows and sizers, and setting the real values.
4132 void wxWindow::SetConstraintSizes(bool recurse
)
4134 wxLayoutConstraints
*constr
= GetConstraints();
4135 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4136 constr
->width
.GetDone() && constr
->height
.GetDone())
4138 int x
= constr
->left
.GetValue();
4139 int y
= constr
->top
.GetValue();
4140 int w
= constr
->width
.GetValue();
4141 int h
= constr
->height
.GetValue();
4143 // If we don't want to resize this window, just move it...
4144 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4145 (constr
->height
.GetRelationship() != wxAsIs
))
4147 // Calls Layout() recursively. AAAGH. How can we stop that.
4148 // Simply take Layout() out of non-top level OnSizes.
4149 SizerSetSize(x
, y
, w
, h
);
4158 char *windowClass
= this->GetClassInfo()->GetClassName();
4161 if (GetName() == "")
4162 winName
= "unnamed";
4164 winName
= GetName();
4165 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4166 (const char *)windowClass
, (const char *)winName
);
4167 if (!constr
->left
.GetDone())
4168 wxLogDebug(" unsatisfied 'left' constraint.");
4169 if (!constr
->right
.GetDone())
4170 wxLogDebug(" unsatisfied 'right' constraint.");
4171 if (!constr
->width
.GetDone())
4172 wxLogDebug(" unsatisfied 'width' constraint.");
4173 if (!constr
->height
.GetDone())
4174 wxLogDebug(" unsatisfied 'height' constraint.");
4175 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
4180 wxNode
*node
= GetChildren().First();
4183 wxWindow
*win
= (wxWindow
*)node
->Data();
4184 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4185 win
->SetConstraintSizes();
4186 node
= node
->Next();
4191 // This assumes that all sizers are 'on' the same
4192 // window, i.e. the parent of this window.
4193 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4195 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4196 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4200 m_sizerParent
->GetPosition(&xp
, &yp
);
4201 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4206 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4210 TransformSizerToActual(&xx
, &yy
);
4211 SetSize(xx
, yy
, w
, h
);
4214 void wxWindow::SizerMove(int x
, int y
)
4218 TransformSizerToActual(&xx
, &yy
);
4222 // Only set the size/position of the constraint (if any)
4223 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4225 wxLayoutConstraints
*constr
= GetConstraints();
4230 constr
->left
.SetValue(x
);
4231 constr
->left
.SetDone(TRUE
);
4235 constr
->top
.SetValue(y
);
4236 constr
->top
.SetDone(TRUE
);
4240 constr
->width
.SetValue(w
);
4241 constr
->width
.SetDone(TRUE
);
4245 constr
->height
.SetValue(h
);
4246 constr
->height
.SetDone(TRUE
);
4251 void wxWindow::MoveConstraint(int x
, int y
)
4253 wxLayoutConstraints
*constr
= GetConstraints();
4258 constr
->left
.SetValue(x
);
4259 constr
->left
.SetDone(TRUE
);
4263 constr
->top
.SetValue(y
);
4264 constr
->top
.SetDone(TRUE
);
4269 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4271 wxLayoutConstraints
*constr
= GetConstraints();
4274 *w
= constr
->width
.GetValue();
4275 *h
= constr
->height
.GetValue();
4281 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4283 wxLayoutConstraints
*constr
= GetConstraints();
4286 *w
= constr
->width
.GetValue();
4287 *h
= constr
->height
.GetValue();
4290 GetClientSize(w
, h
);
4293 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4295 wxLayoutConstraints
*constr
= GetConstraints();
4298 *x
= constr
->left
.GetValue();
4299 *y
= constr
->top
.GetValue();
4305 bool wxWindow::Close(bool force
)
4307 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4308 event
.SetEventObject(this);
4309 #if WXWIN_COMPATIBILITY
4310 event
.SetForce(force
);
4312 event
.SetCanVeto(!force
);
4314 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4317 wxObject
* wxWindow::GetChild(int number
) const
4319 // Return a pointer to the Nth object in the Panel
4320 // if (!GetChildren())
4322 wxNode
*node
= GetChildren().First();
4325 node
= node
->Next() ;
4328 wxObject
*obj
= (wxObject
*)node
->Data();
4335 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4337 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4338 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4341 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4343 wxListBox *lbox = (wxListBox *)initiatingItem;
4344 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4345 event.m_commandInt = -1;
4346 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4348 event.m_commandString = copystring(lbox->GetStringSelection());
4349 event.m_commandInt = lbox->GetSelection();
4350 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4352 event.m_eventObject = lbox;
4354 lbox->ProcessCommand(event);
4356 if (event.m_commandString)
4357 delete[] event.m_commandString;
4361 wxButton *but = GetDefaultItem();
4364 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4365 event.SetEventObject(but);
4366 but->Command(event);
4371 void wxWindow::Clear()
4373 wxClientDC
dc(this);
4374 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4375 dc
.SetBackground(brush
);
4379 // Fits the panel around the items
4380 void wxWindow::Fit()
4384 wxNode
*node
= GetChildren().First();
4387 wxWindow
*win
= (wxWindow
*)node
->Data();
4389 win
->GetPosition(&wx
, &wy
);
4390 win
->GetSize(&ww
, &wh
);
4391 if ( wx
+ ww
> maxX
)
4393 if ( wy
+ wh
> maxY
)
4396 node
= node
->Next();
4398 SetClientSize(maxX
+ 5, maxY
+ 5);
4401 void wxWindow::SetValidator(const wxValidator
& validator
)
4403 if ( m_windowValidator
)
4404 delete m_windowValidator
;
4405 m_windowValidator
= validator
.Clone();
4407 if ( m_windowValidator
)
4408 m_windowValidator
->SetWindow(this) ;
4411 // Find a window by id or name
4412 wxWindow
*wxWindow::FindWindow(long id
)
4417 wxNode
*node
= GetChildren().First();
4420 wxWindow
*child
= (wxWindow
*)node
->Data();
4421 wxWindow
*found
= child
->FindWindow(id
);
4424 node
= node
->Next();
4429 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4431 if ( GetName() == name
)
4434 wxNode
*node
= GetChildren().First();
4437 wxWindow
*child
= (wxWindow
*)node
->Data();
4438 wxWindow
*found
= child
->FindWindow(name
);
4441 node
= node
->Next();
4447 // Default input behaviour for a scrolling canvas should be to scroll
4448 // according to the cursor keys pressed
4449 void wxWindow::OnChar(wxKeyEvent& event)
4461 GetScrollUnitsPerPage(&x_page, &y_page);
4463 GetVirtualSize(&v_width,&v_height);
4465 ViewStart(&start_x, &start_y);
4468 y_pages = (int)(v_height/vert_units) - y_page;
4476 switch (event.keyCode)
4483 if (start_y - y_page > 0)
4484 Scroll(start_x, start_y - y_page);
4494 if ((y_page > 0) && (start_y <= y_pages-y-1))
4496 if (y_pages + y < start_y + y_page)
4497 Scroll(start_x, y_pages + y);
4499 Scroll(start_x, start_y + y_page);
4506 if ((y_page > 0) && (start_y >= 1))
4507 Scroll(start_x, start_y - 1);
4513 if ((y_page > 0) && (start_y <= y_pages-y-1))
4516 Scroll(start_x, start_y + 1);
4522 if ((x_page > 0) && (start_x >= 1))
4523 Scroll(start_x - 1, start_y);
4529 Scroll(start_x + 1, start_y);
4540 Scroll(start_x, y_pages+y);
4548 // Setup background and foreground colours correctly
4549 void wxWindow::SetupColours()
4552 SetBackgroundColour(GetParent()->GetBackgroundColour());
4555 void wxWindow::OnIdle(wxIdleEvent
& event
)
4557 // Check if we need to send a LEAVE event
4558 if (m_mouseInWindow
)
4561 ::GetCursorPos(&pt
);
4562 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4564 // Generate a LEAVE event
4565 m_mouseInWindow
= FALSE
;
4568 if (::GetKeyState(VK_SHIFT
) != 0)
4570 if (::GetKeyState(VK_CONTROL
) != 0)
4571 state
|= MK_CONTROL
;
4573 // Unfortunately the mouse button and keyboard state may have changed
4574 // by the time the OnIdle function is called, so 'state' may be
4577 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4583 // Raise the window to the top of the Z order
4584 void wxWindow::Raise()
4586 ::BringWindowToTop((HWND
) GetHWND());
4589 // Lower the window to the bottom of the Z order
4590 void wxWindow::Lower()
4592 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4595 long wxWindow::MSWGetDlgCode()
4597 // default: just forward to def window proc (the msg has no parameters)
4598 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4601 bool wxWindow::AcceptsFocus() const
4603 // invisible and disabled controls don't need focus
4604 return IsShown() && IsEnabled();
4607 // Update region access
4608 wxRegion
wxWindow::GetUpdateRegion() const
4610 return m_updateRegion
;
4613 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4615 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4618 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4620 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4623 bool wxWindow::IsExposed(const wxRect
& rect
) const
4625 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4628 // Set this window to be the child of 'parent'.
4629 bool wxWindow::Reparent(wxWindow
*parent
)
4631 if (parent
== GetParent())
4634 // Unlink this window from the existing parent.
4637 GetParent()->RemoveChild(this);
4640 wxTopLevelWindows
.DeleteObject(this);
4642 HWND hWndParent
= 0;
4643 HWND hWndChild
= (HWND
) GetHWND();
4644 if (parent
!= (wxWindow
*) NULL
)
4646 parent
->AddChild(this);
4647 hWndParent
= (HWND
) parent
->GetHWND();
4650 wxTopLevelWindows
.Append(this);
4652 ::SetParent(hWndChild
, hWndParent
);
4658 const char *wxGetMessageName(int message
)
4660 switch ( message
) {
4661 case 0x0000: return "WM_NULL";
4662 case 0x0001: return "WM_CREATE";
4663 case 0x0002: return "WM_DESTROY";
4664 case 0x0003: return "WM_MOVE";
4665 case 0x0005: return "WM_SIZE";
4666 case 0x0006: return "WM_ACTIVATE";
4667 case 0x0007: return "WM_SETFOCUS";
4668 case 0x0008: return "WM_KILLFOCUS";
4669 case 0x000A: return "WM_ENABLE";
4670 case 0x000B: return "WM_SETREDRAW";
4671 case 0x000C: return "WM_SETTEXT";
4672 case 0x000D: return "WM_GETTEXT";
4673 case 0x000E: return "WM_GETTEXTLENGTH";
4674 case 0x000F: return "WM_PAINT";
4675 case 0x0010: return "WM_CLOSE";
4676 case 0x0011: return "WM_QUERYENDSESSION";
4677 case 0x0012: return "WM_QUIT";
4678 case 0x0013: return "WM_QUERYOPEN";
4679 case 0x0014: return "WM_ERASEBKGND";
4680 case 0x0015: return "WM_SYSCOLORCHANGE";
4681 case 0x0016: return "WM_ENDSESSION";
4682 case 0x0017: return "WM_SYSTEMERROR";
4683 case 0x0018: return "WM_SHOWWINDOW";
4684 case 0x0019: return "WM_CTLCOLOR";
4685 case 0x001A: return "WM_WININICHANGE";
4686 case 0x001B: return "WM_DEVMODECHANGE";
4687 case 0x001C: return "WM_ACTIVATEAPP";
4688 case 0x001D: return "WM_FONTCHANGE";
4689 case 0x001E: return "WM_TIMECHANGE";
4690 case 0x001F: return "WM_CANCELMODE";
4691 case 0x0020: return "WM_SETCURSOR";
4692 case 0x0021: return "WM_MOUSEACTIVATE";
4693 case 0x0022: return "WM_CHILDACTIVATE";
4694 case 0x0023: return "WM_QUEUESYNC";
4695 case 0x0024: return "WM_GETMINMAXINFO";
4696 case 0x0026: return "WM_PAINTICON";
4697 case 0x0027: return "WM_ICONERASEBKGND";
4698 case 0x0028: return "WM_NEXTDLGCTL";
4699 case 0x002A: return "WM_SPOOLERSTATUS";
4700 case 0x002B: return "WM_DRAWITEM";
4701 case 0x002C: return "WM_MEASUREITEM";
4702 case 0x002D: return "WM_DELETEITEM";
4703 case 0x002E: return "WM_VKEYTOITEM";
4704 case 0x002F: return "WM_CHARTOITEM";
4705 case 0x0030: return "WM_SETFONT";
4706 case 0x0031: return "WM_GETFONT";
4707 case 0x0037: return "WM_QUERYDRAGICON";
4708 case 0x0039: return "WM_COMPAREITEM";
4709 case 0x0041: return "WM_COMPACTING";
4710 case 0x0044: return "WM_COMMNOTIFY";
4711 case 0x0046: return "WM_WINDOWPOSCHANGING";
4712 case 0x0047: return "WM_WINDOWPOSCHANGED";
4713 case 0x0048: return "WM_POWER";
4716 case 0x004A: return "WM_COPYDATA";
4717 case 0x004B: return "WM_CANCELJOURNAL";
4718 case 0x004E: return "WM_NOTIFY";
4719 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4720 case 0x0051: return "WM_INPUTLANGCHANGE";
4721 case 0x0052: return "WM_TCARD";
4722 case 0x0053: return "WM_HELP";
4723 case 0x0054: return "WM_USERCHANGED";
4724 case 0x0055: return "WM_NOTIFYFORMAT";
4725 case 0x007B: return "WM_CONTEXTMENU";
4726 case 0x007C: return "WM_STYLECHANGING";
4727 case 0x007D: return "WM_STYLECHANGED";
4728 case 0x007E: return "WM_DISPLAYCHANGE";
4729 case 0x007F: return "WM_GETICON";
4730 case 0x0080: return "WM_SETICON";
4733 case 0x0081: return "WM_NCCREATE";
4734 case 0x0082: return "WM_NCDESTROY";
4735 case 0x0083: return "WM_NCCALCSIZE";
4736 case 0x0084: return "WM_NCHITTEST";
4737 case 0x0085: return "WM_NCPAINT";
4738 case 0x0086: return "WM_NCACTIVATE";
4739 case 0x0087: return "WM_GETDLGCODE";
4740 case 0x00A0: return "WM_NCMOUSEMOVE";
4741 case 0x00A1: return "WM_NCLBUTTONDOWN";
4742 case 0x00A2: return "WM_NCLBUTTONUP";
4743 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4744 case 0x00A4: return "WM_NCRBUTTONDOWN";
4745 case 0x00A5: return "WM_NCRBUTTONUP";
4746 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4747 case 0x00A7: return "WM_NCMBUTTONDOWN";
4748 case 0x00A8: return "WM_NCMBUTTONUP";
4749 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4750 case 0x0100: return "WM_KEYDOWN";
4751 case 0x0101: return "WM_KEYUP";
4752 case 0x0102: return "WM_CHAR";
4753 case 0x0103: return "WM_DEADCHAR";
4754 case 0x0104: return "WM_SYSKEYDOWN";
4755 case 0x0105: return "WM_SYSKEYUP";
4756 case 0x0106: return "WM_SYSCHAR";
4757 case 0x0107: return "WM_SYSDEADCHAR";
4758 case 0x0108: return "WM_KEYLAST";
4761 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4762 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4763 case 0x010F: return "WM_IME_COMPOSITION";
4766 case 0x0110: return "WM_INITDIALOG";
4767 case 0x0111: return "WM_COMMAND";
4768 case 0x0112: return "WM_SYSCOMMAND";
4769 case 0x0113: return "WM_TIMER";
4770 case 0x0114: return "WM_HSCROLL";
4771 case 0x0115: return "WM_VSCROLL";
4772 case 0x0116: return "WM_INITMENU";
4773 case 0x0117: return "WM_INITMENUPOPUP";
4774 case 0x011F: return "WM_MENUSELECT";
4775 case 0x0120: return "WM_MENUCHAR";
4776 case 0x0121: return "WM_ENTERIDLE";
4777 case 0x0200: return "WM_MOUSEMOVE";
4778 case 0x0201: return "WM_LBUTTONDOWN";
4779 case 0x0202: return "WM_LBUTTONUP";
4780 case 0x0203: return "WM_LBUTTONDBLCLK";
4781 case 0x0204: return "WM_RBUTTONDOWN";
4782 case 0x0205: return "WM_RBUTTONUP";
4783 case 0x0206: return "WM_RBUTTONDBLCLK";
4784 case 0x0207: return "WM_MBUTTONDOWN";
4785 case 0x0208: return "WM_MBUTTONUP";
4786 case 0x0209: return "WM_MBUTTONDBLCLK";
4787 case 0x0210: return "WM_PARENTNOTIFY";
4788 case 0x0211: return "WM_ENTERMENULOOP";
4789 case 0x0212: return "WM_EXITMENULOOP";
4792 case 0x0213: return "WM_NEXTMENU";
4793 case 0x0214: return "WM_SIZING";
4794 case 0x0215: return "WM_CAPTURECHANGED";
4795 case 0x0216: return "WM_MOVING";
4796 case 0x0218: return "WM_POWERBROADCAST";
4797 case 0x0219: return "WM_DEVICECHANGE";
4800 case 0x0220: return "WM_MDICREATE";
4801 case 0x0221: return "WM_MDIDESTROY";
4802 case 0x0222: return "WM_MDIACTIVATE";
4803 case 0x0223: return "WM_MDIRESTORE";
4804 case 0x0224: return "WM_MDINEXT";
4805 case 0x0225: return "WM_MDIMAXIMIZE";
4806 case 0x0226: return "WM_MDITILE";
4807 case 0x0227: return "WM_MDICASCADE";
4808 case 0x0228: return "WM_MDIICONARRANGE";
4809 case 0x0229: return "WM_MDIGETACTIVE";
4810 case 0x0230: return "WM_MDISETMENU";
4811 case 0x0233: return "WM_DROPFILES";
4814 case 0x0281: return "WM_IME_SETCONTEXT";
4815 case 0x0282: return "WM_IME_NOTIFY";
4816 case 0x0283: return "WM_IME_CONTROL";
4817 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4818 case 0x0285: return "WM_IME_SELECT";
4819 case 0x0286: return "WM_IME_CHAR";
4820 case 0x0290: return "WM_IME_KEYDOWN";
4821 case 0x0291: return "WM_IME_KEYUP";
4824 case 0x0300: return "WM_CUT";
4825 case 0x0301: return "WM_COPY";
4826 case 0x0302: return "WM_PASTE";
4827 case 0x0303: return "WM_CLEAR";
4828 case 0x0304: return "WM_UNDO";
4829 case 0x0305: return "WM_RENDERFORMAT";
4830 case 0x0306: return "WM_RENDERALLFORMATS";
4831 case 0x0307: return "WM_DESTROYCLIPBOARD";
4832 case 0x0308: return "WM_DRAWCLIPBOARD";
4833 case 0x0309: return "WM_PAINTCLIPBOARD";
4834 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4835 case 0x030B: return "WM_SIZECLIPBOARD";
4836 case 0x030C: return "WM_ASKCBFORMATNAME";
4837 case 0x030D: return "WM_CHANGECBCHAIN";
4838 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4839 case 0x030F: return "WM_QUERYNEWPALETTE";
4840 case 0x0310: return "WM_PALETTEISCHANGING";
4841 case 0x0311: return "WM_PALETTECHANGED";
4844 // common controls messages - although they're not strictly speaking
4845 // standard, it's nice to decode them nevertheless
4848 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4849 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4850 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4851 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4852 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4853 case 0x1000 + 5: return "LVM_GETITEMA";
4854 case 0x1000 + 75: return "LVM_GETITEMW";
4855 case 0x1000 + 6: return "LVM_SETITEMA";
4856 case 0x1000 + 76: return "LVM_SETITEMW";
4857 case 0x1000 + 7: return "LVM_INSERTITEMA";
4858 case 0x1000 + 77: return "LVM_INSERTITEMW";
4859 case 0x1000 + 8: return "LVM_DELETEITEM";
4860 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4861 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4862 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4863 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4864 case 0x1000 + 13: return "LVM_FINDITEMA";
4865 case 0x1000 + 83: return "LVM_FINDITEMW";
4866 case 0x1000 + 14: return "LVM_GETITEMRECT";
4867 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4868 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4869 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4870 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4871 case 0x1000 + 18: return "LVM_HITTEST";
4872 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4873 case 0x1000 + 20: return "LVM_SCROLL";
4874 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4875 case 0x1000 + 22: return "LVM_ARRANGE";
4876 case 0x1000 + 23: return "LVM_EDITLABELA";
4877 case 0x1000 + 118: return "LVM_EDITLABELW";
4878 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4879 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4880 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4881 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4882 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4883 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4884 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4885 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4886 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4887 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4888 case 0x1000 + 31: return "LVM_GETHEADER";
4889 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4890 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4891 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4892 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4893 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4894 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4895 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4896 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4897 case 0x1000 + 41: return "LVM_GETORIGIN";
4898 case 0x1000 + 42: return "LVM_UPDATE";
4899 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4900 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4901 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4902 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4903 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4904 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4905 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4906 case 0x1000 + 48: return "LVM_SORTITEMS";
4907 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4908 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4909 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4910 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4911 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4912 case 0x1000 + 53: return "LVM_SETICONSPACING";
4913 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4914 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4915 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4916 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4917 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4918 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4919 case 0x1000 + 60: return "LVM_SETHOTITEM";
4920 case 0x1000 + 61: return "LVM_GETHOTITEM";
4921 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4922 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4923 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4924 case 0x1000 + 65: return "LVM_SETWORKAREA";
4927 case 0x1100 + 0: return "TVM_INSERTITEMA";
4928 case 0x1100 + 50: return "TVM_INSERTITEMW";
4929 case 0x1100 + 1: return "TVM_DELETEITEM";
4930 case 0x1100 + 2: return "TVM_EXPAND";
4931 case 0x1100 + 4: return "TVM_GETITEMRECT";
4932 case 0x1100 + 5: return "TVM_GETCOUNT";
4933 case 0x1100 + 6: return "TVM_GETINDENT";
4934 case 0x1100 + 7: return "TVM_SETINDENT";
4935 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4936 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4937 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4938 case 0x1100 + 11: return "TVM_SELECTITEM";
4939 case 0x1100 + 12: return "TVM_GETITEMA";
4940 case 0x1100 + 62: return "TVM_GETITEMW";
4941 case 0x1100 + 13: return "TVM_SETITEMA";
4942 case 0x1100 + 63: return "TVM_SETITEMW";
4943 case 0x1100 + 14: return "TVM_EDITLABELA";
4944 case 0x1100 + 65: return "TVM_EDITLABELW";
4945 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4946 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4947 case 0x1100 + 17: return "TVM_HITTEST";
4948 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4949 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4950 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4951 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4952 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4953 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4954 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4955 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4956 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4959 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4960 case 0x1200 + 1: return "HDM_INSERTITEMA";
4961 case 0x1200 + 10: return "HDM_INSERTITEMW";
4962 case 0x1200 + 2: return "HDM_DELETEITEM";
4963 case 0x1200 + 3: return "HDM_GETITEMA";
4964 case 0x1200 + 11: return "HDM_GETITEMW";
4965 case 0x1200 + 4: return "HDM_SETITEMA";
4966 case 0x1200 + 12: return "HDM_SETITEMW";
4967 case 0x1200 + 5: return "HDM_LAYOUT";
4968 case 0x1200 + 6: return "HDM_HITTEST";
4969 case 0x1200 + 7: return "HDM_GETITEMRECT";
4970 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4971 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4972 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4973 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4974 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4975 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4976 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4979 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4980 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4981 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4982 case 0x1300 + 5: return "TCM_GETITEMA";
4983 case 0x1300 + 60: return "TCM_GETITEMW";
4984 case 0x1300 + 6: return "TCM_SETITEMA";
4985 case 0x1300 + 61: return "TCM_SETITEMW";
4986 case 0x1300 + 7: return "TCM_INSERTITEMA";
4987 case 0x1300 + 62: return "TCM_INSERTITEMW";
4988 case 0x1300 + 8: return "TCM_DELETEITEM";
4989 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4990 case 0x1300 + 10: return "TCM_GETITEMRECT";
4991 case 0x1300 + 11: return "TCM_GETCURSEL";
4992 case 0x1300 + 12: return "TCM_SETCURSEL";
4993 case 0x1300 + 13: return "TCM_HITTEST";
4994 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4995 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4996 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4997 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4998 case 0x1300 + 43: return "TCM_SETPADDING";
4999 case 0x1300 + 44: return "TCM_GETROWCOUNT";
5000 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
5001 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
5002 case 0x1300 + 47: return "TCM_GETCURFOCUS";
5003 case 0x1300 + 48: return "TCM_SETCURFOCUS";
5004 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
5005 case 0x1300 + 50: return "TCM_DESELECTALL";
5008 case WM_USER
+1: return "TB_ENABLEBUTTON";
5009 case WM_USER
+2: return "TB_CHECKBUTTON";
5010 case WM_USER
+3: return "TB_PRESSBUTTON";
5011 case WM_USER
+4: return "TB_HIDEBUTTON";
5012 case WM_USER
+5: return "TB_INDETERMINATE";
5013 case WM_USER
+9: return "TB_ISBUTTONENABLED";
5014 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
5015 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
5016 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
5017 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
5018 case WM_USER
+17: return "TB_SETSTATE";
5019 case WM_USER
+18: return "TB_GETSTATE";
5020 case WM_USER
+19: return "TB_ADDBITMAP";
5021 case WM_USER
+20: return "TB_ADDBUTTONS";
5022 case WM_USER
+21: return "TB_INSERTBUTTON";
5023 case WM_USER
+22: return "TB_DELETEBUTTON";
5024 case WM_USER
+23: return "TB_GETBUTTON";
5025 case WM_USER
+24: return "TB_BUTTONCOUNT";
5026 case WM_USER
+25: return "TB_COMMANDTOINDEX";
5027 case WM_USER
+26: return "TB_SAVERESTOREA";
5028 case WM_USER
+76: return "TB_SAVERESTOREW";
5029 case WM_USER
+27: return "TB_CUSTOMIZE";
5030 case WM_USER
+28: return "TB_ADDSTRINGA";
5031 case WM_USER
+77: return "TB_ADDSTRINGW";
5032 case WM_USER
+29: return "TB_GETITEMRECT";
5033 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
5034 case WM_USER
+31: return "TB_SETBUTTONSIZE";
5035 case WM_USER
+32: return "TB_SETBITMAPSIZE";
5036 case WM_USER
+33: return "TB_AUTOSIZE";
5037 case WM_USER
+35: return "TB_GETTOOLTIPS";
5038 case WM_USER
+36: return "TB_SETTOOLTIPS";
5039 case WM_USER
+37: return "TB_SETPARENT";
5040 case WM_USER
+39: return "TB_SETROWS";
5041 case WM_USER
+40: return "TB_GETROWS";
5042 case WM_USER
+42: return "TB_SETCMDID";
5043 case WM_USER
+43: return "TB_CHANGEBITMAP";
5044 case WM_USER
+44: return "TB_GETBITMAP";
5045 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
5046 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
5047 case WM_USER
+46: return "TB_REPLACEBITMAP";
5048 case WM_USER
+47: return "TB_SETINDENT";
5049 case WM_USER
+48: return "TB_SETIMAGELIST";
5050 case WM_USER
+49: return "TB_GETIMAGELIST";
5051 case WM_USER
+50: return "TB_LOADIMAGES";
5052 case WM_USER
+51: return "TB_GETRECT";
5053 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
5054 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
5055 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
5056 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
5057 case WM_USER
+56: return "TB_SETSTYLE";
5058 case WM_USER
+57: return "TB_GETSTYLE";
5059 case WM_USER
+58: return "TB_GETBUTTONSIZE";
5060 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
5061 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
5062 case WM_USER
+61: return "TB_GETTEXTROWS";
5063 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
5068 static char s_szBuf
[128];
5069 sprintf(s_szBuf
, "<unknown message = %d>", message
);
5073 #endif //__WXDEBUG__