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"
52 #include "wx/tooltip.h"
54 #include "wx/msw/private.h"
67 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
73 #include <wx/msw/gnuwin32/extra.h>
77 // all these are defined in <windows.h>
95 const char *wxGetMessageName(int message
);
98 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
100 wxMenu
*wxCurrentPopupMenu
= NULL
;
101 extern wxList WXDLLEXPORT wxPendingDelete
;
103 void wxRemoveHandleAssociation(wxWindow
*win
);
104 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
105 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
107 #if !USE_SHARED_LIBRARY
108 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
111 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
112 EVT_CHAR(wxWindow::OnChar
)
113 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
114 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
115 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
116 EVT_IDLE(wxWindow::OnIdle
)
119 // Find an item given the MS Windows id
120 wxWindow
*wxWindow::FindItem(int id
) const
122 // if (!GetChildren())
124 wxNode
*current
= GetChildren().First();
127 wxWindow
*childWin
= (wxWindow
*)current
->Data();
129 wxWindow
*wnd
= childWin
->FindItem(id
) ;
133 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
135 wxControl
*item
= (wxControl
*)childWin
;
136 if (item
->GetId() == id
)
140 // In case it's a 'virtual' control (e.g. radiobox)
141 if (item
->GetSubcontrols().Member((wxObject
*)id
))
145 current
= current
->Next();
150 // Find an item given the MS Windows handle
151 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
153 // if (!GetChildren())
155 wxNode
*current
= GetChildren().First();
158 wxObject
*obj
= (wxObject
*)current
->Data() ;
159 // Do a recursive search.
160 wxWindow
*parent
= (wxWindow
*)obj
;
161 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
165 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
167 wxWindow
*item
= (wxWindow
*)current
->Data();
168 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
172 if ( item
->ContainsHWND(hWnd
) )
176 current
= current
->Next();
181 // Default command handler
182 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
187 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
189 WXLPARAM
* WXUNUSED(result
))
193 NMHDR
* hdr
= (NMHDR
*)lParam
;
194 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
196 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
197 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
208 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
212 WXHWND
wxWindow::GetHWND(void) const
214 return (WXHWND
) m_hWnd
;
217 void wxWindow::SetHWND(WXHWND hWnd
)
222 // ----------------------------------------------------------------------------
223 // constructors and such
224 // ----------------------------------------------------------------------------
226 void wxWindow::Init()
232 m_windowParent
= NULL
;
233 m_windowEventHandler
= this;
234 m_windowCursor
= *wxSTANDARD_CURSOR
;
235 m_children
= new wxList
;
236 m_doubleClickAllowed
= 0 ;
237 m_winCaptured
= FALSE
;
238 m_constraints
= NULL
;
239 m_constraintsInvolvedIn
= NULL
;
240 m_windowSizer
= NULL
;
241 m_sizerParent
= NULL
;
242 m_autoLayout
= FALSE
;
243 m_windowValidator
= NULL
;
248 m_caretWidth
= m_caretHeight
= 0;
250 m_caretShown
= FALSE
;
257 m_isBeingDeleted
= FALSE
;
263 m_mouseInWindow
= FALSE
;
265 m_windowParent
= NULL
;
266 m_defaultItem
= NULL
;
268 wxSystemSettings settings
;
270 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
271 m_foregroundColour
= *wxBLACK
;
281 m_backgroundTransparent
= FALSE
;
283 m_lastXPos
= (float)-1.0;
284 m_lastYPos
= (float)-1.0;
288 #if wxUSE_DRAG_AND_DROP
289 m_pDropTarget
= NULL
;
303 wxWindow::~wxWindow()
305 m_isBeingDeleted
= TRUE
;
307 // first of all, delete the things on which nothing else depends
313 // JACS - if behaviour is odd, restore this
314 // to the start of ~wxWindow. Vadim has changed
315 // it to nearer the end. Unsure of side-effects
316 // e.g. when deleting associated global data.
317 // Restore old Window proc, if required
320 // Have to delete constraints/sizer FIRST otherwise
321 // sizers may try to look at deleted windows as they
322 // delete themselves.
323 #if wxUSE_CONSTRAINTS
324 DeleteRelatedConstraints();
328 // This removes any dangling pointers to this window
329 // in other windows' constraintsInvolvedIn lists.
330 UnsetConstraints(m_constraints
);
331 delete m_constraints
;
332 m_constraints
= NULL
;
335 wxDELETE(m_windowSizer
);
337 // If this is a child of a sizer, remove self from parent
339 m_sizerParent
->RemoveChild((wxWindow
*)this);
343 MSWDetachWindowMenu();
346 m_windowParent
->RemoveChild(this);
351 ::DestroyWindow((HWND
)m_hWnd
);
353 wxRemoveHandleAssociation(this);
358 GlobalFree((HGLOBAL
) m_globalHandle
);
366 // Just in case the window has been Closed, but
367 // we're then deleting immediately: don't leave
368 // dangling pointers.
369 wxPendingDelete
.DeleteObject(this);
371 // Just in case we've loaded a top-level window via
372 // wxWindow::LoadNativeDialog but we weren't a dialog
374 wxTopLevelWindows
.DeleteObject(this);
376 if ( m_windowValidator
)
377 delete m_windowValidator
;
379 // Restore old Window proc, if required
380 // and remove hWnd <-> wxWindow association
384 // Destroy the window (delayed, if a managed window)
385 bool wxWindow::Destroy()
391 extern char wxCanvasClassName
[];
393 // real construction (Init() must have been called before!)
394 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
398 const wxString
& name
)
400 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
402 parent
->AddChild(this);
407 m_windowId
= (int)NewControlId();
416 // To be consistent with wxGTK
422 wxSystemSettings settings
;
424 m_windowStyle
= style
;
427 if (style
& wxBORDER
)
428 msflags
|= WS_BORDER
;
429 if (style
& wxTHICK_FRAME
)
430 msflags
|= WS_THICKFRAME
;
432 msflags
|= WS_CHILD
| WS_VISIBLE
;
433 if (style
& wxCLIP_CHILDREN
)
434 msflags
|= WS_CLIPCHILDREN
;
437 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
439 // Even with extended styles, need to combine with WS_BORDER
440 // for them to look right.
441 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
442 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
443 msflags
|= WS_BORDER
;
445 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
446 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
451 void wxWindow::SetFocus()
453 HWND hWnd
= (HWND
) GetHWND();
458 void wxWindow::Enable(bool enable
)
460 m_winEnabled
= enable
;
461 HWND hWnd
= (HWND
) GetHWND();
463 ::EnableWindow(hWnd
, (BOOL
)enable
);
466 void wxWindow::CaptureMouse()
468 HWND hWnd
= (HWND
) GetHWND();
469 if (hWnd
&& !m_winCaptured
)
472 m_winCaptured
= TRUE
;
476 void wxWindow::ReleaseMouse()
481 m_winCaptured
= FALSE
;
485 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
487 m_acceleratorTable
= accel
;
491 // Push/pop event handler (i.e. allow a chain of event handlers
493 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
495 handler
->SetNextHandler(GetEventHandler());
496 SetEventHandler(handler
);
499 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
501 if ( GetEventHandler() )
503 wxEvtHandler
*handlerA
= GetEventHandler();
504 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
505 handlerA
->SetNextHandler(NULL
);
506 SetEventHandler(handlerB
);
519 #if wxUSE_DRAG_AND_DROP
521 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
523 if ( m_pDropTarget
!= 0 ) {
524 m_pDropTarget
->Revoke(m_hWnd
);
525 delete m_pDropTarget
;
528 m_pDropTarget
= pDropTarget
;
529 if ( m_pDropTarget
!= 0 )
530 m_pDropTarget
->Register(m_hWnd
);
533 #endif // wxUSE_DRAG_AND_DROP
536 //old style file-manager drag&drop support
537 // I think we should retain the old-style
538 // DragAcceptFiles in parallel with SetDropTarget.
540 void wxWindow::DragAcceptFiles(bool accept
)
542 HWND hWnd
= (HWND
) GetHWND();
544 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
547 // ----------------------------------------------------------------------------
549 // ----------------------------------------------------------------------------
553 void wxWindow::SetToolTip(const wxString
&tip
)
555 SetToolTip(new wxToolTip(tip
));
558 void wxWindow::SetToolTip(wxToolTip
*tooltip
)
564 m_tooltip
->SetWindow(this);
567 #endif // wxUSE_TOOLTIPS
570 void wxWindow::GetSize(int *x
, int *y
) const
572 HWND hWnd
= (HWND
) GetHWND();
574 GetWindowRect(hWnd
, &rect
);
575 *x
= rect
.right
- rect
.left
;
576 *y
= rect
.bottom
- rect
.top
;
579 void wxWindow::GetPosition(int *x
, int *y
) const
581 HWND hWnd
= (HWND
) GetHWND();
584 hParentWnd
= (HWND
) GetParent()->GetHWND();
587 GetWindowRect(hWnd
, &rect
);
589 // Since we now have the absolute screen coords,
590 // if there's a parent we must subtract its top left corner
596 ::ScreenToClient(hParentWnd
, &point
);
599 // We may be faking the client origin.
600 // So a window that's really at (0, 30) may appear
601 // (to wxWin apps) to be at (0, 0).
604 wxPoint
pt(GetParent()->GetClientAreaOrigin());
612 void wxWindow::ScreenToClient(int *x
, int *y
) const
614 HWND hWnd
= (HWND
) GetHWND();
619 ::ScreenToClient(hWnd
, &pt
);
625 void wxWindow::ClientToScreen(int *x
, int *y
) const
627 HWND hWnd
= (HWND
) GetHWND();
632 ::ClientToScreen(hWnd
, &pt
);
638 void wxWindow::SetCursor(const wxCursor
& cursor
)
640 m_windowCursor
= cursor
;
641 if (m_windowCursor
.Ok())
643 HWND hWnd
= (HWND
) GetHWND();
645 // Change the cursor NOW if we're within the correct window
647 ::GetCursorPos(&point
);
650 ::GetWindowRect(hWnd
, &rect
);
652 if (::PtInRect(&rect
, point
) && !wxIsBusy())
653 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
656 // This will cause big reentrancy problems if wxFlushEvents is implemented.
658 // return old_cursor;
662 // Get size *available for subwindows* i.e. excluding menu bar etc.
663 void wxWindow::GetClientSize(int *x
, int *y
) const
665 HWND hWnd
= (HWND
) GetHWND();
667 GetClientRect(hWnd
, &rect
);
672 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
674 int currentX
, currentY
;
675 GetPosition(¤tX
, ¤tY
);
676 int currentW
,currentH
;
677 GetSize(¤tW
, ¤tH
);
679 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
682 int actualWidth
= width
;
683 int actualHeight
= height
;
686 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
688 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
691 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
694 actualWidth
= currentW
;
696 actualHeight
= currentH
;
698 HWND hWnd
= (HWND
) GetHWND();
700 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
703 void wxWindow::SetClientSize(int width
, int height
)
705 wxWindow
*parent
= GetParent();
706 HWND hWnd
= (HWND
) GetHWND();
707 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
710 GetClientRect(hWnd
, &rect
);
713 GetWindowRect(hWnd
, &rect2
);
715 // Find the difference between the entire window (title bar and all)
716 // and the client area; add this to the new client size to move the
718 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
719 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
721 // If there's a parent, must subtract the parent's top left corner
722 // since MoveWindow moves relative to the parent
725 point
.x
= rect2
.left
;
729 ::ScreenToClient(hParentWnd
, &point
);
732 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
734 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
735 event
.SetEventObject(this);
736 GetEventHandler()->ProcessEvent(event
);
739 // For implementation purposes - sometimes decorations make the client area
741 wxPoint
wxWindow::GetClientAreaOrigin() const
743 return wxPoint(0, 0);
746 // Makes an adjustment to the window position (for example, a frame that has
747 // a toolbar that it manages itself).
748 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
750 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
752 wxPoint
pt(GetParent()->GetClientAreaOrigin());
753 x
+= pt
.x
; y
+= pt
.y
;
757 bool wxWindow::Show(bool show
)
759 HWND hWnd
= (HWND
) GetHWND();
765 ShowWindow(hWnd
, (BOOL
)cshow
);
768 BringWindowToTop(hWnd
);
769 // Next line causes a crash on NT, apparently.
770 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
775 bool wxWindow::IsShown(void) const
777 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
780 int wxWindow::GetCharHeight(void) const
782 TEXTMETRIC lpTextMetric
;
783 HWND hWnd
= (HWND
) GetHWND();
784 HDC dc
= ::GetDC(hWnd
);
786 GetTextMetrics(dc
, &lpTextMetric
);
787 ::ReleaseDC(hWnd
, dc
);
789 return lpTextMetric
.tmHeight
;
792 int wxWindow::GetCharWidth(void) const
794 TEXTMETRIC lpTextMetric
;
795 HWND hWnd
= (HWND
) GetHWND();
796 HDC dc
= ::GetDC(hWnd
);
798 GetTextMetrics(dc
, &lpTextMetric
);
799 ::ReleaseDC(hWnd
, dc
);
801 return lpTextMetric
.tmAveCharWidth
;
804 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
805 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
807 wxFont
*fontToUse
= (wxFont
*)theFont
;
809 fontToUse
= (wxFont
*) & m_windowFont
;
811 HWND hWnd
= (HWND
) GetHWND();
812 HDC dc
= ::GetDC(hWnd
);
816 if (fontToUse
&& fontToUse
->Ok())
818 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
820 was
= (HFONT
) SelectObject(dc
,fnt
) ;
825 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
826 GetTextMetrics(dc
, &tm
);
828 if (fontToUse
&& fnt
&& was
)
829 SelectObject(dc
,was
) ;
835 if (descent
) *descent
= tm
.tmDescent
;
836 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
839 // fontToUse->ReleaseResource();
842 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
844 HWND hWnd
= (HWND
) GetHWND();
850 mswRect
.left
= rect
->x
;
851 mswRect
.top
= rect
->y
;
852 mswRect
.right
= rect
->x
+ rect
->width
;
853 mswRect
.bottom
= rect
->y
+ rect
->height
;
855 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
858 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
862 bool wxWindow::ProcessEvent(wxEvent
& event
)
864 // we save here the information about the last message because it might be
865 // overwritten if the event handler sends any messages to our window (case
866 // in point: wxNotebook::OnSize) - and then if we call Default() later
867 // (which is done quite often if the message is not processed) it will use
868 // incorrect values for m_lastXXX variables
869 WXUINT lastMsg
= m_lastMsg
;
870 WXWPARAM lastWParam
= m_lastWParam
;
871 WXLPARAM lastLParam
= m_lastLParam
;
873 // call the base version
874 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
878 m_lastWParam
= lastWParam
;
879 m_lastLParam
= lastLParam
;
884 // Hook for new window just as it's being created,
885 // when the window isn't yet associated with the handle
886 wxWindow
*wxWndHook
= NULL
;
889 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
891 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
893 if (!wnd
&& wxWndHook
)
895 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
898 wnd
->m_hWnd
= (WXHWND
) hWnd
;
901 // Stop right here if we don't have a valid handle in our wxWindow object.
902 if (wnd
&& !wnd
->m_hWnd
) {
903 wnd
->m_hWnd
= (WXHWND
) hWnd
;
904 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
910 wnd
->m_lastMsg
= message
;
911 wnd
->m_lastWParam
= wParam
;
912 wnd
->m_lastLParam
= lParam
;
915 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
917 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
920 // Should probably have a test for 'genuine' NT
921 #if defined(__WIN32__)
922 #define DIMENSION_TYPE short
924 #define DIMENSION_TYPE int
927 // Main Windows 3 window proc
928 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
930 wxASSERT( m_lastMsg
== message
&&
931 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
934 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
935 wxGetMessageName(message
), wParam
, lParam
);
936 #endif // __WXDEBUG__
938 HWND hWnd
= (HWND
)m_hWnd
;
945 WORD state
= LOWORD(wParam
);
946 WORD minimized
= HIWORD(wParam
);
947 HWND hwnd
= (HWND
)lParam
;
949 WORD state
= (WORD
)wParam
;
950 WORD minimized
= LOWORD(lParam
);
951 HWND hwnd
= (HWND
)HIWORD(lParam
);
953 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
959 HWND hwnd
= (HWND
)wParam
;
960 // return OnSetFocus(hwnd);
962 if (MSWOnSetFocus((WXHWND
) hwnd
))
964 else return MSWDefWindowProc(message
, wParam
, lParam
);
969 HWND hwnd
= (HWND
)lParam
;
970 // return OnKillFocus(hwnd);
971 if (MSWOnKillFocus((WXHWND
) hwnd
))
974 return MSWDefWindowProc(message
, wParam
, lParam
);
979 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
985 MSWOnShow((wParam
!= 0), (int) lParam
);
992 else return MSWDefWindowProc(message
, wParam
, lParam
);
995 case WM_QUERYDRAGICON
:
997 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
1001 return MSWDefWindowProc(message
, wParam
, lParam
);
1007 int width
= LOWORD(lParam
);
1008 int height
= HIWORD(lParam
);
1009 MSWOnSize(width
, height
, wParam
);
1015 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1017 event
.SetEventObject(this);
1018 if ( !GetEventHandler()->ProcessEvent(event
) )
1023 case WM_WINDOWPOSCHANGING
:
1025 MSWOnWindowPosChanging((void *)lParam
);
1029 case WM_RBUTTONDOWN
:
1031 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1032 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1033 MSWOnRButtonDown(x
, y
, wParam
);
1038 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1039 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1040 MSWOnRButtonUp(x
, y
, wParam
);
1043 case WM_RBUTTONDBLCLK
:
1045 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1046 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1047 MSWOnRButtonDClick(x
, y
, wParam
);
1050 case WM_MBUTTONDOWN
:
1052 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1053 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1054 MSWOnMButtonDown(x
, y
, wParam
);
1059 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1060 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1061 MSWOnMButtonUp(x
, y
, wParam
);
1064 case WM_MBUTTONDBLCLK
:
1066 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1067 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1068 MSWOnMButtonDClick(x
, y
, wParam
);
1071 case WM_LBUTTONDOWN
:
1073 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1074 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1075 MSWOnLButtonDown(x
, y
, wParam
);
1080 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1081 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1082 MSWOnLButtonUp(x
, y
, wParam
);
1085 case WM_LBUTTONDBLCLK
:
1087 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1088 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1089 MSWOnLButtonDClick(x
, y
, wParam
);
1094 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1095 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1096 MSWOnMouseMove(x
, y
, wParam
);
1099 case MM_JOY1BUTTONDOWN
:
1101 int x
= LOWORD(lParam
);
1102 int y
= HIWORD(lParam
);
1103 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1106 case MM_JOY2BUTTONDOWN
:
1108 int x
= LOWORD(lParam
);
1109 int y
= HIWORD(lParam
);
1110 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1113 case MM_JOY1BUTTONUP
:
1115 int x
= LOWORD(lParam
);
1116 int y
= HIWORD(lParam
);
1117 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1120 case MM_JOY2BUTTONUP
:
1122 int x
= LOWORD(lParam
);
1123 int y
= HIWORD(lParam
);
1124 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1129 int x
= LOWORD(lParam
);
1130 int y
= HIWORD(lParam
);
1131 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1136 int x
= LOWORD(lParam
);
1137 int y
= HIWORD(lParam
);
1138 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1143 int z
= LOWORD(lParam
);
1144 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1149 int z
= LOWORD(lParam
);
1150 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1157 else return MSWDefWindowProc(message
, wParam
, lParam
);
1162 return MSWOnSysCommand(wParam
, lParam
);
1168 WORD id
= LOWORD(wParam
);
1169 HWND hwnd
= (HWND
)lParam
;
1170 WORD cmd
= HIWORD(wParam
);
1172 WORD id
= (WORD
)wParam
;
1173 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1174 WORD cmd
= HIWORD(lParam
);
1176 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1177 return MSWDefWindowProc(message
, wParam
, lParam
);
1180 #if defined(__WIN95__)
1183 // for some messages (TVN_ITEMEXPANDING for example), the return
1184 // value of WM_NOTIFY handler is important, so don't just return 0
1185 // if we processed the message
1186 return MSWOnNotify(wParam
, lParam
);
1192 WORD flags
= HIWORD(wParam
);
1193 HMENU sysmenu
= (HMENU
)lParam
;
1195 WORD flags
= LOWORD(lParam
);
1196 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1198 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1201 case WM_INITMENUPOPUP
:
1203 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1208 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1211 case WM_MEASUREITEM
:
1213 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1218 MSWOnKeyDown((WORD
) wParam
, lParam
);
1219 // we consider these message "not interesting"
1220 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1223 // Avoid duplicate messages to OnChar for these special keys
1235 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1236 MSWOnChar((WORD
)wParam
, lParam
);
1240 MSWOnChar((WORD
)wParam
, lParam
);
1241 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1250 MSWOnKeyUp((WORD
) wParam
, lParam
);
1253 case WM_CHAR
: // Always an ASCII character
1255 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1262 WORD code
= LOWORD(wParam
);
1263 WORD pos
= HIWORD(wParam
);
1264 HWND control
= (HWND
)lParam
;
1266 WORD code
= (WORD
)wParam
;
1267 WORD pos
= LOWORD(lParam
);
1268 HWND control
= (HWND
)HIWORD(lParam
);
1270 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1276 WORD code
= LOWORD(wParam
);
1277 WORD pos
= HIWORD(wParam
);
1278 HWND control
= (HWND
)lParam
;
1280 WORD code
= (WORD
)wParam
;
1281 WORD pos
= LOWORD(lParam
);
1282 HWND control
= (HWND
)HIWORD(lParam
);
1284 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1288 case WM_CTLCOLORBTN
:
1290 int nCtlColor
= CTLCOLOR_BTN
;
1291 HWND control
= (HWND
)lParam
;
1292 HDC pDC
= (HDC
)wParam
;
1293 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1294 message
, wParam
, lParam
);
1297 case WM_CTLCOLORDLG
:
1299 int nCtlColor
= CTLCOLOR_DLG
;
1300 HWND control
= (HWND
)lParam
;
1301 HDC pDC
= (HDC
)wParam
;
1302 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1303 message
, wParam
, lParam
);\
1306 case WM_CTLCOLORLISTBOX
:
1308 int nCtlColor
= CTLCOLOR_LISTBOX
;
1309 HWND control
= (HWND
)lParam
;
1310 HDC pDC
= (HDC
)wParam
;
1311 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1312 message
, wParam
, lParam
);
1315 case WM_CTLCOLORMSGBOX
:
1317 int nCtlColor
= CTLCOLOR_MSGBOX
;
1318 HWND control
= (HWND
)lParam
;
1319 HDC pDC
= (HDC
)wParam
;
1320 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1321 message
, wParam
, lParam
);
1324 case WM_CTLCOLORSCROLLBAR
:
1326 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1327 HWND control
= (HWND
)lParam
;
1328 HDC pDC
= (HDC
)wParam
;
1329 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1330 message
, wParam
, lParam
);
1333 case WM_CTLCOLORSTATIC
:
1335 int nCtlColor
= CTLCOLOR_STATIC
;
1336 HWND control
= (HWND
)lParam
;
1337 HDC pDC
= (HDC
)wParam
;
1338 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1339 message
, wParam
, lParam
);
1342 case WM_CTLCOLOREDIT
:
1344 int nCtlColor
= CTLCOLOR_EDIT
;
1345 HWND control
= (HWND
)lParam
;
1346 HDC pDC
= (HDC
)wParam
;
1347 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1348 message
, wParam
, lParam
);
1354 HWND control
= (HWND
)LOWORD(lParam
);
1355 int nCtlColor
= (int)HIWORD(lParam
);
1356 HDC pDC
= (HDC
)wParam
;
1357 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1358 message
, wParam
, lParam
);
1362 case WM_SYSCOLORCHANGE
:
1364 // Return value of 0 means, we processed it.
1365 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1368 return MSWDefWindowProc(message
, wParam
, lParam
);
1371 case WM_PALETTECHANGED
:
1373 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1376 case WM_QUERYNEWPALETTE
:
1378 return MSWOnQueryNewPalette();
1383 // Prevents flicker when dragging
1384 if (IsIconic(hWnd
)) return 1;
1386 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1387 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1391 case WM_MDIACTIVATE
:
1394 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1395 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1396 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1397 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1399 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1400 (HWND
)HIWORD(lParam
));
1405 MSWOnDropFiles(wParam
);
1410 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1413 case WM_QUERYENDSESSION
:
1415 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1416 // return MSWOnClose();
1418 return MSWOnQueryEndSession(lParam
);
1423 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1424 MSWOnEndSession((wParam
!= 0), lParam
);
1437 case WM_GETMINMAXINFO
:
1439 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1440 if (m_minSizeX
!= -1)
1441 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1442 if (m_minSizeY
!= -1)
1443 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1444 if (m_maxSizeX
!= -1)
1445 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1446 if (m_maxSizeY
!= -1)
1447 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1448 return MSWDefWindowProc(message
, wParam
, lParam
);
1453 return MSWGetDlgCode();
1456 return MSWDefWindowProc(message
, wParam
, lParam
);
1459 return 0; // Success: we processed this command.
1462 // Dialog window proc
1463 LONG APIENTRY _EXPORT
1464 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1469 wxList
*wxWinHandleList
= NULL
;
1470 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1472 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1475 return (wxWindow
*)node
->Data();
1478 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1480 // adding NULL hWnd is (first) surely a result of an error and
1481 // (secondly) breaks menu command processing
1482 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1484 if ( !wxWinHandleList
->Find((long)hWnd
) )
1485 wxWinHandleList
->Append((long)hWnd
, win
);
1488 void wxRemoveHandleAssociation(wxWindow
*win
)
1490 wxWinHandleList
->DeleteObject(win
);
1493 // Default destroyer - override if you destroy it in some other way
1494 // (e.g. with MDI child windows)
1495 void wxWindow::MSWDestroyWindow()
1499 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1500 int x
, int y
, int width
, int height
,
1501 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1503 bool is_dialog
= (dialog_template
!= NULL
);
1504 int x1
= CW_USEDEFAULT
;
1506 int width1
= CW_USEDEFAULT
;
1509 // Find parent's size, if it exists, to set up a possible default
1510 // panel size the size of the parent window
1514 // Was GetWindowRect: JACS 5/5/95
1515 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1517 width1
= parent_rect
.right
- parent_rect
.left
;
1518 height1
= parent_rect
.bottom
- parent_rect
.top
;
1523 if (width
> -1) width1
= width
;
1524 if (height
> -1) height1
= height
;
1526 HWND hParent
= NULL
;
1528 hParent
= (HWND
) parent
->GetHWND();
1534 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1535 // other compilers???
1536 // VZ: it's always needed for Win16 and never for Win32
1538 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1539 (DLGPROC
)wxDlgProc
);
1541 // N.B.: if we _don't_ use this form,
1542 // then with VC++ 1.5, it crashes horribly.
1544 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1545 (DLGPROC
)wxDlgProc
);
1547 // Crashes when we use this.
1548 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1550 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1556 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1557 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1558 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1563 if (style
& WS_CHILD
)
1568 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1573 hParent
, (HMENU
)controlId
, wxGetInstance(),
1577 wxLogError("Can't create window of class %s!\n"
1578 "Possible Windows 3.x compatibility problem?", wclass
);
1583 wxWinHandleList
->Append((long)m_hWnd
, this);
1586 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1590 bool wxWindow::MSWOnClose()
1595 // Some compilers don't define this
1596 #ifndef ENDSESSION_LOGOFF
1597 #define ENDSESSION_LOGOFF 0x80000000
1600 // Return TRUE to end session, FALSE to veto end session.
1601 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1603 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1604 event
.SetEventObject(wxTheApp
);
1605 event
.SetCanVeto(TRUE
);
1606 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1607 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1608 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1610 return FALSE
; // Veto!
1614 return TRUE
; // Don't veto
1618 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1620 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1621 event
.SetEventObject(wxTheApp
);
1622 event
.SetCanVeto(FALSE
);
1623 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1624 if (endSession
&& // No need to send if the session isn't ending
1625 (this == wxTheApp
->GetTopWindow()) && // Only send once
1626 wxTheApp
->ProcessEvent(event
))
1632 bool wxWindow::MSWOnDestroy()
1634 // delete our drop target if we've got one
1635 #if wxUSE_DRAG_AND_DROP
1636 if ( m_pDropTarget
!= NULL
) {
1637 m_pDropTarget
->Revoke(m_hWnd
);
1639 delete m_pDropTarget
;
1640 m_pDropTarget
= NULL
;
1647 // Deal with child commands from buttons etc.
1649 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1651 #if defined(__WIN95__)
1652 // Find a child window to send the notification to, e.g. a toolbar.
1653 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1654 // handle of the toolbar; it's probably the handle of the tooltip
1655 // window (anyway, it's parent is also the toolbar's parent).
1656 // So, since we don't know which hWnd or wxWindow originated the
1657 // WM_NOTIFY, we'll need to go through all the children of this window
1658 // trying out MSWNotify.
1659 // This won't work now, though, because any number of controls
1660 // could respond to the same generic messages :-(
1662 /* This doesn't work for toolbars, but try for other controls first.
1664 NMHDR
*hdr
= (NMHDR
*)lParam
;
1665 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1666 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1668 WXLPARAM result
= 0;
1672 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1677 // Rely on MSWNotify to check whether the message
1678 // belongs to the window or not
1679 wxNode
*node
= GetChildren().First();
1682 wxWindow
*child
= (wxWindow
*)node
->Data();
1683 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1685 node
= node
->Next();
1688 // finally try this window too (catches toolbar case)
1689 if ( MSWNotify(wParam
, lParam
, &result
) )
1698 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1702 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1706 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1708 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1710 event
.SetEventObject(this);
1711 GetEventHandler()->ProcessEvent(event
);
1715 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1718 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1720 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1722 ::ShowCaret((HWND
) GetHWND());
1725 // panel wants to track the window which was the last to have focus in it
1726 wxWindow
*parent
= GetParent();
1727 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1729 ((wxPanel
*)parent
)->SetLastFocus(this);
1732 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1733 event
.SetEventObject(this);
1734 if (!GetEventHandler()->ProcessEvent(event
))
1739 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1747 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1748 event
.SetEventObject(this);
1749 if (!GetEventHandler()->ProcessEvent(event
))
1754 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1757 HDROP hFilesInfo
= (HDROP
) wParam
;
1759 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1761 // Get the total number of files dropped
1762 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1767 wxString
*files
= new wxString
[gwFilesDropped
];
1769 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1771 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1772 files
[wIndex
] = wxBuffer
;
1774 DragFinish (hFilesInfo
);
1776 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1777 event
.m_eventObject
= this;
1778 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1780 if (!GetEventHandler()->ProcessEvent(event
))
1786 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1788 #if wxUSE_OWNER_DRAWN
1789 if ( id
== 0 ) { // is it a menu item?
1790 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1791 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1792 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1794 // prepare to call OnDrawItem()
1796 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1797 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1798 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1799 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1800 return pMenuItem
->OnDrawItem(
1802 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1803 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1806 #endif // owner-drawn menus
1808 wxWindow
*item
= FindItem(id
);
1809 #if wxUSE_DYNAMIC_CLASSES
1810 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1812 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1819 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1821 #if wxUSE_OWNER_DRAWN
1822 if ( id
== 0 ) { // is it a menu item?
1823 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1824 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1825 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1827 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1828 &pMeasureStruct
->itemHeight
);
1830 #endif // owner-drawn menus
1832 wxWindow
*item
= FindItem(id
);
1833 #if wxUSE_DYNAMIC_CLASSES
1834 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1836 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1843 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1844 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1846 if (nCtlColor
== CTLCOLOR_DLG
)
1848 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1851 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1853 WXHBRUSH hBrush
= 0;
1856 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1858 // I think that even for dialogs, we may need to call DefWindowProc (?)
1859 // Or maybe just rely on the usual default behaviour.
1861 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1866 // Define for each class of dialog and control
1867 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1868 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1870 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1873 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1875 wxSysColourChangedEvent event
;
1876 event
.SetEventObject(this);
1878 // Check if app handles this.
1879 if (GetEventHandler()->ProcessEvent(event
))
1882 // We didn't process it
1886 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1888 wxPaletteChangedEvent
event(GetId());
1889 event
.SetEventObject(this);
1890 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1891 GetEventHandler()->ProcessEvent(event
);
1895 long wxWindow::MSWOnQueryNewPalette()
1897 wxQueryNewPaletteEvent
event(GetId());
1898 event
.SetEventObject(this);
1899 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1901 return (long) FALSE
;
1907 // Responds to colour changes: passes event on to children.
1908 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1910 wxNode
*node
= GetChildren().First();
1913 // Only propagate to non-top-level windows
1914 wxWindow
*win
= (wxWindow
*)node
->Data();
1915 if ( win
->GetParent() )
1917 wxSysColourChangedEvent event2
;
1918 event
.m_eventObject
= win
;
1919 win
->GetEventHandler()->ProcessEvent(event2
);
1922 node
= node
->Next();
1926 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1929 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1931 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1934 long wxWindow::Default()
1936 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1941 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1942 wxGetMessageName(m_lastMsg
));
1943 #endif // __WXDEBUG__
1945 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1948 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1950 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1951 // intercept dialog navigation keys
1952 MSG
*msg
= (MSG
*)pMsg
;
1953 bool bProcess
= TRUE
;
1954 if ( msg
->message
!= WM_KEYDOWN
)
1957 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1962 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1964 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1965 // don't process it if it's the case (except for Ctrl-Tab/Enter
1966 // combinations which are always processed)
1970 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1973 bool bForward
= TRUE
,
1974 bWindowChange
= FALSE
;
1976 switch ( msg
->wParam
)
1979 if ( lDlgCode
& DLGC_WANTTAB
) {
1983 // Ctrl-Tab cycles thru notebook pages
1984 bWindowChange
= bCtrlDown
;
1985 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1991 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1999 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2005 if ( lDlgCode
& DLGC_WANTMESSAGE
)
2007 // control wants to process Enter itself, don't
2008 // call IsDialogMessage() which would interpret
2013 wxButton
*btnDefault
= GetDefaultItem();
2014 if ( btnDefault
&& !bCtrlDown
)
2016 // if there is a default button, Enter should
2018 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
2022 // else: but if there is not it makes sense to make it
2023 // work like a TAB - and that's what we do.
2024 // Note that Ctrl-Enter always works this way.
2034 wxNavigationKeyEvent event
;
2035 event
.SetDirection(bForward
);
2036 event
.SetWindowChange(bWindowChange
);
2037 event
.SetEventObject(this);
2039 if ( GetEventHandler()->ProcessEvent(event
) )
2044 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
2050 // relay mouse move events to the tooltip control
2051 MSG
*msg
= (MSG
*)pMsg
;
2052 if ( msg
->message
== WM_MOUSEMOVE
)
2053 m_tooltip
->RelayEvent(pMsg
);
2055 #endif // wxUSE_TOOLTIPS
2060 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2062 if (m_acceleratorTable
.Ok() &&
2063 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2069 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2074 void wxWindow::MSWDetachWindowMenu()
2078 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2080 for (i
= 0; i
< N
; i
++)
2083 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2084 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2086 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2093 bool wxWindow::MSWOnPaint()
2096 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2097 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2099 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2102 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2104 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2105 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2108 wxPaintEvent
event(m_windowId
);
2109 event
.SetEventObject(this);
2110 if (!GetEventHandler()->ProcessEvent(event
))
2115 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2125 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2126 event
.SetEventObject(this);
2127 if (!GetEventHandler()->ProcessEvent(event
))
2133 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2138 // Deal with child commands from buttons etc.
2139 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2141 if (wxCurrentPopupMenu
)
2143 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2144 wxCurrentPopupMenu
= NULL
;
2145 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2149 wxWindow
*item
= FindItem(id
);
2152 bool value
= item
->MSWCommand(cmd
, id
);
2157 wxWindow
*win
= wxFindWinFromHandle(control
);
2159 return win
->MSWCommand(cmd
, id
);
2164 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2170 wxMaximizeEvent
event(m_windowId
);
2171 event
.SetEventObject(this);
2172 if (!GetEventHandler()->ProcessEvent(event
))
2180 wxIconizeEvent
event(m_windowId
);
2181 event
.SetEventObject(this);
2182 if (!GetEventHandler()->ProcessEvent(event
))
2194 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2196 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2198 event
.m_x
= x
; event
.m_y
= y
;
2199 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2200 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2201 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2202 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2203 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2204 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2205 event
.m_eventObject
= this;
2207 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2209 if (!GetEventHandler()->ProcessEvent(event
))
2213 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2215 wxMouseEvent
event(wxEVT_LEFT_UP
);
2217 event
.m_x
= x
; event
.m_y
= y
;
2218 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2219 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2220 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2221 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2222 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2223 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2224 event
.m_eventObject
= this;
2226 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2228 if (!GetEventHandler()->ProcessEvent(event
))
2232 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2234 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2236 event
.m_x
= x
; event
.m_y
= y
;
2237 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2238 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2239 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2240 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2241 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2242 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2243 event
.m_eventObject
= this;
2245 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2247 if (!GetEventHandler()->ProcessEvent(event
))
2251 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2253 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2255 event
.m_x
= x
; event
.m_y
= y
;
2256 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2257 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2258 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2259 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2260 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2261 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2262 event
.m_eventObject
= this;
2264 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2266 if (!GetEventHandler()->ProcessEvent(event
))
2270 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2272 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2274 event
.m_x
= x
; event
.m_y
= y
;
2275 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2276 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2277 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2278 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2279 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2280 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2281 event
.m_eventObject
= this;
2283 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2285 if (!GetEventHandler()->ProcessEvent(event
))
2289 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2291 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2293 event
.m_x
= x
; event
.m_y
= y
;
2294 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2295 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2296 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2297 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2298 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2299 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2300 event
.m_eventObject
= this;
2302 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2304 if (!GetEventHandler()->ProcessEvent(event
))
2308 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2310 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2312 event
.m_x
= x
; event
.m_y
= y
;
2313 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2314 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2315 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2316 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2317 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2318 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2319 event
.m_eventObject
= this;
2321 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2323 if (!GetEventHandler()->ProcessEvent(event
))
2327 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2329 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2331 event
.m_x
= x
; event
.m_y
= y
;
2332 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2333 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2334 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2335 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2336 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2337 event
.m_eventObject
= this;
2338 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2340 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2342 if (!GetEventHandler()->ProcessEvent(event
))
2346 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2348 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2350 event
.m_x
= x
; event
.m_y
= y
;
2351 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2352 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2353 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2354 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2355 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2356 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2357 event
.m_eventObject
= this;
2359 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2361 if (!GetEventHandler()->ProcessEvent(event
))
2365 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2367 // 'normal' move event...
2368 // Set cursor, but only if we're not in 'busy' mode
2370 // Trouble with this is that it sets the cursor for controls too :-(
2371 if (m_windowCursor
.Ok() && !wxIsBusy())
2372 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2374 if (!m_mouseInWindow
)
2376 // Generate an ENTER event
2377 m_mouseInWindow
= TRUE
;
2378 MSWOnMouseEnter(x
, y
, flags
);
2381 wxMouseEvent
event(wxEVT_MOTION
);
2383 event
.m_x
= x
; event
.m_y
= y
;
2384 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2385 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2386 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2387 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2388 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2389 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2390 event
.m_eventObject
= this;
2392 // Window gets a click down message followed by a mouse move
2393 // message even if position isn't changed! We want to discard
2394 // the trailing move event if x and y are the same.
2395 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2396 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2397 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2399 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2400 m_lastEvent
= wxEVT_MOTION
;
2404 m_lastEvent
= wxEVT_MOTION
;
2405 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2407 if (!GetEventHandler()->ProcessEvent(event
))
2411 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2413 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2415 event
.m_x
= x
; event
.m_y
= y
;
2416 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2417 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2418 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2419 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2420 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2421 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2422 event
.m_eventObject
= this;
2424 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2425 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2426 // No message - ensure we don't try to call the default behaviour accidentally.
2428 GetEventHandler()->ProcessEvent(event
);
2431 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2433 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2435 event
.m_x
= x
; event
.m_y
= y
;
2436 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2437 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2438 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2439 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2440 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2441 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2442 event
.m_eventObject
= this;
2444 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2445 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2446 // No message - ensure we don't try to call the default behaviour accidentally.
2448 GetEventHandler()->ProcessEvent(event
);
2451 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2454 bool tempControlDown
= FALSE
;
2457 // If 1 -> 26, translate to CTRL plus a letter.
2459 if ((id
> 0) && (id
< 27))
2480 tempControlDown
= TRUE
;
2486 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2487 // it's ASCII and will be processed here only when called from
2488 // WM_CHAR (i.e. when isASCII = TRUE)
2494 wxKeyEvent
event(wxEVT_CHAR
);
2495 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2496 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2497 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2498 event
.m_altDown
= TRUE
;
2500 event
.m_eventObject
= this;
2501 event
.m_keyCode
= id
;
2502 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2507 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2511 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2513 if (!GetEventHandler()->ProcessEvent(event
))
2518 void wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2522 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2528 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2529 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2530 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2531 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2532 event
.m_altDown
= TRUE
;
2534 event
.m_eventObject
= this;
2535 event
.m_keyCode
= id
;
2536 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2541 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2545 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2547 if (!GetEventHandler()->ProcessEvent(event
))
2552 void wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2556 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2562 wxKeyEvent
event(wxEVT_KEY_UP
);
2563 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2564 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2565 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2566 event
.m_altDown
= TRUE
;
2568 event
.m_eventObject
= this;
2569 event
.m_keyCode
= id
;
2570 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2575 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2579 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2581 if (!GetEventHandler()->ProcessEvent(event
))
2586 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2590 if (flags
& JOY_BUTTON1CHG
)
2591 change
= wxJOY_BUTTON1
;
2592 if (flags
& JOY_BUTTON2CHG
)
2593 change
= wxJOY_BUTTON2
;
2594 if (flags
& JOY_BUTTON3CHG
)
2595 change
= wxJOY_BUTTON3
;
2596 if (flags
& JOY_BUTTON4CHG
)
2597 change
= wxJOY_BUTTON4
;
2599 if (flags
& JOY_BUTTON1
)
2600 buttons
|= wxJOY_BUTTON1
;
2601 if (flags
& JOY_BUTTON2
)
2602 buttons
|= wxJOY_BUTTON2
;
2603 if (flags
& JOY_BUTTON3
)
2604 buttons
|= wxJOY_BUTTON3
;
2605 if (flags
& JOY_BUTTON4
)
2606 buttons
|= wxJOY_BUTTON4
;
2608 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2609 event
.SetPosition(wxPoint(x
, y
));
2610 event
.SetEventObject(this);
2612 GetEventHandler()->ProcessEvent(event
);
2615 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2619 if (flags
& JOY_BUTTON1CHG
)
2620 change
= wxJOY_BUTTON1
;
2621 if (flags
& JOY_BUTTON2CHG
)
2622 change
= wxJOY_BUTTON2
;
2623 if (flags
& JOY_BUTTON3CHG
)
2624 change
= wxJOY_BUTTON3
;
2625 if (flags
& JOY_BUTTON4CHG
)
2626 change
= wxJOY_BUTTON4
;
2628 if (flags
& JOY_BUTTON1
)
2629 buttons
|= wxJOY_BUTTON1
;
2630 if (flags
& JOY_BUTTON2
)
2631 buttons
|= wxJOY_BUTTON2
;
2632 if (flags
& JOY_BUTTON3
)
2633 buttons
|= wxJOY_BUTTON3
;
2634 if (flags
& JOY_BUTTON4
)
2635 buttons
|= wxJOY_BUTTON4
;
2637 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2638 event
.SetPosition(wxPoint(x
, y
));
2639 event
.SetEventObject(this);
2641 GetEventHandler()->ProcessEvent(event
);
2644 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2647 if (flags
& JOY_BUTTON1
)
2648 buttons
|= wxJOY_BUTTON1
;
2649 if (flags
& JOY_BUTTON2
)
2650 buttons
|= wxJOY_BUTTON2
;
2651 if (flags
& JOY_BUTTON3
)
2652 buttons
|= wxJOY_BUTTON3
;
2653 if (flags
& JOY_BUTTON4
)
2654 buttons
|= wxJOY_BUTTON4
;
2656 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2657 event
.SetPosition(wxPoint(x
, y
));
2658 event
.SetEventObject(this);
2660 GetEventHandler()->ProcessEvent(event
);
2663 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2666 if (flags
& JOY_BUTTON1
)
2667 buttons
|= wxJOY_BUTTON1
;
2668 if (flags
& JOY_BUTTON2
)
2669 buttons
|= wxJOY_BUTTON2
;
2670 if (flags
& JOY_BUTTON3
)
2671 buttons
|= wxJOY_BUTTON3
;
2672 if (flags
& JOY_BUTTON4
)
2673 buttons
|= wxJOY_BUTTON4
;
2675 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2676 event
.SetZPosition(z
);
2677 event
.SetEventObject(this);
2679 GetEventHandler()->ProcessEvent(event
);
2682 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2686 wxWindow
*child
= wxFindWinFromHandle(control
);
2688 child
->MSWOnVScroll(wParam
, pos
, control
);
2692 wxScrollEvent event
;
2693 event
.SetPosition(pos
);
2694 event
.SetOrientation(wxVERTICAL
);
2695 event
.m_eventObject
= this;
2700 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2704 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2708 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2712 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2716 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2720 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2724 case SB_THUMBPOSITION
:
2725 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2733 if (!GetEventHandler()->ProcessEvent(event
))
2737 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2741 wxWindow
*child
= wxFindWinFromHandle(control
);
2743 child
->MSWOnHScroll(wParam
, pos
, control
);
2749 wxScrollEvent event
;
2750 event
.SetPosition(pos
);
2751 event
.SetOrientation(wxHORIZONTAL
);
2752 event
.m_eventObject
= this;
2757 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2761 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2765 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2769 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2773 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2777 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2781 case SB_THUMBPOSITION
:
2782 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2789 if ( GetEventHandler()->ProcessEvent(event
) )
2793 // call the default WM_HSCROLL handler: it's non trivial in some common
2794 // controls (up-down control for example)
2798 void wxWindow::MSWOnShow(bool show
, int status
)
2800 wxShowEvent
event(GetId(), show
);
2801 event
.m_eventObject
= this;
2802 GetEventHandler()->ProcessEvent(event
);
2805 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2807 wxInitDialogEvent
event(GetId());
2808 event
.m_eventObject
= this;
2809 GetEventHandler()->ProcessEvent(event
);
2813 void wxWindow::InitDialog()
2815 wxInitDialogEvent
event(GetId());
2816 event
.SetEventObject( this );
2817 GetEventHandler()->ProcessEvent(event
);
2820 // Default init dialog behaviour is to transfer data to window
2821 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2823 TransferDataToWindow();
2826 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2829 HDC dc
= ::GetDC((HWND
) wnd
);
2834 // the_font->UseResource();
2835 // the_font->RealizeResource();
2836 fnt
= (HFONT
)the_font
->GetResourceHandle();
2838 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2840 GetTextMetrics(dc
, &tm
);
2841 if (the_font
&& fnt
&& was
)
2843 SelectObject(dc
,was
) ;
2845 ReleaseDC((HWND
)wnd
, dc
);
2846 *x
= tm
.tmAveCharWidth
;
2847 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2850 // the_font->ReleaseResource();
2853 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2854 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2855 int wxCharCodeMSWToWX(int keySym
)
2860 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2861 case VK_BACK
: id
= WXK_BACK
; break;
2862 case VK_TAB
: id
= WXK_TAB
; break;
2863 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2864 case VK_RETURN
: id
= WXK_RETURN
; break;
2865 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2866 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2867 case VK_MENU
: id
= WXK_MENU
; break;
2868 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2869 case VK_SPACE
: id
= WXK_SPACE
; break;
2870 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2871 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2872 case VK_NEXT
: id
= WXK_NEXT
; break;
2873 case VK_END
: id
= WXK_END
; break;
2874 case VK_HOME
: id
= WXK_HOME
; break;
2875 case VK_LEFT
: id
= WXK_LEFT
; break;
2876 case VK_UP
: id
= WXK_UP
; break;
2877 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2878 case VK_DOWN
: id
= WXK_DOWN
; break;
2879 case VK_SELECT
: id
= WXK_SELECT
; break;
2880 case VK_PRINT
: id
= WXK_PRINT
; break;
2881 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2882 case VK_INSERT
: id
= WXK_INSERT
; break;
2883 case VK_DELETE
: id
= WXK_DELETE
; break;
2884 case VK_HELP
: id
= WXK_HELP
; break;
2885 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2886 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2887 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2888 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2889 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2890 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2891 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2892 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2893 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2894 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2895 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2896 case VK_ADD
: id
= WXK_ADD
; break;
2897 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2898 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2899 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2900 case VK_F1
: id
= WXK_F1
; break;
2901 case VK_F2
: id
= WXK_F2
; break;
2902 case VK_F3
: id
= WXK_F3
; break;
2903 case VK_F4
: id
= WXK_F4
; break;
2904 case VK_F5
: id
= WXK_F5
; break;
2905 case VK_F6
: id
= WXK_F6
; break;
2906 case VK_F7
: id
= WXK_F7
; break;
2907 case VK_F8
: id
= WXK_F8
; break;
2908 case VK_F9
: id
= WXK_F9
; break;
2909 case VK_F10
: id
= WXK_F10
; break;
2910 case VK_F11
: id
= WXK_F11
; break;
2911 case VK_F12
: id
= WXK_F12
; break;
2912 case VK_F13
: id
= WXK_F13
; break;
2913 case VK_F14
: id
= WXK_F14
; break;
2914 case VK_F15
: id
= WXK_F15
; break;
2915 case VK_F16
: id
= WXK_F16
; break;
2916 case VK_F17
: id
= WXK_F17
; break;
2917 case VK_F18
: id
= WXK_F18
; break;
2918 case VK_F19
: id
= WXK_F19
; break;
2919 case VK_F20
: id
= WXK_F20
; break;
2920 case VK_F21
: id
= WXK_F21
; break;
2921 case VK_F22
: id
= WXK_F22
; break;
2922 case VK_F23
: id
= WXK_F23
; break;
2923 case VK_F24
: id
= WXK_F24
; break;
2924 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2925 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2934 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2940 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2941 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2942 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2943 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2944 case WXK_MENU
: keySym
= VK_MENU
; break;
2945 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2946 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2947 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2948 case WXK_END
: keySym
= VK_END
; break;
2949 case WXK_HOME
: keySym
= VK_HOME
; break;
2950 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2951 case WXK_UP
: keySym
= VK_UP
; break;
2952 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2953 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2954 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2955 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2956 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2957 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2958 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2959 case WXK_HELP
: keySym
= VK_HELP
; break;
2960 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2961 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2962 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2963 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2964 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2965 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2966 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2967 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2968 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2969 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2970 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2971 case WXK_ADD
: keySym
= VK_ADD
; break;
2972 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2973 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2974 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2975 case WXK_F1
: keySym
= VK_F1
; break;
2976 case WXK_F2
: keySym
= VK_F2
; break;
2977 case WXK_F3
: keySym
= VK_F3
; break;
2978 case WXK_F4
: keySym
= VK_F4
; break;
2979 case WXK_F5
: keySym
= VK_F5
; break;
2980 case WXK_F6
: keySym
= VK_F6
; break;
2981 case WXK_F7
: keySym
= VK_F7
; break;
2982 case WXK_F8
: keySym
= VK_F8
; break;
2983 case WXK_F9
: keySym
= VK_F9
; break;
2984 case WXK_F10
: keySym
= VK_F10
; break;
2985 case WXK_F11
: keySym
= VK_F11
; break;
2986 case WXK_F12
: keySym
= VK_F12
; break;
2987 case WXK_F13
: keySym
= VK_F13
; break;
2988 case WXK_F14
: keySym
= VK_F14
; break;
2989 case WXK_F15
: keySym
= VK_F15
; break;
2990 case WXK_F16
: keySym
= VK_F16
; break;
2991 case WXK_F17
: keySym
= VK_F17
; break;
2992 case WXK_F18
: keySym
= VK_F18
; break;
2993 case WXK_F19
: keySym
= VK_F19
; break;
2994 case WXK_F20
: keySym
= VK_F20
; break;
2995 case WXK_F21
: keySym
= VK_F21
; break;
2996 case WXK_F22
: keySym
= VK_F22
; break;
2997 case WXK_F23
: keySym
= VK_F23
; break;
2998 case WXK_F24
: keySym
= VK_F24
; break;
2999 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
3000 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
3011 // Caret manipulation
3012 void wxWindow::CreateCaret(int w
, int h
)
3016 m_caretEnabled
= TRUE
;
3019 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
3024 void wxWindow::ShowCaret(bool show
)
3029 ::ShowCaret((HWND
) GetHWND());
3031 ::HideCaret((HWND
) GetHWND());
3032 m_caretShown
= show
;
3036 void wxWindow::DestroyCaret()
3038 m_caretEnabled
= FALSE
;
3041 void wxWindow::SetCaretPos(int x
, int y
)
3043 ::SetCaretPos(x
, y
);
3046 void wxWindow::GetCaretPos(int *x
, int *y
) const
3049 ::GetCaretPos(&point
);
3054 wxWindow
*wxGetActiveWindow()
3056 HWND hWnd
= GetActiveWindow();
3059 return wxFindWinFromHandle((WXHWND
) hWnd
);
3064 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3065 // in active frames and dialogs, regardless of where the focus is.
3066 static HHOOK wxTheKeyboardHook
= 0;
3067 static FARPROC wxTheKeyboardHookProc
= 0;
3068 int APIENTRY _EXPORT
3069 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3071 void wxSetKeyboardHook(bool doIt
)
3075 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3076 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3077 #if defined(__WIN32__) && !defined(__TWIN32__)
3078 GetCurrentThreadId());
3079 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3086 UnhookWindowsHookEx(wxTheKeyboardHook
);
3087 FreeProcInstance(wxTheKeyboardHookProc
);
3091 int APIENTRY _EXPORT
3092 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3094 DWORD hiWord
= HIWORD(lParam
);
3095 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3098 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3100 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3101 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3102 event
.m_altDown
= TRUE
;
3104 event
.m_eventObject
= NULL
;
3105 event
.m_keyCode
= id
;
3106 /* begin Albert's fix for control and shift key 26.5 */
3107 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3108 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3109 /* end Albert's fix for control and shift key 26.5 */
3110 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3112 wxWindow
*win
= wxGetActiveWindow();
3115 if (win
->GetEventHandler()->ProcessEvent(event
))
3120 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3125 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3128 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3136 void wxWindow::Centre(int direction
)
3138 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3140 wxWindow
*father
= (wxWindow
*)GetParent();
3144 father
->GetClientSize(&panel_width
, &panel_height
);
3145 GetSize(&width
, &height
);
3146 GetPosition(&x
, &y
);
3151 if (direction
& wxHORIZONTAL
)
3152 new_x
= (int)((panel_width
- width
)/2);
3154 if (direction
& wxVERTICAL
)
3155 new_y
= (int)((panel_height
- height
)/2);
3157 SetSize(new_x
, new_y
, -1, -1);
3161 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3163 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3164 // pixel coordinates, relatives to the canvas -- So, we first need to
3165 // substract origin of the window, then convert to screen position
3167 int x
= x_pos
; int y
= y_pos
;
3169 GetWindowRect ((HWND
) GetHWND(), &rect
);
3174 SetCursorPos (x
, y
);
3177 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3181 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3189 wxEraseEvent
event(m_windowId
, &dc
);
3190 event
.m_eventObject
= this;
3191 if (!GetEventHandler()->ProcessEvent(event
))
3194 dc
.SelectOldObjects(pDC
);
3200 dc
.SelectOldObjects(pDC
);
3203 dc
.SetHDC((WXHDC
) NULL
);
3207 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3213 ::GetClientRect((HWND
) GetHWND(), &rect
);
3215 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3216 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3217 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3219 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3220 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3221 ::DeleteObject(hBrush
);
3222 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3224 // Less efficient version (and doesn't account for scrolling)
3226 GetClientSize(& w, & h);
3227 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3228 event.GetDC()->SetBrush(brush);
3229 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3231 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3235 #if WXWIN_COMPATIBILITY
3236 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3238 #if defined(__WIN95__)
3242 // Try to adjust the range to cope with page size > 1
3243 // - a Windows API quirk
3244 int pageSize
= GetScrollPage(orient
);
3245 if ( pageSize
> 1 && range
> 0)
3247 range1
+= (pageSize
- 1);
3253 if (orient
== wxHORIZONTAL
) {
3259 info
.cbSize
= sizeof(SCROLLINFO
);
3260 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3264 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3266 HWND hWnd
= (HWND
) GetHWND();
3268 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3271 if (orient
== wxHORIZONTAL
)
3276 HWND hWnd
= (HWND
) GetHWND();
3278 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3282 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3284 #if defined(__WIN95__)
3288 if (orient
== wxHORIZONTAL
) {
3290 m_xThumbSize
= page
;
3293 m_yThumbSize
= page
;
3296 info
.cbSize
= sizeof(SCROLLINFO
);
3299 info
.fMask
= SIF_PAGE
;
3301 HWND hWnd
= (HWND
) GetHWND();
3303 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3305 if (orient
== wxHORIZONTAL
)
3306 m_xThumbSize
= page
;
3308 m_yThumbSize
= page
;
3312 int wxWindow::OldGetScrollRange(int orient
) const
3315 if (orient
== wxHORIZONTAL
)
3320 #if __WATCOMC__ && defined(__WINDOWS_386__)
3321 short minPos
, maxPos
;
3325 HWND hWnd
= (HWND
) GetHWND();
3328 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3329 #if defined(__WIN95__)
3330 // Try to adjust the range to cope with page size > 1
3331 // - a Windows API quirk
3332 int pageSize
= GetScrollPage(orient
);
3335 maxPos
-= (pageSize
- 1);
3344 int wxWindow::GetScrollPage(int orient
) const
3346 if (orient
== wxHORIZONTAL
)
3347 return m_xThumbSize
;
3349 return m_yThumbSize
;
3353 int wxWindow::GetScrollPos(int orient
) const
3356 if (orient
== wxHORIZONTAL
)
3360 HWND hWnd
= (HWND
) GetHWND();
3363 return ::GetScrollPos(hWnd
, wOrient
);
3369 // This now returns the whole range, not just the number
3370 // of positions that we can scroll.
3371 int wxWindow::GetScrollRange(int orient
) const
3374 if (orient
== wxHORIZONTAL
)
3379 #if __WATCOMC__ && defined(__WINDOWS_386__)
3380 short minPos
, maxPos
;
3384 HWND hWnd
= (HWND
) GetHWND();
3387 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3388 #if defined(__WIN95__)
3389 // Try to adjust the range to cope with page size > 1
3390 // - a Windows API quirk
3391 int pageSize
= GetScrollThumb(orient
);
3394 maxPos
-= (pageSize
- 1);
3396 // October 10th: new range concept.
3406 int wxWindow::GetScrollThumb(int orient
) const
3408 if (orient
== wxHORIZONTAL
)
3409 return m_xThumbSize
;
3411 return m_yThumbSize
;
3414 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3416 #if defined(__WIN95__)
3420 if (orient
== wxHORIZONTAL
) {
3426 info
.cbSize
= sizeof(SCROLLINFO
);
3430 info
.fMask
= SIF_POS
;
3432 HWND hWnd
= (HWND
) GetHWND();
3434 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3437 if (orient
== wxHORIZONTAL
)
3442 HWND hWnd
= (HWND
) GetHWND();
3444 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3448 // New function that will replace some of the above.
3449 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3450 int range
, bool refresh
)
3453 SetScrollPage(orient, thumbVisible, FALSE);
3455 int oldRange = range - thumbVisible ;
3456 SetScrollRange(orient, oldRange, FALSE);
3458 SetScrollPos(orient, pos, refresh);
3460 #if defined(__WIN95__)
3461 int oldRange
= range
- thumbVisible
;
3463 int range1
= oldRange
;
3465 // Try to adjust the range to cope with page size > 1
3466 // - a Windows API quirk
3467 int pageSize
= thumbVisible
;
3468 if ( pageSize
> 1 && range
> 0)
3470 range1
+= (pageSize
- 1);
3476 if (orient
== wxHORIZONTAL
) {
3482 info
.cbSize
= sizeof(SCROLLINFO
);
3483 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3487 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3489 HWND hWnd
= (HWND
) GetHWND();
3491 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3494 if (orient
== wxHORIZONTAL
)
3499 HWND hWnd
= (HWND
) GetHWND();
3502 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3503 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3506 if (orient
== wxHORIZONTAL
) {
3507 m_xThumbSize
= thumbVisible
;
3509 m_yThumbSize
= thumbVisible
;
3513 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3518 rect2
.left
= rect
->x
;
3519 rect2
.top
= rect
->y
;
3520 rect2
.right
= rect
->x
+ rect
->width
;
3521 rect2
.bottom
= rect
->y
+ rect
->height
;
3525 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3527 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3530 void wxWindow::SetFont(const wxFont
& font
)
3532 m_windowFont
= font
;
3534 if (!m_windowFont
.Ok())
3537 HWND hWnd
= (HWND
) GetHWND();
3540 if (m_windowFont
.GetResourceHandle())
3541 SendMessage(hWnd
, WM_SETFONT
,
3542 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3546 void wxWindow::SubclassWin(WXHWND hWnd
)
3548 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3550 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3552 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3553 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3556 void wxWindow::UnsubclassWin()
3558 wxRemoveHandleAssociation(this);
3560 // Restore old Window proc
3561 if ((HWND
) GetHWND())
3563 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3564 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3566 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3572 // Make a Windows extended style from the given wxWindows window style
3573 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3575 WXDWORD exStyle
= 0;
3576 if ( style
& wxTRANSPARENT_WINDOW
)
3577 exStyle
|= WS_EX_TRANSPARENT
;
3579 if ( !eliminateBorders
)
3581 if ( style
& wxSUNKEN_BORDER
)
3582 exStyle
|= WS_EX_CLIENTEDGE
;
3583 if ( style
& wxDOUBLE_BORDER
)
3584 exStyle
|= WS_EX_DLGMODALFRAME
;
3585 #if defined(__WIN95__)
3586 if ( style
& wxRAISED_BORDER
)
3587 exStyle
|= WS_EX_WINDOWEDGE
;
3588 if ( style
& wxSTATIC_BORDER
)
3589 exStyle
|= WS_EX_STATICEDGE
;
3595 // Determines whether native 3D effects or CTL3D should be used,
3596 // applying a default border style if required, and returning an extended
3597 // style to pass to CreateWindowEx.
3598 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3600 // If matches certain criteria, then assume no 3D effects
3601 // unless specifically requested (dealt with in MakeExtendedStyle)
3602 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3605 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3608 // Determine whether we should be using 3D effects or not.
3609 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3611 // 1) App can specify global 3D effects
3612 *want3D
= wxTheApp
->GetAuto3D();
3614 // 2) If the parent is being drawn with user colours, or simple border specified,
3615 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3616 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3619 // 3) Control can override this global setting by defining
3620 // a border style, e.g. wxSUNKEN_BORDER
3621 if (m_windowStyle
& wxSUNKEN_BORDER
)
3624 // 4) If it's a special border, CTL3D can't cope so we want a native border
3625 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3626 (m_windowStyle
& wxSTATIC_BORDER
) )
3629 nativeBorder
= TRUE
;
3632 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3633 // effects from extended style
3636 nativeBorder
= FALSE
;
3639 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3641 // If we want 3D, but haven't specified a border here,
3642 // apply the default border style specified.
3643 // TODO what about non-Win95 WIN32? Does it have borders?
3644 #if defined(__WIN95__) && !wxUSE_CTL3D
3645 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3646 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3647 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3653 void wxWindow::OnChar(wxKeyEvent
& event
)
3656 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3661 if ( !event
.ControlDown() )
3662 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3665 bool wxWindow::IsEnabled(void) const
3667 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3670 // Dialog support: override these and call
3671 // base class members to add functionality
3672 // that can't be done using validators.
3673 // NOTE: these functions assume that controls
3674 // are direct children of this window, not grandchildren
3675 // or other levels of descendant.
3677 // Transfer values to controls. If returns FALSE,
3678 // it's an application error (pops up a dialog)
3679 bool wxWindow::TransferDataToWindow()
3681 wxNode
*node
= GetChildren().First();
3684 wxWindow
*child
= (wxWindow
*)node
->Data();
3685 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3686 !child
->GetValidator()->TransferToWindow() )
3688 wxLogError(_("Could not transfer data to window"));
3692 node
= node
->Next();
3697 // Transfer values from controls. If returns FALSE,
3698 // validation failed: don't quit
3699 bool wxWindow::TransferDataFromWindow()
3701 wxNode
*node
= GetChildren().First();
3704 wxWindow
*child
= (wxWindow
*)node
->Data();
3705 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3710 node
= node
->Next();
3715 bool wxWindow::Validate()
3717 wxNode
*node
= GetChildren().First();
3720 wxWindow
*child
= (wxWindow
*)node
->Data();
3721 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3726 node
= node
->Next();
3731 // Get the window with the focus
3732 wxWindow
*wxWindow::FindFocus()
3734 HWND hWnd
= ::GetFocus();
3737 return wxFindWinFromHandle((WXHWND
) hWnd
);
3742 void wxWindow::AddChild(wxWindow
*child
)
3744 GetChildren().Append(child
);
3745 child
->m_windowParent
= this;
3748 void wxWindow::RemoveChild(wxWindow
*child
)
3750 // if (GetChildren())
3751 GetChildren().DeleteObject(child
);
3752 child
->m_windowParent
= NULL
;
3755 void wxWindow::DestroyChildren()
3758 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3760 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3762 if ( GetChildren().Member(child
) )
3768 void wxWindow::MakeModal(bool modal
)
3770 // Disable all other windows
3771 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3773 wxNode
*node
= wxTopLevelWindows
.First();
3776 wxWindow
*win
= (wxWindow
*)node
->Data();
3778 win
->Enable(!modal
);
3780 node
= node
->Next();
3785 // If nothing defined for this, try the parent.
3786 // E.g. we may be a button loaded from a resource, with no callback function
3788 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3790 if (GetEventHandler()->ProcessEvent(event
) )
3793 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3796 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3800 UnsetConstraints(m_constraints
);
3801 delete m_constraints
;
3806 // Make sure other windows know they're part of a 'meaningful relationship'
3807 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3808 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3809 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3810 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3811 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3812 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3813 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3814 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3815 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3816 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3817 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3818 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3819 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3820 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3821 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3822 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3826 // This removes any dangling pointers to this window
3827 // in other windows' constraintsInvolvedIn lists.
3828 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3832 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3833 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3834 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3835 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3836 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3837 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3838 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3839 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3840 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3841 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3842 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3843 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3844 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3845 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3846 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3847 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3851 // Back-pointer to other windows we're involved with, so if we delete
3852 // this window, we must delete any constraints we're involved with.
3853 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3855 if (!m_constraintsInvolvedIn
)
3856 m_constraintsInvolvedIn
= new wxList
;
3857 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3858 m_constraintsInvolvedIn
->Append(otherWin
);
3861 // REMOVE back-pointer to other windows we're involved with.
3862 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3864 if (m_constraintsInvolvedIn
)
3865 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3868 // Reset any constraints that mention this window
3869 void wxWindow::DeleteRelatedConstraints()
3871 if (m_constraintsInvolvedIn
)
3873 wxNode
*node
= m_constraintsInvolvedIn
->First();
3876 wxWindow
*win
= (wxWindow
*)node
->Data();
3877 wxNode
*next
= node
->Next();
3878 wxLayoutConstraints
*constr
= win
->GetConstraints();
3880 // Reset any constraints involving this window
3883 constr
->left
.ResetIfWin((wxWindow
*)this);
3884 constr
->top
.ResetIfWin((wxWindow
*)this);
3885 constr
->right
.ResetIfWin((wxWindow
*)this);
3886 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3887 constr
->width
.ResetIfWin((wxWindow
*)this);
3888 constr
->height
.ResetIfWin((wxWindow
*)this);
3889 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3890 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3895 delete m_constraintsInvolvedIn
;
3896 m_constraintsInvolvedIn
= NULL
;
3900 void wxWindow::SetSizer(wxSizer
*sizer
)
3902 m_windowSizer
= sizer
;
3904 sizer
->SetSizerParent((wxWindow
*)this);
3911 bool wxWindow::Layout()
3913 if (GetConstraints())
3916 GetClientSize(&w
, &h
);
3917 GetConstraints()->width
.SetValue(w
);
3918 GetConstraints()->height
.SetValue(h
);
3921 // If top level (one sizer), evaluate the sizer's constraints.
3925 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3926 GetSizer()->LayoutPhase1(&noChanges
);
3927 GetSizer()->LayoutPhase2(&noChanges
);
3928 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3933 // Otherwise, evaluate child constraints
3934 ResetConstraints(); // Mark all constraints as unevaluated
3935 DoPhase(1); // Just one phase need if no sizers involved
3937 SetConstraintSizes(); // Recursively set the real window sizes
3943 // Do a phase of evaluating constraints:
3944 // the default behaviour. wxSizers may do a similar
3945 // thing, but also impose their own 'constraints'
3946 // and order the evaluation differently.
3947 bool wxWindow::LayoutPhase1(int *noChanges
)
3949 wxLayoutConstraints
*constr
= GetConstraints();
3952 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3958 bool wxWindow::LayoutPhase2(int *noChanges
)
3968 // Do a phase of evaluating child constraints
3969 bool wxWindow::DoPhase(int phase
)
3971 int noIterations
= 0;
3972 int maxIterations
= 500;
3976 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3980 wxNode
*node
= GetChildren().First();
3983 wxWindow
*child
= (wxWindow
*)node
->Data();
3984 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3986 wxLayoutConstraints
*constr
= child
->GetConstraints();
3989 if (succeeded
.Member(child
))
3994 int tempNoChanges
= 0;
3995 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3996 noChanges
+= tempNoChanges
;
3999 succeeded
.Append(child
);
4004 node
= node
->Next();
4011 void wxWindow::ResetConstraints()
4013 wxLayoutConstraints
*constr
= GetConstraints();
4016 constr
->left
.SetDone(FALSE
);
4017 constr
->top
.SetDone(FALSE
);
4018 constr
->right
.SetDone(FALSE
);
4019 constr
->bottom
.SetDone(FALSE
);
4020 constr
->width
.SetDone(FALSE
);
4021 constr
->height
.SetDone(FALSE
);
4022 constr
->centreX
.SetDone(FALSE
);
4023 constr
->centreY
.SetDone(FALSE
);
4025 wxNode
*node
= GetChildren().First();
4028 wxWindow
*win
= (wxWindow
*)node
->Data();
4029 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4030 win
->ResetConstraints();
4031 node
= node
->Next();
4035 // Need to distinguish between setting the 'fake' size for
4036 // windows and sizers, and setting the real values.
4037 void wxWindow::SetConstraintSizes(bool recurse
)
4039 wxLayoutConstraints
*constr
= GetConstraints();
4040 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4041 constr
->width
.GetDone() && constr
->height
.GetDone())
4043 int x
= constr
->left
.GetValue();
4044 int y
= constr
->top
.GetValue();
4045 int w
= constr
->width
.GetValue();
4046 int h
= constr
->height
.GetValue();
4048 // If we don't want to resize this window, just move it...
4049 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4050 (constr
->height
.GetRelationship() != wxAsIs
))
4052 // Calls Layout() recursively. AAAGH. How can we stop that.
4053 // Simply take Layout() out of non-top level OnSizes.
4054 SizerSetSize(x
, y
, w
, h
);
4063 char *windowClass
= this->GetClassInfo()->GetClassName();
4066 if (GetName() == "")
4067 winName
= "unnamed";
4069 winName
= GetName();
4070 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4071 (const char *)windowClass
, (const char *)winName
);
4072 if (!constr
->left
.GetDone())
4073 wxLogDebug(" unsatisfied 'left' constraint.");
4074 if (!constr
->right
.GetDone())
4075 wxLogDebug(" unsatisfied 'right' constraint.");
4076 if (!constr
->width
.GetDone())
4077 wxLogDebug(" unsatisfied 'width' constraint.");
4078 if (!constr
->height
.GetDone())
4079 wxLogDebug(" unsatisfied 'height' constraint.");
4080 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
4085 wxNode
*node
= GetChildren().First();
4088 wxWindow
*win
= (wxWindow
*)node
->Data();
4089 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4090 win
->SetConstraintSizes();
4091 node
= node
->Next();
4096 // This assumes that all sizers are 'on' the same
4097 // window, i.e. the parent of this window.
4098 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4100 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4101 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4105 m_sizerParent
->GetPosition(&xp
, &yp
);
4106 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4111 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4115 TransformSizerToActual(&xx
, &yy
);
4116 SetSize(xx
, yy
, w
, h
);
4119 void wxWindow::SizerMove(int x
, int y
)
4123 TransformSizerToActual(&xx
, &yy
);
4127 // Only set the size/position of the constraint (if any)
4128 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4130 wxLayoutConstraints
*constr
= GetConstraints();
4135 constr
->left
.SetValue(x
);
4136 constr
->left
.SetDone(TRUE
);
4140 constr
->top
.SetValue(y
);
4141 constr
->top
.SetDone(TRUE
);
4145 constr
->width
.SetValue(w
);
4146 constr
->width
.SetDone(TRUE
);
4150 constr
->height
.SetValue(h
);
4151 constr
->height
.SetDone(TRUE
);
4156 void wxWindow::MoveConstraint(int x
, int y
)
4158 wxLayoutConstraints
*constr
= GetConstraints();
4163 constr
->left
.SetValue(x
);
4164 constr
->left
.SetDone(TRUE
);
4168 constr
->top
.SetValue(y
);
4169 constr
->top
.SetDone(TRUE
);
4174 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4176 wxLayoutConstraints
*constr
= GetConstraints();
4179 *w
= constr
->width
.GetValue();
4180 *h
= constr
->height
.GetValue();
4186 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4188 wxLayoutConstraints
*constr
= GetConstraints();
4191 *w
= constr
->width
.GetValue();
4192 *h
= constr
->height
.GetValue();
4195 GetClientSize(w
, h
);
4198 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4200 wxLayoutConstraints
*constr
= GetConstraints();
4203 *x
= constr
->left
.GetValue();
4204 *y
= constr
->top
.GetValue();
4210 bool wxWindow::Close(bool force
)
4212 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4213 event
.SetEventObject(this);
4214 #if WXWIN_COMPATIBILITY
4215 event
.SetForce(force
);
4217 event
.SetCanVeto(!force
);
4219 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4222 wxObject
* wxWindow::GetChild(int number
) const
4224 // Return a pointer to the Nth object in the Panel
4225 // if (!GetChildren())
4227 wxNode
*node
= GetChildren().First();
4230 node
= node
->Next() ;
4233 wxObject
*obj
= (wxObject
*)node
->Data();
4240 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4242 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4243 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4246 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4248 wxListBox *lbox = (wxListBox *)initiatingItem;
4249 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4250 event.m_commandInt = -1;
4251 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4253 event.m_commandString = copystring(lbox->GetStringSelection());
4254 event.m_commandInt = lbox->GetSelection();
4255 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4257 event.m_eventObject = lbox;
4259 lbox->ProcessCommand(event);
4261 if (event.m_commandString)
4262 delete[] event.m_commandString;
4266 wxButton *but = GetDefaultItem();
4269 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4270 event.SetEventObject(but);
4271 but->Command(event);
4276 void wxWindow::Clear()
4278 wxClientDC
dc(this);
4279 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4280 dc
.SetBackground(brush
);
4284 // Fits the panel around the items
4285 void wxWindow::Fit()
4289 wxNode
*node
= GetChildren().First();
4292 wxWindow
*win
= (wxWindow
*)node
->Data();
4294 win
->GetPosition(&wx
, &wy
);
4295 win
->GetSize(&ww
, &wh
);
4296 if ( wx
+ ww
> maxX
)
4298 if ( wy
+ wh
> maxY
)
4301 node
= node
->Next();
4303 SetClientSize(maxX
+ 5, maxY
+ 5);
4306 void wxWindow::SetValidator(const wxValidator
& validator
)
4308 if ( m_windowValidator
)
4309 delete m_windowValidator
;
4310 m_windowValidator
= validator
.Clone();
4312 if ( m_windowValidator
)
4313 m_windowValidator
->SetWindow(this) ;
4316 // Find a window by id or name
4317 wxWindow
*wxWindow::FindWindow(long id
)
4322 wxNode
*node
= GetChildren().First();
4325 wxWindow
*child
= (wxWindow
*)node
->Data();
4326 wxWindow
*found
= child
->FindWindow(id
);
4329 node
= node
->Next();
4334 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4336 if ( GetName() == name
)
4339 wxNode
*node
= GetChildren().First();
4342 wxWindow
*child
= (wxWindow
*)node
->Data();
4343 wxWindow
*found
= child
->FindWindow(name
);
4346 node
= node
->Next();
4352 // Default input behaviour for a scrolling canvas should be to scroll
4353 // according to the cursor keys pressed
4354 void wxWindow::OnChar(wxKeyEvent& event)
4366 GetScrollUnitsPerPage(&x_page, &y_page);
4368 GetVirtualSize(&v_width,&v_height);
4370 ViewStart(&start_x, &start_y);
4373 y_pages = (int)(v_height/vert_units) - y_page;
4381 switch (event.keyCode)
4388 if (start_y - y_page > 0)
4389 Scroll(start_x, start_y - y_page);
4399 if ((y_page > 0) && (start_y <= y_pages-y-1))
4401 if (y_pages + y < start_y + y_page)
4402 Scroll(start_x, y_pages + y);
4404 Scroll(start_x, start_y + y_page);
4411 if ((y_page > 0) && (start_y >= 1))
4412 Scroll(start_x, start_y - 1);
4418 if ((y_page > 0) && (start_y <= y_pages-y-1))
4421 Scroll(start_x, start_y + 1);
4427 if ((x_page > 0) && (start_x >= 1))
4428 Scroll(start_x - 1, start_y);
4434 Scroll(start_x + 1, start_y);
4445 Scroll(start_x, y_pages+y);
4453 // Setup background and foreground colours correctly
4454 void wxWindow::SetupColours()
4457 SetBackgroundColour(GetParent()->GetBackgroundColour());
4460 void wxWindow::OnIdle(wxIdleEvent
& event
)
4462 // Check if we need to send a LEAVE event
4463 if (m_mouseInWindow
)
4466 ::GetCursorPos(&pt
);
4467 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4469 // Generate a LEAVE event
4470 m_mouseInWindow
= FALSE
;
4473 if (::GetKeyState(VK_SHIFT
) != 0)
4475 if (::GetKeyState(VK_CONTROL
) != 0)
4476 state
|= MK_CONTROL
;
4478 // Unfortunately the mouse button and keyboard state may have changed
4479 // by the time the OnIdle function is called, so 'state' may be
4482 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4488 // Raise the window to the top of the Z order
4489 void wxWindow::Raise()
4491 ::BringWindowToTop((HWND
) GetHWND());
4494 // Lower the window to the bottom of the Z order
4495 void wxWindow::Lower()
4497 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4500 long wxWindow::MSWGetDlgCode()
4502 // default: just forward to def window proc (the msg has no parameters)
4503 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4506 bool wxWindow::AcceptsFocus() const
4508 // invisible and disabled controls don't need focus
4509 return IsShown() && IsEnabled();
4512 // Update region access
4513 wxRegion
wxWindow::GetUpdateRegion() const
4515 return m_updateRegion
;
4518 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4520 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4523 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4525 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4528 bool wxWindow::IsExposed(const wxRect
& rect
) const
4530 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4533 // Set this window to be the child of 'parent'.
4534 bool wxWindow::Reparent(wxWindow
*parent
)
4536 if (parent
== GetParent())
4539 // Unlink this window from the existing parent.
4542 GetParent()->RemoveChild(this);
4545 wxTopLevelWindows
.DeleteObject(this);
4547 HWND hWndParent
= 0;
4548 HWND hWndChild
= (HWND
) GetHWND();
4549 if (parent
!= (wxWindow
*) NULL
)
4551 parent
->AddChild(this);
4552 hWndParent
= (HWND
) parent
->GetHWND();
4555 wxTopLevelWindows
.Append(this);
4557 ::SetParent(hWndChild
, hWndParent
);
4563 const char *wxGetMessageName(int message
)
4565 switch ( message
) {
4566 case 0x0000: return "WM_NULL";
4567 case 0x0001: return "WM_CREATE";
4568 case 0x0002: return "WM_DESTROY";
4569 case 0x0003: return "WM_MOVE";
4570 case 0x0005: return "WM_SIZE";
4571 case 0x0006: return "WM_ACTIVATE";
4572 case 0x0007: return "WM_SETFOCUS";
4573 case 0x0008: return "WM_KILLFOCUS";
4574 case 0x000A: return "WM_ENABLE";
4575 case 0x000B: return "WM_SETREDRAW";
4576 case 0x000C: return "WM_SETTEXT";
4577 case 0x000D: return "WM_GETTEXT";
4578 case 0x000E: return "WM_GETTEXTLENGTH";
4579 case 0x000F: return "WM_PAINT";
4580 case 0x0010: return "WM_CLOSE";
4581 case 0x0011: return "WM_QUERYENDSESSION";
4582 case 0x0012: return "WM_QUIT";
4583 case 0x0013: return "WM_QUERYOPEN";
4584 case 0x0014: return "WM_ERASEBKGND";
4585 case 0x0015: return "WM_SYSCOLORCHANGE";
4586 case 0x0016: return "WM_ENDSESSION";
4587 case 0x0017: return "WM_SYSTEMERROR";
4588 case 0x0018: return "WM_SHOWWINDOW";
4589 case 0x0019: return "WM_CTLCOLOR";
4590 case 0x001A: return "WM_WININICHANGE";
4591 case 0x001B: return "WM_DEVMODECHANGE";
4592 case 0x001C: return "WM_ACTIVATEAPP";
4593 case 0x001D: return "WM_FONTCHANGE";
4594 case 0x001E: return "WM_TIMECHANGE";
4595 case 0x001F: return "WM_CANCELMODE";
4596 case 0x0020: return "WM_SETCURSOR";
4597 case 0x0021: return "WM_MOUSEACTIVATE";
4598 case 0x0022: return "WM_CHILDACTIVATE";
4599 case 0x0023: return "WM_QUEUESYNC";
4600 case 0x0024: return "WM_GETMINMAXINFO";
4601 case 0x0026: return "WM_PAINTICON";
4602 case 0x0027: return "WM_ICONERASEBKGND";
4603 case 0x0028: return "WM_NEXTDLGCTL";
4604 case 0x002A: return "WM_SPOOLERSTATUS";
4605 case 0x002B: return "WM_DRAWITEM";
4606 case 0x002C: return "WM_MEASUREITEM";
4607 case 0x002D: return "WM_DELETEITEM";
4608 case 0x002E: return "WM_VKEYTOITEM";
4609 case 0x002F: return "WM_CHARTOITEM";
4610 case 0x0030: return "WM_SETFONT";
4611 case 0x0031: return "WM_GETFONT";
4612 case 0x0037: return "WM_QUERYDRAGICON";
4613 case 0x0039: return "WM_COMPAREITEM";
4614 case 0x0041: return "WM_COMPACTING";
4615 case 0x0044: return "WM_COMMNOTIFY";
4616 case 0x0046: return "WM_WINDOWPOSCHANGING";
4617 case 0x0047: return "WM_WINDOWPOSCHANGED";
4618 case 0x0048: return "WM_POWER";
4621 case 0x004A: return "WM_COPYDATA";
4622 case 0x004B: return "WM_CANCELJOURNAL";
4623 case 0x004E: return "WM_NOTIFY";
4624 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4625 case 0x0051: return "WM_INPUTLANGCHANGE";
4626 case 0x0052: return "WM_TCARD";
4627 case 0x0053: return "WM_HELP";
4628 case 0x0054: return "WM_USERCHANGED";
4629 case 0x0055: return "WM_NOTIFYFORMAT";
4630 case 0x007B: return "WM_CONTEXTMENU";
4631 case 0x007C: return "WM_STYLECHANGING";
4632 case 0x007D: return "WM_STYLECHANGED";
4633 case 0x007E: return "WM_DISPLAYCHANGE";
4634 case 0x007F: return "WM_GETICON";
4635 case 0x0080: return "WM_SETICON";
4638 case 0x0081: return "WM_NCCREATE";
4639 case 0x0082: return "WM_NCDESTROY";
4640 case 0x0083: return "WM_NCCALCSIZE";
4641 case 0x0084: return "WM_NCHITTEST";
4642 case 0x0085: return "WM_NCPAINT";
4643 case 0x0086: return "WM_NCACTIVATE";
4644 case 0x0087: return "WM_GETDLGCODE";
4645 case 0x00A0: return "WM_NCMOUSEMOVE";
4646 case 0x00A1: return "WM_NCLBUTTONDOWN";
4647 case 0x00A2: return "WM_NCLBUTTONUP";
4648 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4649 case 0x00A4: return "WM_NCRBUTTONDOWN";
4650 case 0x00A5: return "WM_NCRBUTTONUP";
4651 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4652 case 0x00A7: return "WM_NCMBUTTONDOWN";
4653 case 0x00A8: return "WM_NCMBUTTONUP";
4654 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4655 case 0x0100: return "WM_KEYDOWN";
4656 case 0x0101: return "WM_KEYUP";
4657 case 0x0102: return "WM_CHAR";
4658 case 0x0103: return "WM_DEADCHAR";
4659 case 0x0104: return "WM_SYSKEYDOWN";
4660 case 0x0105: return "WM_SYSKEYUP";
4661 case 0x0106: return "WM_SYSCHAR";
4662 case 0x0107: return "WM_SYSDEADCHAR";
4663 case 0x0108: return "WM_KEYLAST";
4666 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4667 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4668 case 0x010F: return "WM_IME_COMPOSITION";
4671 case 0x0110: return "WM_INITDIALOG";
4672 case 0x0111: return "WM_COMMAND";
4673 case 0x0112: return "WM_SYSCOMMAND";
4674 case 0x0113: return "WM_TIMER";
4675 case 0x0114: return "WM_HSCROLL";
4676 case 0x0115: return "WM_VSCROLL";
4677 case 0x0116: return "WM_INITMENU";
4678 case 0x0117: return "WM_INITMENUPOPUP";
4679 case 0x011F: return "WM_MENUSELECT";
4680 case 0x0120: return "WM_MENUCHAR";
4681 case 0x0121: return "WM_ENTERIDLE";
4682 case 0x0200: return "WM_MOUSEMOVE";
4683 case 0x0201: return "WM_LBUTTONDOWN";
4684 case 0x0202: return "WM_LBUTTONUP";
4685 case 0x0203: return "WM_LBUTTONDBLCLK";
4686 case 0x0204: return "WM_RBUTTONDOWN";
4687 case 0x0205: return "WM_RBUTTONUP";
4688 case 0x0206: return "WM_RBUTTONDBLCLK";
4689 case 0x0207: return "WM_MBUTTONDOWN";
4690 case 0x0208: return "WM_MBUTTONUP";
4691 case 0x0209: return "WM_MBUTTONDBLCLK";
4692 case 0x0210: return "WM_PARENTNOTIFY";
4693 case 0x0211: return "WM_ENTERMENULOOP";
4694 case 0x0212: return "WM_EXITMENULOOP";
4697 case 0x0213: return "WM_NEXTMENU";
4698 case 0x0214: return "WM_SIZING";
4699 case 0x0215: return "WM_CAPTURECHANGED";
4700 case 0x0216: return "WM_MOVING";
4701 case 0x0218: return "WM_POWERBROADCAST";
4702 case 0x0219: return "WM_DEVICECHANGE";
4705 case 0x0220: return "WM_MDICREATE";
4706 case 0x0221: return "WM_MDIDESTROY";
4707 case 0x0222: return "WM_MDIACTIVATE";
4708 case 0x0223: return "WM_MDIRESTORE";
4709 case 0x0224: return "WM_MDINEXT";
4710 case 0x0225: return "WM_MDIMAXIMIZE";
4711 case 0x0226: return "WM_MDITILE";
4712 case 0x0227: return "WM_MDICASCADE";
4713 case 0x0228: return "WM_MDIICONARRANGE";
4714 case 0x0229: return "WM_MDIGETACTIVE";
4715 case 0x0230: return "WM_MDISETMENU";
4716 case 0x0233: return "WM_DROPFILES";
4719 case 0x0281: return "WM_IME_SETCONTEXT";
4720 case 0x0282: return "WM_IME_NOTIFY";
4721 case 0x0283: return "WM_IME_CONTROL";
4722 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4723 case 0x0285: return "WM_IME_SELECT";
4724 case 0x0286: return "WM_IME_CHAR";
4725 case 0x0290: return "WM_IME_KEYDOWN";
4726 case 0x0291: return "WM_IME_KEYUP";
4729 case 0x0300: return "WM_CUT";
4730 case 0x0301: return "WM_COPY";
4731 case 0x0302: return "WM_PASTE";
4732 case 0x0303: return "WM_CLEAR";
4733 case 0x0304: return "WM_UNDO";
4734 case 0x0305: return "WM_RENDERFORMAT";
4735 case 0x0306: return "WM_RENDERALLFORMATS";
4736 case 0x0307: return "WM_DESTROYCLIPBOARD";
4737 case 0x0308: return "WM_DRAWCLIPBOARD";
4738 case 0x0309: return "WM_PAINTCLIPBOARD";
4739 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4740 case 0x030B: return "WM_SIZECLIPBOARD";
4741 case 0x030C: return "WM_ASKCBFORMATNAME";
4742 case 0x030D: return "WM_CHANGECBCHAIN";
4743 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4744 case 0x030F: return "WM_QUERYNEWPALETTE";
4745 case 0x0310: return "WM_PALETTEISCHANGING";
4746 case 0x0311: return "WM_PALETTECHANGED";
4749 // common controls messages - although they're not strictly speaking
4750 // standard, it's nice to decode them nevertheless
4753 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4754 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4755 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4756 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4757 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4758 case 0x1000 + 5: return "LVM_GETITEMA";
4759 case 0x1000 + 75: return "LVM_GETITEMW";
4760 case 0x1000 + 6: return "LVM_SETITEMA";
4761 case 0x1000 + 76: return "LVM_SETITEMW";
4762 case 0x1000 + 7: return "LVM_INSERTITEMA";
4763 case 0x1000 + 77: return "LVM_INSERTITEMW";
4764 case 0x1000 + 8: return "LVM_DELETEITEM";
4765 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4766 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4767 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4768 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4769 case 0x1000 + 13: return "LVM_FINDITEMA";
4770 case 0x1000 + 83: return "LVM_FINDITEMW";
4771 case 0x1000 + 14: return "LVM_GETITEMRECT";
4772 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4773 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4774 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4775 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4776 case 0x1000 + 18: return "LVM_HITTEST";
4777 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4778 case 0x1000 + 20: return "LVM_SCROLL";
4779 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4780 case 0x1000 + 22: return "LVM_ARRANGE";
4781 case 0x1000 + 23: return "LVM_EDITLABELA";
4782 case 0x1000 + 118: return "LVM_EDITLABELW";
4783 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4784 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4785 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4786 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4787 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4788 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4789 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4790 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4791 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4792 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4793 case 0x1000 + 31: return "LVM_GETHEADER";
4794 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4795 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4796 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4797 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4798 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4799 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4800 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4801 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4802 case 0x1000 + 41: return "LVM_GETORIGIN";
4803 case 0x1000 + 42: return "LVM_UPDATE";
4804 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4805 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4806 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4807 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4808 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4809 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4810 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4811 case 0x1000 + 48: return "LVM_SORTITEMS";
4812 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4813 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4814 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4815 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4816 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4817 case 0x1000 + 53: return "LVM_SETICONSPACING";
4818 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4819 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4820 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4821 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4822 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4823 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4824 case 0x1000 + 60: return "LVM_SETHOTITEM";
4825 case 0x1000 + 61: return "LVM_GETHOTITEM";
4826 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4827 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4828 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4829 case 0x1000 + 65: return "LVM_SETWORKAREA";
4832 case 0x1100 + 0: return "TVM_INSERTITEMA";
4833 case 0x1100 + 50: return "TVM_INSERTITEMW";
4834 case 0x1100 + 1: return "TVM_DELETEITEM";
4835 case 0x1100 + 2: return "TVM_EXPAND";
4836 case 0x1100 + 4: return "TVM_GETITEMRECT";
4837 case 0x1100 + 5: return "TVM_GETCOUNT";
4838 case 0x1100 + 6: return "TVM_GETINDENT";
4839 case 0x1100 + 7: return "TVM_SETINDENT";
4840 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4841 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4842 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4843 case 0x1100 + 11: return "TVM_SELECTITEM";
4844 case 0x1100 + 12: return "TVM_GETITEMA";
4845 case 0x1100 + 62: return "TVM_GETITEMW";
4846 case 0x1100 + 13: return "TVM_SETITEMA";
4847 case 0x1100 + 63: return "TVM_SETITEMW";
4848 case 0x1100 + 14: return "TVM_EDITLABELA";
4849 case 0x1100 + 65: return "TVM_EDITLABELW";
4850 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4851 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4852 case 0x1100 + 17: return "TVM_HITTEST";
4853 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4854 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4855 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4856 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4857 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4858 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4859 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4860 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4861 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4864 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4865 case 0x1200 + 1: return "HDM_INSERTITEMA";
4866 case 0x1200 + 10: return "HDM_INSERTITEMW";
4867 case 0x1200 + 2: return "HDM_DELETEITEM";
4868 case 0x1200 + 3: return "HDM_GETITEMA";
4869 case 0x1200 + 11: return "HDM_GETITEMW";
4870 case 0x1200 + 4: return "HDM_SETITEMA";
4871 case 0x1200 + 12: return "HDM_SETITEMW";
4872 case 0x1200 + 5: return "HDM_LAYOUT";
4873 case 0x1200 + 6: return "HDM_HITTEST";
4874 case 0x1200 + 7: return "HDM_GETITEMRECT";
4875 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4876 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4877 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4878 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4879 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4880 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4881 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4884 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4885 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4886 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4887 case 0x1300 + 5: return "TCM_GETITEMA";
4888 case 0x1300 + 60: return "TCM_GETITEMW";
4889 case 0x1300 + 6: return "TCM_SETITEMA";
4890 case 0x1300 + 61: return "TCM_SETITEMW";
4891 case 0x1300 + 7: return "TCM_INSERTITEMA";
4892 case 0x1300 + 62: return "TCM_INSERTITEMW";
4893 case 0x1300 + 8: return "TCM_DELETEITEM";
4894 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4895 case 0x1300 + 10: return "TCM_GETITEMRECT";
4896 case 0x1300 + 11: return "TCM_GETCURSEL";
4897 case 0x1300 + 12: return "TCM_SETCURSEL";
4898 case 0x1300 + 13: return "TCM_HITTEST";
4899 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4900 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4901 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4902 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4903 case 0x1300 + 43: return "TCM_SETPADDING";
4904 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4905 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4906 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4907 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4908 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4909 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4910 case 0x1300 + 50: return "TCM_DESELECTALL";
4913 case WM_USER
+1: return "TB_ENABLEBUTTON";
4914 case WM_USER
+2: return "TB_CHECKBUTTON";
4915 case WM_USER
+3: return "TB_PRESSBUTTON";
4916 case WM_USER
+4: return "TB_HIDEBUTTON";
4917 case WM_USER
+5: return "TB_INDETERMINATE";
4918 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4919 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4920 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4921 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4922 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4923 case WM_USER
+17: return "TB_SETSTATE";
4924 case WM_USER
+18: return "TB_GETSTATE";
4925 case WM_USER
+19: return "TB_ADDBITMAP";
4926 case WM_USER
+20: return "TB_ADDBUTTONS";
4927 case WM_USER
+21: return "TB_INSERTBUTTON";
4928 case WM_USER
+22: return "TB_DELETEBUTTON";
4929 case WM_USER
+23: return "TB_GETBUTTON";
4930 case WM_USER
+24: return "TB_BUTTONCOUNT";
4931 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4932 case WM_USER
+26: return "TB_SAVERESTOREA";
4933 case WM_USER
+76: return "TB_SAVERESTOREW";
4934 case WM_USER
+27: return "TB_CUSTOMIZE";
4935 case WM_USER
+28: return "TB_ADDSTRINGA";
4936 case WM_USER
+77: return "TB_ADDSTRINGW";
4937 case WM_USER
+29: return "TB_GETITEMRECT";
4938 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4939 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4940 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4941 case WM_USER
+33: return "TB_AUTOSIZE";
4942 case WM_USER
+35: return "TB_GETTOOLTIPS";
4943 case WM_USER
+36: return "TB_SETTOOLTIPS";
4944 case WM_USER
+37: return "TB_SETPARENT";
4945 case WM_USER
+39: return "TB_SETROWS";
4946 case WM_USER
+40: return "TB_GETROWS";
4947 case WM_USER
+42: return "TB_SETCMDID";
4948 case WM_USER
+43: return "TB_CHANGEBITMAP";
4949 case WM_USER
+44: return "TB_GETBITMAP";
4950 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4951 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4952 case WM_USER
+46: return "TB_REPLACEBITMAP";
4953 case WM_USER
+47: return "TB_SETINDENT";
4954 case WM_USER
+48: return "TB_SETIMAGELIST";
4955 case WM_USER
+49: return "TB_GETIMAGELIST";
4956 case WM_USER
+50: return "TB_LOADIMAGES";
4957 case WM_USER
+51: return "TB_GETRECT";
4958 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4959 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4960 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4961 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4962 case WM_USER
+56: return "TB_SETSTYLE";
4963 case WM_USER
+57: return "TB_GETSTYLE";
4964 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4965 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4966 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4967 case WM_USER
+61: return "TB_GETTEXTROWS";
4968 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4973 static char s_szBuf
[128];
4974 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4978 #endif //__WXDEBUG__