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"
62 #include "wx/textctrl.h"
75 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
81 #include <wx/msw/gnuwin32/extra.h>
85 // all these are defined in <windows.h>
103 const char *wxGetMessageName(int message
);
106 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
108 wxMenu
*wxCurrentPopupMenu
= NULL
;
109 extern wxList WXDLLEXPORT wxPendingDelete
;
111 void wxRemoveHandleAssociation(wxWindow
*win
);
112 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
113 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
115 #if !USE_SHARED_LIBRARY
116 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
119 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
120 EVT_CHAR(wxWindow::OnChar
)
121 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
122 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
123 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
124 EVT_IDLE(wxWindow::OnIdle
)
127 // Find an item given the MS Windows id
128 wxWindow
*wxWindow::FindItem(int id
) const
130 // if (!GetChildren())
132 wxNode
*current
= GetChildren().First();
135 wxWindow
*childWin
= (wxWindow
*)current
->Data();
137 wxWindow
*wnd
= childWin
->FindItem(id
) ;
141 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
143 wxControl
*item
= (wxControl
*)childWin
;
144 if (item
->GetId() == id
)
148 // In case it's a 'virtual' control (e.g. radiobox)
149 if (item
->GetSubcontrols().Member((wxObject
*)id
))
153 current
= current
->Next();
158 // Find an item given the MS Windows handle
159 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
161 // if (!GetChildren())
163 wxNode
*current
= GetChildren().First();
166 wxObject
*obj
= (wxObject
*)current
->Data() ;
167 // Do a recursive search.
168 wxWindow
*parent
= (wxWindow
*)obj
;
169 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
173 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
175 wxWindow
*item
= (wxWindow
*)current
->Data();
176 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
180 if ( item
->ContainsHWND(hWnd
) )
184 current
= current
->Next();
189 // Default command handler
190 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
195 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
197 WXLPARAM
* WXUNUSED(result
))
201 NMHDR
* hdr
= (NMHDR
*)lParam
;
202 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
204 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
205 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
216 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
220 WXHWND
wxWindow::GetHWND(void) const
222 return (WXHWND
) m_hWnd
;
225 void wxWindow::SetHWND(WXHWND hWnd
)
230 // ----------------------------------------------------------------------------
231 // constructors and such
232 // ----------------------------------------------------------------------------
234 void wxWindow::Init()
239 // m_windowCursor = * wxSTANDARD_CURSOR;
243 m_windowParent
= NULL
;
244 m_windowEventHandler
= this;
245 m_children
= new wxList
;
246 m_doubleClickAllowed
= 0 ;
247 m_winCaptured
= FALSE
;
248 m_constraints
= NULL
;
249 m_constraintsInvolvedIn
= NULL
;
250 m_windowSizer
= NULL
;
251 m_sizerParent
= NULL
;
252 m_autoLayout
= FALSE
;
253 m_windowValidator
= NULL
;
258 m_caretWidth
= m_caretHeight
= 0;
260 m_caretShown
= FALSE
;
267 m_isBeingDeleted
= FALSE
;
273 m_mouseInWindow
= FALSE
;
275 m_windowParent
= NULL
;
276 m_defaultItem
= NULL
;
278 wxSystemSettings settings
;
280 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
281 m_foregroundColour
= *wxBLACK
;
291 m_backgroundTransparent
= FALSE
;
293 m_lastXPos
= (float)-1.0;
294 m_lastYPos
= (float)-1.0;
298 #if wxUSE_DRAG_AND_DROP
299 m_pDropTarget
= NULL
;
313 wxWindow::~wxWindow()
315 m_isBeingDeleted
= TRUE
;
317 // first of all, delete the things on which nothing else depends
323 // JACS - if behaviour is odd, restore this
324 // to the start of ~wxWindow. Vadim has changed
325 // it to nearer the end. Unsure of side-effects
326 // e.g. when deleting associated global data.
327 // Restore old Window proc, if required
330 // Have to delete constraints/sizer FIRST otherwise
331 // sizers may try to look at deleted windows as they
332 // delete themselves.
333 #if wxUSE_CONSTRAINTS
334 DeleteRelatedConstraints();
338 // This removes any dangling pointers to this window
339 // in other windows' constraintsInvolvedIn lists.
340 UnsetConstraints(m_constraints
);
341 delete m_constraints
;
342 m_constraints
= NULL
;
345 wxDELETE(m_windowSizer
);
347 // If this is a child of a sizer, remove self from parent
349 m_sizerParent
->RemoveChild((wxWindow
*)this);
353 MSWDetachWindowMenu();
356 m_windowParent
->RemoveChild(this);
361 ::DestroyWindow((HWND
)m_hWnd
);
363 wxRemoveHandleAssociation(this);
368 GlobalFree((HGLOBAL
) m_globalHandle
);
376 // Just in case the window has been Closed, but
377 // we're then deleting immediately: don't leave
378 // dangling pointers.
379 wxPendingDelete
.DeleteObject(this);
381 // Just in case we've loaded a top-level window via
382 // wxWindow::LoadNativeDialog but we weren't a dialog
384 wxTopLevelWindows
.DeleteObject(this);
386 if ( m_windowValidator
)
387 delete m_windowValidator
;
389 // Restore old Window proc, if required
390 // and remove hWnd <-> wxWindow association
394 // Destroy the window (delayed, if a managed window)
395 bool wxWindow::Destroy()
401 extern char wxCanvasClassName
[];
403 // real construction (Init() must have been called before!)
404 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
408 const wxString
& name
)
410 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
412 parent
->AddChild(this);
417 m_windowId
= (int)NewControlId();
426 // To be consistent with wxGTK
432 wxSystemSettings settings
;
434 m_windowStyle
= style
;
437 if (style
& wxBORDER
)
438 msflags
|= WS_BORDER
;
439 if (style
& wxTHICK_FRAME
)
440 msflags
|= WS_THICKFRAME
;
442 msflags
|= WS_CHILD
| WS_VISIBLE
;
443 if (style
& wxCLIP_CHILDREN
)
444 msflags
|= WS_CLIPCHILDREN
;
447 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
449 // Even with extended styles, need to combine with WS_BORDER
450 // for them to look right.
451 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
452 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
453 msflags
|= WS_BORDER
;
455 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
456 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
461 void wxWindow::SetFocus()
463 HWND hWnd
= (HWND
) GetHWND();
468 void wxWindow::Enable(bool enable
)
470 m_winEnabled
= enable
;
471 HWND hWnd
= (HWND
) GetHWND();
473 ::EnableWindow(hWnd
, (BOOL
)enable
);
476 void wxWindow::CaptureMouse()
478 HWND hWnd
= (HWND
) GetHWND();
479 if (hWnd
&& !m_winCaptured
)
482 m_winCaptured
= TRUE
;
486 void wxWindow::ReleaseMouse()
491 m_winCaptured
= FALSE
;
495 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
497 m_acceleratorTable
= accel
;
501 // Push/pop event handler (i.e. allow a chain of event handlers
503 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
505 handler
->SetNextHandler(GetEventHandler());
506 SetEventHandler(handler
);
509 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
511 if ( GetEventHandler() )
513 wxEvtHandler
*handlerA
= GetEventHandler();
514 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
515 handlerA
->SetNextHandler(NULL
);
516 SetEventHandler(handlerB
);
529 #if wxUSE_DRAG_AND_DROP
531 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
533 if ( m_pDropTarget
!= 0 ) {
534 m_pDropTarget
->Revoke(m_hWnd
);
535 delete m_pDropTarget
;
538 m_pDropTarget
= pDropTarget
;
539 if ( m_pDropTarget
!= 0 )
540 m_pDropTarget
->Register(m_hWnd
);
543 #endif // wxUSE_DRAG_AND_DROP
546 //old style file-manager drag&drop support
547 // I think we should retain the old-style
548 // DragAcceptFiles in parallel with SetDropTarget.
550 void wxWindow::DragAcceptFiles(bool accept
)
552 HWND hWnd
= (HWND
) GetHWND();
554 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
557 // ----------------------------------------------------------------------------
559 // ----------------------------------------------------------------------------
563 void wxWindow::SetToolTip(const wxString
&tip
)
565 SetToolTip(new wxToolTip(tip
));
568 void wxWindow::SetToolTip(wxToolTip
*tooltip
)
574 m_tooltip
->SetWindow(this);
577 #endif // wxUSE_TOOLTIPS
580 void wxWindow::GetSize(int *x
, int *y
) const
582 HWND hWnd
= (HWND
) GetHWND();
584 GetWindowRect(hWnd
, &rect
);
585 *x
= rect
.right
- rect
.left
;
586 *y
= rect
.bottom
- rect
.top
;
589 void wxWindow::GetPosition(int *x
, int *y
) const
591 HWND hWnd
= (HWND
) GetHWND();
594 hParentWnd
= (HWND
) GetParent()->GetHWND();
597 GetWindowRect(hWnd
, &rect
);
599 // Since we now have the absolute screen coords,
600 // if there's a parent we must subtract its top left corner
606 ::ScreenToClient(hParentWnd
, &point
);
609 // We may be faking the client origin.
610 // So a window that's really at (0, 30) may appear
611 // (to wxWin apps) to be at (0, 0).
614 wxPoint
pt(GetParent()->GetClientAreaOrigin());
622 void wxWindow::ScreenToClient(int *x
, int *y
) const
624 HWND hWnd
= (HWND
) GetHWND();
629 ::ScreenToClient(hWnd
, &pt
);
635 void wxWindow::ClientToScreen(int *x
, int *y
) const
637 HWND hWnd
= (HWND
) GetHWND();
642 ::ClientToScreen(hWnd
, &pt
);
648 void wxWindow::SetCursor(const wxCursor
& cursor
)
650 m_windowCursor
= cursor
;
651 if (m_windowCursor
.Ok())
653 HWND hWnd
= (HWND
) GetHWND();
655 // Change the cursor NOW if we're within the correct window
657 ::GetCursorPos(&point
);
660 ::GetWindowRect(hWnd
, &rect
);
662 if (::PtInRect(&rect
, point
) && !wxIsBusy())
663 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
666 // This will cause big reentrancy problems if wxFlushEvents is implemented.
668 // return old_cursor;
672 // Get size *available for subwindows* i.e. excluding menu bar etc.
673 void wxWindow::GetClientSize(int *x
, int *y
) const
675 HWND hWnd
= (HWND
) GetHWND();
677 ::GetClientRect(hWnd
, &rect
);
682 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
684 int currentX
, currentY
;
685 GetPosition(¤tX
, ¤tY
);
686 int currentW
,currentH
;
687 GetSize(¤tW
, ¤tH
);
689 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
692 int actualWidth
= width
;
693 int actualHeight
= height
;
696 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
698 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
701 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
704 actualWidth
= currentW
;
706 actualHeight
= currentH
;
708 HWND hWnd
= (HWND
) GetHWND();
710 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
713 void wxWindow::DoSetClientSize(int width
, int height
)
715 wxWindow
*parent
= GetParent();
716 HWND hWnd
= (HWND
) GetHWND();
717 HWND hParentWnd
= (HWND
) 0;
719 hParentWnd
= (HWND
) parent
->GetHWND();
722 ::GetClientRect(hWnd
, &rect
);
725 GetWindowRect(hWnd
, &rect2
);
727 // Find the difference between the entire window (title bar and all)
728 // and the client area; add this to the new client size to move the
730 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
731 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
733 // If there's a parent, must subtract the parent's top left corner
734 // since MoveWindow moves relative to the parent
737 point
.x
= rect2
.left
;
741 ::ScreenToClient(hParentWnd
, &point
);
744 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
746 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
747 event
.SetEventObject(this);
748 GetEventHandler()->ProcessEvent(event
);
751 // For implementation purposes - sometimes decorations make the client area
753 wxPoint
wxWindow::GetClientAreaOrigin() const
755 return wxPoint(0, 0);
758 // Makes an adjustment to the window position (for example, a frame that has
759 // a toolbar that it manages itself).
760 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
762 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
764 wxPoint
pt(GetParent()->GetClientAreaOrigin());
765 x
+= pt
.x
; y
+= pt
.y
;
769 bool wxWindow::Show(bool show
)
772 HWND hWnd
= (HWND
) GetHWND();
778 ShowWindow(hWnd
, cshow
);
781 BringWindowToTop(hWnd
);
782 // Next line causes a crash on NT, apparently.
783 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
788 bool wxWindow::IsShown(void) const
790 // Can't rely on IsWindowVisible, since it will return FALSE
791 // if the parent is not visible.
793 // int ret = ::IsWindowVisible((HWND) GetHWND()) ;
794 // return (ret != 0);
797 int wxWindow::GetCharHeight(void) const
799 TEXTMETRIC lpTextMetric
;
800 HWND hWnd
= (HWND
) GetHWND();
801 HDC dc
= ::GetDC(hWnd
);
803 GetTextMetrics(dc
, &lpTextMetric
);
804 ::ReleaseDC(hWnd
, dc
);
806 return lpTextMetric
.tmHeight
;
809 int wxWindow::GetCharWidth(void) const
811 TEXTMETRIC lpTextMetric
;
812 HWND hWnd
= (HWND
) GetHWND();
813 HDC dc
= ::GetDC(hWnd
);
815 GetTextMetrics(dc
, &lpTextMetric
);
816 ::ReleaseDC(hWnd
, dc
);
818 return lpTextMetric
.tmAveCharWidth
;
821 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
822 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
824 wxFont
*fontToUse
= (wxFont
*)theFont
;
826 fontToUse
= (wxFont
*) & m_windowFont
;
828 HWND hWnd
= (HWND
) GetHWND();
829 HDC dc
= ::GetDC(hWnd
);
833 if (fontToUse
&& fontToUse
->Ok())
835 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
837 was
= (HFONT
) SelectObject(dc
,fnt
) ;
842 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
843 GetTextMetrics(dc
, &tm
);
845 if (fontToUse
&& fnt
&& was
)
846 SelectObject(dc
,was
) ;
852 if (descent
) *descent
= tm
.tmDescent
;
853 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
856 // fontToUse->ReleaseResource();
859 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
861 HWND hWnd
= (HWND
) GetHWND();
867 mswRect
.left
= rect
->x
;
868 mswRect
.top
= rect
->y
;
869 mswRect
.right
= rect
->x
+ rect
->width
;
870 mswRect
.bottom
= rect
->y
+ rect
->height
;
872 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
875 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
879 bool wxWindow::ProcessEvent(wxEvent
& event
)
881 // we save here the information about the last message because it might be
882 // overwritten if the event handler sends any messages to our window (case
883 // in point: wxNotebook::OnSize) - and then if we call Default() later
884 // (which is done quite often if the message is not processed) it will use
885 // incorrect values for m_lastXXX variables
886 WXUINT lastMsg
= m_lastMsg
;
887 WXWPARAM lastWParam
= m_lastWParam
;
888 WXLPARAM lastLParam
= m_lastLParam
;
890 // call the base version
891 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
895 m_lastWParam
= lastWParam
;
896 m_lastLParam
= lastLParam
;
901 // Hook for new window just as it's being created,
902 // when the window isn't yet associated with the handle
903 wxWindow
*wxWndHook
= NULL
;
906 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
908 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
910 if (!wnd
&& wxWndHook
)
912 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
915 wnd
->m_hWnd
= (WXHWND
) hWnd
;
918 // Stop right here if we don't have a valid handle in our wxWindow object.
919 if (wnd
&& !wnd
->m_hWnd
) {
920 wnd
->m_hWnd
= (WXHWND
) hWnd
;
921 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
927 wnd
->m_lastMsg
= message
;
928 wnd
->m_lastWParam
= wParam
;
929 wnd
->m_lastLParam
= lParam
;
932 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
934 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
937 // Should probably have a test for 'genuine' NT
938 #if defined(__WIN32__)
939 #define DIMENSION_TYPE short
941 #define DIMENSION_TYPE int
944 // Main Windows window proc
945 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
947 wxASSERT( m_lastMsg
== message
&&
948 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
951 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
952 wxGetMessageName(message
), wParam
, lParam
);
953 #endif // __WXDEBUG__
955 HWND hWnd
= (HWND
)m_hWnd
;
962 WORD state
= LOWORD(wParam
);
963 WORD minimized
= HIWORD(wParam
);
964 HWND hwnd
= (HWND
)lParam
;
966 WORD state
= (WORD
)wParam
;
967 WORD minimized
= LOWORD(lParam
);
968 HWND hwnd
= (HWND
)HIWORD(lParam
);
970 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
976 HWND hwnd
= (HWND
)wParam
;
977 // return OnSetFocus(hwnd);
979 if (MSWOnSetFocus((WXHWND
) hwnd
))
981 else return MSWDefWindowProc(message
, wParam
, lParam
);
986 HWND hwnd
= (HWND
)lParam
;
987 // return OnKillFocus(hwnd);
988 if (MSWOnKillFocus((WXHWND
) hwnd
))
991 return MSWDefWindowProc(message
, wParam
, lParam
);
996 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
1002 MSWOnShow((wParam
!= 0), (int) lParam
);
1009 else return MSWDefWindowProc(message
, wParam
, lParam
);
1012 case WM_QUERYDRAGICON
:
1014 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
1018 return MSWDefWindowProc(message
, wParam
, lParam
);
1024 int width
= LOWORD(lParam
);
1025 int height
= HIWORD(lParam
);
1026 MSWOnSize(width
, height
, wParam
);
1032 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1034 event
.SetEventObject(this);
1035 if ( !GetEventHandler()->ProcessEvent(event
) )
1040 case WM_WINDOWPOSCHANGING
:
1042 MSWOnWindowPosChanging((void *)lParam
);
1046 case WM_RBUTTONDOWN
:
1048 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1049 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1050 MSWOnRButtonDown(x
, y
, wParam
);
1055 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1056 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1057 MSWOnRButtonUp(x
, y
, wParam
);
1060 case WM_RBUTTONDBLCLK
:
1062 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1063 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1064 MSWOnRButtonDClick(x
, y
, wParam
);
1067 case WM_MBUTTONDOWN
:
1069 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1070 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1071 MSWOnMButtonDown(x
, y
, wParam
);
1076 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1077 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1078 MSWOnMButtonUp(x
, y
, wParam
);
1081 case WM_MBUTTONDBLCLK
:
1083 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1084 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1085 MSWOnMButtonDClick(x
, y
, wParam
);
1088 case WM_LBUTTONDOWN
:
1090 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1091 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1092 MSWOnLButtonDown(x
, y
, wParam
);
1097 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1098 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1099 MSWOnLButtonUp(x
, y
, wParam
);
1102 case WM_LBUTTONDBLCLK
:
1104 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1105 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1106 MSWOnLButtonDClick(x
, y
, wParam
);
1111 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1112 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1113 MSWOnMouseMove(x
, y
, wParam
);
1116 case MM_JOY1BUTTONDOWN
:
1118 int x
= LOWORD(lParam
);
1119 int y
= HIWORD(lParam
);
1120 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1123 case MM_JOY2BUTTONDOWN
:
1125 int x
= LOWORD(lParam
);
1126 int y
= HIWORD(lParam
);
1127 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1130 case MM_JOY1BUTTONUP
:
1132 int x
= LOWORD(lParam
);
1133 int y
= HIWORD(lParam
);
1134 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1137 case MM_JOY2BUTTONUP
:
1139 int x
= LOWORD(lParam
);
1140 int y
= HIWORD(lParam
);
1141 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1146 int x
= LOWORD(lParam
);
1147 int y
= HIWORD(lParam
);
1148 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1153 int x
= LOWORD(lParam
);
1154 int y
= HIWORD(lParam
);
1155 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1160 int z
= LOWORD(lParam
);
1161 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1166 int z
= LOWORD(lParam
);
1167 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1174 else return MSWDefWindowProc(message
, wParam
, lParam
);
1179 return MSWOnSysCommand(wParam
, lParam
);
1186 WORD id
= LOWORD(wParam
);
1187 HWND hwnd
= (HWND
)lParam
;
1188 WORD cmd
= HIWORD(wParam
);
1190 WORD id
= (WORD
)wParam
;
1191 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1192 WORD cmd
= HIWORD(lParam
);
1194 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1195 return MSWDefWindowProc(message
, wParam
, lParam
);
1198 #if defined(__WIN95__)
1201 // for some messages (TVN_ITEMEXPANDING for example), the return
1202 // value of WM_NOTIFY handler is important, so don't just return 0
1203 // if we processed the message
1204 return MSWOnNotify(wParam
, lParam
);
1210 WORD flags
= HIWORD(wParam
);
1211 HMENU sysmenu
= (HMENU
)lParam
;
1213 WORD flags
= LOWORD(lParam
);
1214 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1216 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1219 case WM_INITMENUPOPUP
:
1221 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1226 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1229 case WM_MEASUREITEM
:
1231 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1235 // If this has been processed by an event handler,
1236 // return 0 now (we've handled it).
1237 if ( MSWOnKeyDown((WORD
) wParam
, lParam
) )
1240 // we consider these message "not interesting" to OnChar
1241 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1248 // avoid duplicate messages to OnChar for these ASCII keys: they
1249 // will be translated by TranslateMessage() and received in WM_CHAR
1259 // normally these macros would be defined in windows.h
1260 #ifndef GET_X_LPARAM
1261 #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
1262 #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
1265 // special case of VK_APPS: treat it the same as right mouse click
1266 // because both usually pop up a context menu
1269 // construct the key mask
1270 WPARAM fwKeys
= MK_RBUTTON
;
1271 if ( (::GetKeyState(VK_CONTROL
) & 0x100) != 0 )
1272 fwKeys
|= MK_CONTROL
;
1273 if ( (::GetKeyState(VK_SHIFT
) & 0x100) != 0 )
1276 // simulate right mouse button click
1277 DWORD dwPos
= ::GetMessagePos();
1278 int x
= GET_X_LPARAM(dwPos
),
1279 y
= GET_Y_LPARAM(dwPos
);
1281 ScreenToClient(&x
, &y
);
1282 MSWOnRButtonDown(x
, y
, fwKeys
);
1292 if ( !MSWOnChar((WORD
)wParam
, lParam
) )
1301 if ( !MSWOnKeyUp((WORD
) wParam
, lParam
) )
1305 case WM_CHAR
: // Always an ASCII character
1306 if ( !MSWOnChar((WORD
)wParam
, lParam
, TRUE
) )
1313 WORD code
= LOWORD(wParam
);
1314 WORD pos
= HIWORD(wParam
);
1315 HWND control
= (HWND
)lParam
;
1317 WORD code
= (WORD
)wParam
;
1318 WORD pos
= LOWORD(lParam
);
1319 HWND control
= (HWND
)HIWORD(lParam
);
1321 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1327 WORD code
= LOWORD(wParam
);
1328 WORD pos
= HIWORD(wParam
);
1329 HWND control
= (HWND
)lParam
;
1331 WORD code
= (WORD
)wParam
;
1332 WORD pos
= LOWORD(lParam
);
1333 HWND control
= (HWND
)HIWORD(lParam
);
1335 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1339 case WM_CTLCOLORBTN
:
1341 int nCtlColor
= CTLCOLOR_BTN
;
1342 HWND control
= (HWND
)lParam
;
1343 HDC pDC
= (HDC
)wParam
;
1344 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1345 message
, wParam
, lParam
);
1348 case WM_CTLCOLORDLG
:
1350 int nCtlColor
= CTLCOLOR_DLG
;
1351 HWND control
= (HWND
)lParam
;
1352 HDC pDC
= (HDC
)wParam
;
1353 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1354 message
, wParam
, lParam
);\
1357 case WM_CTLCOLORLISTBOX
:
1359 int nCtlColor
= CTLCOLOR_LISTBOX
;
1360 HWND control
= (HWND
)lParam
;
1361 HDC pDC
= (HDC
)wParam
;
1362 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1363 message
, wParam
, lParam
);
1366 case WM_CTLCOLORMSGBOX
:
1368 int nCtlColor
= CTLCOLOR_MSGBOX
;
1369 HWND control
= (HWND
)lParam
;
1370 HDC pDC
= (HDC
)wParam
;
1371 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1372 message
, wParam
, lParam
);
1375 case WM_CTLCOLORSCROLLBAR
:
1377 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1378 HWND control
= (HWND
)lParam
;
1379 HDC pDC
= (HDC
)wParam
;
1380 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1381 message
, wParam
, lParam
);
1384 case WM_CTLCOLORSTATIC
:
1386 int nCtlColor
= CTLCOLOR_STATIC
;
1387 HWND control
= (HWND
)lParam
;
1388 HDC pDC
= (HDC
)wParam
;
1389 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1390 message
, wParam
, lParam
);
1393 case WM_CTLCOLOREDIT
:
1395 int nCtlColor
= CTLCOLOR_EDIT
;
1396 HWND control
= (HWND
)lParam
;
1397 HDC pDC
= (HDC
)wParam
;
1398 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1399 message
, wParam
, lParam
);
1405 HWND control
= (HWND
)LOWORD(lParam
);
1406 int nCtlColor
= (int)HIWORD(lParam
);
1407 HDC pDC
= (HDC
)wParam
;
1408 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1409 message
, wParam
, lParam
);
1413 case WM_SYSCOLORCHANGE
:
1415 // Return value of 0 means, we processed it.
1416 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1419 return MSWDefWindowProc(message
, wParam
, lParam
);
1422 case WM_PALETTECHANGED
:
1424 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1427 case WM_QUERYNEWPALETTE
:
1429 return MSWOnQueryNewPalette();
1434 // Prevents flicker when dragging
1435 if (IsIconic(hWnd
)) return 1;
1437 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1438 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1442 case WM_MDIACTIVATE
:
1445 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1446 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1447 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1448 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1450 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1451 (HWND
)HIWORD(lParam
));
1456 MSWOnDropFiles(wParam
);
1461 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1464 case WM_QUERYENDSESSION
:
1466 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1467 // return MSWOnClose();
1469 return MSWOnQueryEndSession(lParam
);
1474 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1475 MSWOnEndSession((wParam
!= 0), lParam
);
1487 case WM_GETMINMAXINFO
:
1489 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1490 if (m_minSizeX
!= -1)
1491 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1492 if (m_minSizeY
!= -1)
1493 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1494 if (m_maxSizeX
!= -1)
1495 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1496 if (m_maxSizeY
!= -1)
1497 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1498 return MSWDefWindowProc(message
, wParam
, lParam
);
1503 return MSWGetDlgCode();
1507 // don't set cursor for other windows, only for this one: this
1508 // prevents children of this window from gettign the same cursor
1509 // as the parent has (don't forget that this message is propagated
1510 // by default up the window parent-child hierarchy)
1511 if ( (HWND
)wParam
== hWnd
)
1513 // don't set cursor when the mouse is not in the client part
1514 short nHitTest
= LOWORD(lParam
);
1515 if ( nHitTest
== HTCLIENT
|| nHitTest
== HTERROR
)
1517 HCURSOR hcursor
= 0;
1520 // from msw\utils.cpp
1521 extern HCURSOR gs_wxBusyCursor
;
1523 hcursor
= gs_wxBusyCursor
;
1527 wxCursor
*cursor
= NULL
;
1529 if ( m_windowCursor
.Ok() )
1531 cursor
= &m_windowCursor
;
1535 // from msw\data.cpp
1536 extern wxCursor
*g_globalCursor
;
1538 if ( g_globalCursor
&& g_globalCursor
->Ok() )
1539 cursor
= g_globalCursor
;
1543 hcursor
= (HCURSOR
)cursor
->GetHCURSOR();
1548 ::SetCursor(hcursor
);
1550 // returning TRUE stops the DefWindowProc() from
1551 // further processing this message - exactly what we
1552 // need because we've just set the cursor.
1558 return MSWDefWindowProc(message
, wParam
, lParam
);
1561 return MSWDefWindowProc(message
, wParam
, lParam
);
1564 return 0; // Success: we processed this command.
1567 // Dialog window proc
1568 LONG APIENTRY _EXPORT
1569 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1574 wxList
*wxWinHandleList
= NULL
;
1575 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1577 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1580 return (wxWindow
*)node
->Data();
1583 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1585 // adding NULL hWnd is (first) surely a result of an error and
1586 // (secondly) breaks menu command processing
1587 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1589 if ( !wxWinHandleList
->Find((long)hWnd
) )
1590 wxWinHandleList
->Append((long)hWnd
, win
);
1593 void wxRemoveHandleAssociation(wxWindow
*win
)
1595 wxWinHandleList
->DeleteObject(win
);
1598 // Default destroyer - override if you destroy it in some other way
1599 // (e.g. with MDI child windows)
1600 void wxWindow::MSWDestroyWindow()
1604 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1605 int x
, int y
, int width
, int height
,
1606 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1608 bool is_dialog
= (dialog_template
!= NULL
);
1609 int x1
= CW_USEDEFAULT
;
1611 int width1
= CW_USEDEFAULT
;
1614 // Find parent's size, if it exists, to set up a possible default
1615 // panel size the size of the parent window
1619 // Was GetWindowRect: JACS 5/5/95
1620 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1622 width1
= parent_rect
.right
- parent_rect
.left
;
1623 height1
= parent_rect
.bottom
- parent_rect
.top
;
1628 if (width
> -1) width1
= width
;
1629 if (height
> -1) height1
= height
;
1631 HWND hParent
= NULL
;
1633 hParent
= (HWND
) parent
->GetHWND();
1639 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1640 // other compilers???
1641 // VZ: it's always needed for Win16 and never for Win32
1643 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1644 (DLGPROC
)wxDlgProc
);
1646 // N.B.: if we _don't_ use this form,
1647 // then with VC++ 1.5, it crashes horribly.
1649 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1650 (DLGPROC
)wxDlgProc
);
1652 // Crashes when we use this.
1653 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1655 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1661 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1662 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1663 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1668 if (style
& WS_CHILD
)
1673 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1678 hParent
, (HMENU
)controlId
, wxGetInstance(),
1682 wxLogError("Can't create window of class %s!\n"
1683 "Possible Windows 3.x compatibility problem?", wclass
);
1688 wxWinHandleList
->Append((long)m_hWnd
, this);
1691 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1695 bool wxWindow::MSWOnClose()
1700 // Some compilers don't define this
1701 #ifndef ENDSESSION_LOGOFF
1702 #define ENDSESSION_LOGOFF 0x80000000
1705 // Return TRUE to end session, FALSE to veto end session.
1706 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1708 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1709 event
.SetEventObject(wxTheApp
);
1710 event
.SetCanVeto(TRUE
);
1711 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1712 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1713 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1715 return FALSE
; // Veto!
1719 return TRUE
; // Don't veto
1723 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1725 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1726 event
.SetEventObject(wxTheApp
);
1727 event
.SetCanVeto(FALSE
);
1728 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1729 if (endSession
&& // No need to send if the session isn't ending
1730 (this == wxTheApp
->GetTopWindow()) && // Only send once
1731 wxTheApp
->ProcessEvent(event
))
1737 bool wxWindow::MSWOnDestroy()
1739 // delete our drop target if we've got one
1740 #if wxUSE_DRAG_AND_DROP
1741 if ( m_pDropTarget
!= NULL
) {
1742 m_pDropTarget
->Revoke(m_hWnd
);
1744 delete m_pDropTarget
;
1745 m_pDropTarget
= NULL
;
1752 // Deal with child commands from buttons etc.
1754 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1756 #if defined(__WIN95__)
1757 // Find a child window to send the notification to, e.g. a toolbar.
1758 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1759 // handle of the toolbar; it's probably the handle of the tooltip
1760 // window (anyway, it's parent is also the toolbar's parent).
1761 // So, since we don't know which hWnd or wxWindow originated the
1762 // WM_NOTIFY, we'll need to go through all the children of this window
1763 // trying out MSWNotify.
1764 // This won't work now, though, because any number of controls
1765 // could respond to the same generic messages :-(
1767 /* This doesn't work for toolbars, but try for other controls first.
1769 NMHDR
*hdr
= (NMHDR
*)lParam
;
1770 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1771 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1773 WXLPARAM result
= 0;
1777 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1782 // Rely on MSWNotify to check whether the message
1783 // belongs to the window or not
1784 wxNode
*node
= GetChildren().First();
1787 wxWindow
*child
= (wxWindow
*)node
->Data();
1788 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1790 node
= node
->Next();
1793 // finally try this window too (catches toolbar case)
1794 if ( MSWNotify(wParam
, lParam
, &result
) )
1803 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1807 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1811 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1813 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1815 event
.SetEventObject(this);
1816 GetEventHandler()->ProcessEvent(event
);
1820 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1823 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1825 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1827 ::ShowCaret((HWND
) GetHWND());
1830 // panel wants to track the window which was the last to have focus in it
1831 wxWindow
*parent
= GetParent();
1832 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1834 ((wxPanel
*)parent
)->SetLastFocus(GetId());
1837 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1838 event
.SetEventObject(this);
1839 if (!GetEventHandler()->ProcessEvent(event
))
1844 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1852 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1853 event
.SetEventObject(this);
1854 if (!GetEventHandler()->ProcessEvent(event
))
1859 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1862 HDROP hFilesInfo
= (HDROP
) wParam
;
1864 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1866 // Get the total number of files dropped
1867 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1872 wxString
*files
= new wxString
[gwFilesDropped
];
1874 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1876 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1877 files
[wIndex
] = wxBuffer
;
1879 DragFinish (hFilesInfo
);
1881 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1882 event
.m_eventObject
= this;
1883 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1885 if (!GetEventHandler()->ProcessEvent(event
))
1891 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1893 #if wxUSE_OWNER_DRAWN
1894 if ( id
== 0 ) { // is it a menu item?
1895 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1896 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1897 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1899 // prepare to call OnDrawItem()
1901 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1902 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1903 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1904 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1905 return pMenuItem
->OnDrawItem(
1907 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1908 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1911 #endif // owner-drawn menus
1913 wxWindow
*item
= FindItem(id
);
1914 #if wxUSE_DYNAMIC_CLASSES
1915 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1917 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1924 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1926 #if wxUSE_OWNER_DRAWN
1927 if ( id
== 0 ) { // is it a menu item?
1928 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1929 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1930 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1932 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1933 &pMeasureStruct
->itemHeight
);
1935 #endif // owner-drawn menus
1937 wxWindow
*item
= FindItem(id
);
1938 #if wxUSE_DYNAMIC_CLASSES
1939 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1941 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1948 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1949 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1951 if (nCtlColor
== CTLCOLOR_DLG
)
1953 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1956 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1958 WXHBRUSH hBrush
= 0;
1961 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1963 // I think that even for dialogs, we may need to call DefWindowProc (?)
1964 // Or maybe just rely on the usual default behaviour.
1966 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1971 // Define for each class of dialog and control
1972 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1973 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1975 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1978 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1980 wxSysColourChangedEvent event
;
1981 event
.SetEventObject(this);
1983 // Check if app handles this.
1984 if (GetEventHandler()->ProcessEvent(event
))
1987 // We didn't process it
1991 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1993 wxPaletteChangedEvent
event(GetId());
1994 event
.SetEventObject(this);
1995 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1996 GetEventHandler()->ProcessEvent(event
);
2000 long wxWindow::MSWOnQueryNewPalette()
2002 wxQueryNewPaletteEvent
event(GetId());
2003 event
.SetEventObject(this);
2004 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
2006 return (long) FALSE
;
2012 // Responds to colour changes: passes event on to children.
2013 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
2015 wxNode
*node
= GetChildren().First();
2018 // Only propagate to non-top-level windows
2019 wxWindow
*win
= (wxWindow
*)node
->Data();
2020 if ( win
->GetParent() )
2022 wxSysColourChangedEvent event2
;
2023 event
.m_eventObject
= win
;
2024 win
->GetEventHandler()->ProcessEvent(event2
);
2027 node
= node
->Next();
2031 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
2034 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
2036 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
2039 long wxWindow::Default()
2041 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
2046 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
2047 wxGetMessageName(m_lastMsg
));
2048 #endif // __WXDEBUG__
2050 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
2053 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
2055 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
2056 // intercept dialog navigation keys
2057 MSG
*msg
= (MSG
*)pMsg
;
2058 bool bProcess
= TRUE
;
2059 if ( msg
->message
!= WM_KEYDOWN
)
2062 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2067 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
2069 // WM_GETDLGCODE: ask the control if it wants the key for itself,
2070 // don't process it if it's the case (except for Ctrl-Tab/Enter
2071 // combinations which are always processed)
2075 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
2078 bool bForward
= TRUE
,
2079 bWindowChange
= FALSE
;
2081 switch ( msg
->wParam
)
2084 if ( lDlgCode
& DLGC_WANTTAB
) {
2088 // Ctrl-Tab cycles thru notebook pages
2089 bWindowChange
= bCtrlDown
;
2090 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
2096 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2104 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2110 if ( lDlgCode
& DLGC_WANTMESSAGE
)
2112 // control wants to process Enter itself, don't
2113 // call IsDialogMessage() which would interpret
2118 wxButton
*btnDefault
= GetDefaultItem();
2119 if ( btnDefault
&& !bCtrlDown
)
2121 // if there is a default button, Enter should
2123 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
2127 // else: but if there is not it makes sense to make it
2128 // work like a TAB - and that's what we do.
2129 // Note that Ctrl-Enter always works this way.
2140 wxNavigationKeyEvent event
;
2141 event
.SetDirection(bForward
);
2142 event
.SetWindowChange(bWindowChange
);
2143 event
.SetEventObject(this);
2145 if ( GetEventHandler()->ProcessEvent(event
) )
2150 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
2157 // relay mouse move events to the tooltip control
2158 MSG
*msg
= (MSG
*)pMsg
;
2159 if ( msg
->message
== WM_MOUSEMOVE
)
2160 m_tooltip
->RelayEvent(pMsg
);
2162 #endif // wxUSE_TOOLTIPS
2164 /* This code manages to disable character input completely. Nice one!
2165 * Probably because the dialog is requesting all char input. Or,
2166 * it gets called by non-dialog windows.
2168 // In case we don't have wxTAB_TRAVERSAL style on.
2169 // If we don't call this, we may never process Enter correctly.
2170 if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) == 0 )
2172 MSG *msg = (MSG *)pMsg;
2173 if ( ::IsDialogMessage((HWND)GetHWND(), msg) )
2180 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2182 if (m_acceleratorTable
.Ok() &&
2183 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2189 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2194 void wxWindow::MSWDetachWindowMenu()
2198 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2200 for (i
= 0; i
< N
; i
++)
2203 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2204 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2206 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2213 bool wxWindow::MSWOnPaint()
2216 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2217 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2219 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2222 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2224 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2225 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2228 wxPaintEvent
event(m_windowId
);
2229 event
.SetEventObject(this);
2230 if (!GetEventHandler()->ProcessEvent(event
))
2235 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2245 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2246 event
.SetEventObject(this);
2247 if (!GetEventHandler()->ProcessEvent(event
))
2253 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2258 // Deal with child commands from buttons etc.
2259 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2261 if (wxCurrentPopupMenu
)
2263 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2264 wxCurrentPopupMenu
= NULL
;
2265 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2269 wxWindow
*item
= FindItem(id
);
2272 bool value
= item
->MSWCommand(cmd
, id
);
2277 wxWindow
*win
= wxFindWinFromHandle(control
);
2279 return win
->MSWCommand(cmd
, id
);
2284 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2286 switch (wParam
& 0xFFFFFFF0)
2290 wxMaximizeEvent
event(m_windowId
);
2291 event
.SetEventObject(this);
2292 if (!GetEventHandler()->ProcessEvent(event
))
2300 wxIconizeEvent
event(m_windowId
);
2301 event
.SetEventObject(this);
2302 if (!GetEventHandler()->ProcessEvent(event
))
2314 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2316 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2318 event
.m_x
= x
; event
.m_y
= y
;
2319 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2320 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2321 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2322 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2323 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2324 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2325 event
.m_eventObject
= this;
2327 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2329 if (!GetEventHandler()->ProcessEvent(event
))
2333 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2335 wxMouseEvent
event(wxEVT_LEFT_UP
);
2337 event
.m_x
= x
; event
.m_y
= y
;
2338 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2339 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2340 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2341 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2342 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2343 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2344 event
.m_eventObject
= this;
2346 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2348 if (!GetEventHandler()->ProcessEvent(event
))
2352 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2354 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2356 event
.m_x
= x
; event
.m_y
= y
;
2357 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2358 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2359 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2360 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2361 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2362 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2363 event
.m_eventObject
= this;
2365 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2367 if (!GetEventHandler()->ProcessEvent(event
))
2371 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2373 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2375 event
.m_x
= x
; event
.m_y
= y
;
2376 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2377 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2378 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2379 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2380 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2381 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2382 event
.m_eventObject
= this;
2384 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2386 if (!GetEventHandler()->ProcessEvent(event
))
2390 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2392 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2394 event
.m_x
= x
; event
.m_y
= y
;
2395 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2396 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2397 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2398 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2399 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2400 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2401 event
.m_eventObject
= this;
2403 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2405 if (!GetEventHandler()->ProcessEvent(event
))
2409 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2411 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2413 event
.m_x
= x
; event
.m_y
= y
;
2414 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2415 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2416 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2417 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2418 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2419 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2420 event
.m_eventObject
= this;
2422 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2424 if (!GetEventHandler()->ProcessEvent(event
))
2428 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2430 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2432 event
.m_x
= x
; event
.m_y
= y
;
2433 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2434 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2435 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2436 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2437 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2438 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2439 event
.m_eventObject
= this;
2441 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2443 if (!GetEventHandler()->ProcessEvent(event
))
2447 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2449 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2451 event
.m_x
= x
; event
.m_y
= y
;
2452 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2453 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2454 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2455 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2456 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2457 event
.m_eventObject
= this;
2458 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2460 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2462 if (!GetEventHandler()->ProcessEvent(event
))
2466 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2468 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2470 event
.m_x
= x
; event
.m_y
= y
;
2471 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2472 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2473 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2474 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2475 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2476 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2477 event
.m_eventObject
= this;
2479 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2481 if (!GetEventHandler()->ProcessEvent(event
))
2485 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2487 // 'normal' move event...
2489 if (!m_mouseInWindow
)
2491 // Generate an ENTER event
2492 m_mouseInWindow
= TRUE
;
2493 MSWOnMouseEnter(x
, y
, flags
);
2496 wxMouseEvent
event(wxEVT_MOTION
);
2498 event
.m_x
= x
; event
.m_y
= y
;
2499 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2500 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2501 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2502 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2503 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2504 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2505 event
.m_eventObject
= this;
2507 // Window gets a click down message followed by a mouse move
2508 // message even if position isn't changed! We want to discard
2509 // the trailing move event if x and y are the same.
2510 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2511 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2512 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2514 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2515 m_lastEvent
= wxEVT_MOTION
;
2519 m_lastEvent
= wxEVT_MOTION
;
2520 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2522 if (!GetEventHandler()->ProcessEvent(event
))
2526 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2528 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2530 event
.m_x
= x
; event
.m_y
= y
;
2531 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2532 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2533 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2534 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2535 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2536 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2537 event
.m_eventObject
= this;
2539 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2540 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2541 // No message - ensure we don't try to call the default behaviour accidentally.
2543 GetEventHandler()->ProcessEvent(event
);
2546 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2548 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2550 event
.m_x
= x
; event
.m_y
= y
;
2551 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2552 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2553 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2554 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2555 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2556 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2557 event
.m_eventObject
= this;
2559 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2560 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2561 // No message - ensure we don't try to call the default behaviour accidentally.
2563 GetEventHandler()->ProcessEvent(event
);
2566 // isASCII is TRUE only when we're called from WM_CHAR handler and not from
2568 bool wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2571 bool tempControlDown
= FALSE
;
2574 // If 1 -> 26, translate to CTRL plus a letter.
2576 if ((id
> 0) && (id
< 27))
2597 tempControlDown
= TRUE
;
2603 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2604 // it's ASCII and will be processed here only when called from
2605 // WM_CHAR (i.e. when isASCII = TRUE)
2611 wxKeyEvent
event(wxEVT_CHAR
);
2612 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2613 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2614 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2615 event
.m_altDown
= TRUE
;
2617 event
.m_eventObject
= this;
2618 event
.m_keyCode
= id
;
2619 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2624 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2628 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2630 if (GetEventHandler()->ProcessEvent(event
))
2639 bool wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
)
2643 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2649 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2650 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2651 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2652 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2653 event
.m_altDown
= TRUE
;
2655 event
.m_eventObject
= this;
2656 event
.m_keyCode
= id
;
2657 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2662 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2666 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2668 if (GetEventHandler()->ProcessEvent(event
))
2680 bool wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
)
2684 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2690 wxKeyEvent
event(wxEVT_KEY_UP
);
2691 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2692 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2693 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2694 event
.m_altDown
= TRUE
;
2696 event
.m_eventObject
= this;
2697 event
.m_keyCode
= id
;
2698 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2703 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2707 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2709 if (GetEventHandler()->ProcessEvent(event
))
2718 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2722 if (flags
& JOY_BUTTON1CHG
)
2723 change
= wxJOY_BUTTON1
;
2724 if (flags
& JOY_BUTTON2CHG
)
2725 change
= wxJOY_BUTTON2
;
2726 if (flags
& JOY_BUTTON3CHG
)
2727 change
= wxJOY_BUTTON3
;
2728 if (flags
& JOY_BUTTON4CHG
)
2729 change
= wxJOY_BUTTON4
;
2731 if (flags
& JOY_BUTTON1
)
2732 buttons
|= wxJOY_BUTTON1
;
2733 if (flags
& JOY_BUTTON2
)
2734 buttons
|= wxJOY_BUTTON2
;
2735 if (flags
& JOY_BUTTON3
)
2736 buttons
|= wxJOY_BUTTON3
;
2737 if (flags
& JOY_BUTTON4
)
2738 buttons
|= wxJOY_BUTTON4
;
2740 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2741 event
.SetPosition(wxPoint(x
, y
));
2742 event
.SetEventObject(this);
2744 GetEventHandler()->ProcessEvent(event
);
2747 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2751 if (flags
& JOY_BUTTON1CHG
)
2752 change
= wxJOY_BUTTON1
;
2753 if (flags
& JOY_BUTTON2CHG
)
2754 change
= wxJOY_BUTTON2
;
2755 if (flags
& JOY_BUTTON3CHG
)
2756 change
= wxJOY_BUTTON3
;
2757 if (flags
& JOY_BUTTON4CHG
)
2758 change
= wxJOY_BUTTON4
;
2760 if (flags
& JOY_BUTTON1
)
2761 buttons
|= wxJOY_BUTTON1
;
2762 if (flags
& JOY_BUTTON2
)
2763 buttons
|= wxJOY_BUTTON2
;
2764 if (flags
& JOY_BUTTON3
)
2765 buttons
|= wxJOY_BUTTON3
;
2766 if (flags
& JOY_BUTTON4
)
2767 buttons
|= wxJOY_BUTTON4
;
2769 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2770 event
.SetPosition(wxPoint(x
, y
));
2771 event
.SetEventObject(this);
2773 GetEventHandler()->ProcessEvent(event
);
2776 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2779 if (flags
& JOY_BUTTON1
)
2780 buttons
|= wxJOY_BUTTON1
;
2781 if (flags
& JOY_BUTTON2
)
2782 buttons
|= wxJOY_BUTTON2
;
2783 if (flags
& JOY_BUTTON3
)
2784 buttons
|= wxJOY_BUTTON3
;
2785 if (flags
& JOY_BUTTON4
)
2786 buttons
|= wxJOY_BUTTON4
;
2788 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2789 event
.SetPosition(wxPoint(x
, y
));
2790 event
.SetEventObject(this);
2792 GetEventHandler()->ProcessEvent(event
);
2795 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2798 if (flags
& JOY_BUTTON1
)
2799 buttons
|= wxJOY_BUTTON1
;
2800 if (flags
& JOY_BUTTON2
)
2801 buttons
|= wxJOY_BUTTON2
;
2802 if (flags
& JOY_BUTTON3
)
2803 buttons
|= wxJOY_BUTTON3
;
2804 if (flags
& JOY_BUTTON4
)
2805 buttons
|= wxJOY_BUTTON4
;
2807 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2808 event
.SetZPosition(z
);
2809 event
.SetEventObject(this);
2811 GetEventHandler()->ProcessEvent(event
);
2814 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2818 wxWindow
*child
= wxFindWinFromHandle(control
);
2820 child
->MSWOnVScroll(wParam
, pos
, control
);
2824 wxScrollEvent event
;
2825 event
.SetPosition(pos
);
2826 event
.SetOrientation(wxVERTICAL
);
2827 event
.m_eventObject
= this;
2832 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2836 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2840 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2844 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2848 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2852 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2856 case SB_THUMBPOSITION
:
2857 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2865 if (!GetEventHandler()->ProcessEvent(event
))
2869 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2873 wxWindow
*child
= wxFindWinFromHandle(control
);
2875 child
->MSWOnHScroll(wParam
, pos
, control
);
2881 wxScrollEvent event
;
2882 event
.SetPosition(pos
);
2883 event
.SetOrientation(wxHORIZONTAL
);
2884 event
.m_eventObject
= this;
2889 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2893 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2897 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2901 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2905 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2909 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2913 case SB_THUMBPOSITION
:
2914 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2921 if ( GetEventHandler()->ProcessEvent(event
) )
2925 // call the default WM_HSCROLL handler: it's non trivial in some common
2926 // controls (up-down control for example)
2930 void wxWindow::MSWOnShow(bool show
, int status
)
2932 wxShowEvent
event(GetId(), show
);
2933 event
.m_eventObject
= this;
2934 GetEventHandler()->ProcessEvent(event
);
2937 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2939 wxInitDialogEvent
event(GetId());
2940 event
.m_eventObject
= this;
2941 GetEventHandler()->ProcessEvent(event
);
2945 void wxWindow::InitDialog()
2947 wxInitDialogEvent
event(GetId());
2948 event
.SetEventObject( this );
2949 GetEventHandler()->ProcessEvent(event
);
2952 // Default init dialog behaviour is to transfer data to window
2953 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2955 TransferDataToWindow();
2958 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2961 HDC dc
= ::GetDC((HWND
) wnd
);
2966 // the_font->UseResource();
2967 // the_font->RealizeResource();
2968 fnt
= (HFONT
)the_font
->GetResourceHandle();
2970 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2972 GetTextMetrics(dc
, &tm
);
2973 if (the_font
&& fnt
&& was
)
2975 SelectObject(dc
,was
) ;
2977 ReleaseDC((HWND
)wnd
, dc
);
2978 *x
= tm
.tmAveCharWidth
;
2979 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2982 // the_font->ReleaseResource();
2985 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2986 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2987 int wxCharCodeMSWToWX(int keySym
)
2992 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2993 case VK_BACK
: id
= WXK_BACK
; break;
2994 case VK_TAB
: id
= WXK_TAB
; break;
2995 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2996 case VK_RETURN
: id
= WXK_RETURN
; break;
2997 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2998 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2999 case VK_MENU
: id
= WXK_MENU
; break;
3000 case VK_PAUSE
: id
= WXK_PAUSE
; break;
3001 case VK_SPACE
: id
= WXK_SPACE
; break;
3002 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
3003 case VK_PRIOR
: id
= WXK_PRIOR
; break;
3004 case VK_NEXT
: id
= WXK_NEXT
; break;
3005 case VK_END
: id
= WXK_END
; break;
3006 case VK_HOME
: id
= WXK_HOME
; break;
3007 case VK_LEFT
: id
= WXK_LEFT
; break;
3008 case VK_UP
: id
= WXK_UP
; break;
3009 case VK_RIGHT
: id
= WXK_RIGHT
; break;
3010 case VK_DOWN
: id
= WXK_DOWN
; break;
3011 case VK_SELECT
: id
= WXK_SELECT
; break;
3012 case VK_PRINT
: id
= WXK_PRINT
; break;
3013 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
3014 case VK_INSERT
: id
= WXK_INSERT
; break;
3015 case VK_DELETE
: id
= WXK_DELETE
; break;
3016 case VK_HELP
: id
= WXK_HELP
; break;
3017 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
3018 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
3019 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
3020 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
3021 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
3022 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
3023 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
3024 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
3025 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
3026 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
3027 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
3028 case VK_ADD
: id
= WXK_ADD
; break;
3029 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
3030 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
3031 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
3032 case VK_F1
: id
= WXK_F1
; break;
3033 case VK_F2
: id
= WXK_F2
; break;
3034 case VK_F3
: id
= WXK_F3
; break;
3035 case VK_F4
: id
= WXK_F4
; break;
3036 case VK_F5
: id
= WXK_F5
; break;
3037 case VK_F6
: id
= WXK_F6
; break;
3038 case VK_F7
: id
= WXK_F7
; break;
3039 case VK_F8
: id
= WXK_F8
; break;
3040 case VK_F9
: id
= WXK_F9
; break;
3041 case VK_F10
: id
= WXK_F10
; break;
3042 case VK_F11
: id
= WXK_F11
; break;
3043 case VK_F12
: id
= WXK_F12
; break;
3044 case VK_F13
: id
= WXK_F13
; break;
3045 case VK_F14
: id
= WXK_F14
; break;
3046 case VK_F15
: id
= WXK_F15
; break;
3047 case VK_F16
: id
= WXK_F16
; break;
3048 case VK_F17
: id
= WXK_F17
; break;
3049 case VK_F18
: id
= WXK_F18
; break;
3050 case VK_F19
: id
= WXK_F19
; break;
3051 case VK_F20
: id
= WXK_F20
; break;
3052 case VK_F21
: id
= WXK_F21
; break;
3053 case VK_F22
: id
= WXK_F22
; break;
3054 case VK_F23
: id
= WXK_F23
; break;
3055 case VK_F24
: id
= WXK_F24
; break;
3056 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
3057 case VK_SCROLL
: id
= WXK_SCROLL
; break;
3066 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
3072 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
3073 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
3074 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
3075 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
3076 case WXK_MENU
: keySym
= VK_MENU
; break;
3077 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
3078 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
3079 case WXK_NEXT
: keySym
= VK_NEXT
; break;
3080 case WXK_END
: keySym
= VK_END
; break;
3081 case WXK_HOME
: keySym
= VK_HOME
; break;
3082 case WXK_LEFT
: keySym
= VK_LEFT
; break;
3083 case WXK_UP
: keySym
= VK_UP
; break;
3084 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
3085 case WXK_DOWN
: keySym
= VK_DOWN
; break;
3086 case WXK_SELECT
: keySym
= VK_SELECT
; break;
3087 case WXK_PRINT
: keySym
= VK_PRINT
; break;
3088 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
3089 case WXK_INSERT
: keySym
= VK_INSERT
; break;
3090 case WXK_DELETE
: keySym
= VK_DELETE
; break;
3091 case WXK_HELP
: keySym
= VK_HELP
; break;
3092 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
3093 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
3094 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
3095 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
3096 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
3097 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
3098 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
3099 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
3100 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
3101 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
3102 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
3103 case WXK_ADD
: keySym
= VK_ADD
; break;
3104 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
3105 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
3106 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
3107 case WXK_F1
: keySym
= VK_F1
; break;
3108 case WXK_F2
: keySym
= VK_F2
; break;
3109 case WXK_F3
: keySym
= VK_F3
; break;
3110 case WXK_F4
: keySym
= VK_F4
; break;
3111 case WXK_F5
: keySym
= VK_F5
; break;
3112 case WXK_F6
: keySym
= VK_F6
; break;
3113 case WXK_F7
: keySym
= VK_F7
; break;
3114 case WXK_F8
: keySym
= VK_F8
; break;
3115 case WXK_F9
: keySym
= VK_F9
; break;
3116 case WXK_F10
: keySym
= VK_F10
; break;
3117 case WXK_F11
: keySym
= VK_F11
; break;
3118 case WXK_F12
: keySym
= VK_F12
; break;
3119 case WXK_F13
: keySym
= VK_F13
; break;
3120 case WXK_F14
: keySym
= VK_F14
; break;
3121 case WXK_F15
: keySym
= VK_F15
; break;
3122 case WXK_F16
: keySym
= VK_F16
; break;
3123 case WXK_F17
: keySym
= VK_F17
; break;
3124 case WXK_F18
: keySym
= VK_F18
; break;
3125 case WXK_F19
: keySym
= VK_F19
; break;
3126 case WXK_F20
: keySym
= VK_F20
; break;
3127 case WXK_F21
: keySym
= VK_F21
; break;
3128 case WXK_F22
: keySym
= VK_F22
; break;
3129 case WXK_F23
: keySym
= VK_F23
; break;
3130 case WXK_F24
: keySym
= VK_F24
; break;
3131 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
3132 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
3143 // Caret manipulation
3144 void wxWindow::CreateCaret(int w
, int h
)
3148 m_caretEnabled
= TRUE
;
3151 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
3156 void wxWindow::ShowCaret(bool show
)
3161 ::ShowCaret((HWND
) GetHWND());
3163 ::HideCaret((HWND
) GetHWND());
3164 m_caretShown
= show
;
3168 void wxWindow::DestroyCaret()
3170 m_caretEnabled
= FALSE
;
3173 void wxWindow::SetCaretPos(int x
, int y
)
3175 ::SetCaretPos(x
, y
);
3178 void wxWindow::GetCaretPos(int *x
, int *y
) const
3181 ::GetCaretPos(&point
);
3186 wxWindow
*wxGetActiveWindow()
3188 HWND hWnd
= GetActiveWindow();
3191 return wxFindWinFromHandle((WXHWND
) hWnd
);
3196 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3197 // in active frames and dialogs, regardless of where the focus is.
3198 static HHOOK wxTheKeyboardHook
= 0;
3199 static FARPROC wxTheKeyboardHookProc
= 0;
3200 int APIENTRY _EXPORT
3201 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3203 void wxSetKeyboardHook(bool doIt
)
3207 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3208 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3209 #if defined(__WIN32__) && !defined(__TWIN32__)
3210 GetCurrentThreadId());
3211 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3218 UnhookWindowsHookEx(wxTheKeyboardHook
);
3219 FreeProcInstance(wxTheKeyboardHookProc
);
3223 int APIENTRY _EXPORT
3224 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3226 DWORD hiWord
= HIWORD(lParam
);
3227 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3230 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3232 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3233 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3234 event
.m_altDown
= TRUE
;
3236 event
.m_eventObject
= NULL
;
3237 event
.m_keyCode
= id
;
3238 /* begin Albert's fix for control and shift key 26.5 */
3239 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3240 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3241 /* end Albert's fix for control and shift key 26.5 */
3242 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3244 wxWindow
*win
= wxGetActiveWindow();
3247 if (win
->GetEventHandler()->ProcessEvent(event
))
3252 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3257 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3260 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3268 void wxWindow::Centre(int direction
)
3270 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3272 wxWindow
*father
= (wxWindow
*)GetParent();
3276 father
->GetClientSize(&panel_width
, &panel_height
);
3277 GetSize(&width
, &height
);
3278 GetPosition(&x
, &y
);
3283 if (direction
& wxHORIZONTAL
)
3284 new_x
= (int)((panel_width
- width
)/2);
3286 if (direction
& wxVERTICAL
)
3287 new_y
= (int)((panel_height
- height
)/2);
3289 SetSize(new_x
, new_y
, -1, -1);
3293 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3295 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3296 // pixel coordinates, relatives to the canvas -- So, we first need to
3297 // substract origin of the window, then convert to screen position
3299 int x
= x_pos
; int y
= y_pos
;
3301 GetWindowRect ((HWND
) GetHWND(), &rect
);
3306 SetCursorPos (x
, y
);
3309 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3313 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3321 wxEraseEvent
event(m_windowId
, &dc
);
3322 event
.m_eventObject
= this;
3323 if (!GetEventHandler()->ProcessEvent(event
))
3326 dc
.SelectOldObjects(pDC
);
3332 dc
.SelectOldObjects(pDC
);
3335 dc
.SetHDC((WXHDC
) NULL
);
3339 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3345 ::GetClientRect((HWND
) GetHWND(), &rect
);
3347 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3348 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3349 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3351 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3352 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3353 ::DeleteObject(hBrush
);
3354 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3356 // Less efficient version (and doesn't account for scrolling)
3358 GetClientSize(& w, & h);
3359 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3360 event.GetDC()->SetBrush(brush);
3361 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3363 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3367 #if WXWIN_COMPATIBILITY
3368 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3370 #if defined(__WIN95__)
3374 // Try to adjust the range to cope with page size > 1
3375 // - a Windows API quirk
3376 int pageSize
= GetScrollPage(orient
);
3377 if ( pageSize
> 1 && range
> 0)
3379 range1
+= (pageSize
- 1);
3385 if (orient
== wxHORIZONTAL
) {
3391 info
.cbSize
= sizeof(SCROLLINFO
);
3392 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3396 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3398 HWND hWnd
= (HWND
) GetHWND();
3400 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3403 if (orient
== wxHORIZONTAL
)
3408 HWND hWnd
= (HWND
) GetHWND();
3410 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3414 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3416 #if defined(__WIN95__)
3420 if (orient
== wxHORIZONTAL
) {
3422 m_xThumbSize
= page
;
3425 m_yThumbSize
= page
;
3428 info
.cbSize
= sizeof(SCROLLINFO
);
3431 info
.fMask
= SIF_PAGE
;
3433 HWND hWnd
= (HWND
) GetHWND();
3435 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3437 if (orient
== wxHORIZONTAL
)
3438 m_xThumbSize
= page
;
3440 m_yThumbSize
= page
;
3444 int wxWindow::OldGetScrollRange(int orient
) const
3447 if (orient
== wxHORIZONTAL
)
3452 #if __WATCOMC__ && defined(__WINDOWS_386__)
3453 short minPos
, maxPos
;
3457 HWND hWnd
= (HWND
) GetHWND();
3460 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3461 #if defined(__WIN95__)
3462 // Try to adjust the range to cope with page size > 1
3463 // - a Windows API quirk
3464 int pageSize
= GetScrollPage(orient
);
3467 maxPos
-= (pageSize
- 1);
3476 int wxWindow::GetScrollPage(int orient
) const
3478 if (orient
== wxHORIZONTAL
)
3479 return m_xThumbSize
;
3481 return m_yThumbSize
;
3485 int wxWindow::GetScrollPos(int orient
) const
3488 if (orient
== wxHORIZONTAL
)
3492 HWND hWnd
= (HWND
) GetHWND();
3495 return ::GetScrollPos(hWnd
, wOrient
);
3501 // This now returns the whole range, not just the number
3502 // of positions that we can scroll.
3503 int wxWindow::GetScrollRange(int orient
) const
3506 if (orient
== wxHORIZONTAL
)
3511 #if __WATCOMC__ && defined(__WINDOWS_386__)
3512 short minPos
, maxPos
;
3516 HWND hWnd
= (HWND
) GetHWND();
3519 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3520 #if defined(__WIN95__)
3521 // Try to adjust the range to cope with page size > 1
3522 // - a Windows API quirk
3523 int pageSize
= GetScrollThumb(orient
);
3526 maxPos
-= (pageSize
- 1);
3528 // October 10th: new range concept.
3538 int wxWindow::GetScrollThumb(int orient
) const
3540 if (orient
== wxHORIZONTAL
)
3541 return m_xThumbSize
;
3543 return m_yThumbSize
;
3546 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3548 #if defined(__WIN95__)
3552 if (orient
== wxHORIZONTAL
) {
3558 info
.cbSize
= sizeof(SCROLLINFO
);
3562 info
.fMask
= SIF_POS
;
3564 HWND hWnd
= (HWND
) GetHWND();
3566 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3569 if (orient
== wxHORIZONTAL
)
3574 HWND hWnd
= (HWND
) GetHWND();
3576 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3580 // New function that will replace some of the above.
3581 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3582 int range
, bool refresh
)
3585 SetScrollPage(orient, thumbVisible, FALSE);
3587 int oldRange = range - thumbVisible ;
3588 SetScrollRange(orient, oldRange, FALSE);
3590 SetScrollPos(orient, pos, refresh);
3592 #if defined(__WIN95__)
3593 int oldRange
= range
- thumbVisible
;
3595 int range1
= oldRange
;
3597 // Try to adjust the range to cope with page size > 1
3598 // - a Windows API quirk
3599 int pageSize
= thumbVisible
;
3600 if ( pageSize
> 1 && range
> 0)
3602 range1
+= (pageSize
- 1);
3608 if (orient
== wxHORIZONTAL
) {
3614 info
.cbSize
= sizeof(SCROLLINFO
);
3615 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3619 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3621 HWND hWnd
= (HWND
) GetHWND();
3623 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3626 if (orient
== wxHORIZONTAL
)
3631 HWND hWnd
= (HWND
) GetHWND();
3634 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3635 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3638 if (orient
== wxHORIZONTAL
) {
3639 m_xThumbSize
= thumbVisible
;
3641 m_yThumbSize
= thumbVisible
;
3645 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3650 rect2
.left
= rect
->x
;
3651 rect2
.top
= rect
->y
;
3652 rect2
.right
= rect
->x
+ rect
->width
;
3653 rect2
.bottom
= rect
->y
+ rect
->height
;
3657 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3659 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3662 void wxWindow::SetFont(const wxFont
& font
)
3664 m_windowFont
= font
;
3666 if (!m_windowFont
.Ok())
3669 HWND hWnd
= (HWND
) GetHWND();
3672 if (m_windowFont
.GetResourceHandle())
3673 SendMessage(hWnd
, WM_SETFONT
,
3674 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3678 void wxWindow::SubclassWin(WXHWND hWnd
)
3680 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3682 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3684 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3685 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3688 void wxWindow::UnsubclassWin()
3690 wxRemoveHandleAssociation(this);
3692 // Restore old Window proc
3693 if ((HWND
) GetHWND())
3695 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3696 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3698 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3704 // Make a Windows extended style from the given wxWindows window style
3705 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3707 WXDWORD exStyle
= 0;
3708 if ( style
& wxTRANSPARENT_WINDOW
)
3709 exStyle
|= WS_EX_TRANSPARENT
;
3711 if ( !eliminateBorders
)
3713 if ( style
& wxSUNKEN_BORDER
)
3714 exStyle
|= WS_EX_CLIENTEDGE
;
3715 if ( style
& wxDOUBLE_BORDER
)
3716 exStyle
|= WS_EX_DLGMODALFRAME
;
3717 #if defined(__WIN95__)
3718 if ( style
& wxRAISED_BORDER
)
3719 exStyle
|= WS_EX_WINDOWEDGE
;
3720 if ( style
& wxSTATIC_BORDER
)
3721 exStyle
|= WS_EX_STATICEDGE
;
3727 // Determines whether native 3D effects or CTL3D should be used,
3728 // applying a default border style if required, and returning an extended
3729 // style to pass to CreateWindowEx.
3730 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3732 // If matches certain criteria, then assume no 3D effects
3733 // unless specifically requested (dealt with in MakeExtendedStyle)
3734 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3737 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3740 // Determine whether we should be using 3D effects or not.
3741 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3743 // 1) App can specify global 3D effects
3744 *want3D
= wxTheApp
->GetAuto3D();
3746 // 2) If the parent is being drawn with user colours, or simple border specified,
3747 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3748 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3751 // 3) Control can override this global setting by defining
3752 // a border style, e.g. wxSUNKEN_BORDER
3753 if (m_windowStyle
& wxSUNKEN_BORDER
)
3756 // 4) If it's a special border, CTL3D can't cope so we want a native border
3757 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3758 (m_windowStyle
& wxSTATIC_BORDER
) )
3761 nativeBorder
= TRUE
;
3764 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3765 // effects from extended style
3768 nativeBorder
= FALSE
;
3771 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3773 // If we want 3D, but haven't specified a border here,
3774 // apply the default border style specified.
3775 // TODO what about non-Win95 WIN32? Does it have borders?
3776 #if defined(__WIN95__) && !wxUSE_CTL3D
3777 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3778 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3779 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3785 void wxWindow::OnChar(wxKeyEvent
& event
)
3788 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3793 if ( !event
.ControlDown() ) // Why this test?
3794 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3797 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3802 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3807 void wxWindow::OnPaint(wxPaintEvent
& event
)
3812 bool wxWindow::IsEnabled(void) const
3814 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3817 // Dialog support: override these and call
3818 // base class members to add functionality
3819 // that can't be done using validators.
3820 // NOTE: these functions assume that controls
3821 // are direct children of this window, not grandchildren
3822 // or other levels of descendant.
3824 // Transfer values to controls. If returns FALSE,
3825 // it's an application error (pops up a dialog)
3826 bool wxWindow::TransferDataToWindow()
3828 wxNode
*node
= GetChildren().First();
3831 wxWindow
*child
= (wxWindow
*)node
->Data();
3832 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3833 !child
->GetValidator()->TransferToWindow() )
3835 wxLogError(_("Could not transfer data to window"));
3839 node
= node
->Next();
3844 // Transfer values from controls. If returns FALSE,
3845 // validation failed: don't quit
3846 bool wxWindow::TransferDataFromWindow()
3848 wxNode
*node
= GetChildren().First();
3851 wxWindow
*child
= (wxWindow
*)node
->Data();
3852 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3857 node
= node
->Next();
3862 bool wxWindow::Validate()
3864 wxNode
*node
= GetChildren().First();
3867 wxWindow
*child
= (wxWindow
*)node
->Data();
3868 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3873 node
= node
->Next();
3878 // Get the window with the focus
3879 wxWindow
*wxWindow::FindFocus()
3881 HWND hWnd
= ::GetFocus();
3884 return wxFindWinFromHandle((WXHWND
) hWnd
);
3889 void wxWindow::AddChild(wxWindow
*child
)
3891 GetChildren().Append(child
);
3892 child
->m_windowParent
= this;
3895 void wxWindow::RemoveChild(wxWindow
*child
)
3897 // if (GetChildren())
3898 GetChildren().DeleteObject(child
);
3899 child
->m_windowParent
= NULL
;
3902 void wxWindow::DestroyChildren()
3905 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3907 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3909 if ( GetChildren().Member(child
) )
3915 void wxWindow::MakeModal(bool modal
)
3917 // Disable all other windows
3918 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3920 wxNode
*node
= wxTopLevelWindows
.First();
3923 wxWindow
*win
= (wxWindow
*)node
->Data();
3925 win
->Enable(!modal
);
3927 node
= node
->Next();
3932 // If nothing defined for this, try the parent.
3933 // E.g. we may be a button loaded from a resource, with no callback function
3935 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3937 if (GetEventHandler()->ProcessEvent(event
) )
3940 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3943 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3947 UnsetConstraints(m_constraints
);
3948 delete m_constraints
;
3953 // Make sure other windows know they're part of a 'meaningful relationship'
3954 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3955 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3956 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3957 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3958 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3959 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3960 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3961 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3962 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3963 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3964 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3965 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3966 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3967 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3968 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3969 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3973 // This removes any dangling pointers to this window
3974 // in other windows' constraintsInvolvedIn lists.
3975 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3979 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3980 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3981 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3982 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3983 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3984 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3985 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3986 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3987 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3988 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3989 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3990 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3991 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3992 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3993 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3994 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3998 // Back-pointer to other windows we're involved with, so if we delete
3999 // this window, we must delete any constraints we're involved with.
4000 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
4002 if (!m_constraintsInvolvedIn
)
4003 m_constraintsInvolvedIn
= new wxList
;
4004 if (!m_constraintsInvolvedIn
->Member(otherWin
))
4005 m_constraintsInvolvedIn
->Append(otherWin
);
4008 // REMOVE back-pointer to other windows we're involved with.
4009 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
4011 if (m_constraintsInvolvedIn
)
4012 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
4015 // Reset any constraints that mention this window
4016 void wxWindow::DeleteRelatedConstraints()
4018 if (m_constraintsInvolvedIn
)
4020 wxNode
*node
= m_constraintsInvolvedIn
->First();
4023 wxWindow
*win
= (wxWindow
*)node
->Data();
4024 wxNode
*next
= node
->Next();
4025 wxLayoutConstraints
*constr
= win
->GetConstraints();
4027 // Reset any constraints involving this window
4030 constr
->left
.ResetIfWin((wxWindow
*)this);
4031 constr
->top
.ResetIfWin((wxWindow
*)this);
4032 constr
->right
.ResetIfWin((wxWindow
*)this);
4033 constr
->bottom
.ResetIfWin((wxWindow
*)this);
4034 constr
->width
.ResetIfWin((wxWindow
*)this);
4035 constr
->height
.ResetIfWin((wxWindow
*)this);
4036 constr
->centreX
.ResetIfWin((wxWindow
*)this);
4037 constr
->centreY
.ResetIfWin((wxWindow
*)this);
4042 delete m_constraintsInvolvedIn
;
4043 m_constraintsInvolvedIn
= NULL
;
4047 void wxWindow::SetSizer(wxSizer
*sizer
)
4049 m_windowSizer
= sizer
;
4051 sizer
->SetSizerParent((wxWindow
*)this);
4058 bool wxWindow::Layout()
4060 if (GetConstraints())
4063 GetClientSize(&w
, &h
);
4064 GetConstraints()->width
.SetValue(w
);
4065 GetConstraints()->height
.SetValue(h
);
4068 // If top level (one sizer), evaluate the sizer's constraints.
4072 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
4073 GetSizer()->LayoutPhase1(&noChanges
);
4074 GetSizer()->LayoutPhase2(&noChanges
);
4075 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
4080 // Otherwise, evaluate child constraints
4081 ResetConstraints(); // Mark all constraints as unevaluated
4082 DoPhase(1); // Just one phase need if no sizers involved
4084 SetConstraintSizes(); // Recursively set the real window sizes
4090 // Do a phase of evaluating constraints:
4091 // the default behaviour. wxSizers may do a similar
4092 // thing, but also impose their own 'constraints'
4093 // and order the evaluation differently.
4094 bool wxWindow::LayoutPhase1(int *noChanges
)
4096 wxLayoutConstraints
*constr
= GetConstraints();
4099 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
4105 bool wxWindow::LayoutPhase2(int *noChanges
)
4115 // Do a phase of evaluating child constraints
4116 bool wxWindow::DoPhase(int phase
)
4118 int noIterations
= 0;
4119 int maxIterations
= 500;
4123 while ((noChanges
> 0) && (noIterations
< maxIterations
))
4127 wxNode
*node
= GetChildren().First();
4130 wxWindow
*child
= (wxWindow
*)node
->Data();
4131 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
4133 wxLayoutConstraints
*constr
= child
->GetConstraints();
4136 if (succeeded
.Member(child
))
4141 int tempNoChanges
= 0;
4142 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
4143 noChanges
+= tempNoChanges
;
4146 succeeded
.Append(child
);
4151 node
= node
->Next();
4158 void wxWindow::ResetConstraints()
4160 wxLayoutConstraints
*constr
= GetConstraints();
4163 constr
->left
.SetDone(FALSE
);
4164 constr
->top
.SetDone(FALSE
);
4165 constr
->right
.SetDone(FALSE
);
4166 constr
->bottom
.SetDone(FALSE
);
4167 constr
->width
.SetDone(FALSE
);
4168 constr
->height
.SetDone(FALSE
);
4169 constr
->centreX
.SetDone(FALSE
);
4170 constr
->centreY
.SetDone(FALSE
);
4172 wxNode
*node
= GetChildren().First();
4175 wxWindow
*win
= (wxWindow
*)node
->Data();
4176 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4177 win
->ResetConstraints();
4178 node
= node
->Next();
4182 // Need to distinguish between setting the 'fake' size for
4183 // windows and sizers, and setting the real values.
4184 void wxWindow::SetConstraintSizes(bool recurse
)
4186 wxLayoutConstraints
*constr
= GetConstraints();
4187 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4188 constr
->width
.GetDone() && constr
->height
.GetDone())
4190 int x
= constr
->left
.GetValue();
4191 int y
= constr
->top
.GetValue();
4192 int w
= constr
->width
.GetValue();
4193 int h
= constr
->height
.GetValue();
4195 // If we don't want to resize this window, just move it...
4196 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4197 (constr
->height
.GetRelationship() != wxAsIs
))
4199 // Calls Layout() recursively. AAAGH. How can we stop that.
4200 // Simply take Layout() out of non-top level OnSizes.
4201 SizerSetSize(x
, y
, w
, h
);
4210 char *windowClass
= this->GetClassInfo()->GetClassName();
4213 if (GetName() == "")
4214 winName
= "unnamed";
4216 winName
= GetName();
4217 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4218 (const char *)windowClass
, (const char *)winName
);
4219 if (!constr
->left
.GetDone())
4220 wxLogDebug(" unsatisfied 'left' constraint.");
4221 if (!constr
->right
.GetDone())
4222 wxLogDebug(" unsatisfied 'right' constraint.");
4223 if (!constr
->width
.GetDone())
4224 wxLogDebug(" unsatisfied 'width' constraint.");
4225 if (!constr
->height
.GetDone())
4226 wxLogDebug(" unsatisfied 'height' constraint.");
4227 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
4232 wxNode
*node
= GetChildren().First();
4235 wxWindow
*win
= (wxWindow
*)node
->Data();
4236 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4237 win
->SetConstraintSizes();
4238 node
= node
->Next();
4243 // This assumes that all sizers are 'on' the same
4244 // window, i.e. the parent of this window.
4245 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4247 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4248 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4252 m_sizerParent
->GetPosition(&xp
, &yp
);
4253 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4258 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4262 TransformSizerToActual(&xx
, &yy
);
4263 SetSize(xx
, yy
, w
, h
);
4266 void wxWindow::SizerMove(int x
, int y
)
4270 TransformSizerToActual(&xx
, &yy
);
4274 // Only set the size/position of the constraint (if any)
4275 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4277 wxLayoutConstraints
*constr
= GetConstraints();
4282 constr
->left
.SetValue(x
);
4283 constr
->left
.SetDone(TRUE
);
4287 constr
->top
.SetValue(y
);
4288 constr
->top
.SetDone(TRUE
);
4292 constr
->width
.SetValue(w
);
4293 constr
->width
.SetDone(TRUE
);
4297 constr
->height
.SetValue(h
);
4298 constr
->height
.SetDone(TRUE
);
4303 void wxWindow::MoveConstraint(int x
, int y
)
4305 wxLayoutConstraints
*constr
= GetConstraints();
4310 constr
->left
.SetValue(x
);
4311 constr
->left
.SetDone(TRUE
);
4315 constr
->top
.SetValue(y
);
4316 constr
->top
.SetDone(TRUE
);
4321 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4323 wxLayoutConstraints
*constr
= GetConstraints();
4326 *w
= constr
->width
.GetValue();
4327 *h
= constr
->height
.GetValue();
4333 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4335 wxLayoutConstraints
*constr
= GetConstraints();
4338 *w
= constr
->width
.GetValue();
4339 *h
= constr
->height
.GetValue();
4342 GetClientSize(w
, h
);
4345 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4347 wxLayoutConstraints
*constr
= GetConstraints();
4350 *x
= constr
->left
.GetValue();
4351 *y
= constr
->top
.GetValue();
4357 bool wxWindow::Close(bool force
)
4359 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4360 event
.SetEventObject(this);
4361 #if WXWIN_COMPATIBILITY
4362 event
.SetForce(force
);
4364 event
.SetCanVeto(!force
);
4366 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4369 wxObject
* wxWindow::GetChild(int number
) const
4371 // Return a pointer to the Nth object in the Panel
4372 // if (!GetChildren())
4374 wxNode
*node
= GetChildren().First();
4377 node
= node
->Next() ;
4380 wxObject
*obj
= (wxObject
*)node
->Data();
4387 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4389 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4390 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4393 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4395 wxListBox *lbox = (wxListBox *)initiatingItem;
4396 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4397 event.m_commandInt = -1;
4398 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4400 event.m_commandString = copystring(lbox->GetStringSelection());
4401 event.m_commandInt = lbox->GetSelection();
4402 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4404 event.m_eventObject = lbox;
4406 lbox->ProcessCommand(event);
4408 if (event.m_commandString)
4409 delete[] event.m_commandString;
4413 wxButton *but = GetDefaultItem();
4416 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4417 event.SetEventObject(but);
4418 but->Command(event);
4423 void wxWindow::Clear()
4425 wxClientDC
dc(this);
4426 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4427 dc
.SetBackground(brush
);
4431 // Fits the panel around the items
4432 void wxWindow::Fit()
4436 wxNode
*node
= GetChildren().First();
4439 wxWindow
*win
= (wxWindow
*)node
->Data();
4441 win
->GetPosition(&wx
, &wy
);
4442 win
->GetSize(&ww
, &wh
);
4443 if ( wx
+ ww
> maxX
)
4445 if ( wy
+ wh
> maxY
)
4448 node
= node
->Next();
4450 SetClientSize(maxX
+ 5, maxY
+ 5);
4453 void wxWindow::SetValidator(const wxValidator
& validator
)
4455 if ( m_windowValidator
)
4456 delete m_windowValidator
;
4457 m_windowValidator
= validator
.Clone();
4459 if ( m_windowValidator
)
4460 m_windowValidator
->SetWindow(this) ;
4463 // Find a window by id or name
4464 wxWindow
*wxWindow::FindWindow(long id
)
4469 wxNode
*node
= GetChildren().First();
4472 wxWindow
*child
= (wxWindow
*)node
->Data();
4473 wxWindow
*found
= child
->FindWindow(id
);
4476 node
= node
->Next();
4481 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4483 if ( GetName() == name
)
4486 wxNode
*node
= GetChildren().First();
4489 wxWindow
*child
= (wxWindow
*)node
->Data();
4490 wxWindow
*found
= child
->FindWindow(name
);
4493 node
= node
->Next();
4499 // Default input behaviour for a scrolling canvas should be to scroll
4500 // according to the cursor keys pressed
4501 void wxWindow::OnChar(wxKeyEvent& event)
4513 GetScrollUnitsPerPage(&x_page, &y_page);
4515 GetVirtualSize(&v_width,&v_height);
4517 ViewStart(&start_x, &start_y);
4520 y_pages = (int)(v_height/vert_units) - y_page;
4528 switch (event.keyCode)
4535 if (start_y - y_page > 0)
4536 Scroll(start_x, start_y - y_page);
4546 if ((y_page > 0) && (start_y <= y_pages-y-1))
4548 if (y_pages + y < start_y + y_page)
4549 Scroll(start_x, y_pages + y);
4551 Scroll(start_x, start_y + y_page);
4558 if ((y_page > 0) && (start_y >= 1))
4559 Scroll(start_x, start_y - 1);
4565 if ((y_page > 0) && (start_y <= y_pages-y-1))
4568 Scroll(start_x, start_y + 1);
4574 if ((x_page > 0) && (start_x >= 1))
4575 Scroll(start_x - 1, start_y);
4581 Scroll(start_x + 1, start_y);
4592 Scroll(start_x, y_pages+y);
4600 // Setup background and foreground colours correctly
4601 void wxWindow::SetupColours()
4604 SetBackgroundColour(GetParent()->GetBackgroundColour());
4607 void wxWindow::OnIdle(wxIdleEvent
& event
)
4609 // Check if we need to send a LEAVE event
4610 if (m_mouseInWindow
)
4613 ::GetCursorPos(&pt
);
4614 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4616 // Generate a LEAVE event
4617 m_mouseInWindow
= FALSE
;
4620 if (::GetKeyState(VK_SHIFT
) != 0)
4622 if (::GetKeyState(VK_CONTROL
) != 0)
4623 state
|= MK_CONTROL
;
4625 // Unfortunately the mouse button and keyboard state may have changed
4626 // by the time the OnIdle function is called, so 'state' may be
4629 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4635 // Raise the window to the top of the Z order
4636 void wxWindow::Raise()
4638 ::BringWindowToTop((HWND
) GetHWND());
4641 // Lower the window to the bottom of the Z order
4642 void wxWindow::Lower()
4644 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4647 long wxWindow::MSWGetDlgCode()
4649 // default: just forward to def window proc (the msg has no parameters)
4650 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4653 bool wxWindow::AcceptsFocus() const
4655 // invisible and disabled controls don't need focus
4656 return IsShown() && IsEnabled();
4659 // Update region access
4660 wxRegion
wxWindow::GetUpdateRegion() const
4662 return m_updateRegion
;
4665 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4667 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4670 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4672 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4675 bool wxWindow::IsExposed(const wxRect
& rect
) const
4677 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4680 // Set this window to be the child of 'parent'.
4681 bool wxWindow::Reparent(wxWindow
*parent
)
4683 if (parent
== GetParent())
4686 // Unlink this window from the existing parent.
4689 GetParent()->RemoveChild(this);
4692 wxTopLevelWindows
.DeleteObject(this);
4694 HWND hWndParent
= 0;
4695 HWND hWndChild
= (HWND
) GetHWND();
4696 if (parent
!= (wxWindow
*) NULL
)
4698 parent
->AddChild(this);
4699 hWndParent
= (HWND
) parent
->GetHWND();
4702 wxTopLevelWindows
.Append(this);
4704 ::SetParent(hWndChild
, hWndParent
);
4710 const char *wxGetMessageName(int message
)
4712 switch ( message
) {
4713 case 0x0000: return "WM_NULL";
4714 case 0x0001: return "WM_CREATE";
4715 case 0x0002: return "WM_DESTROY";
4716 case 0x0003: return "WM_MOVE";
4717 case 0x0005: return "WM_SIZE";
4718 case 0x0006: return "WM_ACTIVATE";
4719 case 0x0007: return "WM_SETFOCUS";
4720 case 0x0008: return "WM_KILLFOCUS";
4721 case 0x000A: return "WM_ENABLE";
4722 case 0x000B: return "WM_SETREDRAW";
4723 case 0x000C: return "WM_SETTEXT";
4724 case 0x000D: return "WM_GETTEXT";
4725 case 0x000E: return "WM_GETTEXTLENGTH";
4726 case 0x000F: return "WM_PAINT";
4727 case 0x0010: return "WM_CLOSE";
4728 case 0x0011: return "WM_QUERYENDSESSION";
4729 case 0x0012: return "WM_QUIT";
4730 case 0x0013: return "WM_QUERYOPEN";
4731 case 0x0014: return "WM_ERASEBKGND";
4732 case 0x0015: return "WM_SYSCOLORCHANGE";
4733 case 0x0016: return "WM_ENDSESSION";
4734 case 0x0017: return "WM_SYSTEMERROR";
4735 case 0x0018: return "WM_SHOWWINDOW";
4736 case 0x0019: return "WM_CTLCOLOR";
4737 case 0x001A: return "WM_WININICHANGE";
4738 case 0x001B: return "WM_DEVMODECHANGE";
4739 case 0x001C: return "WM_ACTIVATEAPP";
4740 case 0x001D: return "WM_FONTCHANGE";
4741 case 0x001E: return "WM_TIMECHANGE";
4742 case 0x001F: return "WM_CANCELMODE";
4743 case 0x0020: return "WM_SETCURSOR";
4744 case 0x0021: return "WM_MOUSEACTIVATE";
4745 case 0x0022: return "WM_CHILDACTIVATE";
4746 case 0x0023: return "WM_QUEUESYNC";
4747 case 0x0024: return "WM_GETMINMAXINFO";
4748 case 0x0026: return "WM_PAINTICON";
4749 case 0x0027: return "WM_ICONERASEBKGND";
4750 case 0x0028: return "WM_NEXTDLGCTL";
4751 case 0x002A: return "WM_SPOOLERSTATUS";
4752 case 0x002B: return "WM_DRAWITEM";
4753 case 0x002C: return "WM_MEASUREITEM";
4754 case 0x002D: return "WM_DELETEITEM";
4755 case 0x002E: return "WM_VKEYTOITEM";
4756 case 0x002F: return "WM_CHARTOITEM";
4757 case 0x0030: return "WM_SETFONT";
4758 case 0x0031: return "WM_GETFONT";
4759 case 0x0037: return "WM_QUERYDRAGICON";
4760 case 0x0039: return "WM_COMPAREITEM";
4761 case 0x0041: return "WM_COMPACTING";
4762 case 0x0044: return "WM_COMMNOTIFY";
4763 case 0x0046: return "WM_WINDOWPOSCHANGING";
4764 case 0x0047: return "WM_WINDOWPOSCHANGED";
4765 case 0x0048: return "WM_POWER";
4768 case 0x004A: return "WM_COPYDATA";
4769 case 0x004B: return "WM_CANCELJOURNAL";
4770 case 0x004E: return "WM_NOTIFY";
4771 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4772 case 0x0051: return "WM_INPUTLANGCHANGE";
4773 case 0x0052: return "WM_TCARD";
4774 case 0x0053: return "WM_HELP";
4775 case 0x0054: return "WM_USERCHANGED";
4776 case 0x0055: return "WM_NOTIFYFORMAT";
4777 case 0x007B: return "WM_CONTEXTMENU";
4778 case 0x007C: return "WM_STYLECHANGING";
4779 case 0x007D: return "WM_STYLECHANGED";
4780 case 0x007E: return "WM_DISPLAYCHANGE";
4781 case 0x007F: return "WM_GETICON";
4782 case 0x0080: return "WM_SETICON";
4785 case 0x0081: return "WM_NCCREATE";
4786 case 0x0082: return "WM_NCDESTROY";
4787 case 0x0083: return "WM_NCCALCSIZE";
4788 case 0x0084: return "WM_NCHITTEST";
4789 case 0x0085: return "WM_NCPAINT";
4790 case 0x0086: return "WM_NCACTIVATE";
4791 case 0x0087: return "WM_GETDLGCODE";
4792 case 0x00A0: return "WM_NCMOUSEMOVE";
4793 case 0x00A1: return "WM_NCLBUTTONDOWN";
4794 case 0x00A2: return "WM_NCLBUTTONUP";
4795 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4796 case 0x00A4: return "WM_NCRBUTTONDOWN";
4797 case 0x00A5: return "WM_NCRBUTTONUP";
4798 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4799 case 0x00A7: return "WM_NCMBUTTONDOWN";
4800 case 0x00A8: return "WM_NCMBUTTONUP";
4801 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4802 case 0x0100: return "WM_KEYDOWN";
4803 case 0x0101: return "WM_KEYUP";
4804 case 0x0102: return "WM_CHAR";
4805 case 0x0103: return "WM_DEADCHAR";
4806 case 0x0104: return "WM_SYSKEYDOWN";
4807 case 0x0105: return "WM_SYSKEYUP";
4808 case 0x0106: return "WM_SYSCHAR";
4809 case 0x0107: return "WM_SYSDEADCHAR";
4810 case 0x0108: return "WM_KEYLAST";
4813 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4814 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4815 case 0x010F: return "WM_IME_COMPOSITION";
4818 case 0x0110: return "WM_INITDIALOG";
4819 case 0x0111: return "WM_COMMAND";
4820 case 0x0112: return "WM_SYSCOMMAND";
4821 case 0x0113: return "WM_TIMER";
4822 case 0x0114: return "WM_HSCROLL";
4823 case 0x0115: return "WM_VSCROLL";
4824 case 0x0116: return "WM_INITMENU";
4825 case 0x0117: return "WM_INITMENUPOPUP";
4826 case 0x011F: return "WM_MENUSELECT";
4827 case 0x0120: return "WM_MENUCHAR";
4828 case 0x0121: return "WM_ENTERIDLE";
4829 case 0x0200: return "WM_MOUSEMOVE";
4830 case 0x0201: return "WM_LBUTTONDOWN";
4831 case 0x0202: return "WM_LBUTTONUP";
4832 case 0x0203: return "WM_LBUTTONDBLCLK";
4833 case 0x0204: return "WM_RBUTTONDOWN";
4834 case 0x0205: return "WM_RBUTTONUP";
4835 case 0x0206: return "WM_RBUTTONDBLCLK";
4836 case 0x0207: return "WM_MBUTTONDOWN";
4837 case 0x0208: return "WM_MBUTTONUP";
4838 case 0x0209: return "WM_MBUTTONDBLCLK";
4839 case 0x0210: return "WM_PARENTNOTIFY";
4840 case 0x0211: return "WM_ENTERMENULOOP";
4841 case 0x0212: return "WM_EXITMENULOOP";
4844 case 0x0213: return "WM_NEXTMENU";
4845 case 0x0214: return "WM_SIZING";
4846 case 0x0215: return "WM_CAPTURECHANGED";
4847 case 0x0216: return "WM_MOVING";
4848 case 0x0218: return "WM_POWERBROADCAST";
4849 case 0x0219: return "WM_DEVICECHANGE";
4852 case 0x0220: return "WM_MDICREATE";
4853 case 0x0221: return "WM_MDIDESTROY";
4854 case 0x0222: return "WM_MDIACTIVATE";
4855 case 0x0223: return "WM_MDIRESTORE";
4856 case 0x0224: return "WM_MDINEXT";
4857 case 0x0225: return "WM_MDIMAXIMIZE";
4858 case 0x0226: return "WM_MDITILE";
4859 case 0x0227: return "WM_MDICASCADE";
4860 case 0x0228: return "WM_MDIICONARRANGE";
4861 case 0x0229: return "WM_MDIGETACTIVE";
4862 case 0x0230: return "WM_MDISETMENU";
4863 case 0x0233: return "WM_DROPFILES";
4866 case 0x0281: return "WM_IME_SETCONTEXT";
4867 case 0x0282: return "WM_IME_NOTIFY";
4868 case 0x0283: return "WM_IME_CONTROL";
4869 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4870 case 0x0285: return "WM_IME_SELECT";
4871 case 0x0286: return "WM_IME_CHAR";
4872 case 0x0290: return "WM_IME_KEYDOWN";
4873 case 0x0291: return "WM_IME_KEYUP";
4876 case 0x0300: return "WM_CUT";
4877 case 0x0301: return "WM_COPY";
4878 case 0x0302: return "WM_PASTE";
4879 case 0x0303: return "WM_CLEAR";
4880 case 0x0304: return "WM_UNDO";
4881 case 0x0305: return "WM_RENDERFORMAT";
4882 case 0x0306: return "WM_RENDERALLFORMATS";
4883 case 0x0307: return "WM_DESTROYCLIPBOARD";
4884 case 0x0308: return "WM_DRAWCLIPBOARD";
4885 case 0x0309: return "WM_PAINTCLIPBOARD";
4886 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4887 case 0x030B: return "WM_SIZECLIPBOARD";
4888 case 0x030C: return "WM_ASKCBFORMATNAME";
4889 case 0x030D: return "WM_CHANGECBCHAIN";
4890 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4891 case 0x030F: return "WM_QUERYNEWPALETTE";
4892 case 0x0310: return "WM_PALETTEISCHANGING";
4893 case 0x0311: return "WM_PALETTECHANGED";
4896 // common controls messages - although they're not strictly speaking
4897 // standard, it's nice to decode them nevertheless
4900 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4901 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4902 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4903 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4904 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4905 case 0x1000 + 5: return "LVM_GETITEMA";
4906 case 0x1000 + 75: return "LVM_GETITEMW";
4907 case 0x1000 + 6: return "LVM_SETITEMA";
4908 case 0x1000 + 76: return "LVM_SETITEMW";
4909 case 0x1000 + 7: return "LVM_INSERTITEMA";
4910 case 0x1000 + 77: return "LVM_INSERTITEMW";
4911 case 0x1000 + 8: return "LVM_DELETEITEM";
4912 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4913 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4914 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4915 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4916 case 0x1000 + 13: return "LVM_FINDITEMA";
4917 case 0x1000 + 83: return "LVM_FINDITEMW";
4918 case 0x1000 + 14: return "LVM_GETITEMRECT";
4919 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4920 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4921 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4922 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4923 case 0x1000 + 18: return "LVM_HITTEST";
4924 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4925 case 0x1000 + 20: return "LVM_SCROLL";
4926 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4927 case 0x1000 + 22: return "LVM_ARRANGE";
4928 case 0x1000 + 23: return "LVM_EDITLABELA";
4929 case 0x1000 + 118: return "LVM_EDITLABELW";
4930 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4931 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4932 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4933 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4934 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4935 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4936 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4937 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4938 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4939 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4940 case 0x1000 + 31: return "LVM_GETHEADER";
4941 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4942 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4943 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4944 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4945 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4946 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4947 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4948 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4949 case 0x1000 + 41: return "LVM_GETORIGIN";
4950 case 0x1000 + 42: return "LVM_UPDATE";
4951 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4952 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4953 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4954 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4955 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4956 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4957 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4958 case 0x1000 + 48: return "LVM_SORTITEMS";
4959 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4960 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4961 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4962 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4963 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4964 case 0x1000 + 53: return "LVM_SETICONSPACING";
4965 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4966 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4967 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4968 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4969 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4970 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4971 case 0x1000 + 60: return "LVM_SETHOTITEM";
4972 case 0x1000 + 61: return "LVM_GETHOTITEM";
4973 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4974 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4975 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4976 case 0x1000 + 65: return "LVM_SETWORKAREA";
4979 case 0x1100 + 0: return "TVM_INSERTITEMA";
4980 case 0x1100 + 50: return "TVM_INSERTITEMW";
4981 case 0x1100 + 1: return "TVM_DELETEITEM";
4982 case 0x1100 + 2: return "TVM_EXPAND";
4983 case 0x1100 + 4: return "TVM_GETITEMRECT";
4984 case 0x1100 + 5: return "TVM_GETCOUNT";
4985 case 0x1100 + 6: return "TVM_GETINDENT";
4986 case 0x1100 + 7: return "TVM_SETINDENT";
4987 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4988 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4989 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4990 case 0x1100 + 11: return "TVM_SELECTITEM";
4991 case 0x1100 + 12: return "TVM_GETITEMA";
4992 case 0x1100 + 62: return "TVM_GETITEMW";
4993 case 0x1100 + 13: return "TVM_SETITEMA";
4994 case 0x1100 + 63: return "TVM_SETITEMW";
4995 case 0x1100 + 14: return "TVM_EDITLABELA";
4996 case 0x1100 + 65: return "TVM_EDITLABELW";
4997 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4998 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4999 case 0x1100 + 17: return "TVM_HITTEST";
5000 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
5001 case 0x1100 + 19: return "TVM_SORTCHILDREN";
5002 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
5003 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
5004 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
5005 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
5006 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
5007 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
5008 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
5011 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
5012 case 0x1200 + 1: return "HDM_INSERTITEMA";
5013 case 0x1200 + 10: return "HDM_INSERTITEMW";
5014 case 0x1200 + 2: return "HDM_DELETEITEM";
5015 case 0x1200 + 3: return "HDM_GETITEMA";
5016 case 0x1200 + 11: return "HDM_GETITEMW";
5017 case 0x1200 + 4: return "HDM_SETITEMA";
5018 case 0x1200 + 12: return "HDM_SETITEMW";
5019 case 0x1200 + 5: return "HDM_LAYOUT";
5020 case 0x1200 + 6: return "HDM_HITTEST";
5021 case 0x1200 + 7: return "HDM_GETITEMRECT";
5022 case 0x1200 + 8: return "HDM_SETIMAGELIST";
5023 case 0x1200 + 9: return "HDM_GETIMAGELIST";
5024 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
5025 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
5026 case 0x1200 + 17: return "HDM_GETORDERARRAY";
5027 case 0x1200 + 18: return "HDM_SETORDERARRAY";
5028 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
5031 case 0x1300 + 2: return "TCM_GETIMAGELIST";
5032 case 0x1300 + 3: return "TCM_SETIMAGELIST";
5033 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
5034 case 0x1300 + 5: return "TCM_GETITEMA";
5035 case 0x1300 + 60: return "TCM_GETITEMW";
5036 case 0x1300 + 6: return "TCM_SETITEMA";
5037 case 0x1300 + 61: return "TCM_SETITEMW";
5038 case 0x1300 + 7: return "TCM_INSERTITEMA";
5039 case 0x1300 + 62: return "TCM_INSERTITEMW";
5040 case 0x1300 + 8: return "TCM_DELETEITEM";
5041 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
5042 case 0x1300 + 10: return "TCM_GETITEMRECT";
5043 case 0x1300 + 11: return "TCM_GETCURSEL";
5044 case 0x1300 + 12: return "TCM_SETCURSEL";
5045 case 0x1300 + 13: return "TCM_HITTEST";
5046 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
5047 case 0x1300 + 40: return "TCM_ADJUSTRECT";
5048 case 0x1300 + 41: return "TCM_SETITEMSIZE";
5049 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
5050 case 0x1300 + 43: return "TCM_SETPADDING";
5051 case 0x1300 + 44: return "TCM_GETROWCOUNT";
5052 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
5053 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
5054 case 0x1300 + 47: return "TCM_GETCURFOCUS";
5055 case 0x1300 + 48: return "TCM_SETCURFOCUS";
5056 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
5057 case 0x1300 + 50: return "TCM_DESELECTALL";
5060 case WM_USER
+1: return "TB_ENABLEBUTTON";
5061 case WM_USER
+2: return "TB_CHECKBUTTON";
5062 case WM_USER
+3: return "TB_PRESSBUTTON";
5063 case WM_USER
+4: return "TB_HIDEBUTTON";
5064 case WM_USER
+5: return "TB_INDETERMINATE";
5065 case WM_USER
+9: return "TB_ISBUTTONENABLED";
5066 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
5067 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
5068 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
5069 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
5070 case WM_USER
+17: return "TB_SETSTATE";
5071 case WM_USER
+18: return "TB_GETSTATE";
5072 case WM_USER
+19: return "TB_ADDBITMAP";
5073 case WM_USER
+20: return "TB_ADDBUTTONS";
5074 case WM_USER
+21: return "TB_INSERTBUTTON";
5075 case WM_USER
+22: return "TB_DELETEBUTTON";
5076 case WM_USER
+23: return "TB_GETBUTTON";
5077 case WM_USER
+24: return "TB_BUTTONCOUNT";
5078 case WM_USER
+25: return "TB_COMMANDTOINDEX";
5079 case WM_USER
+26: return "TB_SAVERESTOREA";
5080 case WM_USER
+76: return "TB_SAVERESTOREW";
5081 case WM_USER
+27: return "TB_CUSTOMIZE";
5082 case WM_USER
+28: return "TB_ADDSTRINGA";
5083 case WM_USER
+77: return "TB_ADDSTRINGW";
5084 case WM_USER
+29: return "TB_GETITEMRECT";
5085 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
5086 case WM_USER
+31: return "TB_SETBUTTONSIZE";
5087 case WM_USER
+32: return "TB_SETBITMAPSIZE";
5088 case WM_USER
+33: return "TB_AUTOSIZE";
5089 case WM_USER
+35: return "TB_GETTOOLTIPS";
5090 case WM_USER
+36: return "TB_SETTOOLTIPS";
5091 case WM_USER
+37: return "TB_SETPARENT";
5092 case WM_USER
+39: return "TB_SETROWS";
5093 case WM_USER
+40: return "TB_GETROWS";
5094 case WM_USER
+42: return "TB_SETCMDID";
5095 case WM_USER
+43: return "TB_CHANGEBITMAP";
5096 case WM_USER
+44: return "TB_GETBITMAP";
5097 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
5098 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
5099 case WM_USER
+46: return "TB_REPLACEBITMAP";
5100 case WM_USER
+47: return "TB_SETINDENT";
5101 case WM_USER
+48: return "TB_SETIMAGELIST";
5102 case WM_USER
+49: return "TB_GETIMAGELIST";
5103 case WM_USER
+50: return "TB_LOADIMAGES";
5104 case WM_USER
+51: return "TB_GETRECT";
5105 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
5106 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
5107 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
5108 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
5109 case WM_USER
+56: return "TB_SETSTYLE";
5110 case WM_USER
+57: return "TB_GETSTYLE";
5111 case WM_USER
+58: return "TB_GETBUTTONSIZE";
5112 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
5113 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
5114 case WM_USER
+61: return "TB_GETTEXTROWS";
5115 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
5120 static char s_szBuf
[128];
5121 sprintf(s_szBuf
, "<unknown message = %d>", message
);
5125 #endif //__WXDEBUG__