1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dcclient.h"
31 #include "wx/layout.h"
32 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/settings.h"
37 #include "wx/msgdlg.h"
43 #include "wx/ownerdrw.h"
46 #if wxUSE_DRAG_AND_DROP
47 #include "wx/msw/ole/droptgt.h"
50 #include "wx/menuitem.h"
54 #include "wx/tooltip.h"
60 #include "wx/msw/private.h"
73 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
79 #include <wx/msw/gnuwin32/extra.h>
83 // all these are defined in <windows.h>
101 const char *wxGetMessageName(int message
);
104 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
106 wxMenu
*wxCurrentPopupMenu
= NULL
;
107 extern wxList WXDLLEXPORT wxPendingDelete
;
109 void wxRemoveHandleAssociation(wxWindow
*win
);
110 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
111 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
113 #if !USE_SHARED_LIBRARY
114 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
117 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
118 EVT_CHAR(wxWindow::OnChar
)
119 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
120 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
121 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
122 EVT_IDLE(wxWindow::OnIdle
)
125 // Find an item given the MS Windows id
126 wxWindow
*wxWindow::FindItem(int id
) const
128 // if (!GetChildren())
130 wxNode
*current
= GetChildren().First();
133 wxWindow
*childWin
= (wxWindow
*)current
->Data();
135 wxWindow
*wnd
= childWin
->FindItem(id
) ;
139 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
141 wxControl
*item
= (wxControl
*)childWin
;
142 if (item
->GetId() == id
)
146 // In case it's a 'virtual' control (e.g. radiobox)
147 if (item
->GetSubcontrols().Member((wxObject
*)id
))
151 current
= current
->Next();
156 // Find an item given the MS Windows handle
157 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
159 // if (!GetChildren())
161 wxNode
*current
= GetChildren().First();
164 wxObject
*obj
= (wxObject
*)current
->Data() ;
165 // Do a recursive search.
166 wxWindow
*parent
= (wxWindow
*)obj
;
167 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
171 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
173 wxWindow
*item
= (wxWindow
*)current
->Data();
174 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
178 if ( item
->ContainsHWND(hWnd
) )
182 current
= current
->Next();
187 // Default command handler
188 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
193 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
195 WXLPARAM
* WXUNUSED(result
))
199 NMHDR
* hdr
= (NMHDR
*)lParam
;
200 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
202 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
203 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
214 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
218 WXHWND
wxWindow::GetHWND(void) const
220 return (WXHWND
) m_hWnd
;
223 void wxWindow::SetHWND(WXHWND hWnd
)
228 // ----------------------------------------------------------------------------
229 // constructors and such
230 // ----------------------------------------------------------------------------
232 void wxWindow::Init()
240 m_windowParent
= NULL
;
241 m_windowEventHandler
= this;
242 m_windowCursor
= *wxSTANDARD_CURSOR
;
243 m_children
= new wxList
;
244 m_doubleClickAllowed
= 0 ;
245 m_winCaptured
= FALSE
;
246 m_constraints
= NULL
;
247 m_constraintsInvolvedIn
= NULL
;
248 m_windowSizer
= NULL
;
249 m_sizerParent
= NULL
;
250 m_autoLayout
= FALSE
;
251 m_windowValidator
= NULL
;
256 m_caretWidth
= m_caretHeight
= 0;
258 m_caretShown
= FALSE
;
265 m_isBeingDeleted
= FALSE
;
271 m_mouseInWindow
= FALSE
;
273 m_windowParent
= NULL
;
274 m_defaultItem
= NULL
;
276 wxSystemSettings settings
;
278 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
279 m_foregroundColour
= *wxBLACK
;
289 m_backgroundTransparent
= FALSE
;
291 m_lastXPos
= (float)-1.0;
292 m_lastYPos
= (float)-1.0;
296 #if wxUSE_DRAG_AND_DROP
297 m_pDropTarget
= NULL
;
311 wxWindow::~wxWindow()
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::DoSetSize(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::DoSetClientSize(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
)
768 HWND hWnd
= (HWND
) GetHWND();
774 ShowWindow(hWnd
, cshow
);
777 BringWindowToTop(hWnd
);
778 // Next line causes a crash on NT, apparently.
779 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
784 bool wxWindow::IsShown(void) const
786 // Can't rely on IsWindowVisible, since it will return FALSE
787 // if the parent is not visible.
789 // int ret = ::IsWindowVisible((HWND) GetHWND()) ;
790 // return (ret != 0);
793 int wxWindow::GetCharHeight(void) const
795 TEXTMETRIC lpTextMetric
;
796 HWND hWnd
= (HWND
) GetHWND();
797 HDC dc
= ::GetDC(hWnd
);
799 GetTextMetrics(dc
, &lpTextMetric
);
800 ::ReleaseDC(hWnd
, dc
);
802 return lpTextMetric
.tmHeight
;
805 int wxWindow::GetCharWidth(void) const
807 TEXTMETRIC lpTextMetric
;
808 HWND hWnd
= (HWND
) GetHWND();
809 HDC dc
= ::GetDC(hWnd
);
811 GetTextMetrics(dc
, &lpTextMetric
);
812 ::ReleaseDC(hWnd
, dc
);
814 return lpTextMetric
.tmAveCharWidth
;
817 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
818 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
820 wxFont
*fontToUse
= (wxFont
*)theFont
;
822 fontToUse
= (wxFont
*) & m_windowFont
;
824 HWND hWnd
= (HWND
) GetHWND();
825 HDC dc
= ::GetDC(hWnd
);
829 if (fontToUse
&& fontToUse
->Ok())
831 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
833 was
= (HFONT
) SelectObject(dc
,fnt
) ;
838 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
839 GetTextMetrics(dc
, &tm
);
841 if (fontToUse
&& fnt
&& was
)
842 SelectObject(dc
,was
) ;
848 if (descent
) *descent
= tm
.tmDescent
;
849 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
852 // fontToUse->ReleaseResource();
855 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
857 HWND hWnd
= (HWND
) GetHWND();
863 mswRect
.left
= rect
->x
;
864 mswRect
.top
= rect
->y
;
865 mswRect
.right
= rect
->x
+ rect
->width
;
866 mswRect
.bottom
= rect
->y
+ rect
->height
;
868 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
871 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
875 bool wxWindow::ProcessEvent(wxEvent
& event
)
877 // we save here the information about the last message because it might be
878 // overwritten if the event handler sends any messages to our window (case
879 // in point: wxNotebook::OnSize) - and then if we call Default() later
880 // (which is done quite often if the message is not processed) it will use
881 // incorrect values for m_lastXXX variables
882 WXUINT lastMsg
= m_lastMsg
;
883 WXWPARAM lastWParam
= m_lastWParam
;
884 WXLPARAM lastLParam
= m_lastLParam
;
886 // call the base version
887 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
891 m_lastWParam
= lastWParam
;
892 m_lastLParam
= lastLParam
;
897 // Hook for new window just as it's being created,
898 // when the window isn't yet associated with the handle
899 wxWindow
*wxWndHook
= NULL
;
902 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
904 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
906 if (!wnd
&& wxWndHook
)
908 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
911 wnd
->m_hWnd
= (WXHWND
) hWnd
;
914 // Stop right here if we don't have a valid handle in our wxWindow object.
915 if (wnd
&& !wnd
->m_hWnd
) {
916 wnd
->m_hWnd
= (WXHWND
) hWnd
;
917 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
923 wnd
->m_lastMsg
= message
;
924 wnd
->m_lastWParam
= wParam
;
925 wnd
->m_lastLParam
= lParam
;
928 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
930 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
933 // Should probably have a test for 'genuine' NT
934 #if defined(__WIN32__)
935 #define DIMENSION_TYPE short
937 #define DIMENSION_TYPE int
940 // Main Windows 3 window proc
941 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
943 wxASSERT( m_lastMsg
== message
&&
944 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
947 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
948 wxGetMessageName(message
), wParam
, lParam
);
949 #endif // __WXDEBUG__
951 HWND hWnd
= (HWND
)m_hWnd
;
958 WORD state
= LOWORD(wParam
);
959 WORD minimized
= HIWORD(wParam
);
960 HWND hwnd
= (HWND
)lParam
;
962 WORD state
= (WORD
)wParam
;
963 WORD minimized
= LOWORD(lParam
);
964 HWND hwnd
= (HWND
)HIWORD(lParam
);
966 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
972 HWND hwnd
= (HWND
)wParam
;
973 // return OnSetFocus(hwnd);
975 if (MSWOnSetFocus((WXHWND
) hwnd
))
977 else return MSWDefWindowProc(message
, wParam
, lParam
);
982 HWND hwnd
= (HWND
)lParam
;
983 // return OnKillFocus(hwnd);
984 if (MSWOnKillFocus((WXHWND
) hwnd
))
987 return MSWDefWindowProc(message
, wParam
, lParam
);
992 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
998 MSWOnShow((wParam
!= 0), (int) lParam
);
1005 else return MSWDefWindowProc(message
, wParam
, lParam
);
1008 case WM_QUERYDRAGICON
:
1010 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
1014 return MSWDefWindowProc(message
, wParam
, lParam
);
1020 int width
= LOWORD(lParam
);
1021 int height
= HIWORD(lParam
);
1022 MSWOnSize(width
, height
, wParam
);
1028 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1030 event
.SetEventObject(this);
1031 if ( !GetEventHandler()->ProcessEvent(event
) )
1036 case WM_WINDOWPOSCHANGING
:
1038 MSWOnWindowPosChanging((void *)lParam
);
1042 case WM_RBUTTONDOWN
:
1044 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1045 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1046 MSWOnRButtonDown(x
, y
, wParam
);
1051 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1052 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1053 MSWOnRButtonUp(x
, y
, wParam
);
1056 case WM_RBUTTONDBLCLK
:
1058 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1059 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1060 MSWOnRButtonDClick(x
, y
, wParam
);
1063 case WM_MBUTTONDOWN
:
1065 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1066 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1067 MSWOnMButtonDown(x
, y
, wParam
);
1072 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1073 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1074 MSWOnMButtonUp(x
, y
, wParam
);
1077 case WM_MBUTTONDBLCLK
:
1079 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1080 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1081 MSWOnMButtonDClick(x
, y
, wParam
);
1084 case WM_LBUTTONDOWN
:
1086 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1087 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1088 MSWOnLButtonDown(x
, y
, wParam
);
1093 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1094 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1095 MSWOnLButtonUp(x
, y
, wParam
);
1098 case WM_LBUTTONDBLCLK
:
1100 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1101 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1102 MSWOnLButtonDClick(x
, y
, wParam
);
1107 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1108 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1109 MSWOnMouseMove(x
, y
, wParam
);
1112 case MM_JOY1BUTTONDOWN
:
1114 int x
= LOWORD(lParam
);
1115 int y
= HIWORD(lParam
);
1116 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1119 case MM_JOY2BUTTONDOWN
:
1121 int x
= LOWORD(lParam
);
1122 int y
= HIWORD(lParam
);
1123 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1126 case MM_JOY1BUTTONUP
:
1128 int x
= LOWORD(lParam
);
1129 int y
= HIWORD(lParam
);
1130 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1133 case MM_JOY2BUTTONUP
:
1135 int x
= LOWORD(lParam
);
1136 int y
= HIWORD(lParam
);
1137 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1142 int x
= LOWORD(lParam
);
1143 int y
= HIWORD(lParam
);
1144 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1149 int x
= LOWORD(lParam
);
1150 int y
= HIWORD(lParam
);
1151 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1156 int z
= LOWORD(lParam
);
1157 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1162 int z
= LOWORD(lParam
);
1163 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1170 else return MSWDefWindowProc(message
, wParam
, lParam
);
1175 return MSWOnSysCommand(wParam
, lParam
);
1181 WORD id
= LOWORD(wParam
);
1182 HWND hwnd
= (HWND
)lParam
;
1183 WORD cmd
= HIWORD(wParam
);
1185 WORD id
= (WORD
)wParam
;
1186 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1187 WORD cmd
= HIWORD(lParam
);
1189 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1190 return MSWDefWindowProc(message
, wParam
, lParam
);
1193 #if defined(__WIN95__)
1196 // for some messages (TVN_ITEMEXPANDING for example), the return
1197 // value of WM_NOTIFY handler is important, so don't just return 0
1198 // if we processed the message
1199 return MSWOnNotify(wParam
, lParam
);
1205 WORD flags
= HIWORD(wParam
);
1206 HMENU sysmenu
= (HMENU
)lParam
;
1208 WORD flags
= LOWORD(lParam
);
1209 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1211 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1214 case WM_INITMENUPOPUP
:
1216 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1221 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1224 case WM_MEASUREITEM
:
1226 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1232 // If this has been processed by an event handler,
1233 // return 0 now (we've handled it).
1234 if (MSWOnKeyDown((WORD
) wParam
, lParam
))
1239 // we consider these message "not interesting" to OnChar
1240 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1245 // Avoid duplicate messages to OnChar for these special keys
1259 // if ( ::GetKeyState(VK_CONTROL) & 0x100 ) // Don't understand purpose of this test
1260 if (!MSWOnChar((WORD)wParam, lParam))
1266 if (!MSWOnChar((WORD
)wParam
, lParam
))
1271 if ( ::GetKeyState(VK_CONTROL) & 0x100 )
1281 if (!MSWOnKeyUp((WORD
) wParam
, lParam
))
1285 case WM_CHAR
: // Always an ASCII character
1287 if (!MSWOnChar((WORD
)wParam
, lParam
, TRUE
))
1295 WORD code
= LOWORD(wParam
);
1296 WORD pos
= HIWORD(wParam
);
1297 HWND control
= (HWND
)lParam
;
1299 WORD code
= (WORD
)wParam
;
1300 WORD pos
= LOWORD(lParam
);
1301 HWND control
= (HWND
)HIWORD(lParam
);
1303 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1309 WORD code
= LOWORD(wParam
);
1310 WORD pos
= HIWORD(wParam
);
1311 HWND control
= (HWND
)lParam
;
1313 WORD code
= (WORD
)wParam
;
1314 WORD pos
= LOWORD(lParam
);
1315 HWND control
= (HWND
)HIWORD(lParam
);
1317 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1321 case WM_CTLCOLORBTN
:
1323 int nCtlColor
= CTLCOLOR_BTN
;
1324 HWND control
= (HWND
)lParam
;
1325 HDC pDC
= (HDC
)wParam
;
1326 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1327 message
, wParam
, lParam
);
1330 case WM_CTLCOLORDLG
:
1332 int nCtlColor
= CTLCOLOR_DLG
;
1333 HWND control
= (HWND
)lParam
;
1334 HDC pDC
= (HDC
)wParam
;
1335 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1336 message
, wParam
, lParam
);\
1339 case WM_CTLCOLORLISTBOX
:
1341 int nCtlColor
= CTLCOLOR_LISTBOX
;
1342 HWND control
= (HWND
)lParam
;
1343 HDC pDC
= (HDC
)wParam
;
1344 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1345 message
, wParam
, lParam
);
1348 case WM_CTLCOLORMSGBOX
:
1350 int nCtlColor
= CTLCOLOR_MSGBOX
;
1351 HWND control
= (HWND
)lParam
;
1352 HDC pDC
= (HDC
)wParam
;
1353 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1354 message
, wParam
, lParam
);
1357 case WM_CTLCOLORSCROLLBAR
:
1359 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1360 HWND control
= (HWND
)lParam
;
1361 HDC pDC
= (HDC
)wParam
;
1362 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1363 message
, wParam
, lParam
);
1366 case WM_CTLCOLORSTATIC
:
1368 int nCtlColor
= CTLCOLOR_STATIC
;
1369 HWND control
= (HWND
)lParam
;
1370 HDC pDC
= (HDC
)wParam
;
1371 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1372 message
, wParam
, lParam
);
1375 case WM_CTLCOLOREDIT
:
1377 int nCtlColor
= CTLCOLOR_EDIT
;
1378 HWND control
= (HWND
)lParam
;
1379 HDC pDC
= (HDC
)wParam
;
1380 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1381 message
, wParam
, lParam
);
1387 HWND control
= (HWND
)LOWORD(lParam
);
1388 int nCtlColor
= (int)HIWORD(lParam
);
1389 HDC pDC
= (HDC
)wParam
;
1390 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1391 message
, wParam
, lParam
);
1395 case WM_SYSCOLORCHANGE
:
1397 // Return value of 0 means, we processed it.
1398 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1401 return MSWDefWindowProc(message
, wParam
, lParam
);
1404 case WM_PALETTECHANGED
:
1406 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1409 case WM_QUERYNEWPALETTE
:
1411 return MSWOnQueryNewPalette();
1416 // Prevents flicker when dragging
1417 if (IsIconic(hWnd
)) return 1;
1419 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1420 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1424 case WM_MDIACTIVATE
:
1427 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1428 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1429 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1430 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1432 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1433 (HWND
)HIWORD(lParam
));
1438 MSWOnDropFiles(wParam
);
1443 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1446 case WM_QUERYENDSESSION
:
1448 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1449 // return MSWOnClose();
1451 return MSWOnQueryEndSession(lParam
);
1456 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1457 MSWOnEndSession((wParam
!= 0), lParam
);
1470 case WM_GETMINMAXINFO
:
1472 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1473 if (m_minSizeX
!= -1)
1474 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1475 if (m_minSizeY
!= -1)
1476 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1477 if (m_maxSizeX
!= -1)
1478 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1479 if (m_maxSizeY
!= -1)
1480 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1481 return MSWDefWindowProc(message
, wParam
, lParam
);
1486 return MSWGetDlgCode();
1491 extern HCURSOR gs_wxBusyCursor
; // from msw\utils.cpp
1493 ::SetCursor(gs_wxBusyCursor
);
1495 // returning TRUE stops the DefWindowProc() from further processing
1496 // this message - exactly what we need because we've just set the
1500 break; // leave it to DefWindowProc()
1503 return MSWDefWindowProc(message
, wParam
, lParam
);
1506 return 0; // Success: we processed this command.
1509 // Dialog window proc
1510 LONG APIENTRY _EXPORT
1511 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1516 wxList
*wxWinHandleList
= NULL
;
1517 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1519 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1522 return (wxWindow
*)node
->Data();
1525 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1527 // adding NULL hWnd is (first) surely a result of an error and
1528 // (secondly) breaks menu command processing
1529 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1531 if ( !wxWinHandleList
->Find((long)hWnd
) )
1532 wxWinHandleList
->Append((long)hWnd
, win
);
1535 void wxRemoveHandleAssociation(wxWindow
*win
)
1537 wxWinHandleList
->DeleteObject(win
);
1540 // Default destroyer - override if you destroy it in some other way
1541 // (e.g. with MDI child windows)
1542 void wxWindow::MSWDestroyWindow()
1546 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1547 int x
, int y
, int width
, int height
,
1548 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1550 bool is_dialog
= (dialog_template
!= NULL
);
1551 int x1
= CW_USEDEFAULT
;
1553 int width1
= CW_USEDEFAULT
;
1556 // Find parent's size, if it exists, to set up a possible default
1557 // panel size the size of the parent window
1561 // Was GetWindowRect: JACS 5/5/95
1562 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1564 width1
= parent_rect
.right
- parent_rect
.left
;
1565 height1
= parent_rect
.bottom
- parent_rect
.top
;
1570 if (width
> -1) width1
= width
;
1571 if (height
> -1) height1
= height
;
1573 HWND hParent
= NULL
;
1575 hParent
= (HWND
) parent
->GetHWND();
1581 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1582 // other compilers???
1583 // VZ: it's always needed for Win16 and never for Win32
1585 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1586 (DLGPROC
)wxDlgProc
);
1588 // N.B.: if we _don't_ use this form,
1589 // then with VC++ 1.5, it crashes horribly.
1591 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1592 (DLGPROC
)wxDlgProc
);
1594 // Crashes when we use this.
1595 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1597 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1603 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1604 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1605 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1610 if (style
& WS_CHILD
)
1615 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1620 hParent
, (HMENU
)controlId
, wxGetInstance(),
1624 wxLogError("Can't create window of class %s!\n"
1625 "Possible Windows 3.x compatibility problem?", wclass
);
1630 wxWinHandleList
->Append((long)m_hWnd
, this);
1633 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1637 bool wxWindow::MSWOnClose()
1642 // Some compilers don't define this
1643 #ifndef ENDSESSION_LOGOFF
1644 #define ENDSESSION_LOGOFF 0x80000000
1647 // Return TRUE to end session, FALSE to veto end session.
1648 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1650 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1651 event
.SetEventObject(wxTheApp
);
1652 event
.SetCanVeto(TRUE
);
1653 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1654 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1655 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1657 return FALSE
; // Veto!
1661 return TRUE
; // Don't veto
1665 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1667 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1668 event
.SetEventObject(wxTheApp
);
1669 event
.SetCanVeto(FALSE
);
1670 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1671 if (endSession
&& // No need to send if the session isn't ending
1672 (this == wxTheApp
->GetTopWindow()) && // Only send once
1673 wxTheApp
->ProcessEvent(event
))
1679 bool wxWindow::MSWOnDestroy()
1681 // delete our drop target if we've got one
1682 #if wxUSE_DRAG_AND_DROP
1683 if ( m_pDropTarget
!= NULL
) {
1684 m_pDropTarget
->Revoke(m_hWnd
);
1686 delete m_pDropTarget
;
1687 m_pDropTarget
= NULL
;
1694 // Deal with child commands from buttons etc.
1696 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1698 #if defined(__WIN95__)
1699 // Find a child window to send the notification to, e.g. a toolbar.
1700 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1701 // handle of the toolbar; it's probably the handle of the tooltip
1702 // window (anyway, it's parent is also the toolbar's parent).
1703 // So, since we don't know which hWnd or wxWindow originated the
1704 // WM_NOTIFY, we'll need to go through all the children of this window
1705 // trying out MSWNotify.
1706 // This won't work now, though, because any number of controls
1707 // could respond to the same generic messages :-(
1709 /* This doesn't work for toolbars, but try for other controls first.
1711 NMHDR
*hdr
= (NMHDR
*)lParam
;
1712 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1713 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1715 WXLPARAM result
= 0;
1719 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1724 // Rely on MSWNotify to check whether the message
1725 // belongs to the window or not
1726 wxNode
*node
= GetChildren().First();
1729 wxWindow
*child
= (wxWindow
*)node
->Data();
1730 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1732 node
= node
->Next();
1735 // finally try this window too (catches toolbar case)
1736 if ( MSWNotify(wParam
, lParam
, &result
) )
1745 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1749 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1753 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1755 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1757 event
.SetEventObject(this);
1758 GetEventHandler()->ProcessEvent(event
);
1762 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1765 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1767 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1769 ::ShowCaret((HWND
) GetHWND());
1772 // panel wants to track the window which was the last to have focus in it
1773 wxWindow
*parent
= GetParent();
1774 if ( parent
&& parent
->IsKindOf(CLASSINFO(wxPanel
)) )
1776 ((wxPanel
*)parent
)->SetLastFocus(GetId());
1779 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1780 event
.SetEventObject(this);
1781 if (!GetEventHandler()->ProcessEvent(event
))
1786 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1794 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1795 event
.SetEventObject(this);
1796 if (!GetEventHandler()->ProcessEvent(event
))
1801 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1804 HDROP hFilesInfo
= (HDROP
) wParam
;
1806 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1808 // Get the total number of files dropped
1809 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1814 wxString
*files
= new wxString
[gwFilesDropped
];
1816 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1818 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1819 files
[wIndex
] = wxBuffer
;
1821 DragFinish (hFilesInfo
);
1823 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1824 event
.m_eventObject
= this;
1825 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1827 if (!GetEventHandler()->ProcessEvent(event
))
1833 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1835 #if wxUSE_OWNER_DRAWN
1836 if ( id
== 0 ) { // is it a menu item?
1837 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1838 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1839 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1841 // prepare to call OnDrawItem()
1843 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1844 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1845 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1846 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1847 return pMenuItem
->OnDrawItem(
1849 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1850 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1853 #endif // owner-drawn menus
1855 wxWindow
*item
= FindItem(id
);
1856 #if wxUSE_DYNAMIC_CLASSES
1857 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1859 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1866 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1868 #if wxUSE_OWNER_DRAWN
1869 if ( id
== 0 ) { // is it a menu item?
1870 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1871 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1872 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1874 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1875 &pMeasureStruct
->itemHeight
);
1877 #endif // owner-drawn menus
1879 wxWindow
*item
= FindItem(id
);
1880 #if wxUSE_DYNAMIC_CLASSES
1881 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1883 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1890 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1891 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1893 if (nCtlColor
== CTLCOLOR_DLG
)
1895 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1898 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1900 WXHBRUSH hBrush
= 0;
1903 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1905 // I think that even for dialogs, we may need to call DefWindowProc (?)
1906 // Or maybe just rely on the usual default behaviour.
1908 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1913 // Define for each class of dialog and control
1914 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1915 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1917 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1920 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1922 wxSysColourChangedEvent event
;
1923 event
.SetEventObject(this);
1925 // Check if app handles this.
1926 if (GetEventHandler()->ProcessEvent(event
))
1929 // We didn't process it
1933 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1935 wxPaletteChangedEvent
event(GetId());
1936 event
.SetEventObject(this);
1937 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1938 GetEventHandler()->ProcessEvent(event
);
1942 long wxWindow::MSWOnQueryNewPalette()
1944 wxQueryNewPaletteEvent
event(GetId());
1945 event
.SetEventObject(this);
1946 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1948 return (long) FALSE
;
1954 // Responds to colour changes: passes event on to children.
1955 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1957 wxNode
*node
= GetChildren().First();
1960 // Only propagate to non-top-level windows
1961 wxWindow
*win
= (wxWindow
*)node
->Data();
1962 if ( win
->GetParent() )
1964 wxSysColourChangedEvent event2
;
1965 event
.m_eventObject
= win
;
1966 win
->GetEventHandler()->ProcessEvent(event2
);
1969 node
= node
->Next();
1973 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1976 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1978 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1981 long wxWindow::Default()
1983 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1988 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1989 wxGetMessageName(m_lastMsg
));
1990 #endif // __WXDEBUG__
1992 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1995 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1997 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1998 // intercept dialog navigation keys
1999 MSG
*msg
= (MSG
*)pMsg
;
2000 bool bProcess
= TRUE
;
2001 if ( msg
->message
!= WM_KEYDOWN
)
2004 if ( bProcess
&& (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2009 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
2011 // WM_GETDLGCODE: ask the control if it wants the key for itself,
2012 // don't process it if it's the case (except for Ctrl-Tab/Enter
2013 // combinations which are always processed)
2017 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
2020 bool bForward
= TRUE
,
2021 bWindowChange
= FALSE
;
2023 switch ( msg
->wParam
)
2026 if ( lDlgCode
& DLGC_WANTTAB
) {
2030 // Ctrl-Tab cycles thru notebook pages
2031 bWindowChange
= bCtrlDown
;
2032 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
2038 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2046 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2052 if ( lDlgCode
& DLGC_WANTMESSAGE
)
2054 // control wants to process Enter itself, don't
2055 // call IsDialogMessage() which would interpret
2060 wxButton
*btnDefault
= GetDefaultItem();
2061 if ( btnDefault
&& !bCtrlDown
)
2063 // if there is a default button, Enter should
2065 (void)::SendMessage((HWND
)btnDefault
->GetHWND(),
2069 // else: but if there is not it makes sense to make it
2070 // work like a TAB - and that's what we do.
2071 // Note that Ctrl-Enter always works this way.
2082 wxNavigationKeyEvent event
;
2083 event
.SetDirection(bForward
);
2084 event
.SetWindowChange(bWindowChange
);
2085 event
.SetEventObject(this);
2087 if ( GetEventHandler()->ProcessEvent(event
) )
2092 if ( ::IsDialogMessage((HWND
)GetHWND(), msg
) )
2098 // relay mouse move events to the tooltip control
2099 MSG
*msg
= (MSG
*)pMsg
;
2100 if ( msg
->message
== WM_MOUSEMOVE
)
2101 m_tooltip
->RelayEvent(pMsg
);
2103 #endif // wxUSE_TOOLTIPS
2108 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2110 if (m_acceleratorTable
.Ok() &&
2111 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2117 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2122 void wxWindow::MSWDetachWindowMenu()
2126 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2128 for (i
= 0; i
< N
; i
++)
2131 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2132 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2134 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2141 bool wxWindow::MSWOnPaint()
2144 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2145 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2147 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2150 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2152 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2153 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2156 wxPaintEvent
event(m_windowId
);
2157 event
.SetEventObject(this);
2158 if (!GetEventHandler()->ProcessEvent(event
))
2163 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2173 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2174 event
.SetEventObject(this);
2175 if (!GetEventHandler()->ProcessEvent(event
))
2181 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2186 // Deal with child commands from buttons etc.
2187 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2189 if (wxCurrentPopupMenu
)
2191 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2192 wxCurrentPopupMenu
= NULL
;
2193 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2197 wxWindow
*item
= FindItem(id
);
2200 bool value
= item
->MSWCommand(cmd
, id
);
2205 wxWindow
*win
= wxFindWinFromHandle(control
);
2207 return win
->MSWCommand(cmd
, id
);
2212 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2214 switch (wParam
& 0xFFFFFFF0)
2218 wxMaximizeEvent
event(m_windowId
);
2219 event
.SetEventObject(this);
2220 if (!GetEventHandler()->ProcessEvent(event
))
2228 wxIconizeEvent
event(m_windowId
);
2229 event
.SetEventObject(this);
2230 if (!GetEventHandler()->ProcessEvent(event
))
2242 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2244 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2246 event
.m_x
= x
; event
.m_y
= y
;
2247 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2248 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2249 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2250 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2251 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2252 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2253 event
.m_eventObject
= this;
2255 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2257 if (!GetEventHandler()->ProcessEvent(event
))
2261 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2263 wxMouseEvent
event(wxEVT_LEFT_UP
);
2265 event
.m_x
= x
; event
.m_y
= y
;
2266 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2267 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2268 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2269 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2270 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2271 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2272 event
.m_eventObject
= this;
2274 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2276 if (!GetEventHandler()->ProcessEvent(event
))
2280 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2282 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2284 event
.m_x
= x
; event
.m_y
= y
;
2285 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2286 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2287 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2288 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2289 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2290 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2291 event
.m_eventObject
= this;
2293 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2295 if (!GetEventHandler()->ProcessEvent(event
))
2299 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2301 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2303 event
.m_x
= x
; event
.m_y
= y
;
2304 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2305 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2306 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2307 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2308 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2309 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2310 event
.m_eventObject
= this;
2312 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2314 if (!GetEventHandler()->ProcessEvent(event
))
2318 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2320 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2322 event
.m_x
= x
; event
.m_y
= y
;
2323 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2324 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2325 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2326 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2327 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2328 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2329 event
.m_eventObject
= this;
2331 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2333 if (!GetEventHandler()->ProcessEvent(event
))
2337 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2339 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2341 event
.m_x
= x
; event
.m_y
= y
;
2342 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2343 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2344 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2345 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2346 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2347 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2348 event
.m_eventObject
= this;
2350 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2352 if (!GetEventHandler()->ProcessEvent(event
))
2356 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2358 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2360 event
.m_x
= x
; event
.m_y
= y
;
2361 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2362 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2363 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2364 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2365 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2366 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2367 event
.m_eventObject
= this;
2369 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2371 if (!GetEventHandler()->ProcessEvent(event
))
2375 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2377 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2379 event
.m_x
= x
; event
.m_y
= y
;
2380 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2381 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2382 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2383 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2384 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2385 event
.m_eventObject
= this;
2386 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2388 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2390 if (!GetEventHandler()->ProcessEvent(event
))
2394 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2396 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2398 event
.m_x
= x
; event
.m_y
= y
;
2399 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2400 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2401 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2402 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2403 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2404 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2405 event
.m_eventObject
= this;
2407 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2409 if (!GetEventHandler()->ProcessEvent(event
))
2413 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2415 // 'normal' move event...
2416 // Set cursor, but only if we're not in 'busy' mode
2418 // Trouble with this is that it sets the cursor for controls too :-(
2419 if (m_windowCursor
.Ok() && !wxIsBusy())
2420 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2422 if (!m_mouseInWindow
)
2424 // Generate an ENTER event
2425 m_mouseInWindow
= TRUE
;
2426 MSWOnMouseEnter(x
, y
, flags
);
2429 wxMouseEvent
event(wxEVT_MOTION
);
2431 event
.m_x
= x
; event
.m_y
= y
;
2432 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2433 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2434 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2435 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2436 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2437 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2438 event
.m_eventObject
= this;
2440 // Window gets a click down message followed by a mouse move
2441 // message even if position isn't changed! We want to discard
2442 // the trailing move event if x and y are the same.
2443 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2444 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2445 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2447 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2448 m_lastEvent
= wxEVT_MOTION
;
2452 m_lastEvent
= wxEVT_MOTION
;
2453 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2455 if (!GetEventHandler()->ProcessEvent(event
))
2459 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2461 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2463 event
.m_x
= x
; event
.m_y
= y
;
2464 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2465 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2466 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2467 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2468 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2469 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2470 event
.m_eventObject
= this;
2472 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2473 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2474 // No message - ensure we don't try to call the default behaviour accidentally.
2476 GetEventHandler()->ProcessEvent(event
);
2479 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2481 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2483 event
.m_x
= x
; event
.m_y
= y
;
2484 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2485 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2486 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2487 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2488 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2489 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2490 event
.m_eventObject
= this;
2492 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2493 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2494 // No message - ensure we don't try to call the default behaviour accidentally.
2496 GetEventHandler()->ProcessEvent(event
);
2499 bool wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2502 bool tempControlDown
= FALSE
;
2505 // If 1 -> 26, translate to CTRL plus a letter.
2507 if ((id
> 0) && (id
< 27))
2528 tempControlDown
= TRUE
;
2534 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2535 // it's ASCII and will be processed here only when called from
2536 // WM_CHAR (i.e. when isASCII = TRUE)
2542 wxKeyEvent
event(wxEVT_CHAR
);
2543 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2544 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2545 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2546 event
.m_altDown
= TRUE
;
2548 event
.m_eventObject
= this;
2549 event
.m_keyCode
= id
;
2550 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2555 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2559 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2561 if (GetEventHandler()->ProcessEvent(event
))
2570 bool wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2574 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2580 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2581 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2582 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2583 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2584 event
.m_altDown
= TRUE
;
2586 event
.m_eventObject
= this;
2587 event
.m_keyCode
= id
;
2588 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2593 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2597 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2599 if (GetEventHandler()->ProcessEvent(event
))
2611 bool wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2615 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2621 wxKeyEvent
event(wxEVT_KEY_UP
);
2622 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2623 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2624 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2625 event
.m_altDown
= TRUE
;
2627 event
.m_eventObject
= this;
2628 event
.m_keyCode
= id
;
2629 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2634 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2638 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2640 if (GetEventHandler()->ProcessEvent(event
))
2649 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2653 if (flags
& JOY_BUTTON1CHG
)
2654 change
= wxJOY_BUTTON1
;
2655 if (flags
& JOY_BUTTON2CHG
)
2656 change
= wxJOY_BUTTON2
;
2657 if (flags
& JOY_BUTTON3CHG
)
2658 change
= wxJOY_BUTTON3
;
2659 if (flags
& JOY_BUTTON4CHG
)
2660 change
= wxJOY_BUTTON4
;
2662 if (flags
& JOY_BUTTON1
)
2663 buttons
|= wxJOY_BUTTON1
;
2664 if (flags
& JOY_BUTTON2
)
2665 buttons
|= wxJOY_BUTTON2
;
2666 if (flags
& JOY_BUTTON3
)
2667 buttons
|= wxJOY_BUTTON3
;
2668 if (flags
& JOY_BUTTON4
)
2669 buttons
|= wxJOY_BUTTON4
;
2671 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2672 event
.SetPosition(wxPoint(x
, y
));
2673 event
.SetEventObject(this);
2675 GetEventHandler()->ProcessEvent(event
);
2678 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2682 if (flags
& JOY_BUTTON1CHG
)
2683 change
= wxJOY_BUTTON1
;
2684 if (flags
& JOY_BUTTON2CHG
)
2685 change
= wxJOY_BUTTON2
;
2686 if (flags
& JOY_BUTTON3CHG
)
2687 change
= wxJOY_BUTTON3
;
2688 if (flags
& JOY_BUTTON4CHG
)
2689 change
= wxJOY_BUTTON4
;
2691 if (flags
& JOY_BUTTON1
)
2692 buttons
|= wxJOY_BUTTON1
;
2693 if (flags
& JOY_BUTTON2
)
2694 buttons
|= wxJOY_BUTTON2
;
2695 if (flags
& JOY_BUTTON3
)
2696 buttons
|= wxJOY_BUTTON3
;
2697 if (flags
& JOY_BUTTON4
)
2698 buttons
|= wxJOY_BUTTON4
;
2700 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2701 event
.SetPosition(wxPoint(x
, y
));
2702 event
.SetEventObject(this);
2704 GetEventHandler()->ProcessEvent(event
);
2707 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2710 if (flags
& JOY_BUTTON1
)
2711 buttons
|= wxJOY_BUTTON1
;
2712 if (flags
& JOY_BUTTON2
)
2713 buttons
|= wxJOY_BUTTON2
;
2714 if (flags
& JOY_BUTTON3
)
2715 buttons
|= wxJOY_BUTTON3
;
2716 if (flags
& JOY_BUTTON4
)
2717 buttons
|= wxJOY_BUTTON4
;
2719 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2720 event
.SetPosition(wxPoint(x
, y
));
2721 event
.SetEventObject(this);
2723 GetEventHandler()->ProcessEvent(event
);
2726 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2729 if (flags
& JOY_BUTTON1
)
2730 buttons
|= wxJOY_BUTTON1
;
2731 if (flags
& JOY_BUTTON2
)
2732 buttons
|= wxJOY_BUTTON2
;
2733 if (flags
& JOY_BUTTON3
)
2734 buttons
|= wxJOY_BUTTON3
;
2735 if (flags
& JOY_BUTTON4
)
2736 buttons
|= wxJOY_BUTTON4
;
2738 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2739 event
.SetZPosition(z
);
2740 event
.SetEventObject(this);
2742 GetEventHandler()->ProcessEvent(event
);
2745 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2749 wxWindow
*child
= wxFindWinFromHandle(control
);
2751 child
->MSWOnVScroll(wParam
, pos
, control
);
2755 wxScrollEvent event
;
2756 event
.SetPosition(pos
);
2757 event
.SetOrientation(wxVERTICAL
);
2758 event
.m_eventObject
= this;
2763 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2767 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2771 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2775 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2779 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2783 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2787 case SB_THUMBPOSITION
:
2788 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2796 if (!GetEventHandler()->ProcessEvent(event
))
2800 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2804 wxWindow
*child
= wxFindWinFromHandle(control
);
2806 child
->MSWOnHScroll(wParam
, pos
, control
);
2812 wxScrollEvent event
;
2813 event
.SetPosition(pos
);
2814 event
.SetOrientation(wxHORIZONTAL
);
2815 event
.m_eventObject
= this;
2820 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2824 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2828 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2832 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2836 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2840 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2844 case SB_THUMBPOSITION
:
2845 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2852 if ( GetEventHandler()->ProcessEvent(event
) )
2856 // call the default WM_HSCROLL handler: it's non trivial in some common
2857 // controls (up-down control for example)
2861 void wxWindow::MSWOnShow(bool show
, int status
)
2863 wxShowEvent
event(GetId(), show
);
2864 event
.m_eventObject
= this;
2865 GetEventHandler()->ProcessEvent(event
);
2868 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2870 wxInitDialogEvent
event(GetId());
2871 event
.m_eventObject
= this;
2872 GetEventHandler()->ProcessEvent(event
);
2876 void wxWindow::InitDialog()
2878 wxInitDialogEvent
event(GetId());
2879 event
.SetEventObject( this );
2880 GetEventHandler()->ProcessEvent(event
);
2883 // Default init dialog behaviour is to transfer data to window
2884 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2886 TransferDataToWindow();
2889 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2892 HDC dc
= ::GetDC((HWND
) wnd
);
2897 // the_font->UseResource();
2898 // the_font->RealizeResource();
2899 fnt
= (HFONT
)the_font
->GetResourceHandle();
2901 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2903 GetTextMetrics(dc
, &tm
);
2904 if (the_font
&& fnt
&& was
)
2906 SelectObject(dc
,was
) ;
2908 ReleaseDC((HWND
)wnd
, dc
);
2909 *x
= tm
.tmAveCharWidth
;
2910 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2913 // the_font->ReleaseResource();
2916 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2917 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2918 int wxCharCodeMSWToWX(int keySym
)
2923 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2924 case VK_BACK
: id
= WXK_BACK
; break;
2925 case VK_TAB
: id
= WXK_TAB
; break;
2926 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2927 case VK_RETURN
: id
= WXK_RETURN
; break;
2928 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2929 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2930 case VK_MENU
: id
= WXK_MENU
; break;
2931 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2932 case VK_SPACE
: id
= WXK_SPACE
; break;
2933 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2934 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2935 case VK_NEXT
: id
= WXK_NEXT
; break;
2936 case VK_END
: id
= WXK_END
; break;
2937 case VK_HOME
: id
= WXK_HOME
; break;
2938 case VK_LEFT
: id
= WXK_LEFT
; break;
2939 case VK_UP
: id
= WXK_UP
; break;
2940 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2941 case VK_DOWN
: id
= WXK_DOWN
; break;
2942 case VK_SELECT
: id
= WXK_SELECT
; break;
2943 case VK_PRINT
: id
= WXK_PRINT
; break;
2944 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2945 case VK_INSERT
: id
= WXK_INSERT
; break;
2946 case VK_DELETE
: id
= WXK_DELETE
; break;
2947 case VK_HELP
: id
= WXK_HELP
; break;
2948 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2949 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2950 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2951 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2952 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2953 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2954 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2955 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2956 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2957 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2958 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2959 case VK_ADD
: id
= WXK_ADD
; break;
2960 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2961 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2962 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2963 case VK_F1
: id
= WXK_F1
; break;
2964 case VK_F2
: id
= WXK_F2
; break;
2965 case VK_F3
: id
= WXK_F3
; break;
2966 case VK_F4
: id
= WXK_F4
; break;
2967 case VK_F5
: id
= WXK_F5
; break;
2968 case VK_F6
: id
= WXK_F6
; break;
2969 case VK_F7
: id
= WXK_F7
; break;
2970 case VK_F8
: id
= WXK_F8
; break;
2971 case VK_F9
: id
= WXK_F9
; break;
2972 case VK_F10
: id
= WXK_F10
; break;
2973 case VK_F11
: id
= WXK_F11
; break;
2974 case VK_F12
: id
= WXK_F12
; break;
2975 case VK_F13
: id
= WXK_F13
; break;
2976 case VK_F14
: id
= WXK_F14
; break;
2977 case VK_F15
: id
= WXK_F15
; break;
2978 case VK_F16
: id
= WXK_F16
; break;
2979 case VK_F17
: id
= WXK_F17
; break;
2980 case VK_F18
: id
= WXK_F18
; break;
2981 case VK_F19
: id
= WXK_F19
; break;
2982 case VK_F20
: id
= WXK_F20
; break;
2983 case VK_F21
: id
= WXK_F21
; break;
2984 case VK_F22
: id
= WXK_F22
; break;
2985 case VK_F23
: id
= WXK_F23
; break;
2986 case VK_F24
: id
= WXK_F24
; break;
2987 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2988 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2997 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
3003 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
3004 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
3005 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
3006 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
3007 case WXK_MENU
: keySym
= VK_MENU
; break;
3008 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
3009 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
3010 case WXK_NEXT
: keySym
= VK_NEXT
; break;
3011 case WXK_END
: keySym
= VK_END
; break;
3012 case WXK_HOME
: keySym
= VK_HOME
; break;
3013 case WXK_LEFT
: keySym
= VK_LEFT
; break;
3014 case WXK_UP
: keySym
= VK_UP
; break;
3015 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
3016 case WXK_DOWN
: keySym
= VK_DOWN
; break;
3017 case WXK_SELECT
: keySym
= VK_SELECT
; break;
3018 case WXK_PRINT
: keySym
= VK_PRINT
; break;
3019 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
3020 case WXK_INSERT
: keySym
= VK_INSERT
; break;
3021 case WXK_DELETE
: keySym
= VK_DELETE
; break;
3022 case WXK_HELP
: keySym
= VK_HELP
; break;
3023 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
3024 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
3025 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
3026 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
3027 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
3028 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
3029 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
3030 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
3031 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
3032 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
3033 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
3034 case WXK_ADD
: keySym
= VK_ADD
; break;
3035 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
3036 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
3037 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
3038 case WXK_F1
: keySym
= VK_F1
; break;
3039 case WXK_F2
: keySym
= VK_F2
; break;
3040 case WXK_F3
: keySym
= VK_F3
; break;
3041 case WXK_F4
: keySym
= VK_F4
; break;
3042 case WXK_F5
: keySym
= VK_F5
; break;
3043 case WXK_F6
: keySym
= VK_F6
; break;
3044 case WXK_F7
: keySym
= VK_F7
; break;
3045 case WXK_F8
: keySym
= VK_F8
; break;
3046 case WXK_F9
: keySym
= VK_F9
; break;
3047 case WXK_F10
: keySym
= VK_F10
; break;
3048 case WXK_F11
: keySym
= VK_F11
; break;
3049 case WXK_F12
: keySym
= VK_F12
; break;
3050 case WXK_F13
: keySym
= VK_F13
; break;
3051 case WXK_F14
: keySym
= VK_F14
; break;
3052 case WXK_F15
: keySym
= VK_F15
; break;
3053 case WXK_F16
: keySym
= VK_F16
; break;
3054 case WXK_F17
: keySym
= VK_F17
; break;
3055 case WXK_F18
: keySym
= VK_F18
; break;
3056 case WXK_F19
: keySym
= VK_F19
; break;
3057 case WXK_F20
: keySym
= VK_F20
; break;
3058 case WXK_F21
: keySym
= VK_F21
; break;
3059 case WXK_F22
: keySym
= VK_F22
; break;
3060 case WXK_F23
: keySym
= VK_F23
; break;
3061 case WXK_F24
: keySym
= VK_F24
; break;
3062 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
3063 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
3074 // Caret manipulation
3075 void wxWindow::CreateCaret(int w
, int h
)
3079 m_caretEnabled
= TRUE
;
3082 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
3087 void wxWindow::ShowCaret(bool show
)
3092 ::ShowCaret((HWND
) GetHWND());
3094 ::HideCaret((HWND
) GetHWND());
3095 m_caretShown
= show
;
3099 void wxWindow::DestroyCaret()
3101 m_caretEnabled
= FALSE
;
3104 void wxWindow::SetCaretPos(int x
, int y
)
3106 ::SetCaretPos(x
, y
);
3109 void wxWindow::GetCaretPos(int *x
, int *y
) const
3112 ::GetCaretPos(&point
);
3117 wxWindow
*wxGetActiveWindow()
3119 HWND hWnd
= GetActiveWindow();
3122 return wxFindWinFromHandle((WXHWND
) hWnd
);
3127 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3128 // in active frames and dialogs, regardless of where the focus is.
3129 static HHOOK wxTheKeyboardHook
= 0;
3130 static FARPROC wxTheKeyboardHookProc
= 0;
3131 int APIENTRY _EXPORT
3132 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3134 void wxSetKeyboardHook(bool doIt
)
3138 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3139 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3140 #if defined(__WIN32__) && !defined(__TWIN32__)
3141 GetCurrentThreadId());
3142 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3149 UnhookWindowsHookEx(wxTheKeyboardHook
);
3150 FreeProcInstance(wxTheKeyboardHookProc
);
3154 int APIENTRY _EXPORT
3155 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3157 DWORD hiWord
= HIWORD(lParam
);
3158 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3161 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3163 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3164 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3165 event
.m_altDown
= TRUE
;
3167 event
.m_eventObject
= NULL
;
3168 event
.m_keyCode
= id
;
3169 /* begin Albert's fix for control and shift key 26.5 */
3170 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3171 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3172 /* end Albert's fix for control and shift key 26.5 */
3173 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3175 wxWindow
*win
= wxGetActiveWindow();
3178 if (win
->GetEventHandler()->ProcessEvent(event
))
3183 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3188 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3191 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3199 void wxWindow::Centre(int direction
)
3201 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3203 wxWindow
*father
= (wxWindow
*)GetParent();
3207 father
->GetClientSize(&panel_width
, &panel_height
);
3208 GetSize(&width
, &height
);
3209 GetPosition(&x
, &y
);
3214 if (direction
& wxHORIZONTAL
)
3215 new_x
= (int)((panel_width
- width
)/2);
3217 if (direction
& wxVERTICAL
)
3218 new_y
= (int)((panel_height
- height
)/2);
3220 SetSize(new_x
, new_y
, -1, -1);
3224 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3226 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3227 // pixel coordinates, relatives to the canvas -- So, we first need to
3228 // substract origin of the window, then convert to screen position
3230 int x
= x_pos
; int y
= y_pos
;
3232 GetWindowRect ((HWND
) GetHWND(), &rect
);
3237 SetCursorPos (x
, y
);
3240 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3244 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3252 wxEraseEvent
event(m_windowId
, &dc
);
3253 event
.m_eventObject
= this;
3254 if (!GetEventHandler()->ProcessEvent(event
))
3257 dc
.SelectOldObjects(pDC
);
3263 dc
.SelectOldObjects(pDC
);
3266 dc
.SetHDC((WXHDC
) NULL
);
3270 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3276 ::GetClientRect((HWND
) GetHWND(), &rect
);
3278 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3279 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3280 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3282 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3283 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3284 ::DeleteObject(hBrush
);
3285 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3287 // Less efficient version (and doesn't account for scrolling)
3289 GetClientSize(& w, & h);
3290 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3291 event.GetDC()->SetBrush(brush);
3292 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3294 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3298 #if WXWIN_COMPATIBILITY
3299 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3301 #if defined(__WIN95__)
3305 // Try to adjust the range to cope with page size > 1
3306 // - a Windows API quirk
3307 int pageSize
= GetScrollPage(orient
);
3308 if ( pageSize
> 1 && range
> 0)
3310 range1
+= (pageSize
- 1);
3316 if (orient
== wxHORIZONTAL
) {
3322 info
.cbSize
= sizeof(SCROLLINFO
);
3323 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3327 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3329 HWND hWnd
= (HWND
) GetHWND();
3331 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3334 if (orient
== wxHORIZONTAL
)
3339 HWND hWnd
= (HWND
) GetHWND();
3341 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3345 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3347 #if defined(__WIN95__)
3351 if (orient
== wxHORIZONTAL
) {
3353 m_xThumbSize
= page
;
3356 m_yThumbSize
= page
;
3359 info
.cbSize
= sizeof(SCROLLINFO
);
3362 info
.fMask
= SIF_PAGE
;
3364 HWND hWnd
= (HWND
) GetHWND();
3366 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3368 if (orient
== wxHORIZONTAL
)
3369 m_xThumbSize
= page
;
3371 m_yThumbSize
= page
;
3375 int wxWindow::OldGetScrollRange(int orient
) const
3378 if (orient
== wxHORIZONTAL
)
3383 #if __WATCOMC__ && defined(__WINDOWS_386__)
3384 short minPos
, maxPos
;
3388 HWND hWnd
= (HWND
) GetHWND();
3391 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3392 #if defined(__WIN95__)
3393 // Try to adjust the range to cope with page size > 1
3394 // - a Windows API quirk
3395 int pageSize
= GetScrollPage(orient
);
3398 maxPos
-= (pageSize
- 1);
3407 int wxWindow::GetScrollPage(int orient
) const
3409 if (orient
== wxHORIZONTAL
)
3410 return m_xThumbSize
;
3412 return m_yThumbSize
;
3416 int wxWindow::GetScrollPos(int orient
) const
3419 if (orient
== wxHORIZONTAL
)
3423 HWND hWnd
= (HWND
) GetHWND();
3426 return ::GetScrollPos(hWnd
, wOrient
);
3432 // This now returns the whole range, not just the number
3433 // of positions that we can scroll.
3434 int wxWindow::GetScrollRange(int orient
) const
3437 if (orient
== wxHORIZONTAL
)
3442 #if __WATCOMC__ && defined(__WINDOWS_386__)
3443 short minPos
, maxPos
;
3447 HWND hWnd
= (HWND
) GetHWND();
3450 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3451 #if defined(__WIN95__)
3452 // Try to adjust the range to cope with page size > 1
3453 // - a Windows API quirk
3454 int pageSize
= GetScrollThumb(orient
);
3457 maxPos
-= (pageSize
- 1);
3459 // October 10th: new range concept.
3469 int wxWindow::GetScrollThumb(int orient
) const
3471 if (orient
== wxHORIZONTAL
)
3472 return m_xThumbSize
;
3474 return m_yThumbSize
;
3477 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3479 #if defined(__WIN95__)
3483 if (orient
== wxHORIZONTAL
) {
3489 info
.cbSize
= sizeof(SCROLLINFO
);
3493 info
.fMask
= SIF_POS
;
3495 HWND hWnd
= (HWND
) GetHWND();
3497 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3500 if (orient
== wxHORIZONTAL
)
3505 HWND hWnd
= (HWND
) GetHWND();
3507 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3511 // New function that will replace some of the above.
3512 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3513 int range
, bool refresh
)
3516 SetScrollPage(orient, thumbVisible, FALSE);
3518 int oldRange = range - thumbVisible ;
3519 SetScrollRange(orient, oldRange, FALSE);
3521 SetScrollPos(orient, pos, refresh);
3523 #if defined(__WIN95__)
3524 int oldRange
= range
- thumbVisible
;
3526 int range1
= oldRange
;
3528 // Try to adjust the range to cope with page size > 1
3529 // - a Windows API quirk
3530 int pageSize
= thumbVisible
;
3531 if ( pageSize
> 1 && range
> 0)
3533 range1
+= (pageSize
- 1);
3539 if (orient
== wxHORIZONTAL
) {
3545 info
.cbSize
= sizeof(SCROLLINFO
);
3546 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3550 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3552 HWND hWnd
= (HWND
) GetHWND();
3554 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3557 if (orient
== wxHORIZONTAL
)
3562 HWND hWnd
= (HWND
) GetHWND();
3565 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3566 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3569 if (orient
== wxHORIZONTAL
) {
3570 m_xThumbSize
= thumbVisible
;
3572 m_yThumbSize
= thumbVisible
;
3576 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3581 rect2
.left
= rect
->x
;
3582 rect2
.top
= rect
->y
;
3583 rect2
.right
= rect
->x
+ rect
->width
;
3584 rect2
.bottom
= rect
->y
+ rect
->height
;
3588 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3590 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3593 void wxWindow::SetFont(const wxFont
& font
)
3595 m_windowFont
= font
;
3597 if (!m_windowFont
.Ok())
3600 HWND hWnd
= (HWND
) GetHWND();
3603 if (m_windowFont
.GetResourceHandle())
3604 SendMessage(hWnd
, WM_SETFONT
,
3605 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3609 void wxWindow::SubclassWin(WXHWND hWnd
)
3611 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3613 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3615 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3616 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3619 void wxWindow::UnsubclassWin()
3621 wxRemoveHandleAssociation(this);
3623 // Restore old Window proc
3624 if ((HWND
) GetHWND())
3626 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3627 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3629 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3635 // Make a Windows extended style from the given wxWindows window style
3636 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3638 WXDWORD exStyle
= 0;
3639 if ( style
& wxTRANSPARENT_WINDOW
)
3640 exStyle
|= WS_EX_TRANSPARENT
;
3642 if ( !eliminateBorders
)
3644 if ( style
& wxSUNKEN_BORDER
)
3645 exStyle
|= WS_EX_CLIENTEDGE
;
3646 if ( style
& wxDOUBLE_BORDER
)
3647 exStyle
|= WS_EX_DLGMODALFRAME
;
3648 #if defined(__WIN95__)
3649 if ( style
& wxRAISED_BORDER
)
3650 exStyle
|= WS_EX_WINDOWEDGE
;
3651 if ( style
& wxSTATIC_BORDER
)
3652 exStyle
|= WS_EX_STATICEDGE
;
3658 // Determines whether native 3D effects or CTL3D should be used,
3659 // applying a default border style if required, and returning an extended
3660 // style to pass to CreateWindowEx.
3661 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3663 // If matches certain criteria, then assume no 3D effects
3664 // unless specifically requested (dealt with in MakeExtendedStyle)
3665 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3668 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3671 // Determine whether we should be using 3D effects or not.
3672 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3674 // 1) App can specify global 3D effects
3675 *want3D
= wxTheApp
->GetAuto3D();
3677 // 2) If the parent is being drawn with user colours, or simple border specified,
3678 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3679 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3682 // 3) Control can override this global setting by defining
3683 // a border style, e.g. wxSUNKEN_BORDER
3684 if (m_windowStyle
& wxSUNKEN_BORDER
)
3687 // 4) If it's a special border, CTL3D can't cope so we want a native border
3688 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3689 (m_windowStyle
& wxSTATIC_BORDER
) )
3692 nativeBorder
= TRUE
;
3695 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3696 // effects from extended style
3699 nativeBorder
= FALSE
;
3702 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3704 // If we want 3D, but haven't specified a border here,
3705 // apply the default border style specified.
3706 // TODO what about non-Win95 WIN32? Does it have borders?
3707 #if defined(__WIN95__) && !wxUSE_CTL3D
3708 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3709 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3710 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3716 void wxWindow::OnChar(wxKeyEvent
& event
)
3719 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3724 if ( !event
.ControlDown() ) // Why this test?
3725 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3728 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3733 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3738 void wxWindow::OnPaint(wxPaintEvent
& event
)
3743 bool wxWindow::IsEnabled(void) const
3745 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3748 // Dialog support: override these and call
3749 // base class members to add functionality
3750 // that can't be done using validators.
3751 // NOTE: these functions assume that controls
3752 // are direct children of this window, not grandchildren
3753 // or other levels of descendant.
3755 // Transfer values to controls. If returns FALSE,
3756 // it's an application error (pops up a dialog)
3757 bool wxWindow::TransferDataToWindow()
3759 wxNode
*node
= GetChildren().First();
3762 wxWindow
*child
= (wxWindow
*)node
->Data();
3763 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3764 !child
->GetValidator()->TransferToWindow() )
3766 wxLogError(_("Could not transfer data to window"));
3770 node
= node
->Next();
3775 // Transfer values from controls. If returns FALSE,
3776 // validation failed: don't quit
3777 bool wxWindow::TransferDataFromWindow()
3779 wxNode
*node
= GetChildren().First();
3782 wxWindow
*child
= (wxWindow
*)node
->Data();
3783 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3788 node
= node
->Next();
3793 bool wxWindow::Validate()
3795 wxNode
*node
= GetChildren().First();
3798 wxWindow
*child
= (wxWindow
*)node
->Data();
3799 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3804 node
= node
->Next();
3809 // Get the window with the focus
3810 wxWindow
*wxWindow::FindFocus()
3812 HWND hWnd
= ::GetFocus();
3815 return wxFindWinFromHandle((WXHWND
) hWnd
);
3820 void wxWindow::AddChild(wxWindow
*child
)
3822 GetChildren().Append(child
);
3823 child
->m_windowParent
= this;
3826 void wxWindow::RemoveChild(wxWindow
*child
)
3828 // if (GetChildren())
3829 GetChildren().DeleteObject(child
);
3830 child
->m_windowParent
= NULL
;
3833 void wxWindow::DestroyChildren()
3836 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3838 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3840 if ( GetChildren().Member(child
) )
3846 void wxWindow::MakeModal(bool modal
)
3848 // Disable all other windows
3849 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3851 wxNode
*node
= wxTopLevelWindows
.First();
3854 wxWindow
*win
= (wxWindow
*)node
->Data();
3856 win
->Enable(!modal
);
3858 node
= node
->Next();
3863 // If nothing defined for this, try the parent.
3864 // E.g. we may be a button loaded from a resource, with no callback function
3866 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3868 if (GetEventHandler()->ProcessEvent(event
) )
3871 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3874 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3878 UnsetConstraints(m_constraints
);
3879 delete m_constraints
;
3884 // Make sure other windows know they're part of a 'meaningful relationship'
3885 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3886 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3887 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3888 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3889 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3890 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3891 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3892 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3893 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3894 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3895 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3896 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3897 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3898 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3899 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3900 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3904 // This removes any dangling pointers to this window
3905 // in other windows' constraintsInvolvedIn lists.
3906 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3910 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3911 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3912 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3913 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3914 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3915 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3916 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3917 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3918 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3919 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3920 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3921 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3922 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3923 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3924 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3925 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3929 // Back-pointer to other windows we're involved with, so if we delete
3930 // this window, we must delete any constraints we're involved with.
3931 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3933 if (!m_constraintsInvolvedIn
)
3934 m_constraintsInvolvedIn
= new wxList
;
3935 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3936 m_constraintsInvolvedIn
->Append(otherWin
);
3939 // REMOVE back-pointer to other windows we're involved with.
3940 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3942 if (m_constraintsInvolvedIn
)
3943 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3946 // Reset any constraints that mention this window
3947 void wxWindow::DeleteRelatedConstraints()
3949 if (m_constraintsInvolvedIn
)
3951 wxNode
*node
= m_constraintsInvolvedIn
->First();
3954 wxWindow
*win
= (wxWindow
*)node
->Data();
3955 wxNode
*next
= node
->Next();
3956 wxLayoutConstraints
*constr
= win
->GetConstraints();
3958 // Reset any constraints involving this window
3961 constr
->left
.ResetIfWin((wxWindow
*)this);
3962 constr
->top
.ResetIfWin((wxWindow
*)this);
3963 constr
->right
.ResetIfWin((wxWindow
*)this);
3964 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3965 constr
->width
.ResetIfWin((wxWindow
*)this);
3966 constr
->height
.ResetIfWin((wxWindow
*)this);
3967 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3968 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3973 delete m_constraintsInvolvedIn
;
3974 m_constraintsInvolvedIn
= NULL
;
3978 void wxWindow::SetSizer(wxSizer
*sizer
)
3980 m_windowSizer
= sizer
;
3982 sizer
->SetSizerParent((wxWindow
*)this);
3989 bool wxWindow::Layout()
3991 if (GetConstraints())
3994 GetClientSize(&w
, &h
);
3995 GetConstraints()->width
.SetValue(w
);
3996 GetConstraints()->height
.SetValue(h
);
3999 // If top level (one sizer), evaluate the sizer's constraints.
4003 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
4004 GetSizer()->LayoutPhase1(&noChanges
);
4005 GetSizer()->LayoutPhase2(&noChanges
);
4006 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
4011 // Otherwise, evaluate child constraints
4012 ResetConstraints(); // Mark all constraints as unevaluated
4013 DoPhase(1); // Just one phase need if no sizers involved
4015 SetConstraintSizes(); // Recursively set the real window sizes
4021 // Do a phase of evaluating constraints:
4022 // the default behaviour. wxSizers may do a similar
4023 // thing, but also impose their own 'constraints'
4024 // and order the evaluation differently.
4025 bool wxWindow::LayoutPhase1(int *noChanges
)
4027 wxLayoutConstraints
*constr
= GetConstraints();
4030 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
4036 bool wxWindow::LayoutPhase2(int *noChanges
)
4046 // Do a phase of evaluating child constraints
4047 bool wxWindow::DoPhase(int phase
)
4049 int noIterations
= 0;
4050 int maxIterations
= 500;
4054 while ((noChanges
> 0) && (noIterations
< maxIterations
))
4058 wxNode
*node
= GetChildren().First();
4061 wxWindow
*child
= (wxWindow
*)node
->Data();
4062 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
4064 wxLayoutConstraints
*constr
= child
->GetConstraints();
4067 if (succeeded
.Member(child
))
4072 int tempNoChanges
= 0;
4073 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
4074 noChanges
+= tempNoChanges
;
4077 succeeded
.Append(child
);
4082 node
= node
->Next();
4089 void wxWindow::ResetConstraints()
4091 wxLayoutConstraints
*constr
= GetConstraints();
4094 constr
->left
.SetDone(FALSE
);
4095 constr
->top
.SetDone(FALSE
);
4096 constr
->right
.SetDone(FALSE
);
4097 constr
->bottom
.SetDone(FALSE
);
4098 constr
->width
.SetDone(FALSE
);
4099 constr
->height
.SetDone(FALSE
);
4100 constr
->centreX
.SetDone(FALSE
);
4101 constr
->centreY
.SetDone(FALSE
);
4103 wxNode
*node
= GetChildren().First();
4106 wxWindow
*win
= (wxWindow
*)node
->Data();
4107 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4108 win
->ResetConstraints();
4109 node
= node
->Next();
4113 // Need to distinguish between setting the 'fake' size for
4114 // windows and sizers, and setting the real values.
4115 void wxWindow::SetConstraintSizes(bool recurse
)
4117 wxLayoutConstraints
*constr
= GetConstraints();
4118 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4119 constr
->width
.GetDone() && constr
->height
.GetDone())
4121 int x
= constr
->left
.GetValue();
4122 int y
= constr
->top
.GetValue();
4123 int w
= constr
->width
.GetValue();
4124 int h
= constr
->height
.GetValue();
4126 // If we don't want to resize this window, just move it...
4127 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4128 (constr
->height
.GetRelationship() != wxAsIs
))
4130 // Calls Layout() recursively. AAAGH. How can we stop that.
4131 // Simply take Layout() out of non-top level OnSizes.
4132 SizerSetSize(x
, y
, w
, h
);
4141 char *windowClass
= this->GetClassInfo()->GetClassName();
4144 if (GetName() == "")
4145 winName
= "unnamed";
4147 winName
= GetName();
4148 wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:",
4149 (const char *)windowClass
, (const char *)winName
);
4150 if (!constr
->left
.GetDone())
4151 wxLogDebug(" unsatisfied 'left' constraint.");
4152 if (!constr
->right
.GetDone())
4153 wxLogDebug(" unsatisfied 'right' constraint.");
4154 if (!constr
->width
.GetDone())
4155 wxLogDebug(" unsatisfied 'width' constraint.");
4156 if (!constr
->height
.GetDone())
4157 wxLogDebug(" unsatisfied 'height' constraint.");
4158 wxLogDebug("Please check constraints: try adding AsIs() constraints.\n");
4163 wxNode
*node
= GetChildren().First();
4166 wxWindow
*win
= (wxWindow
*)node
->Data();
4167 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4168 win
->SetConstraintSizes();
4169 node
= node
->Next();
4174 // This assumes that all sizers are 'on' the same
4175 // window, i.e. the parent of this window.
4176 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4178 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4179 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4183 m_sizerParent
->GetPosition(&xp
, &yp
);
4184 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4189 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4193 TransformSizerToActual(&xx
, &yy
);
4194 SetSize(xx
, yy
, w
, h
);
4197 void wxWindow::SizerMove(int x
, int y
)
4201 TransformSizerToActual(&xx
, &yy
);
4205 // Only set the size/position of the constraint (if any)
4206 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4208 wxLayoutConstraints
*constr
= GetConstraints();
4213 constr
->left
.SetValue(x
);
4214 constr
->left
.SetDone(TRUE
);
4218 constr
->top
.SetValue(y
);
4219 constr
->top
.SetDone(TRUE
);
4223 constr
->width
.SetValue(w
);
4224 constr
->width
.SetDone(TRUE
);
4228 constr
->height
.SetValue(h
);
4229 constr
->height
.SetDone(TRUE
);
4234 void wxWindow::MoveConstraint(int x
, int y
)
4236 wxLayoutConstraints
*constr
= GetConstraints();
4241 constr
->left
.SetValue(x
);
4242 constr
->left
.SetDone(TRUE
);
4246 constr
->top
.SetValue(y
);
4247 constr
->top
.SetDone(TRUE
);
4252 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4254 wxLayoutConstraints
*constr
= GetConstraints();
4257 *w
= constr
->width
.GetValue();
4258 *h
= constr
->height
.GetValue();
4264 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4266 wxLayoutConstraints
*constr
= GetConstraints();
4269 *w
= constr
->width
.GetValue();
4270 *h
= constr
->height
.GetValue();
4273 GetClientSize(w
, h
);
4276 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4278 wxLayoutConstraints
*constr
= GetConstraints();
4281 *x
= constr
->left
.GetValue();
4282 *y
= constr
->top
.GetValue();
4288 bool wxWindow::Close(bool force
)
4290 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4291 event
.SetEventObject(this);
4292 #if WXWIN_COMPATIBILITY
4293 event
.SetForce(force
);
4295 event
.SetCanVeto(!force
);
4297 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4300 wxObject
* wxWindow::GetChild(int number
) const
4302 // Return a pointer to the Nth object in the Panel
4303 // if (!GetChildren())
4305 wxNode
*node
= GetChildren().First();
4308 node
= node
->Next() ;
4311 wxObject
*obj
= (wxObject
*)node
->Data();
4318 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4320 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4321 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4324 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4326 wxListBox *lbox = (wxListBox *)initiatingItem;
4327 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4328 event.m_commandInt = -1;
4329 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4331 event.m_commandString = copystring(lbox->GetStringSelection());
4332 event.m_commandInt = lbox->GetSelection();
4333 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4335 event.m_eventObject = lbox;
4337 lbox->ProcessCommand(event);
4339 if (event.m_commandString)
4340 delete[] event.m_commandString;
4344 wxButton *but = GetDefaultItem();
4347 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4348 event.SetEventObject(but);
4349 but->Command(event);
4354 void wxWindow::Clear()
4356 wxClientDC
dc(this);
4357 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4358 dc
.SetBackground(brush
);
4362 // Fits the panel around the items
4363 void wxWindow::Fit()
4367 wxNode
*node
= GetChildren().First();
4370 wxWindow
*win
= (wxWindow
*)node
->Data();
4372 win
->GetPosition(&wx
, &wy
);
4373 win
->GetSize(&ww
, &wh
);
4374 if ( wx
+ ww
> maxX
)
4376 if ( wy
+ wh
> maxY
)
4379 node
= node
->Next();
4381 SetClientSize(maxX
+ 5, maxY
+ 5);
4384 void wxWindow::SetValidator(const wxValidator
& validator
)
4386 if ( m_windowValidator
)
4387 delete m_windowValidator
;
4388 m_windowValidator
= validator
.Clone();
4390 if ( m_windowValidator
)
4391 m_windowValidator
->SetWindow(this) ;
4394 // Find a window by id or name
4395 wxWindow
*wxWindow::FindWindow(long id
)
4400 wxNode
*node
= GetChildren().First();
4403 wxWindow
*child
= (wxWindow
*)node
->Data();
4404 wxWindow
*found
= child
->FindWindow(id
);
4407 node
= node
->Next();
4412 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4414 if ( GetName() == name
)
4417 wxNode
*node
= GetChildren().First();
4420 wxWindow
*child
= (wxWindow
*)node
->Data();
4421 wxWindow
*found
= child
->FindWindow(name
);
4424 node
= node
->Next();
4430 // Default input behaviour for a scrolling canvas should be to scroll
4431 // according to the cursor keys pressed
4432 void wxWindow::OnChar(wxKeyEvent& event)
4444 GetScrollUnitsPerPage(&x_page, &y_page);
4446 GetVirtualSize(&v_width,&v_height);
4448 ViewStart(&start_x, &start_y);
4451 y_pages = (int)(v_height/vert_units) - y_page;
4459 switch (event.keyCode)
4466 if (start_y - y_page > 0)
4467 Scroll(start_x, start_y - y_page);
4477 if ((y_page > 0) && (start_y <= y_pages-y-1))
4479 if (y_pages + y < start_y + y_page)
4480 Scroll(start_x, y_pages + y);
4482 Scroll(start_x, start_y + y_page);
4489 if ((y_page > 0) && (start_y >= 1))
4490 Scroll(start_x, start_y - 1);
4496 if ((y_page > 0) && (start_y <= y_pages-y-1))
4499 Scroll(start_x, start_y + 1);
4505 if ((x_page > 0) && (start_x >= 1))
4506 Scroll(start_x - 1, start_y);
4512 Scroll(start_x + 1, start_y);
4523 Scroll(start_x, y_pages+y);
4531 // Setup background and foreground colours correctly
4532 void wxWindow::SetupColours()
4535 SetBackgroundColour(GetParent()->GetBackgroundColour());
4538 void wxWindow::OnIdle(wxIdleEvent
& event
)
4540 // Check if we need to send a LEAVE event
4541 if (m_mouseInWindow
)
4544 ::GetCursorPos(&pt
);
4545 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4547 // Generate a LEAVE event
4548 m_mouseInWindow
= FALSE
;
4551 if (::GetKeyState(VK_SHIFT
) != 0)
4553 if (::GetKeyState(VK_CONTROL
) != 0)
4554 state
|= MK_CONTROL
;
4556 // Unfortunately the mouse button and keyboard state may have changed
4557 // by the time the OnIdle function is called, so 'state' may be
4560 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4566 // Raise the window to the top of the Z order
4567 void wxWindow::Raise()
4569 ::BringWindowToTop((HWND
) GetHWND());
4572 // Lower the window to the bottom of the Z order
4573 void wxWindow::Lower()
4575 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4578 long wxWindow::MSWGetDlgCode()
4580 // default: just forward to def window proc (the msg has no parameters)
4581 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4584 bool wxWindow::AcceptsFocus() const
4586 // invisible and disabled controls don't need focus
4587 return IsShown() && IsEnabled();
4590 // Update region access
4591 wxRegion
wxWindow::GetUpdateRegion() const
4593 return m_updateRegion
;
4596 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4598 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4601 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4603 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4606 bool wxWindow::IsExposed(const wxRect
& rect
) const
4608 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4611 // Set this window to be the child of 'parent'.
4612 bool wxWindow::Reparent(wxWindow
*parent
)
4614 if (parent
== GetParent())
4617 // Unlink this window from the existing parent.
4620 GetParent()->RemoveChild(this);
4623 wxTopLevelWindows
.DeleteObject(this);
4625 HWND hWndParent
= 0;
4626 HWND hWndChild
= (HWND
) GetHWND();
4627 if (parent
!= (wxWindow
*) NULL
)
4629 parent
->AddChild(this);
4630 hWndParent
= (HWND
) parent
->GetHWND();
4633 wxTopLevelWindows
.Append(this);
4635 ::SetParent(hWndChild
, hWndParent
);
4641 const char *wxGetMessageName(int message
)
4643 switch ( message
) {
4644 case 0x0000: return "WM_NULL";
4645 case 0x0001: return "WM_CREATE";
4646 case 0x0002: return "WM_DESTROY";
4647 case 0x0003: return "WM_MOVE";
4648 case 0x0005: return "WM_SIZE";
4649 case 0x0006: return "WM_ACTIVATE";
4650 case 0x0007: return "WM_SETFOCUS";
4651 case 0x0008: return "WM_KILLFOCUS";
4652 case 0x000A: return "WM_ENABLE";
4653 case 0x000B: return "WM_SETREDRAW";
4654 case 0x000C: return "WM_SETTEXT";
4655 case 0x000D: return "WM_GETTEXT";
4656 case 0x000E: return "WM_GETTEXTLENGTH";
4657 case 0x000F: return "WM_PAINT";
4658 case 0x0010: return "WM_CLOSE";
4659 case 0x0011: return "WM_QUERYENDSESSION";
4660 case 0x0012: return "WM_QUIT";
4661 case 0x0013: return "WM_QUERYOPEN";
4662 case 0x0014: return "WM_ERASEBKGND";
4663 case 0x0015: return "WM_SYSCOLORCHANGE";
4664 case 0x0016: return "WM_ENDSESSION";
4665 case 0x0017: return "WM_SYSTEMERROR";
4666 case 0x0018: return "WM_SHOWWINDOW";
4667 case 0x0019: return "WM_CTLCOLOR";
4668 case 0x001A: return "WM_WININICHANGE";
4669 case 0x001B: return "WM_DEVMODECHANGE";
4670 case 0x001C: return "WM_ACTIVATEAPP";
4671 case 0x001D: return "WM_FONTCHANGE";
4672 case 0x001E: return "WM_TIMECHANGE";
4673 case 0x001F: return "WM_CANCELMODE";
4674 case 0x0020: return "WM_SETCURSOR";
4675 case 0x0021: return "WM_MOUSEACTIVATE";
4676 case 0x0022: return "WM_CHILDACTIVATE";
4677 case 0x0023: return "WM_QUEUESYNC";
4678 case 0x0024: return "WM_GETMINMAXINFO";
4679 case 0x0026: return "WM_PAINTICON";
4680 case 0x0027: return "WM_ICONERASEBKGND";
4681 case 0x0028: return "WM_NEXTDLGCTL";
4682 case 0x002A: return "WM_SPOOLERSTATUS";
4683 case 0x002B: return "WM_DRAWITEM";
4684 case 0x002C: return "WM_MEASUREITEM";
4685 case 0x002D: return "WM_DELETEITEM";
4686 case 0x002E: return "WM_VKEYTOITEM";
4687 case 0x002F: return "WM_CHARTOITEM";
4688 case 0x0030: return "WM_SETFONT";
4689 case 0x0031: return "WM_GETFONT";
4690 case 0x0037: return "WM_QUERYDRAGICON";
4691 case 0x0039: return "WM_COMPAREITEM";
4692 case 0x0041: return "WM_COMPACTING";
4693 case 0x0044: return "WM_COMMNOTIFY";
4694 case 0x0046: return "WM_WINDOWPOSCHANGING";
4695 case 0x0047: return "WM_WINDOWPOSCHANGED";
4696 case 0x0048: return "WM_POWER";
4699 case 0x004A: return "WM_COPYDATA";
4700 case 0x004B: return "WM_CANCELJOURNAL";
4701 case 0x004E: return "WM_NOTIFY";
4702 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4703 case 0x0051: return "WM_INPUTLANGCHANGE";
4704 case 0x0052: return "WM_TCARD";
4705 case 0x0053: return "WM_HELP";
4706 case 0x0054: return "WM_USERCHANGED";
4707 case 0x0055: return "WM_NOTIFYFORMAT";
4708 case 0x007B: return "WM_CONTEXTMENU";
4709 case 0x007C: return "WM_STYLECHANGING";
4710 case 0x007D: return "WM_STYLECHANGED";
4711 case 0x007E: return "WM_DISPLAYCHANGE";
4712 case 0x007F: return "WM_GETICON";
4713 case 0x0080: return "WM_SETICON";
4716 case 0x0081: return "WM_NCCREATE";
4717 case 0x0082: return "WM_NCDESTROY";
4718 case 0x0083: return "WM_NCCALCSIZE";
4719 case 0x0084: return "WM_NCHITTEST";
4720 case 0x0085: return "WM_NCPAINT";
4721 case 0x0086: return "WM_NCACTIVATE";
4722 case 0x0087: return "WM_GETDLGCODE";
4723 case 0x00A0: return "WM_NCMOUSEMOVE";
4724 case 0x00A1: return "WM_NCLBUTTONDOWN";
4725 case 0x00A2: return "WM_NCLBUTTONUP";
4726 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4727 case 0x00A4: return "WM_NCRBUTTONDOWN";
4728 case 0x00A5: return "WM_NCRBUTTONUP";
4729 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4730 case 0x00A7: return "WM_NCMBUTTONDOWN";
4731 case 0x00A8: return "WM_NCMBUTTONUP";
4732 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4733 case 0x0100: return "WM_KEYDOWN";
4734 case 0x0101: return "WM_KEYUP";
4735 case 0x0102: return "WM_CHAR";
4736 case 0x0103: return "WM_DEADCHAR";
4737 case 0x0104: return "WM_SYSKEYDOWN";
4738 case 0x0105: return "WM_SYSKEYUP";
4739 case 0x0106: return "WM_SYSCHAR";
4740 case 0x0107: return "WM_SYSDEADCHAR";
4741 case 0x0108: return "WM_KEYLAST";
4744 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4745 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4746 case 0x010F: return "WM_IME_COMPOSITION";
4749 case 0x0110: return "WM_INITDIALOG";
4750 case 0x0111: return "WM_COMMAND";
4751 case 0x0112: return "WM_SYSCOMMAND";
4752 case 0x0113: return "WM_TIMER";
4753 case 0x0114: return "WM_HSCROLL";
4754 case 0x0115: return "WM_VSCROLL";
4755 case 0x0116: return "WM_INITMENU";
4756 case 0x0117: return "WM_INITMENUPOPUP";
4757 case 0x011F: return "WM_MENUSELECT";
4758 case 0x0120: return "WM_MENUCHAR";
4759 case 0x0121: return "WM_ENTERIDLE";
4760 case 0x0200: return "WM_MOUSEMOVE";
4761 case 0x0201: return "WM_LBUTTONDOWN";
4762 case 0x0202: return "WM_LBUTTONUP";
4763 case 0x0203: return "WM_LBUTTONDBLCLK";
4764 case 0x0204: return "WM_RBUTTONDOWN";
4765 case 0x0205: return "WM_RBUTTONUP";
4766 case 0x0206: return "WM_RBUTTONDBLCLK";
4767 case 0x0207: return "WM_MBUTTONDOWN";
4768 case 0x0208: return "WM_MBUTTONUP";
4769 case 0x0209: return "WM_MBUTTONDBLCLK";
4770 case 0x0210: return "WM_PARENTNOTIFY";
4771 case 0x0211: return "WM_ENTERMENULOOP";
4772 case 0x0212: return "WM_EXITMENULOOP";
4775 case 0x0213: return "WM_NEXTMENU";
4776 case 0x0214: return "WM_SIZING";
4777 case 0x0215: return "WM_CAPTURECHANGED";
4778 case 0x0216: return "WM_MOVING";
4779 case 0x0218: return "WM_POWERBROADCAST";
4780 case 0x0219: return "WM_DEVICECHANGE";
4783 case 0x0220: return "WM_MDICREATE";
4784 case 0x0221: return "WM_MDIDESTROY";
4785 case 0x0222: return "WM_MDIACTIVATE";
4786 case 0x0223: return "WM_MDIRESTORE";
4787 case 0x0224: return "WM_MDINEXT";
4788 case 0x0225: return "WM_MDIMAXIMIZE";
4789 case 0x0226: return "WM_MDITILE";
4790 case 0x0227: return "WM_MDICASCADE";
4791 case 0x0228: return "WM_MDIICONARRANGE";
4792 case 0x0229: return "WM_MDIGETACTIVE";
4793 case 0x0230: return "WM_MDISETMENU";
4794 case 0x0233: return "WM_DROPFILES";
4797 case 0x0281: return "WM_IME_SETCONTEXT";
4798 case 0x0282: return "WM_IME_NOTIFY";
4799 case 0x0283: return "WM_IME_CONTROL";
4800 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4801 case 0x0285: return "WM_IME_SELECT";
4802 case 0x0286: return "WM_IME_CHAR";
4803 case 0x0290: return "WM_IME_KEYDOWN";
4804 case 0x0291: return "WM_IME_KEYUP";
4807 case 0x0300: return "WM_CUT";
4808 case 0x0301: return "WM_COPY";
4809 case 0x0302: return "WM_PASTE";
4810 case 0x0303: return "WM_CLEAR";
4811 case 0x0304: return "WM_UNDO";
4812 case 0x0305: return "WM_RENDERFORMAT";
4813 case 0x0306: return "WM_RENDERALLFORMATS";
4814 case 0x0307: return "WM_DESTROYCLIPBOARD";
4815 case 0x0308: return "WM_DRAWCLIPBOARD";
4816 case 0x0309: return "WM_PAINTCLIPBOARD";
4817 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4818 case 0x030B: return "WM_SIZECLIPBOARD";
4819 case 0x030C: return "WM_ASKCBFORMATNAME";
4820 case 0x030D: return "WM_CHANGECBCHAIN";
4821 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4822 case 0x030F: return "WM_QUERYNEWPALETTE";
4823 case 0x0310: return "WM_PALETTEISCHANGING";
4824 case 0x0311: return "WM_PALETTECHANGED";
4827 // common controls messages - although they're not strictly speaking
4828 // standard, it's nice to decode them nevertheless
4831 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4832 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4833 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4834 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4835 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4836 case 0x1000 + 5: return "LVM_GETITEMA";
4837 case 0x1000 + 75: return "LVM_GETITEMW";
4838 case 0x1000 + 6: return "LVM_SETITEMA";
4839 case 0x1000 + 76: return "LVM_SETITEMW";
4840 case 0x1000 + 7: return "LVM_INSERTITEMA";
4841 case 0x1000 + 77: return "LVM_INSERTITEMW";
4842 case 0x1000 + 8: return "LVM_DELETEITEM";
4843 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4844 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4845 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4846 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4847 case 0x1000 + 13: return "LVM_FINDITEMA";
4848 case 0x1000 + 83: return "LVM_FINDITEMW";
4849 case 0x1000 + 14: return "LVM_GETITEMRECT";
4850 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4851 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4852 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4853 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4854 case 0x1000 + 18: return "LVM_HITTEST";
4855 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4856 case 0x1000 + 20: return "LVM_SCROLL";
4857 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4858 case 0x1000 + 22: return "LVM_ARRANGE";
4859 case 0x1000 + 23: return "LVM_EDITLABELA";
4860 case 0x1000 + 118: return "LVM_EDITLABELW";
4861 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4862 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4863 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4864 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4865 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4866 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4867 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4868 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4869 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4870 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4871 case 0x1000 + 31: return "LVM_GETHEADER";
4872 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4873 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4874 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4875 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4876 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4877 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4878 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4879 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4880 case 0x1000 + 41: return "LVM_GETORIGIN";
4881 case 0x1000 + 42: return "LVM_UPDATE";
4882 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4883 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4884 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4885 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4886 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4887 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4888 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4889 case 0x1000 + 48: return "LVM_SORTITEMS";
4890 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4891 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4892 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4893 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4894 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4895 case 0x1000 + 53: return "LVM_SETICONSPACING";
4896 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4897 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4898 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4899 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4900 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4901 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4902 case 0x1000 + 60: return "LVM_SETHOTITEM";
4903 case 0x1000 + 61: return "LVM_GETHOTITEM";
4904 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4905 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4906 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4907 case 0x1000 + 65: return "LVM_SETWORKAREA";
4910 case 0x1100 + 0: return "TVM_INSERTITEMA";
4911 case 0x1100 + 50: return "TVM_INSERTITEMW";
4912 case 0x1100 + 1: return "TVM_DELETEITEM";
4913 case 0x1100 + 2: return "TVM_EXPAND";
4914 case 0x1100 + 4: return "TVM_GETITEMRECT";
4915 case 0x1100 + 5: return "TVM_GETCOUNT";
4916 case 0x1100 + 6: return "TVM_GETINDENT";
4917 case 0x1100 + 7: return "TVM_SETINDENT";
4918 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4919 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4920 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4921 case 0x1100 + 11: return "TVM_SELECTITEM";
4922 case 0x1100 + 12: return "TVM_GETITEMA";
4923 case 0x1100 + 62: return "TVM_GETITEMW";
4924 case 0x1100 + 13: return "TVM_SETITEMA";
4925 case 0x1100 + 63: return "TVM_SETITEMW";
4926 case 0x1100 + 14: return "TVM_EDITLABELA";
4927 case 0x1100 + 65: return "TVM_EDITLABELW";
4928 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4929 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4930 case 0x1100 + 17: return "TVM_HITTEST";
4931 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4932 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4933 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4934 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4935 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4936 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4937 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4938 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4939 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4942 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4943 case 0x1200 + 1: return "HDM_INSERTITEMA";
4944 case 0x1200 + 10: return "HDM_INSERTITEMW";
4945 case 0x1200 + 2: return "HDM_DELETEITEM";
4946 case 0x1200 + 3: return "HDM_GETITEMA";
4947 case 0x1200 + 11: return "HDM_GETITEMW";
4948 case 0x1200 + 4: return "HDM_SETITEMA";
4949 case 0x1200 + 12: return "HDM_SETITEMW";
4950 case 0x1200 + 5: return "HDM_LAYOUT";
4951 case 0x1200 + 6: return "HDM_HITTEST";
4952 case 0x1200 + 7: return "HDM_GETITEMRECT";
4953 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4954 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4955 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4956 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4957 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4958 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4959 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4962 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4963 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4964 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4965 case 0x1300 + 5: return "TCM_GETITEMA";
4966 case 0x1300 + 60: return "TCM_GETITEMW";
4967 case 0x1300 + 6: return "TCM_SETITEMA";
4968 case 0x1300 + 61: return "TCM_SETITEMW";
4969 case 0x1300 + 7: return "TCM_INSERTITEMA";
4970 case 0x1300 + 62: return "TCM_INSERTITEMW";
4971 case 0x1300 + 8: return "TCM_DELETEITEM";
4972 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4973 case 0x1300 + 10: return "TCM_GETITEMRECT";
4974 case 0x1300 + 11: return "TCM_GETCURSEL";
4975 case 0x1300 + 12: return "TCM_SETCURSEL";
4976 case 0x1300 + 13: return "TCM_HITTEST";
4977 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4978 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4979 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4980 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4981 case 0x1300 + 43: return "TCM_SETPADDING";
4982 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4983 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4984 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4985 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4986 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4987 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4988 case 0x1300 + 50: return "TCM_DESELECTALL";
4991 case WM_USER
+1: return "TB_ENABLEBUTTON";
4992 case WM_USER
+2: return "TB_CHECKBUTTON";
4993 case WM_USER
+3: return "TB_PRESSBUTTON";
4994 case WM_USER
+4: return "TB_HIDEBUTTON";
4995 case WM_USER
+5: return "TB_INDETERMINATE";
4996 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4997 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4998 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4999 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
5000 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
5001 case WM_USER
+17: return "TB_SETSTATE";
5002 case WM_USER
+18: return "TB_GETSTATE";
5003 case WM_USER
+19: return "TB_ADDBITMAP";
5004 case WM_USER
+20: return "TB_ADDBUTTONS";
5005 case WM_USER
+21: return "TB_INSERTBUTTON";
5006 case WM_USER
+22: return "TB_DELETEBUTTON";
5007 case WM_USER
+23: return "TB_GETBUTTON";
5008 case WM_USER
+24: return "TB_BUTTONCOUNT";
5009 case WM_USER
+25: return "TB_COMMANDTOINDEX";
5010 case WM_USER
+26: return "TB_SAVERESTOREA";
5011 case WM_USER
+76: return "TB_SAVERESTOREW";
5012 case WM_USER
+27: return "TB_CUSTOMIZE";
5013 case WM_USER
+28: return "TB_ADDSTRINGA";
5014 case WM_USER
+77: return "TB_ADDSTRINGW";
5015 case WM_USER
+29: return "TB_GETITEMRECT";
5016 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
5017 case WM_USER
+31: return "TB_SETBUTTONSIZE";
5018 case WM_USER
+32: return "TB_SETBITMAPSIZE";
5019 case WM_USER
+33: return "TB_AUTOSIZE";
5020 case WM_USER
+35: return "TB_GETTOOLTIPS";
5021 case WM_USER
+36: return "TB_SETTOOLTIPS";
5022 case WM_USER
+37: return "TB_SETPARENT";
5023 case WM_USER
+39: return "TB_SETROWS";
5024 case WM_USER
+40: return "TB_GETROWS";
5025 case WM_USER
+42: return "TB_SETCMDID";
5026 case WM_USER
+43: return "TB_CHANGEBITMAP";
5027 case WM_USER
+44: return "TB_GETBITMAP";
5028 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
5029 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
5030 case WM_USER
+46: return "TB_REPLACEBITMAP";
5031 case WM_USER
+47: return "TB_SETINDENT";
5032 case WM_USER
+48: return "TB_SETIMAGELIST";
5033 case WM_USER
+49: return "TB_GETIMAGELIST";
5034 case WM_USER
+50: return "TB_LOADIMAGES";
5035 case WM_USER
+51: return "TB_GETRECT";
5036 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
5037 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
5038 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
5039 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
5040 case WM_USER
+56: return "TB_SETSTYLE";
5041 case WM_USER
+57: return "TB_GETSTYLE";
5042 case WM_USER
+58: return "TB_GETBUTTONSIZE";
5043 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
5044 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
5045 case WM_USER
+61: return "TB_GETTEXTROWS";
5046 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
5051 static char s_szBuf
[128];
5052 sprintf(s_szBuf
, "<unknown message = %d>", message
);
5056 #endif //__WXDEBUG__