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 // Remove potential dangling pointer
306 if (GetParent() && GetParent()->IsKindOf(CLASSINFO(wxPanel
)))
308 wxPanel
* panel
= (wxPanel
*) GetParent();
309 if (panel
->GetLastFocus() == this)
310 panel
->SetLastFocus((wxWindow
*) NULL
);
313 m_isBeingDeleted
= TRUE
;
315 // first of all, delete the things on which nothing else depends
321 // JACS - if behaviour is odd, restore this
322 // to the start of ~wxWindow. Vadim has changed
323 // it to nearer the end. Unsure of side-effects
324 // e.g. when deleting associated global data.
325 // Restore old Window proc, if required
328 // Have to delete constraints/sizer FIRST otherwise
329 // sizers may try to look at deleted windows as they
330 // delete themselves.
331 #if wxUSE_CONSTRAINTS
332 DeleteRelatedConstraints();
336 // This removes any dangling pointers to this window
337 // in other windows' constraintsInvolvedIn lists.
338 UnsetConstraints(m_constraints
);
339 delete m_constraints
;
340 m_constraints
= NULL
;
343 wxDELETE(m_windowSizer
);
345 // If this is a child of a sizer, remove self from parent
347 m_sizerParent
->RemoveChild((wxWindow
*)this);
351 MSWDetachWindowMenu();
354 m_windowParent
->RemoveChild(this);
359 ::DestroyWindow((HWND
)m_hWnd
);
361 wxRemoveHandleAssociation(this);
366 GlobalFree((HGLOBAL
) m_globalHandle
);
374 // Just in case the window has been Closed, but
375 // we're then deleting immediately: don't leave
376 // dangling pointers.
377 wxPendingDelete
.DeleteObject(this);
379 // Just in case we've loaded a top-level window via
380 // wxWindow::LoadNativeDialog but we weren't a dialog
382 wxTopLevelWindows
.DeleteObject(this);
384 if ( m_windowValidator
)
385 delete m_windowValidator
;
387 // Restore old Window proc, if required
388 // and remove hWnd <-> wxWindow association
392 // Destroy the window (delayed, if a managed window)
393 bool wxWindow::Destroy()
399 extern char wxCanvasClassName
[];
401 // real construction (Init() must have been called before!)
402 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
406 const wxString
& name
)
408 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
410 parent
->AddChild(this);
415 m_windowId
= (int)NewControlId();
424 // To be consistent with wxGTK
430 wxSystemSettings settings
;
432 m_windowStyle
= style
;
435 if (style
& wxBORDER
)
436 msflags
|= WS_BORDER
;
437 if (style
& wxTHICK_FRAME
)
438 msflags
|= WS_THICKFRAME
;
440 msflags
|= WS_CHILD
| WS_VISIBLE
;
441 if (style
& wxCLIP_CHILDREN
)
442 msflags
|= WS_CLIPCHILDREN
;
445 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
447 // Even with extended styles, need to combine with WS_BORDER
448 // for them to look right.
449 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
450 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
451 msflags
|= WS_BORDER
;
453 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
454 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
459 void wxWindow::SetFocus()
461 HWND hWnd
= (HWND
) GetHWND();
466 void wxWindow::Enable(bool enable
)
468 m_winEnabled
= enable
;
469 HWND hWnd
= (HWND
) GetHWND();
471 ::EnableWindow(hWnd
, (BOOL
)enable
);
474 void wxWindow::CaptureMouse()
476 HWND hWnd
= (HWND
) GetHWND();
477 if (hWnd
&& !m_winCaptured
)
480 m_winCaptured
= TRUE
;
484 void wxWindow::ReleaseMouse()
489 m_winCaptured
= FALSE
;
493 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
495 m_acceleratorTable
= accel
;
499 // Push/pop event handler (i.e. allow a chain of event handlers
501 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
503 handler
->SetNextHandler(GetEventHandler());
504 SetEventHandler(handler
);
507 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
509 if ( GetEventHandler() )
511 wxEvtHandler
*handlerA
= GetEventHandler();
512 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
513 handlerA
->SetNextHandler(NULL
);
514 SetEventHandler(handlerB
);
527 #if wxUSE_DRAG_AND_DROP
529 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
531 if ( m_pDropTarget
!= 0 ) {
532 m_pDropTarget
->Revoke(m_hWnd
);
533 delete m_pDropTarget
;
536 m_pDropTarget
= pDropTarget
;
537 if ( m_pDropTarget
!= 0 )
538 m_pDropTarget
->Register(m_hWnd
);
541 #endif // wxUSE_DRAG_AND_DROP
544 //old style file-manager drag&drop support
545 // I think we should retain the old-style
546 // DragAcceptFiles in parallel with SetDropTarget.
548 void wxWindow::DragAcceptFiles(bool accept
)
550 HWND hWnd
= (HWND
) GetHWND();
552 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
555 // ----------------------------------------------------------------------------
557 // ----------------------------------------------------------------------------
561 void wxWindow::SetToolTip(const wxString
&tip
)
563 SetToolTip(new wxToolTip(tip
));
566 void wxWindow::SetToolTip(wxToolTip
*tooltip
)
572 m_tooltip
->SetWindow(this);
575 #endif // wxUSE_TOOLTIPS
578 void wxWindow::GetSize(int *x
, int *y
) const
580 HWND hWnd
= (HWND
) GetHWND();
582 GetWindowRect(hWnd
, &rect
);
583 *x
= rect
.right
- rect
.left
;
584 *y
= rect
.bottom
- rect
.top
;
587 void wxWindow::GetPosition(int *x
, int *y
) const
589 HWND hWnd
= (HWND
) GetHWND();
592 hParentWnd
= (HWND
) GetParent()->GetHWND();
595 GetWindowRect(hWnd
, &rect
);
597 // Since we now have the absolute screen coords,
598 // if there's a parent we must subtract its top left corner
604 ::ScreenToClient(hParentWnd
, &point
);
607 // We may be faking the client origin.
608 // So a window that's really at (0, 30) may appear
609 // (to wxWin apps) to be at (0, 0).
612 wxPoint
pt(GetParent()->GetClientAreaOrigin());
620 void wxWindow::ScreenToClient(int *x
, int *y
) const
622 HWND hWnd
= (HWND
) GetHWND();
627 ::ScreenToClient(hWnd
, &pt
);
633 void wxWindow::ClientToScreen(int *x
, int *y
) const
635 HWND hWnd
= (HWND
) GetHWND();
640 ::ClientToScreen(hWnd
, &pt
);
646 void wxWindow::SetCursor(const wxCursor
& cursor
)
648 m_windowCursor
= cursor
;
649 if (m_windowCursor
.Ok())
651 HWND hWnd
= (HWND
) GetHWND();
653 // Change the cursor NOW if we're within the correct window
655 ::GetCursorPos(&point
);
658 ::GetWindowRect(hWnd
, &rect
);
660 if (::PtInRect(&rect
, point
) && !wxIsBusy())
661 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
664 // This will cause big reentrancy problems if wxFlushEvents is implemented.
666 // return old_cursor;
670 // Get size *available for subwindows* i.e. excluding menu bar etc.
671 void wxWindow::GetClientSize(int *x
, int *y
) const
673 HWND hWnd
= (HWND
) GetHWND();
675 GetClientRect(hWnd
, &rect
);
680 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
682 int currentX
, currentY
;
683 GetPosition(¤tX
, ¤tY
);
684 int currentW
,currentH
;
685 GetSize(¤tW
, ¤tH
);
687 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
690 int actualWidth
= width
;
691 int actualHeight
= height
;
694 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
696 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
699 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
702 actualWidth
= currentW
;
704 actualHeight
= currentH
;
706 HWND hWnd
= (HWND
) GetHWND();
708 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
711 void wxWindow::SetClientSize(int width
, int height
)
713 wxWindow
*parent
= GetParent();
714 HWND hWnd
= (HWND
) GetHWND();
715 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
718 GetClientRect(hWnd
, &rect
);
721 GetWindowRect(hWnd
, &rect2
);
723 // Find the difference between the entire window (title bar and all)
724 // and the client area; add this to the new client size to move the
726 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
727 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
729 // If there's a parent, must subtract the parent's top left corner
730 // since MoveWindow moves relative to the parent
733 point
.x
= rect2
.left
;
737 ::ScreenToClient(hParentWnd
, &point
);
740 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
742 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
743 event
.SetEventObject(this);
744 GetEventHandler()->ProcessEvent(event
);
747 // For implementation purposes - sometimes decorations make the client area
749 wxPoint
wxWindow::GetClientAreaOrigin() const
751 return wxPoint(0, 0);
754 // Makes an adjustment to the window position (for example, a frame that has
755 // a toolbar that it manages itself).
756 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
758 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
760 wxPoint
pt(GetParent()->GetClientAreaOrigin());
761 x
+= pt
.x
; y
+= pt
.y
;
765 bool wxWindow::Show(bool show
)
767 HWND hWnd
= (HWND
) GetHWND();
773 ShowWindow(hWnd
, (BOOL
)cshow
);
776 BringWindowToTop(hWnd
);
777 // Next line causes a crash on NT, apparently.
778 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
783 bool wxWindow::IsShown(void) const
785 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
788 int wxWindow::GetCharHeight(void) const
790 TEXTMETRIC lpTextMetric
;
791 HWND hWnd
= (HWND
) GetHWND();
792 HDC dc
= ::GetDC(hWnd
);
794 GetTextMetrics(dc
, &lpTextMetric
);
795 ::ReleaseDC(hWnd
, dc
);
797 return lpTextMetric
.tmHeight
;
800 int wxWindow::GetCharWidth(void) const
802 TEXTMETRIC lpTextMetric
;
803 HWND hWnd
= (HWND
) GetHWND();
804 HDC dc
= ::GetDC(hWnd
);
806 GetTextMetrics(dc
, &lpTextMetric
);
807 ::ReleaseDC(hWnd
, dc
);
809 return lpTextMetric
.tmAveCharWidth
;
812 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
813 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
815 wxFont
*fontToUse
= (wxFont
*)theFont
;
817 fontToUse
= (wxFont
*) & m_windowFont
;
819 HWND hWnd
= (HWND
) GetHWND();
820 HDC dc
= ::GetDC(hWnd
);
824 if (fontToUse
&& fontToUse
->Ok())
826 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
828 was
= (HFONT
) SelectObject(dc
,fnt
) ;
833 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
834 GetTextMetrics(dc
, &tm
);
836 if (fontToUse
&& fnt
&& was
)
837 SelectObject(dc
,was
) ;
843 if (descent
) *descent
= tm
.tmDescent
;
844 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
847 // fontToUse->ReleaseResource();
850 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
852 HWND hWnd
= (HWND
) GetHWND();
858 mswRect
.left
= rect
->x
;
859 mswRect
.top
= rect
->y
;
860 mswRect
.right
= rect
->x
+ rect
->width
;
861 mswRect
.bottom
= rect
->y
+ rect
->height
;
863 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
866 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
870 bool wxWindow::ProcessEvent(wxEvent
& event
)
872 // we save here the information about the last message because it might be
873 // overwritten if the event handler sends any messages to our window (case
874 // in point: wxNotebook::OnSize) - and then if we call Default() later
875 // (which is done quite often if the message is not processed) it will use
876 // incorrect values for m_lastXXX variables
877 WXUINT lastMsg
= m_lastMsg
;
878 WXWPARAM lastWParam
= m_lastWParam
;
879 WXLPARAM lastLParam
= m_lastLParam
;
881 // call the base version
882 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
886 m_lastWParam
= lastWParam
;
887 m_lastLParam
= lastLParam
;
892 // Hook for new window just as it's being created,
893 // when the window isn't yet associated with the handle
894 wxWindow
*wxWndHook
= NULL
;
897 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
899 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
901 if (!wnd
&& wxWndHook
)
903 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
906 wnd
->m_hWnd
= (WXHWND
) hWnd
;
909 // Stop right here if we don't have a valid handle in our wxWindow object.
910 if (wnd
&& !wnd
->m_hWnd
) {
911 wnd
->m_hWnd
= (WXHWND
) hWnd
;
912 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
918 wnd
->m_lastMsg
= message
;
919 wnd
->m_lastWParam
= wParam
;
920 wnd
->m_lastLParam
= lParam
;
923 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
925 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
928 // Should probably have a test for 'genuine' NT
929 #if defined(__WIN32__)
930 #define DIMENSION_TYPE short
932 #define DIMENSION_TYPE int
935 // Main Windows 3 window proc
936 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
938 wxASSERT( m_lastMsg
== message
&&
939 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
942 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
943 wxGetMessageName(message
), wParam
, lParam
);
944 #endif // __WXDEBUG__
946 HWND hWnd
= (HWND
)m_hWnd
;
953 WORD state
= LOWORD(wParam
);
954 WORD minimized
= HIWORD(wParam
);
955 HWND hwnd
= (HWND
)lParam
;
957 WORD state
= (WORD
)wParam
;
958 WORD minimized
= LOWORD(lParam
);
959 HWND hwnd
= (HWND
)HIWORD(lParam
);
961 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
967 HWND hwnd
= (HWND
)wParam
;
968 // return OnSetFocus(hwnd);
970 if (MSWOnSetFocus((WXHWND
) hwnd
))
972 else return MSWDefWindowProc(message
, wParam
, lParam
);
977 HWND hwnd
= (HWND
)lParam
;
978 // return OnKillFocus(hwnd);
979 if (MSWOnKillFocus((WXHWND
) hwnd
))
982 return MSWDefWindowProc(message
, wParam
, lParam
);
987 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
993 MSWOnShow((wParam
!= 0), (int) lParam
);
1000 else return MSWDefWindowProc(message
, wParam
, lParam
);
1003 case WM_QUERYDRAGICON
:
1005 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
1009 return MSWDefWindowProc(message
, wParam
, lParam
);
1015 int width
= LOWORD(lParam
);
1016 int height
= HIWORD(lParam
);
1017 MSWOnSize(width
, height
, wParam
);
1023 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1025 event
.SetEventObject(this);
1026 if ( !GetEventHandler()->ProcessEvent(event
) )
1031 case WM_WINDOWPOSCHANGING
:
1033 MSWOnWindowPosChanging((void *)lParam
);
1037 case WM_RBUTTONDOWN
:
1039 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1040 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1041 MSWOnRButtonDown(x
, y
, wParam
);
1046 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1047 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1048 MSWOnRButtonUp(x
, y
, wParam
);
1051 case WM_RBUTTONDBLCLK
:
1053 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1054 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1055 MSWOnRButtonDClick(x
, y
, wParam
);
1058 case WM_MBUTTONDOWN
:
1060 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1061 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1062 MSWOnMButtonDown(x
, y
, wParam
);
1067 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1068 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1069 MSWOnMButtonUp(x
, y
, wParam
);
1072 case WM_MBUTTONDBLCLK
:
1074 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1075 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1076 MSWOnMButtonDClick(x
, y
, wParam
);
1079 case WM_LBUTTONDOWN
:
1081 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1082 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1083 MSWOnLButtonDown(x
, y
, wParam
);
1088 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1089 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1090 MSWOnLButtonUp(x
, y
, wParam
);
1093 case WM_LBUTTONDBLCLK
:
1095 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1096 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1097 MSWOnLButtonDClick(x
, y
, wParam
);
1102 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1103 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1104 MSWOnMouseMove(x
, y
, wParam
);
1107 case MM_JOY1BUTTONDOWN
:
1109 int x
= LOWORD(lParam
);
1110 int y
= HIWORD(lParam
);
1111 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1114 case MM_JOY2BUTTONDOWN
:
1116 int x
= LOWORD(lParam
);
1117 int y
= HIWORD(lParam
);
1118 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1121 case MM_JOY1BUTTONUP
:
1123 int x
= LOWORD(lParam
);
1124 int y
= HIWORD(lParam
);
1125 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1128 case MM_JOY2BUTTONUP
:
1130 int x
= LOWORD(lParam
);
1131 int y
= HIWORD(lParam
);
1132 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1137 int x
= LOWORD(lParam
);
1138 int y
= HIWORD(lParam
);
1139 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1144 int x
= LOWORD(lParam
);
1145 int y
= HIWORD(lParam
);
1146 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1151 int z
= LOWORD(lParam
);
1152 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1157 int z
= LOWORD(lParam
);
1158 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1165 else return MSWDefWindowProc(message
, wParam
, lParam
);
1170 return MSWOnSysCommand(wParam
, lParam
);
1176 WORD id
= LOWORD(wParam
);
1177 HWND hwnd
= (HWND
)lParam
;
1178 WORD cmd
= HIWORD(wParam
);
1180 WORD id
= (WORD
)wParam
;
1181 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1182 WORD cmd
= HIWORD(lParam
);
1184 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1185 return MSWDefWindowProc(message
, wParam
, lParam
);
1188 #if defined(__WIN95__)
1191 // for some messages (TVN_ITEMEXPANDING for example), the return
1192 // value of WM_NOTIFY handler is important, so don't just return 0
1193 // if we processed the message
1194 return MSWOnNotify(wParam
, lParam
);
1200 WORD flags
= HIWORD(wParam
);
1201 HMENU sysmenu
= (HMENU
)lParam
;
1203 WORD flags
= LOWORD(lParam
);
1204 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1206 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1209 case WM_INITMENUPOPUP
:
1211 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1216 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1219 case WM_MEASUREITEM
:
1221 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1226 MSWOnKeyDown((WORD
) wParam
, lParam
);
1227 // we consider these message "not interesting"
1228 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1231 // Avoid duplicate messages to OnChar for these special keys
1243 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1244 MSWOnChar((WORD
)wParam
, lParam
);
1248 MSWOnChar((WORD
)wParam
, lParam
);
1249 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1258 MSWOnKeyUp((WORD
) wParam
, lParam
);
1261 case WM_CHAR
: // Always an ASCII character
1263 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1270 WORD code
= LOWORD(wParam
);
1271 WORD pos
= HIWORD(wParam
);
1272 HWND control
= (HWND
)lParam
;
1274 WORD code
= (WORD
)wParam
;
1275 WORD pos
= LOWORD(lParam
);
1276 HWND control
= (HWND
)HIWORD(lParam
);
1278 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1284 WORD code
= LOWORD(wParam
);
1285 WORD pos
= HIWORD(wParam
);
1286 HWND control
= (HWND
)lParam
;
1288 WORD code
= (WORD
)wParam
;
1289 WORD pos
= LOWORD(lParam
);
1290 HWND control
= (HWND
)HIWORD(lParam
);
1292 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1296 case WM_CTLCOLORBTN
:
1298 int nCtlColor
= CTLCOLOR_BTN
;
1299 HWND control
= (HWND
)lParam
;
1300 HDC pDC
= (HDC
)wParam
;
1301 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1302 message
, wParam
, lParam
);
1305 case WM_CTLCOLORDLG
:
1307 int nCtlColor
= CTLCOLOR_DLG
;
1308 HWND control
= (HWND
)lParam
;
1309 HDC pDC
= (HDC
)wParam
;
1310 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1311 message
, wParam
, lParam
);\
1314 case WM_CTLCOLORLISTBOX
:
1316 int nCtlColor
= CTLCOLOR_LISTBOX
;
1317 HWND control
= (HWND
)lParam
;
1318 HDC pDC
= (HDC
)wParam
;
1319 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1320 message
, wParam
, lParam
);
1323 case WM_CTLCOLORMSGBOX
:
1325 int nCtlColor
= CTLCOLOR_MSGBOX
;
1326 HWND control
= (HWND
)lParam
;
1327 HDC pDC
= (HDC
)wParam
;
1328 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1329 message
, wParam
, lParam
);
1332 case WM_CTLCOLORSCROLLBAR
:
1334 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1335 HWND control
= (HWND
)lParam
;
1336 HDC pDC
= (HDC
)wParam
;
1337 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1338 message
, wParam
, lParam
);
1341 case WM_CTLCOLORSTATIC
:
1343 int nCtlColor
= CTLCOLOR_STATIC
;
1344 HWND control
= (HWND
)lParam
;
1345 HDC pDC
= (HDC
)wParam
;
1346 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1347 message
, wParam
, lParam
);
1350 case WM_CTLCOLOREDIT
:
1352 int nCtlColor
= CTLCOLOR_EDIT
;
1353 HWND control
= (HWND
)lParam
;
1354 HDC pDC
= (HDC
)wParam
;
1355 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1356 message
, wParam
, lParam
);
1362 HWND control
= (HWND
)LOWORD(lParam
);
1363 int nCtlColor
= (int)HIWORD(lParam
);
1364 HDC pDC
= (HDC
)wParam
;
1365 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1366 message
, wParam
, lParam
);
1370 case WM_SYSCOLORCHANGE
:
1372 // Return value of 0 means, we processed it.
1373 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1376 return MSWDefWindowProc(message
, wParam
, lParam
);
1379 case WM_PALETTECHANGED
:
1381 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1384 case WM_QUERYNEWPALETTE
:
1386 return MSWOnQueryNewPalette();
1391 // Prevents flicker when dragging
1392 if (IsIconic(hWnd
)) return 1;
1394 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1395 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1399 case WM_MDIACTIVATE
:
1402 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1403 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1404 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1405 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1407 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1408 (HWND
)HIWORD(lParam
));
1413 MSWOnDropFiles(wParam
);
1418 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1421 case WM_QUERYENDSESSION
:
1423 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1424 // return MSWOnClose();
1426 return MSWOnQueryEndSession(lParam
);
1431 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1432 MSWOnEndSession((wParam
!= 0), lParam
);
1445 case WM_GETMINMAXINFO
:
1447 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1448 if (m_minSizeX
!= -1)
1449 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1450 if (m_minSizeY
!= -1)
1451 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1452 if (m_maxSizeX
!= -1)
1453 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1454 if (m_maxSizeY
!= -1)
1455 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1456 return MSWDefWindowProc(message
, wParam
, lParam
);
1461 return MSWGetDlgCode();
1464 return MSWDefWindowProc(message
, wParam
, lParam
);
1467 return 0; // Success: we processed this command.
1470 // Dialog window proc
1471 LONG APIENTRY _EXPORT
1472 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1477 wxList
*wxWinHandleList
= NULL
;
1478 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1480 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1483 return (wxWindow
*)node
->Data();
1486 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1488 // adding NULL hWnd is (first) surely a result of an error and
1489 // (secondly) breaks menu command processing
1490 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1492 if ( !wxWinHandleList
->Find((long)hWnd
) )
1493 wxWinHandleList
->Append((long)hWnd
, win
);
1496 void wxRemoveHandleAssociation(wxWindow
*win
)
1498 wxWinHandleList
->DeleteObject(win
);
1501 // Default destroyer - override if you destroy it in some other way
1502 // (e.g. with MDI child windows)
1503 void wxWindow::MSWDestroyWindow()
1507 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1508 int x
, int y
, int width
, int height
,
1509 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1511 bool is_dialog
= (dialog_template
!= NULL
);
1512 int x1
= CW_USEDEFAULT
;
1514 int width1
= CW_USEDEFAULT
;
1517 // Find parent's size, if it exists, to set up a possible default
1518 // panel size the size of the parent window
1522 // Was GetWindowRect: JACS 5/5/95
1523 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1525 width1
= parent_rect
.right
- parent_rect
.left
;
1526 height1
= parent_rect
.bottom
- parent_rect
.top
;
1531 if (width
> -1) width1
= width
;
1532 if (height
> -1) height1
= height
;
1534 HWND hParent
= NULL
;
1536 hParent
= (HWND
) parent
->GetHWND();
1542 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1543 // other compilers???
1544 // VZ: it's always needed for Win16 and never for Win32
1546 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1547 (DLGPROC
)wxDlgProc
);
1549 // N.B.: if we _don't_ use this form,
1550 // then with VC++ 1.5, it crashes horribly.
1552 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1553 (DLGPROC
)wxDlgProc
);
1555 // Crashes when we use this.
1556 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1558 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1564 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1565 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1566 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1571 if (style
& WS_CHILD
)
1576 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1581 hParent
, (HMENU
)controlId
, wxGetInstance(),
1585 wxLogError("Can't create window of class %s!\n"
1586 "Possible Windows 3.x compatibility problem?", wclass
);
1591 wxWinHandleList
->Append((long)m_hWnd
, this);
1594 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1598 bool wxWindow::MSWOnClose()
1603 // Some compilers don't define this
1604 #ifndef ENDSESSION_LOGOFF
1605 #define ENDSESSION_LOGOFF 0x80000000
1608 // Return TRUE to end session, FALSE to veto end session.
1609 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1611 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1612 event
.SetEventObject(wxTheApp
);
1613 event
.SetCanVeto(TRUE
);
1614 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1615 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1616 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1618 return FALSE
; // Veto!
1622 return TRUE
; // Don't veto
1626 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1628 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1629 event
.SetEventObject(wxTheApp
);
1630 event
.SetCanVeto(FALSE
);
1631 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1632 if (endSession
&& // No need to send if the session isn't ending
1633 (this == wxTheApp
->GetTopWindow()) && // Only send once
1634 wxTheApp
->ProcessEvent(event
))
1640 bool wxWindow::MSWOnDestroy()
1642 // delete our drop target if we've got one
1643 #if wxUSE_DRAG_AND_DROP
1644 if ( m_pDropTarget
!= NULL
) {
1645 m_pDropTarget
->Revoke(m_hWnd
);
1647 delete m_pDropTarget
;
1648 m_pDropTarget
= NULL
;
1655 // Deal with child commands from buttons etc.
1657 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1659 #if defined(__WIN95__)
1660 // Find a child window to send the notification to, e.g. a toolbar.
1661 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1662 // handle of the toolbar; it's probably the handle of the tooltip
1663 // window (anyway, it's parent is also the toolbar's parent).
1664 // So, since we don't know which hWnd or wxWindow originated the
1665 // WM_NOTIFY, we'll need to go through all the children of this window
1666 // trying out MSWNotify.
1667 // This won't work now, though, because any number of controls
1668 // could respond to the same generic messages :-(
1670 /* This doesn't work for toolbars, but try for other controls first.
1672 NMHDR
*hdr
= (NMHDR
*)lParam
;
1673 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1674 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1676 WXLPARAM result
= 0;
1680 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1685 // Rely on MSWNotify to check whether the message
1686 // belongs to the window or not
1687 wxNode
*node
= GetChildren().First();
1690 wxWindow
*child
= (wxWindow
*)node
->Data();
1691 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1693 node
= node
->Next();
1696 // finally try this window too (catches toolbar case)
1697 if ( MSWNotify(wParam
, lParam
, &result
) )
1706 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1710 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1714 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1716 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1718 event
.SetEventObject(this);
1719 GetEventHandler()->ProcessEvent(event
);
1723 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1726 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1728 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1730 ::ShowCaret((HWND
) GetHWND());
1733 // panel wants to track the window which was the last to have focus in it
1734 wxWindow
*parent
= GetParent();
1735 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1737 ((wxPanel
*)parent
)->SetLastFocus(this);
1740 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1741 event
.SetEventObject(this);
1742 if (!GetEventHandler()->ProcessEvent(event
))
1747 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1755 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1756 event
.SetEventObject(this);
1757 if (!GetEventHandler()->ProcessEvent(event
))
1762 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1765 HDROP hFilesInfo
= (HDROP
) wParam
;
1767 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1769 // Get the total number of files dropped
1770 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1775 wxString
*files
= new wxString
[gwFilesDropped
];
1777 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1779 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1780 files
[wIndex
] = wxBuffer
;
1782 DragFinish (hFilesInfo
);
1784 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1785 event
.m_eventObject
= this;
1786 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1788 if (!GetEventHandler()->ProcessEvent(event
))
1794 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1796 #if wxUSE_OWNER_DRAWN
1797 if ( id
== 0 ) { // is it a menu item?
1798 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1799 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1800 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1802 // prepare to call OnDrawItem()
1804 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1805 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1806 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1807 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1808 return pMenuItem
->OnDrawItem(
1810 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1811 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1814 #endif // owner-drawn menus
1816 wxWindow
*item
= FindItem(id
);
1817 #if wxUSE_DYNAMIC_CLASSES
1818 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1820 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1827 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1829 #if wxUSE_OWNER_DRAWN
1830 if ( id
== 0 ) { // is it a menu item?
1831 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1832 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1833 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1835 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1836 &pMeasureStruct
->itemHeight
);
1838 #endif // owner-drawn menus
1840 wxWindow
*item
= FindItem(id
);
1841 #if wxUSE_DYNAMIC_CLASSES
1842 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1844 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1851 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1852 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1854 if (nCtlColor
== CTLCOLOR_DLG
)
1856 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1859 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1861 WXHBRUSH hBrush
= 0;
1864 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1866 // I think that even for dialogs, we may need to call DefWindowProc (?)
1867 // Or maybe just rely on the usual default behaviour.
1869 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1874 // Define for each class of dialog and control
1875 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1876 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1878 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1881 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1883 wxSysColourChangedEvent event
;
1884 event
.SetEventObject(this);
1886 // Check if app handles this.
1887 if (GetEventHandler()->ProcessEvent(event
))
1890 // We didn't process it
1894 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1896 wxPaletteChangedEvent
event(GetId());
1897 event
.SetEventObject(this);
1898 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1899 GetEventHandler()->ProcessEvent(event
);
1903 long wxWindow::MSWOnQueryNewPalette()
1905 wxQueryNewPaletteEvent
event(GetId());
1906 event
.SetEventObject(this);
1907 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1909 return (long) FALSE
;
1915 // Responds to colour changes: passes event on to children.
1916 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1918 wxNode
*node
= GetChildren().First();
1921 // Only propagate to non-top-level windows
1922 wxWindow
*win
= (wxWindow
*)node
->Data();
1923 if ( win
->GetParent() )
1925 wxSysColourChangedEvent event2
;
1926 event
.m_eventObject
= win
;
1927 win
->GetEventHandler()->ProcessEvent(event2
);
1930 node
= node
->Next();
1934 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1937 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1939 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1942 long wxWindow::Default()
1944 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1949 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1950 wxGetMessageName(m_lastMsg
));
1951 #endif // __WXDEBUG__
1953 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1956 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1958 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1959 // intercept dialog navigation keys
1960 MSG
*msg
= (MSG
*)pMsg
;
1961 bool bProcess
= TRUE
;
1962 if ( msg
->message
!= WM_KEYDOWN
)
1965 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1970 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1972 // WM_GETDLGCODE: ask the control if it wants the key for itself,
1973 // don't process it if it's the case (except for Ctrl-Tab/Enter
1974 // combinations which are always processed)
1978 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1981 bool bForward
= TRUE
,
1982 bWindowChange
= FALSE
;
1984 switch ( msg
->wParam
)
1987 if ( lDlgCode
& DLGC_WANTTAB
) {
1991 // Ctrl-Tab cycles thru notebook pages
1992 bWindowChange
= bCtrlDown
;
1993 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1999 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2007 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2013 if ( lDlgCode
& DLGC_WANTMESSAGE
)
2015 // control wants to process Enter itself, don't
2016 // call IsDialogMessage() which would interpret
2021 wxButton
*btnDefault
= GetDefaultItem();
2022 if ( btnDefault
&& !bCtrlDown
)
2024 // if there is a default button, Enter should
2026 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
2030 // else: but if there is not it makes sense to make it
2031 // work like a TAB - and that's what we do.
2032 // Note that Ctrl-Enter always works this way.
2042 wxNavigationKeyEvent event
;
2043 event
.SetDirection(bForward
);
2044 event
.SetWindowChange(bWindowChange
);
2045 event
.SetEventObject(this);
2047 if ( GetEventHandler()->ProcessEvent(event
) )
2052 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
2058 // relay mouse move events to the tooltip control
2059 MSG
*msg
= (MSG
*)pMsg
;
2060 if ( msg
->message
== WM_MOUSEMOVE
)
2061 m_tooltip
->RelayEvent(pMsg
);
2063 #endif // wxUSE_TOOLTIPS
2068 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2070 if (m_acceleratorTable
.Ok() &&
2071 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2077 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2082 void wxWindow::MSWDetachWindowMenu()
2086 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2088 for (i
= 0; i
< N
; i
++)
2091 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2092 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2094 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2101 bool wxWindow::MSWOnPaint()
2104 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2105 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2107 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2110 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2112 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2113 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2116 wxPaintEvent
event(m_windowId
);
2117 event
.SetEventObject(this);
2118 if (!GetEventHandler()->ProcessEvent(event
))
2123 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2133 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2134 event
.SetEventObject(this);
2135 if (!GetEventHandler()->ProcessEvent(event
))
2141 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2146 // Deal with child commands from buttons etc.
2147 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2149 if (wxCurrentPopupMenu
)
2151 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2152 wxCurrentPopupMenu
= NULL
;
2153 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2157 wxWindow
*item
= FindItem(id
);
2160 bool value
= item
->MSWCommand(cmd
, id
);
2165 wxWindow
*win
= wxFindWinFromHandle(control
);
2167 return win
->MSWCommand(cmd
, id
);
2172 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2178 wxMaximizeEvent
event(m_windowId
);
2179 event
.SetEventObject(this);
2180 if (!GetEventHandler()->ProcessEvent(event
))
2188 wxIconizeEvent
event(m_windowId
);
2189 event
.SetEventObject(this);
2190 if (!GetEventHandler()->ProcessEvent(event
))
2202 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2204 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2206 event
.m_x
= x
; event
.m_y
= y
;
2207 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2208 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2209 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2210 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2211 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2212 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2213 event
.m_eventObject
= this;
2215 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2217 if (!GetEventHandler()->ProcessEvent(event
))
2221 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2223 wxMouseEvent
event(wxEVT_LEFT_UP
);
2225 event
.m_x
= x
; event
.m_y
= y
;
2226 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2227 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2228 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2229 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2230 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2231 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2232 event
.m_eventObject
= this;
2234 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2236 if (!GetEventHandler()->ProcessEvent(event
))
2240 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2242 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2244 event
.m_x
= x
; event
.m_y
= y
;
2245 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2246 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2247 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2248 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2249 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2250 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2251 event
.m_eventObject
= this;
2253 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2255 if (!GetEventHandler()->ProcessEvent(event
))
2259 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2261 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2263 event
.m_x
= x
; event
.m_y
= y
;
2264 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2265 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2266 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2267 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2268 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2269 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2270 event
.m_eventObject
= this;
2272 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2274 if (!GetEventHandler()->ProcessEvent(event
))
2278 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2280 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2282 event
.m_x
= x
; event
.m_y
= y
;
2283 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2284 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2285 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2286 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2287 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2288 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2289 event
.m_eventObject
= this;
2291 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2293 if (!GetEventHandler()->ProcessEvent(event
))
2297 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2299 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2301 event
.m_x
= x
; event
.m_y
= y
;
2302 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2303 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2304 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2305 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2306 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2307 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2308 event
.m_eventObject
= this;
2310 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2312 if (!GetEventHandler()->ProcessEvent(event
))
2316 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2318 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2320 event
.m_x
= x
; event
.m_y
= y
;
2321 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2322 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2323 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2324 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2325 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2326 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2327 event
.m_eventObject
= this;
2329 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2331 if (!GetEventHandler()->ProcessEvent(event
))
2335 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2337 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2339 event
.m_x
= x
; event
.m_y
= y
;
2340 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2341 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2342 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2343 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2344 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2345 event
.m_eventObject
= this;
2346 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2348 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2350 if (!GetEventHandler()->ProcessEvent(event
))
2354 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2356 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2358 event
.m_x
= x
; event
.m_y
= y
;
2359 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2360 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2361 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2362 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2363 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2364 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2365 event
.m_eventObject
= this;
2367 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2369 if (!GetEventHandler()->ProcessEvent(event
))
2373 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2375 // 'normal' move event...
2376 // Set cursor, but only if we're not in 'busy' mode
2378 // Trouble with this is that it sets the cursor for controls too :-(
2379 if (m_windowCursor
.Ok() && !wxIsBusy())
2380 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2382 if (!m_mouseInWindow
)
2384 // Generate an ENTER event
2385 m_mouseInWindow
= TRUE
;
2386 MSWOnMouseEnter(x
, y
, flags
);
2389 wxMouseEvent
event(wxEVT_MOTION
);
2391 event
.m_x
= x
; event
.m_y
= y
;
2392 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2393 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2394 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2395 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2396 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2397 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2398 event
.m_eventObject
= this;
2400 // Window gets a click down message followed by a mouse move
2401 // message even if position isn't changed! We want to discard
2402 // the trailing move event if x and y are the same.
2403 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2404 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2405 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2407 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2408 m_lastEvent
= wxEVT_MOTION
;
2412 m_lastEvent
= wxEVT_MOTION
;
2413 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2415 if (!GetEventHandler()->ProcessEvent(event
))
2419 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2421 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2423 event
.m_x
= x
; event
.m_y
= y
;
2424 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2425 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2426 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2427 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2428 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2429 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2430 event
.m_eventObject
= this;
2432 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2433 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2434 // No message - ensure we don't try to call the default behaviour accidentally.
2436 GetEventHandler()->ProcessEvent(event
);
2439 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2441 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2443 event
.m_x
= x
; event
.m_y
= y
;
2444 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2445 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2446 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2447 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2448 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2449 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2450 event
.m_eventObject
= this;
2452 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2453 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2454 // No message - ensure we don't try to call the default behaviour accidentally.
2456 GetEventHandler()->ProcessEvent(event
);
2459 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2462 bool tempControlDown
= FALSE
;
2465 // If 1 -> 26, translate to CTRL plus a letter.
2467 if ((id
> 0) && (id
< 27))
2488 tempControlDown
= TRUE
;
2494 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2495 // it's ASCII and will be processed here only when called from
2496 // WM_CHAR (i.e. when isASCII = TRUE)
2502 wxKeyEvent
event(wxEVT_CHAR
);
2503 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2504 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2505 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2506 event
.m_altDown
= TRUE
;
2508 event
.m_eventObject
= this;
2509 event
.m_keyCode
= id
;
2510 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2515 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2519 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2521 if (!GetEventHandler()->ProcessEvent(event
))
2526 void wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2530 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2536 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2537 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2538 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2539 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2540 event
.m_altDown
= TRUE
;
2542 event
.m_eventObject
= this;
2543 event
.m_keyCode
= id
;
2544 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2549 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2553 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2555 if (!GetEventHandler()->ProcessEvent(event
))
2560 void wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2564 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2570 wxKeyEvent
event(wxEVT_KEY_UP
);
2571 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2572 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2573 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2574 event
.m_altDown
= TRUE
;
2576 event
.m_eventObject
= this;
2577 event
.m_keyCode
= id
;
2578 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2583 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2587 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2589 if (!GetEventHandler()->ProcessEvent(event
))
2594 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2598 if (flags
& JOY_BUTTON1CHG
)
2599 change
= wxJOY_BUTTON1
;
2600 if (flags
& JOY_BUTTON2CHG
)
2601 change
= wxJOY_BUTTON2
;
2602 if (flags
& JOY_BUTTON3CHG
)
2603 change
= wxJOY_BUTTON3
;
2604 if (flags
& JOY_BUTTON4CHG
)
2605 change
= wxJOY_BUTTON4
;
2607 if (flags
& JOY_BUTTON1
)
2608 buttons
|= wxJOY_BUTTON1
;
2609 if (flags
& JOY_BUTTON2
)
2610 buttons
|= wxJOY_BUTTON2
;
2611 if (flags
& JOY_BUTTON3
)
2612 buttons
|= wxJOY_BUTTON3
;
2613 if (flags
& JOY_BUTTON4
)
2614 buttons
|= wxJOY_BUTTON4
;
2616 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2617 event
.SetPosition(wxPoint(x
, y
));
2618 event
.SetEventObject(this);
2620 GetEventHandler()->ProcessEvent(event
);
2623 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2627 if (flags
& JOY_BUTTON1CHG
)
2628 change
= wxJOY_BUTTON1
;
2629 if (flags
& JOY_BUTTON2CHG
)
2630 change
= wxJOY_BUTTON2
;
2631 if (flags
& JOY_BUTTON3CHG
)
2632 change
= wxJOY_BUTTON3
;
2633 if (flags
& JOY_BUTTON4CHG
)
2634 change
= wxJOY_BUTTON4
;
2636 if (flags
& JOY_BUTTON1
)
2637 buttons
|= wxJOY_BUTTON1
;
2638 if (flags
& JOY_BUTTON2
)
2639 buttons
|= wxJOY_BUTTON2
;
2640 if (flags
& JOY_BUTTON3
)
2641 buttons
|= wxJOY_BUTTON3
;
2642 if (flags
& JOY_BUTTON4
)
2643 buttons
|= wxJOY_BUTTON4
;
2645 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2646 event
.SetPosition(wxPoint(x
, y
));
2647 event
.SetEventObject(this);
2649 GetEventHandler()->ProcessEvent(event
);
2652 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2655 if (flags
& JOY_BUTTON1
)
2656 buttons
|= wxJOY_BUTTON1
;
2657 if (flags
& JOY_BUTTON2
)
2658 buttons
|= wxJOY_BUTTON2
;
2659 if (flags
& JOY_BUTTON3
)
2660 buttons
|= wxJOY_BUTTON3
;
2661 if (flags
& JOY_BUTTON4
)
2662 buttons
|= wxJOY_BUTTON4
;
2664 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2665 event
.SetPosition(wxPoint(x
, y
));
2666 event
.SetEventObject(this);
2668 GetEventHandler()->ProcessEvent(event
);
2671 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2674 if (flags
& JOY_BUTTON1
)
2675 buttons
|= wxJOY_BUTTON1
;
2676 if (flags
& JOY_BUTTON2
)
2677 buttons
|= wxJOY_BUTTON2
;
2678 if (flags
& JOY_BUTTON3
)
2679 buttons
|= wxJOY_BUTTON3
;
2680 if (flags
& JOY_BUTTON4
)
2681 buttons
|= wxJOY_BUTTON4
;
2683 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2684 event
.SetZPosition(z
);
2685 event
.SetEventObject(this);
2687 GetEventHandler()->ProcessEvent(event
);
2690 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2694 wxWindow
*child
= wxFindWinFromHandle(control
);
2696 child
->MSWOnVScroll(wParam
, pos
, control
);
2700 wxScrollEvent event
;
2701 event
.SetPosition(pos
);
2702 event
.SetOrientation(wxVERTICAL
);
2703 event
.m_eventObject
= this;
2708 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2712 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2716 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2720 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2724 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2728 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2732 case SB_THUMBPOSITION
:
2733 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2741 if (!GetEventHandler()->ProcessEvent(event
))
2745 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2749 wxWindow
*child
= wxFindWinFromHandle(control
);
2751 child
->MSWOnHScroll(wParam
, pos
, control
);
2757 wxScrollEvent event
;
2758 event
.SetPosition(pos
);
2759 event
.SetOrientation(wxHORIZONTAL
);
2760 event
.m_eventObject
= this;
2765 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2769 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2773 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2777 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2781 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2785 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2789 case SB_THUMBPOSITION
:
2790 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2797 if ( GetEventHandler()->ProcessEvent(event
) )
2801 // call the default WM_HSCROLL handler: it's non trivial in some common
2802 // controls (up-down control for example)
2806 void wxWindow::MSWOnShow(bool show
, int status
)
2808 wxShowEvent
event(GetId(), show
);
2809 event
.m_eventObject
= this;
2810 GetEventHandler()->ProcessEvent(event
);
2813 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2815 wxInitDialogEvent
event(GetId());
2816 event
.m_eventObject
= this;
2817 GetEventHandler()->ProcessEvent(event
);
2821 void wxWindow::InitDialog()
2823 wxInitDialogEvent
event(GetId());
2824 event
.SetEventObject( this );
2825 GetEventHandler()->ProcessEvent(event
);
2828 // Default init dialog behaviour is to transfer data to window
2829 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2831 TransferDataToWindow();
2834 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2837 HDC dc
= ::GetDC((HWND
) wnd
);
2842 // the_font->UseResource();
2843 // the_font->RealizeResource();
2844 fnt
= (HFONT
)the_font
->GetResourceHandle();
2846 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2848 GetTextMetrics(dc
, &tm
);
2849 if (the_font
&& fnt
&& was
)
2851 SelectObject(dc
,was
) ;
2853 ReleaseDC((HWND
)wnd
, dc
);
2854 *x
= tm
.tmAveCharWidth
;
2855 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2858 // the_font->ReleaseResource();
2861 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2862 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2863 int wxCharCodeMSWToWX(int keySym
)
2868 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2869 case VK_BACK
: id
= WXK_BACK
; break;
2870 case VK_TAB
: id
= WXK_TAB
; break;
2871 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2872 case VK_RETURN
: id
= WXK_RETURN
; break;
2873 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2874 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2875 case VK_MENU
: id
= WXK_MENU
; break;
2876 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2877 case VK_SPACE
: id
= WXK_SPACE
; break;
2878 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2879 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2880 case VK_NEXT
: id
= WXK_NEXT
; break;
2881 case VK_END
: id
= WXK_END
; break;
2882 case VK_HOME
: id
= WXK_HOME
; break;
2883 case VK_LEFT
: id
= WXK_LEFT
; break;
2884 case VK_UP
: id
= WXK_UP
; break;
2885 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2886 case VK_DOWN
: id
= WXK_DOWN
; break;
2887 case VK_SELECT
: id
= WXK_SELECT
; break;
2888 case VK_PRINT
: id
= WXK_PRINT
; break;
2889 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2890 case VK_INSERT
: id
= WXK_INSERT
; break;
2891 case VK_DELETE
: id
= WXK_DELETE
; break;
2892 case VK_HELP
: id
= WXK_HELP
; break;
2893 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2894 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2895 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2896 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2897 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2898 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2899 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2900 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2901 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2902 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2903 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2904 case VK_ADD
: id
= WXK_ADD
; break;
2905 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2906 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2907 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2908 case VK_F1
: id
= WXK_F1
; break;
2909 case VK_F2
: id
= WXK_F2
; break;
2910 case VK_F3
: id
= WXK_F3
; break;
2911 case VK_F4
: id
= WXK_F4
; break;
2912 case VK_F5
: id
= WXK_F5
; break;
2913 case VK_F6
: id
= WXK_F6
; break;
2914 case VK_F7
: id
= WXK_F7
; break;
2915 case VK_F8
: id
= WXK_F8
; break;
2916 case VK_F9
: id
= WXK_F9
; break;
2917 case VK_F10
: id
= WXK_F10
; break;
2918 case VK_F11
: id
= WXK_F11
; break;
2919 case VK_F12
: id
= WXK_F12
; break;
2920 case VK_F13
: id
= WXK_F13
; break;
2921 case VK_F14
: id
= WXK_F14
; break;
2922 case VK_F15
: id
= WXK_F15
; break;
2923 case VK_F16
: id
= WXK_F16
; break;
2924 case VK_F17
: id
= WXK_F17
; break;
2925 case VK_F18
: id
= WXK_F18
; break;
2926 case VK_F19
: id
= WXK_F19
; break;
2927 case VK_F20
: id
= WXK_F20
; break;
2928 case VK_F21
: id
= WXK_F21
; break;
2929 case VK_F22
: id
= WXK_F22
; break;
2930 case VK_F23
: id
= WXK_F23
; break;
2931 case VK_F24
: id
= WXK_F24
; break;
2932 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2933 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2942 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2948 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2949 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2950 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2951 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2952 case WXK_MENU
: keySym
= VK_MENU
; break;
2953 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2954 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2955 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2956 case WXK_END
: keySym
= VK_END
; break;
2957 case WXK_HOME
: keySym
= VK_HOME
; break;
2958 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2959 case WXK_UP
: keySym
= VK_UP
; break;
2960 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2961 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2962 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2963 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2964 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2965 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2966 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2967 case WXK_HELP
: keySym
= VK_HELP
; break;
2968 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2969 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2970 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2971 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2972 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2973 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2974 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2975 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2976 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2977 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2978 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2979 case WXK_ADD
: keySym
= VK_ADD
; break;
2980 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2981 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2982 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2983 case WXK_F1
: keySym
= VK_F1
; break;
2984 case WXK_F2
: keySym
= VK_F2
; break;
2985 case WXK_F3
: keySym
= VK_F3
; break;
2986 case WXK_F4
: keySym
= VK_F4
; break;
2987 case WXK_F5
: keySym
= VK_F5
; break;
2988 case WXK_F6
: keySym
= VK_F6
; break;
2989 case WXK_F7
: keySym
= VK_F7
; break;
2990 case WXK_F8
: keySym
= VK_F8
; break;
2991 case WXK_F9
: keySym
= VK_F9
; break;
2992 case WXK_F10
: keySym
= VK_F10
; break;
2993 case WXK_F11
: keySym
= VK_F11
; break;
2994 case WXK_F12
: keySym
= VK_F12
; break;
2995 case WXK_F13
: keySym
= VK_F13
; break;
2996 case WXK_F14
: keySym
= VK_F14
; break;
2997 case WXK_F15
: keySym
= VK_F15
; break;
2998 case WXK_F16
: keySym
= VK_F16
; break;
2999 case WXK_F17
: keySym
= VK_F17
; break;
3000 case WXK_F18
: keySym
= VK_F18
; break;
3001 case WXK_F19
: keySym
= VK_F19
; break;
3002 case WXK_F20
: keySym
= VK_F20
; break;
3003 case WXK_F21
: keySym
= VK_F21
; break;
3004 case WXK_F22
: keySym
= VK_F22
; break;
3005 case WXK_F23
: keySym
= VK_F23
; break;
3006 case WXK_F24
: keySym
= VK_F24
; break;
3007 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
3008 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
3019 // Caret manipulation
3020 void wxWindow::CreateCaret(int w
, int h
)
3024 m_caretEnabled
= TRUE
;
3027 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
3032 void wxWindow::ShowCaret(bool show
)
3037 ::ShowCaret((HWND
) GetHWND());
3039 ::HideCaret((HWND
) GetHWND());
3040 m_caretShown
= show
;
3044 void wxWindow::DestroyCaret()
3046 m_caretEnabled
= FALSE
;
3049 void wxWindow::SetCaretPos(int x
, int y
)
3051 ::SetCaretPos(x
, y
);
3054 void wxWindow::GetCaretPos(int *x
, int *y
) const
3057 ::GetCaretPos(&point
);
3062 wxWindow
*wxGetActiveWindow()
3064 HWND hWnd
= GetActiveWindow();
3067 return wxFindWinFromHandle((WXHWND
) hWnd
);
3072 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3073 // in active frames and dialogs, regardless of where the focus is.
3074 static HHOOK wxTheKeyboardHook
= 0;
3075 static FARPROC wxTheKeyboardHookProc
= 0;
3076 int APIENTRY _EXPORT
3077 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3079 void wxSetKeyboardHook(bool doIt
)
3083 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3084 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3085 #if defined(__WIN32__) && !defined(__TWIN32__)
3086 GetCurrentThreadId());
3087 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3094 UnhookWindowsHookEx(wxTheKeyboardHook
);
3095 FreeProcInstance(wxTheKeyboardHookProc
);
3099 int APIENTRY _EXPORT
3100 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3102 DWORD hiWord
= HIWORD(lParam
);
3103 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3106 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3108 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3109 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3110 event
.m_altDown
= TRUE
;
3112 event
.m_eventObject
= NULL
;
3113 event
.m_keyCode
= id
;
3114 /* begin Albert's fix for control and shift key 26.5 */
3115 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3116 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3117 /* end Albert's fix for control and shift key 26.5 */
3118 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3120 wxWindow
*win
= wxGetActiveWindow();
3123 if (win
->GetEventHandler()->ProcessEvent(event
))
3128 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3133 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3136 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3144 void wxWindow::Centre(int direction
)
3146 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3148 wxWindow
*father
= (wxWindow
*)GetParent();
3152 father
->GetClientSize(&panel_width
, &panel_height
);
3153 GetSize(&width
, &height
);
3154 GetPosition(&x
, &y
);
3159 if (direction
& wxHORIZONTAL
)
3160 new_x
= (int)((panel_width
- width
)/2);
3162 if (direction
& wxVERTICAL
)
3163 new_y
= (int)((panel_height
- height
)/2);
3165 SetSize(new_x
, new_y
, -1, -1);
3169 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3171 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3172 // pixel coordinates, relatives to the canvas -- So, we first need to
3173 // substract origin of the window, then convert to screen position
3175 int x
= x_pos
; int y
= y_pos
;
3177 GetWindowRect ((HWND
) GetHWND(), &rect
);
3182 SetCursorPos (x
, y
);
3185 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3189 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3197 wxEraseEvent
event(m_windowId
, &dc
);
3198 event
.m_eventObject
= this;
3199 if (!GetEventHandler()->ProcessEvent(event
))
3202 dc
.SelectOldObjects(pDC
);
3208 dc
.SelectOldObjects(pDC
);
3211 dc
.SetHDC((WXHDC
) NULL
);
3215 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3221 ::GetClientRect((HWND
) GetHWND(), &rect
);
3223 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3224 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3225 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3227 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3228 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3229 ::DeleteObject(hBrush
);
3230 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3232 // Less efficient version (and doesn't account for scrolling)
3234 GetClientSize(& w, & h);
3235 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3236 event.GetDC()->SetBrush(brush);
3237 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3239 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3243 #if WXWIN_COMPATIBILITY
3244 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3246 #if defined(__WIN95__)
3250 // Try to adjust the range to cope with page size > 1
3251 // - a Windows API quirk
3252 int pageSize
= GetScrollPage(orient
);
3253 if ( pageSize
> 1 && range
> 0)
3255 range1
+= (pageSize
- 1);
3261 if (orient
== wxHORIZONTAL
) {
3267 info
.cbSize
= sizeof(SCROLLINFO
);
3268 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3272 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3274 HWND hWnd
= (HWND
) GetHWND();
3276 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3279 if (orient
== wxHORIZONTAL
)
3284 HWND hWnd
= (HWND
) GetHWND();
3286 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3290 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3292 #if defined(__WIN95__)
3296 if (orient
== wxHORIZONTAL
) {
3298 m_xThumbSize
= page
;
3301 m_yThumbSize
= page
;
3304 info
.cbSize
= sizeof(SCROLLINFO
);
3307 info
.fMask
= SIF_PAGE
;
3309 HWND hWnd
= (HWND
) GetHWND();
3311 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3313 if (orient
== wxHORIZONTAL
)
3314 m_xThumbSize
= page
;
3316 m_yThumbSize
= page
;
3320 int wxWindow::OldGetScrollRange(int orient
) const
3323 if (orient
== wxHORIZONTAL
)
3328 #if __WATCOMC__ && defined(__WINDOWS_386__)
3329 short minPos
, maxPos
;
3333 HWND hWnd
= (HWND
) GetHWND();
3336 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3337 #if defined(__WIN95__)
3338 // Try to adjust the range to cope with page size > 1
3339 // - a Windows API quirk
3340 int pageSize
= GetScrollPage(orient
);
3343 maxPos
-= (pageSize
- 1);
3352 int wxWindow::GetScrollPage(int orient
) const
3354 if (orient
== wxHORIZONTAL
)
3355 return m_xThumbSize
;
3357 return m_yThumbSize
;
3361 int wxWindow::GetScrollPos(int orient
) const
3364 if (orient
== wxHORIZONTAL
)
3368 HWND hWnd
= (HWND
) GetHWND();
3371 return ::GetScrollPos(hWnd
, wOrient
);
3377 // This now returns the whole range, not just the number
3378 // of positions that we can scroll.
3379 int wxWindow::GetScrollRange(int orient
) const
3382 if (orient
== wxHORIZONTAL
)
3387 #if __WATCOMC__ && defined(__WINDOWS_386__)
3388 short minPos
, maxPos
;
3392 HWND hWnd
= (HWND
) GetHWND();
3395 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3396 #if defined(__WIN95__)
3397 // Try to adjust the range to cope with page size > 1
3398 // - a Windows API quirk
3399 int pageSize
= GetScrollThumb(orient
);
3402 maxPos
-= (pageSize
- 1);
3404 // October 10th: new range concept.
3414 int wxWindow::GetScrollThumb(int orient
) const
3416 if (orient
== wxHORIZONTAL
)
3417 return m_xThumbSize
;
3419 return m_yThumbSize
;
3422 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3424 #if defined(__WIN95__)
3428 if (orient
== wxHORIZONTAL
) {
3434 info
.cbSize
= sizeof(SCROLLINFO
);
3438 info
.fMask
= SIF_POS
;
3440 HWND hWnd
= (HWND
) GetHWND();
3442 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3445 if (orient
== wxHORIZONTAL
)
3450 HWND hWnd
= (HWND
) GetHWND();
3452 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3456 // New function that will replace some of the above.
3457 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3458 int range
, bool refresh
)
3461 SetScrollPage(orient, thumbVisible, FALSE);
3463 int oldRange = range - thumbVisible ;
3464 SetScrollRange(orient, oldRange, FALSE);
3466 SetScrollPos(orient, pos, refresh);
3468 #if defined(__WIN95__)
3469 int oldRange
= range
- thumbVisible
;
3471 int range1
= oldRange
;
3473 // Try to adjust the range to cope with page size > 1
3474 // - a Windows API quirk
3475 int pageSize
= thumbVisible
;
3476 if ( pageSize
> 1 && range
> 0)
3478 range1
+= (pageSize
- 1);
3484 if (orient
== wxHORIZONTAL
) {
3490 info
.cbSize
= sizeof(SCROLLINFO
);
3491 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3495 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3497 HWND hWnd
= (HWND
) GetHWND();
3499 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3502 if (orient
== wxHORIZONTAL
)
3507 HWND hWnd
= (HWND
) GetHWND();
3510 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3511 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3514 if (orient
== wxHORIZONTAL
) {
3515 m_xThumbSize
= thumbVisible
;
3517 m_yThumbSize
= thumbVisible
;
3521 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3526 rect2
.left
= rect
->x
;
3527 rect2
.top
= rect
->y
;
3528 rect2
.right
= rect
->x
+ rect
->width
;
3529 rect2
.bottom
= rect
->y
+ rect
->height
;
3533 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3535 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3538 void wxWindow::SetFont(const wxFont
& font
)
3540 m_windowFont
= font
;
3542 if (!m_windowFont
.Ok())
3545 HWND hWnd
= (HWND
) GetHWND();
3548 if (m_windowFont
.GetResourceHandle())
3549 SendMessage(hWnd
, WM_SETFONT
,
3550 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3554 void wxWindow::SubclassWin(WXHWND hWnd
)
3556 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3558 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3560 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3561 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3564 void wxWindow::UnsubclassWin()
3566 wxRemoveHandleAssociation(this);
3568 // Restore old Window proc
3569 if ((HWND
) GetHWND())
3571 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3572 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3574 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3580 // Make a Windows extended style from the given wxWindows window style
3581 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3583 WXDWORD exStyle
= 0;
3584 if ( style
& wxTRANSPARENT_WINDOW
)
3585 exStyle
|= WS_EX_TRANSPARENT
;
3587 if ( !eliminateBorders
)
3589 if ( style
& wxSUNKEN_BORDER
)
3590 exStyle
|= WS_EX_CLIENTEDGE
;
3591 if ( style
& wxDOUBLE_BORDER
)
3592 exStyle
|= WS_EX_DLGMODALFRAME
;
3593 #if defined(__WIN95__)
3594 if ( style
& wxRAISED_BORDER
)
3595 exStyle
|= WS_EX_WINDOWEDGE
;
3596 if ( style
& wxSTATIC_BORDER
)
3597 exStyle
|= WS_EX_STATICEDGE
;
3603 // Determines whether native 3D effects or CTL3D should be used,
3604 // applying a default border style if required, and returning an extended
3605 // style to pass to CreateWindowEx.
3606 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3608 // If matches certain criteria, then assume no 3D effects
3609 // unless specifically requested (dealt with in MakeExtendedStyle)
3610 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3613 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3616 // Determine whether we should be using 3D effects or not.
3617 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3619 // 1) App can specify global 3D effects
3620 *want3D
= wxTheApp
->GetAuto3D();
3622 // 2) If the parent is being drawn with user colours, or simple border specified,
3623 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3624 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3627 // 3) Control can override this global setting by defining
3628 // a border style, e.g. wxSUNKEN_BORDER
3629 if (m_windowStyle
& wxSUNKEN_BORDER
)
3632 // 4) If it's a special border, CTL3D can't cope so we want a native border
3633 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3634 (m_windowStyle
& wxSTATIC_BORDER
) )
3637 nativeBorder
= TRUE
;
3640 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3641 // effects from extended style
3644 nativeBorder
= FALSE
;
3647 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3649 // If we want 3D, but haven't specified a border here,
3650 // apply the default border style specified.
3651 // TODO what about non-Win95 WIN32? Does it have borders?
3652 #if defined(__WIN95__) && !wxUSE_CTL3D
3653 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3654 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3655 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3661 void wxWindow::OnChar(wxKeyEvent
& event
)
3664 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3669 if ( !event
.ControlDown() )
3670 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3673 bool wxWindow::IsEnabled(void) const
3675 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3678 // Dialog support: override these and call
3679 // base class members to add functionality
3680 // that can't be done using validators.
3681 // NOTE: these functions assume that controls
3682 // are direct children of this window, not grandchildren
3683 // or other levels of descendant.
3685 // Transfer values to controls. If returns FALSE,
3686 // it's an application error (pops up a dialog)
3687 bool wxWindow::TransferDataToWindow()
3689 wxNode
*node
= GetChildren().First();
3692 wxWindow
*child
= (wxWindow
*)node
->Data();
3693 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3694 !child
->GetValidator()->TransferToWindow() )
3696 wxLogError(_("Could not transfer data to window"));
3700 node
= node
->Next();
3705 // Transfer values from controls. If returns FALSE,
3706 // validation failed: don't quit
3707 bool wxWindow::TransferDataFromWindow()
3709 wxNode
*node
= GetChildren().First();
3712 wxWindow
*child
= (wxWindow
*)node
->Data();
3713 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3718 node
= node
->Next();
3723 bool wxWindow::Validate()
3725 wxNode
*node
= GetChildren().First();
3728 wxWindow
*child
= (wxWindow
*)node
->Data();
3729 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3734 node
= node
->Next();
3739 // Get the window with the focus
3740 wxWindow
*wxWindow::FindFocus()
3742 HWND hWnd
= ::GetFocus();
3745 return wxFindWinFromHandle((WXHWND
) hWnd
);
3750 void wxWindow::AddChild(wxWindow
*child
)
3752 GetChildren().Append(child
);
3753 child
->m_windowParent
= this;
3756 void wxWindow::RemoveChild(wxWindow
*child
)
3758 // if (GetChildren())
3759 GetChildren().DeleteObject(child
);
3760 child
->m_windowParent
= NULL
;
3763 void wxWindow::DestroyChildren()
3766 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3768 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3770 if ( GetChildren().Member(child
) )
3776 void wxWindow::MakeModal(bool modal
)
3778 // Disable all other windows
3779 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3781 wxNode
*node
= wxTopLevelWindows
.First();
3784 wxWindow
*win
= (wxWindow
*)node
->Data();
3786 win
->Enable(!modal
);
3788 node
= node
->Next();
3793 // If nothing defined for this, try the parent.
3794 // E.g. we may be a button loaded from a resource, with no callback function
3796 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3798 if (GetEventHandler()->ProcessEvent(event
) )
3801 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3804 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3808 UnsetConstraints(m_constraints
);
3809 delete m_constraints
;
3814 // Make sure other windows know they're part of a 'meaningful relationship'
3815 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3816 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3817 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3818 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3819 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3820 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3821 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3822 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3823 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3824 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3825 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3826 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3827 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3828 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3829 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3830 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3834 // This removes any dangling pointers to this window
3835 // in other windows' constraintsInvolvedIn lists.
3836 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3840 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3841 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3842 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3843 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3844 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3845 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3846 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3847 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3848 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3849 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3850 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3851 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3852 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3853 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3854 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3855 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3859 // Back-pointer to other windows we're involved with, so if we delete
3860 // this window, we must delete any constraints we're involved with.
3861 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3863 if (!m_constraintsInvolvedIn
)
3864 m_constraintsInvolvedIn
= new wxList
;
3865 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3866 m_constraintsInvolvedIn
->Append(otherWin
);
3869 // REMOVE back-pointer to other windows we're involved with.
3870 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3872 if (m_constraintsInvolvedIn
)
3873 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3876 // Reset any constraints that mention this window
3877 void wxWindow::DeleteRelatedConstraints()
3879 if (m_constraintsInvolvedIn
)
3881 wxNode
*node
= m_constraintsInvolvedIn
->First();
3884 wxWindow
*win
= (wxWindow
*)node
->Data();
3885 wxNode
*next
= node
->Next();
3886 wxLayoutConstraints
*constr
= win
->GetConstraints();
3888 // Reset any constraints involving this window
3891 constr
->left
.ResetIfWin((wxWindow
*)this);
3892 constr
->top
.ResetIfWin((wxWindow
*)this);
3893 constr
->right
.ResetIfWin((wxWindow
*)this);
3894 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3895 constr
->width
.ResetIfWin((wxWindow
*)this);
3896 constr
->height
.ResetIfWin((wxWindow
*)this);
3897 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3898 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3903 delete m_constraintsInvolvedIn
;
3904 m_constraintsInvolvedIn
= NULL
;
3908 void wxWindow::SetSizer(wxSizer
*sizer
)
3910 m_windowSizer
= sizer
;
3912 sizer
->SetSizerParent((wxWindow
*)this);
3919 bool wxWindow::Layout()
3921 if (GetConstraints())
3924 GetClientSize(&w
, &h
);
3925 GetConstraints()->width
.SetValue(w
);
3926 GetConstraints()->height
.SetValue(h
);
3929 // If top level (one sizer), evaluate the sizer's constraints.
3933 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3934 GetSizer()->LayoutPhase1(&noChanges
);
3935 GetSizer()->LayoutPhase2(&noChanges
);
3936 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3941 // Otherwise, evaluate child constraints
3942 ResetConstraints(); // Mark all constraints as unevaluated
3943 DoPhase(1); // Just one phase need if no sizers involved
3945 SetConstraintSizes(); // Recursively set the real window sizes
3951 // Do a phase of evaluating constraints:
3952 // the default behaviour. wxSizers may do a similar
3953 // thing, but also impose their own 'constraints'
3954 // and order the evaluation differently.
3955 bool wxWindow::LayoutPhase1(int *noChanges
)
3957 wxLayoutConstraints
*constr
= GetConstraints();
3960 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3966 bool wxWindow::LayoutPhase2(int *noChanges
)
3976 // Do a phase of evaluating child constraints
3977 bool wxWindow::DoPhase(int phase
)
3979 int noIterations
= 0;
3980 int maxIterations
= 500;
3984 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3988 wxNode
*node
= GetChildren().First();
3991 wxWindow
*child
= (wxWindow
*)node
->Data();
3992 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3994 wxLayoutConstraints
*constr
= child
->GetConstraints();
3997 if (succeeded
.Member(child
))
4002 int tempNoChanges
= 0;
4003 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
4004 noChanges
+= tempNoChanges
;
4007 succeeded
.Append(child
);
4012 node
= node
->Next();
4019 void wxWindow::ResetConstraints()
4021 wxLayoutConstraints
*constr
= GetConstraints();
4024 constr
->left
.SetDone(FALSE
);
4025 constr
->top
.SetDone(FALSE
);
4026 constr
->right
.SetDone(FALSE
);
4027 constr
->bottom
.SetDone(FALSE
);
4028 constr
->width
.SetDone(FALSE
);
4029 constr
->height
.SetDone(FALSE
);
4030 constr
->centreX
.SetDone(FALSE
);
4031 constr
->centreY
.SetDone(FALSE
);
4033 wxNode
*node
= GetChildren().First();
4036 wxWindow
*win
= (wxWindow
*)node
->Data();
4037 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4038 win
->ResetConstraints();
4039 node
= node
->Next();
4043 // Need to distinguish between setting the 'fake' size for
4044 // windows and sizers, and setting the real values.
4045 void wxWindow::SetConstraintSizes(bool recurse
)
4047 wxLayoutConstraints
*constr
= GetConstraints();
4048 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4049 constr
->width
.GetDone() && constr
->height
.GetDone())
4051 int x
= constr
->left
.GetValue();
4052 int y
= constr
->top
.GetValue();
4053 int w
= constr
->width
.GetValue();
4054 int h
= constr
->height
.GetValue();
4056 // If we don't want to resize this window, just move it...
4057 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4058 (constr
->height
.GetRelationship() != wxAsIs
))
4060 // Calls Layout() recursively. AAAGH. How can we stop that.
4061 // Simply take Layout() out of non-top level OnSizes.
4062 SizerSetSize(x
, y
, w
, h
);
4071 char *windowClass
= this->GetClassInfo()->GetClassName();
4074 if (GetName() == "")
4075 winName
= "unnamed";
4077 winName
= GetName();
4078 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4079 (const char *)windowClass
, (const char *)winName
);
4080 if (!constr
->left
.GetDone())
4081 wxLogDebug(" unsatisfied 'left' constraint.");
4082 if (!constr
->right
.GetDone())
4083 wxLogDebug(" unsatisfied 'right' constraint.");
4084 if (!constr
->width
.GetDone())
4085 wxLogDebug(" unsatisfied 'width' constraint.");
4086 if (!constr
->height
.GetDone())
4087 wxLogDebug(" unsatisfied 'height' constraint.");
4088 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
4093 wxNode
*node
= GetChildren().First();
4096 wxWindow
*win
= (wxWindow
*)node
->Data();
4097 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4098 win
->SetConstraintSizes();
4099 node
= node
->Next();
4104 // This assumes that all sizers are 'on' the same
4105 // window, i.e. the parent of this window.
4106 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4108 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4109 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4113 m_sizerParent
->GetPosition(&xp
, &yp
);
4114 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4119 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4123 TransformSizerToActual(&xx
, &yy
);
4124 SetSize(xx
, yy
, w
, h
);
4127 void wxWindow::SizerMove(int x
, int y
)
4131 TransformSizerToActual(&xx
, &yy
);
4135 // Only set the size/position of the constraint (if any)
4136 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4138 wxLayoutConstraints
*constr
= GetConstraints();
4143 constr
->left
.SetValue(x
);
4144 constr
->left
.SetDone(TRUE
);
4148 constr
->top
.SetValue(y
);
4149 constr
->top
.SetDone(TRUE
);
4153 constr
->width
.SetValue(w
);
4154 constr
->width
.SetDone(TRUE
);
4158 constr
->height
.SetValue(h
);
4159 constr
->height
.SetDone(TRUE
);
4164 void wxWindow::MoveConstraint(int x
, int y
)
4166 wxLayoutConstraints
*constr
= GetConstraints();
4171 constr
->left
.SetValue(x
);
4172 constr
->left
.SetDone(TRUE
);
4176 constr
->top
.SetValue(y
);
4177 constr
->top
.SetDone(TRUE
);
4182 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4184 wxLayoutConstraints
*constr
= GetConstraints();
4187 *w
= constr
->width
.GetValue();
4188 *h
= constr
->height
.GetValue();
4194 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4196 wxLayoutConstraints
*constr
= GetConstraints();
4199 *w
= constr
->width
.GetValue();
4200 *h
= constr
->height
.GetValue();
4203 GetClientSize(w
, h
);
4206 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4208 wxLayoutConstraints
*constr
= GetConstraints();
4211 *x
= constr
->left
.GetValue();
4212 *y
= constr
->top
.GetValue();
4218 bool wxWindow::Close(bool force
)
4220 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4221 event
.SetEventObject(this);
4222 #if WXWIN_COMPATIBILITY
4223 event
.SetForce(force
);
4225 event
.SetCanVeto(!force
);
4227 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4230 wxObject
* wxWindow::GetChild(int number
) const
4232 // Return a pointer to the Nth object in the Panel
4233 // if (!GetChildren())
4235 wxNode
*node
= GetChildren().First();
4238 node
= node
->Next() ;
4241 wxObject
*obj
= (wxObject
*)node
->Data();
4248 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4250 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4251 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4254 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4256 wxListBox *lbox = (wxListBox *)initiatingItem;
4257 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4258 event.m_commandInt = -1;
4259 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4261 event.m_commandString = copystring(lbox->GetStringSelection());
4262 event.m_commandInt = lbox->GetSelection();
4263 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4265 event.m_eventObject = lbox;
4267 lbox->ProcessCommand(event);
4269 if (event.m_commandString)
4270 delete[] event.m_commandString;
4274 wxButton *but = GetDefaultItem();
4277 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4278 event.SetEventObject(but);
4279 but->Command(event);
4284 void wxWindow::Clear()
4286 wxClientDC
dc(this);
4287 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4288 dc
.SetBackground(brush
);
4292 // Fits the panel around the items
4293 void wxWindow::Fit()
4297 wxNode
*node
= GetChildren().First();
4300 wxWindow
*win
= (wxWindow
*)node
->Data();
4302 win
->GetPosition(&wx
, &wy
);
4303 win
->GetSize(&ww
, &wh
);
4304 if ( wx
+ ww
> maxX
)
4306 if ( wy
+ wh
> maxY
)
4309 node
= node
->Next();
4311 SetClientSize(maxX
+ 5, maxY
+ 5);
4314 void wxWindow::SetValidator(const wxValidator
& validator
)
4316 if ( m_windowValidator
)
4317 delete m_windowValidator
;
4318 m_windowValidator
= validator
.Clone();
4320 if ( m_windowValidator
)
4321 m_windowValidator
->SetWindow(this) ;
4324 // Find a window by id or name
4325 wxWindow
*wxWindow::FindWindow(long id
)
4330 wxNode
*node
= GetChildren().First();
4333 wxWindow
*child
= (wxWindow
*)node
->Data();
4334 wxWindow
*found
= child
->FindWindow(id
);
4337 node
= node
->Next();
4342 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4344 if ( GetName() == name
)
4347 wxNode
*node
= GetChildren().First();
4350 wxWindow
*child
= (wxWindow
*)node
->Data();
4351 wxWindow
*found
= child
->FindWindow(name
);
4354 node
= node
->Next();
4360 // Default input behaviour for a scrolling canvas should be to scroll
4361 // according to the cursor keys pressed
4362 void wxWindow::OnChar(wxKeyEvent& event)
4374 GetScrollUnitsPerPage(&x_page, &y_page);
4376 GetVirtualSize(&v_width,&v_height);
4378 ViewStart(&start_x, &start_y);
4381 y_pages = (int)(v_height/vert_units) - y_page;
4389 switch (event.keyCode)
4396 if (start_y - y_page > 0)
4397 Scroll(start_x, start_y - y_page);
4407 if ((y_page > 0) && (start_y <= y_pages-y-1))
4409 if (y_pages + y < start_y + y_page)
4410 Scroll(start_x, y_pages + y);
4412 Scroll(start_x, start_y + y_page);
4419 if ((y_page > 0) && (start_y >= 1))
4420 Scroll(start_x, start_y - 1);
4426 if ((y_page > 0) && (start_y <= y_pages-y-1))
4429 Scroll(start_x, start_y + 1);
4435 if ((x_page > 0) && (start_x >= 1))
4436 Scroll(start_x - 1, start_y);
4442 Scroll(start_x + 1, start_y);
4453 Scroll(start_x, y_pages+y);
4461 // Setup background and foreground colours correctly
4462 void wxWindow::SetupColours()
4465 SetBackgroundColour(GetParent()->GetBackgroundColour());
4468 void wxWindow::OnIdle(wxIdleEvent
& event
)
4470 // Check if we need to send a LEAVE event
4471 if (m_mouseInWindow
)
4474 ::GetCursorPos(&pt
);
4475 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4477 // Generate a LEAVE event
4478 m_mouseInWindow
= FALSE
;
4481 if (::GetKeyState(VK_SHIFT
) != 0)
4483 if (::GetKeyState(VK_CONTROL
) != 0)
4484 state
|= MK_CONTROL
;
4486 // Unfortunately the mouse button and keyboard state may have changed
4487 // by the time the OnIdle function is called, so 'state' may be
4490 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4496 // Raise the window to the top of the Z order
4497 void wxWindow::Raise()
4499 ::BringWindowToTop((HWND
) GetHWND());
4502 // Lower the window to the bottom of the Z order
4503 void wxWindow::Lower()
4505 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4508 long wxWindow::MSWGetDlgCode()
4510 // default: just forward to def window proc (the msg has no parameters)
4511 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4514 bool wxWindow::AcceptsFocus() const
4516 // invisible and disabled controls don't need focus
4517 return IsShown() && IsEnabled();
4520 // Update region access
4521 wxRegion
wxWindow::GetUpdateRegion() const
4523 return m_updateRegion
;
4526 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4528 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4531 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4533 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4536 bool wxWindow::IsExposed(const wxRect
& rect
) const
4538 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4541 // Set this window to be the child of 'parent'.
4542 bool wxWindow::Reparent(wxWindow
*parent
)
4544 if (parent
== GetParent())
4547 // Unlink this window from the existing parent.
4550 GetParent()->RemoveChild(this);
4553 wxTopLevelWindows
.DeleteObject(this);
4555 HWND hWndParent
= 0;
4556 HWND hWndChild
= (HWND
) GetHWND();
4557 if (parent
!= (wxWindow
*) NULL
)
4559 parent
->AddChild(this);
4560 hWndParent
= (HWND
) parent
->GetHWND();
4563 wxTopLevelWindows
.Append(this);
4565 ::SetParent(hWndChild
, hWndParent
);
4571 const char *wxGetMessageName(int message
)
4573 switch ( message
) {
4574 case 0x0000: return "WM_NULL";
4575 case 0x0001: return "WM_CREATE";
4576 case 0x0002: return "WM_DESTROY";
4577 case 0x0003: return "WM_MOVE";
4578 case 0x0005: return "WM_SIZE";
4579 case 0x0006: return "WM_ACTIVATE";
4580 case 0x0007: return "WM_SETFOCUS";
4581 case 0x0008: return "WM_KILLFOCUS";
4582 case 0x000A: return "WM_ENABLE";
4583 case 0x000B: return "WM_SETREDRAW";
4584 case 0x000C: return "WM_SETTEXT";
4585 case 0x000D: return "WM_GETTEXT";
4586 case 0x000E: return "WM_GETTEXTLENGTH";
4587 case 0x000F: return "WM_PAINT";
4588 case 0x0010: return "WM_CLOSE";
4589 case 0x0011: return "WM_QUERYENDSESSION";
4590 case 0x0012: return "WM_QUIT";
4591 case 0x0013: return "WM_QUERYOPEN";
4592 case 0x0014: return "WM_ERASEBKGND";
4593 case 0x0015: return "WM_SYSCOLORCHANGE";
4594 case 0x0016: return "WM_ENDSESSION";
4595 case 0x0017: return "WM_SYSTEMERROR";
4596 case 0x0018: return "WM_SHOWWINDOW";
4597 case 0x0019: return "WM_CTLCOLOR";
4598 case 0x001A: return "WM_WININICHANGE";
4599 case 0x001B: return "WM_DEVMODECHANGE";
4600 case 0x001C: return "WM_ACTIVATEAPP";
4601 case 0x001D: return "WM_FONTCHANGE";
4602 case 0x001E: return "WM_TIMECHANGE";
4603 case 0x001F: return "WM_CANCELMODE";
4604 case 0x0020: return "WM_SETCURSOR";
4605 case 0x0021: return "WM_MOUSEACTIVATE";
4606 case 0x0022: return "WM_CHILDACTIVATE";
4607 case 0x0023: return "WM_QUEUESYNC";
4608 case 0x0024: return "WM_GETMINMAXINFO";
4609 case 0x0026: return "WM_PAINTICON";
4610 case 0x0027: return "WM_ICONERASEBKGND";
4611 case 0x0028: return "WM_NEXTDLGCTL";
4612 case 0x002A: return "WM_SPOOLERSTATUS";
4613 case 0x002B: return "WM_DRAWITEM";
4614 case 0x002C: return "WM_MEASUREITEM";
4615 case 0x002D: return "WM_DELETEITEM";
4616 case 0x002E: return "WM_VKEYTOITEM";
4617 case 0x002F: return "WM_CHARTOITEM";
4618 case 0x0030: return "WM_SETFONT";
4619 case 0x0031: return "WM_GETFONT";
4620 case 0x0037: return "WM_QUERYDRAGICON";
4621 case 0x0039: return "WM_COMPAREITEM";
4622 case 0x0041: return "WM_COMPACTING";
4623 case 0x0044: return "WM_COMMNOTIFY";
4624 case 0x0046: return "WM_WINDOWPOSCHANGING";
4625 case 0x0047: return "WM_WINDOWPOSCHANGED";
4626 case 0x0048: return "WM_POWER";
4629 case 0x004A: return "WM_COPYDATA";
4630 case 0x004B: return "WM_CANCELJOURNAL";
4631 case 0x004E: return "WM_NOTIFY";
4632 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4633 case 0x0051: return "WM_INPUTLANGCHANGE";
4634 case 0x0052: return "WM_TCARD";
4635 case 0x0053: return "WM_HELP";
4636 case 0x0054: return "WM_USERCHANGED";
4637 case 0x0055: return "WM_NOTIFYFORMAT";
4638 case 0x007B: return "WM_CONTEXTMENU";
4639 case 0x007C: return "WM_STYLECHANGING";
4640 case 0x007D: return "WM_STYLECHANGED";
4641 case 0x007E: return "WM_DISPLAYCHANGE";
4642 case 0x007F: return "WM_GETICON";
4643 case 0x0080: return "WM_SETICON";
4646 case 0x0081: return "WM_NCCREATE";
4647 case 0x0082: return "WM_NCDESTROY";
4648 case 0x0083: return "WM_NCCALCSIZE";
4649 case 0x0084: return "WM_NCHITTEST";
4650 case 0x0085: return "WM_NCPAINT";
4651 case 0x0086: return "WM_NCACTIVATE";
4652 case 0x0087: return "WM_GETDLGCODE";
4653 case 0x00A0: return "WM_NCMOUSEMOVE";
4654 case 0x00A1: return "WM_NCLBUTTONDOWN";
4655 case 0x00A2: return "WM_NCLBUTTONUP";
4656 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4657 case 0x00A4: return "WM_NCRBUTTONDOWN";
4658 case 0x00A5: return "WM_NCRBUTTONUP";
4659 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4660 case 0x00A7: return "WM_NCMBUTTONDOWN";
4661 case 0x00A8: return "WM_NCMBUTTONUP";
4662 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4663 case 0x0100: return "WM_KEYDOWN";
4664 case 0x0101: return "WM_KEYUP";
4665 case 0x0102: return "WM_CHAR";
4666 case 0x0103: return "WM_DEADCHAR";
4667 case 0x0104: return "WM_SYSKEYDOWN";
4668 case 0x0105: return "WM_SYSKEYUP";
4669 case 0x0106: return "WM_SYSCHAR";
4670 case 0x0107: return "WM_SYSDEADCHAR";
4671 case 0x0108: return "WM_KEYLAST";
4674 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4675 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4676 case 0x010F: return "WM_IME_COMPOSITION";
4679 case 0x0110: return "WM_INITDIALOG";
4680 case 0x0111: return "WM_COMMAND";
4681 case 0x0112: return "WM_SYSCOMMAND";
4682 case 0x0113: return "WM_TIMER";
4683 case 0x0114: return "WM_HSCROLL";
4684 case 0x0115: return "WM_VSCROLL";
4685 case 0x0116: return "WM_INITMENU";
4686 case 0x0117: return "WM_INITMENUPOPUP";
4687 case 0x011F: return "WM_MENUSELECT";
4688 case 0x0120: return "WM_MENUCHAR";
4689 case 0x0121: return "WM_ENTERIDLE";
4690 case 0x0200: return "WM_MOUSEMOVE";
4691 case 0x0201: return "WM_LBUTTONDOWN";
4692 case 0x0202: return "WM_LBUTTONUP";
4693 case 0x0203: return "WM_LBUTTONDBLCLK";
4694 case 0x0204: return "WM_RBUTTONDOWN";
4695 case 0x0205: return "WM_RBUTTONUP";
4696 case 0x0206: return "WM_RBUTTONDBLCLK";
4697 case 0x0207: return "WM_MBUTTONDOWN";
4698 case 0x0208: return "WM_MBUTTONUP";
4699 case 0x0209: return "WM_MBUTTONDBLCLK";
4700 case 0x0210: return "WM_PARENTNOTIFY";
4701 case 0x0211: return "WM_ENTERMENULOOP";
4702 case 0x0212: return "WM_EXITMENULOOP";
4705 case 0x0213: return "WM_NEXTMENU";
4706 case 0x0214: return "WM_SIZING";
4707 case 0x0215: return "WM_CAPTURECHANGED";
4708 case 0x0216: return "WM_MOVING";
4709 case 0x0218: return "WM_POWERBROADCAST";
4710 case 0x0219: return "WM_DEVICECHANGE";
4713 case 0x0220: return "WM_MDICREATE";
4714 case 0x0221: return "WM_MDIDESTROY";
4715 case 0x0222: return "WM_MDIACTIVATE";
4716 case 0x0223: return "WM_MDIRESTORE";
4717 case 0x0224: return "WM_MDINEXT";
4718 case 0x0225: return "WM_MDIMAXIMIZE";
4719 case 0x0226: return "WM_MDITILE";
4720 case 0x0227: return "WM_MDICASCADE";
4721 case 0x0228: return "WM_MDIICONARRANGE";
4722 case 0x0229: return "WM_MDIGETACTIVE";
4723 case 0x0230: return "WM_MDISETMENU";
4724 case 0x0233: return "WM_DROPFILES";
4727 case 0x0281: return "WM_IME_SETCONTEXT";
4728 case 0x0282: return "WM_IME_NOTIFY";
4729 case 0x0283: return "WM_IME_CONTROL";
4730 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4731 case 0x0285: return "WM_IME_SELECT";
4732 case 0x0286: return "WM_IME_CHAR";
4733 case 0x0290: return "WM_IME_KEYDOWN";
4734 case 0x0291: return "WM_IME_KEYUP";
4737 case 0x0300: return "WM_CUT";
4738 case 0x0301: return "WM_COPY";
4739 case 0x0302: return "WM_PASTE";
4740 case 0x0303: return "WM_CLEAR";
4741 case 0x0304: return "WM_UNDO";
4742 case 0x0305: return "WM_RENDERFORMAT";
4743 case 0x0306: return "WM_RENDERALLFORMATS";
4744 case 0x0307: return "WM_DESTROYCLIPBOARD";
4745 case 0x0308: return "WM_DRAWCLIPBOARD";
4746 case 0x0309: return "WM_PAINTCLIPBOARD";
4747 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4748 case 0x030B: return "WM_SIZECLIPBOARD";
4749 case 0x030C: return "WM_ASKCBFORMATNAME";
4750 case 0x030D: return "WM_CHANGECBCHAIN";
4751 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4752 case 0x030F: return "WM_QUERYNEWPALETTE";
4753 case 0x0310: return "WM_PALETTEISCHANGING";
4754 case 0x0311: return "WM_PALETTECHANGED";
4757 // common controls messages - although they're not strictly speaking
4758 // standard, it's nice to decode them nevertheless
4761 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4762 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4763 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4764 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4765 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4766 case 0x1000 + 5: return "LVM_GETITEMA";
4767 case 0x1000 + 75: return "LVM_GETITEMW";
4768 case 0x1000 + 6: return "LVM_SETITEMA";
4769 case 0x1000 + 76: return "LVM_SETITEMW";
4770 case 0x1000 + 7: return "LVM_INSERTITEMA";
4771 case 0x1000 + 77: return "LVM_INSERTITEMW";
4772 case 0x1000 + 8: return "LVM_DELETEITEM";
4773 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4774 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4775 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4776 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4777 case 0x1000 + 13: return "LVM_FINDITEMA";
4778 case 0x1000 + 83: return "LVM_FINDITEMW";
4779 case 0x1000 + 14: return "LVM_GETITEMRECT";
4780 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4781 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4782 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4783 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4784 case 0x1000 + 18: return "LVM_HITTEST";
4785 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4786 case 0x1000 + 20: return "LVM_SCROLL";
4787 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4788 case 0x1000 + 22: return "LVM_ARRANGE";
4789 case 0x1000 + 23: return "LVM_EDITLABELA";
4790 case 0x1000 + 118: return "LVM_EDITLABELW";
4791 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4792 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4793 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4794 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4795 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4796 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4797 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4798 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4799 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4800 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4801 case 0x1000 + 31: return "LVM_GETHEADER";
4802 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4803 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4804 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4805 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4806 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4807 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4808 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4809 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4810 case 0x1000 + 41: return "LVM_GETORIGIN";
4811 case 0x1000 + 42: return "LVM_UPDATE";
4812 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4813 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4814 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4815 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4816 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4817 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4818 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4819 case 0x1000 + 48: return "LVM_SORTITEMS";
4820 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4821 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4822 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4823 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4824 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4825 case 0x1000 + 53: return "LVM_SETICONSPACING";
4826 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4827 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4828 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4829 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4830 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4831 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4832 case 0x1000 + 60: return "LVM_SETHOTITEM";
4833 case 0x1000 + 61: return "LVM_GETHOTITEM";
4834 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4835 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4836 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4837 case 0x1000 + 65: return "LVM_SETWORKAREA";
4840 case 0x1100 + 0: return "TVM_INSERTITEMA";
4841 case 0x1100 + 50: return "TVM_INSERTITEMW";
4842 case 0x1100 + 1: return "TVM_DELETEITEM";
4843 case 0x1100 + 2: return "TVM_EXPAND";
4844 case 0x1100 + 4: return "TVM_GETITEMRECT";
4845 case 0x1100 + 5: return "TVM_GETCOUNT";
4846 case 0x1100 + 6: return "TVM_GETINDENT";
4847 case 0x1100 + 7: return "TVM_SETINDENT";
4848 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4849 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4850 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4851 case 0x1100 + 11: return "TVM_SELECTITEM";
4852 case 0x1100 + 12: return "TVM_GETITEMA";
4853 case 0x1100 + 62: return "TVM_GETITEMW";
4854 case 0x1100 + 13: return "TVM_SETITEMA";
4855 case 0x1100 + 63: return "TVM_SETITEMW";
4856 case 0x1100 + 14: return "TVM_EDITLABELA";
4857 case 0x1100 + 65: return "TVM_EDITLABELW";
4858 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4859 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4860 case 0x1100 + 17: return "TVM_HITTEST";
4861 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4862 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4863 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4864 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4865 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4866 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4867 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4868 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4869 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4872 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4873 case 0x1200 + 1: return "HDM_INSERTITEMA";
4874 case 0x1200 + 10: return "HDM_INSERTITEMW";
4875 case 0x1200 + 2: return "HDM_DELETEITEM";
4876 case 0x1200 + 3: return "HDM_GETITEMA";
4877 case 0x1200 + 11: return "HDM_GETITEMW";
4878 case 0x1200 + 4: return "HDM_SETITEMA";
4879 case 0x1200 + 12: return "HDM_SETITEMW";
4880 case 0x1200 + 5: return "HDM_LAYOUT";
4881 case 0x1200 + 6: return "HDM_HITTEST";
4882 case 0x1200 + 7: return "HDM_GETITEMRECT";
4883 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4884 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4885 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4886 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4887 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4888 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4889 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4892 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4893 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4894 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4895 case 0x1300 + 5: return "TCM_GETITEMA";
4896 case 0x1300 + 60: return "TCM_GETITEMW";
4897 case 0x1300 + 6: return "TCM_SETITEMA";
4898 case 0x1300 + 61: return "TCM_SETITEMW";
4899 case 0x1300 + 7: return "TCM_INSERTITEMA";
4900 case 0x1300 + 62: return "TCM_INSERTITEMW";
4901 case 0x1300 + 8: return "TCM_DELETEITEM";
4902 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4903 case 0x1300 + 10: return "TCM_GETITEMRECT";
4904 case 0x1300 + 11: return "TCM_GETCURSEL";
4905 case 0x1300 + 12: return "TCM_SETCURSEL";
4906 case 0x1300 + 13: return "TCM_HITTEST";
4907 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4908 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4909 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4910 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4911 case 0x1300 + 43: return "TCM_SETPADDING";
4912 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4913 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4914 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4915 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4916 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4917 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4918 case 0x1300 + 50: return "TCM_DESELECTALL";
4921 case WM_USER
+1: return "TB_ENABLEBUTTON";
4922 case WM_USER
+2: return "TB_CHECKBUTTON";
4923 case WM_USER
+3: return "TB_PRESSBUTTON";
4924 case WM_USER
+4: return "TB_HIDEBUTTON";
4925 case WM_USER
+5: return "TB_INDETERMINATE";
4926 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4927 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4928 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4929 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4930 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4931 case WM_USER
+17: return "TB_SETSTATE";
4932 case WM_USER
+18: return "TB_GETSTATE";
4933 case WM_USER
+19: return "TB_ADDBITMAP";
4934 case WM_USER
+20: return "TB_ADDBUTTONS";
4935 case WM_USER
+21: return "TB_INSERTBUTTON";
4936 case WM_USER
+22: return "TB_DELETEBUTTON";
4937 case WM_USER
+23: return "TB_GETBUTTON";
4938 case WM_USER
+24: return "TB_BUTTONCOUNT";
4939 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4940 case WM_USER
+26: return "TB_SAVERESTOREA";
4941 case WM_USER
+76: return "TB_SAVERESTOREW";
4942 case WM_USER
+27: return "TB_CUSTOMIZE";
4943 case WM_USER
+28: return "TB_ADDSTRINGA";
4944 case WM_USER
+77: return "TB_ADDSTRINGW";
4945 case WM_USER
+29: return "TB_GETITEMRECT";
4946 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4947 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4948 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4949 case WM_USER
+33: return "TB_AUTOSIZE";
4950 case WM_USER
+35: return "TB_GETTOOLTIPS";
4951 case WM_USER
+36: return "TB_SETTOOLTIPS";
4952 case WM_USER
+37: return "TB_SETPARENT";
4953 case WM_USER
+39: return "TB_SETROWS";
4954 case WM_USER
+40: return "TB_GETROWS";
4955 case WM_USER
+42: return "TB_SETCMDID";
4956 case WM_USER
+43: return "TB_CHANGEBITMAP";
4957 case WM_USER
+44: return "TB_GETBITMAP";
4958 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4959 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4960 case WM_USER
+46: return "TB_REPLACEBITMAP";
4961 case WM_USER
+47: return "TB_SETINDENT";
4962 case WM_USER
+48: return "TB_SETIMAGELIST";
4963 case WM_USER
+49: return "TB_GETIMAGELIST";
4964 case WM_USER
+50: return "TB_LOADIMAGES";
4965 case WM_USER
+51: return "TB_GETRECT";
4966 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4967 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4968 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4969 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4970 case WM_USER
+56: return "TB_SETSTYLE";
4971 case WM_USER
+57: return "TB_GETSTYLE";
4972 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4973 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4974 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4975 case WM_USER
+61: return "TB_GETTEXTROWS";
4976 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4981 static char s_szBuf
[128];
4982 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4986 #endif //__WXDEBUG__