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"
28 #include "wx/dcclient.h"
32 #include "wx/layout.h"
33 #include "wx/dialog.h"
35 #include "wx/listbox.h"
36 #include "wx/button.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
46 #include "wx/msw/ole/droptgt.h"
49 #include "wx/menuitem.h"
51 #include "wx/tooltip.h"
53 #include "wx/msw/private.h"
66 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
72 #include <wx/msw/gnuwin32/extra.h>
76 // all these are defined in <windows.h>
94 const char *wxGetMessageName(int message
);
97 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
99 wxMenu
*wxCurrentPopupMenu
= NULL
;
100 extern wxList WXDLLEXPORT wxPendingDelete
;
102 void wxRemoveHandleAssociation(wxWindow
*win
);
103 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
104 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
106 #if !USE_SHARED_LIBRARY
107 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
110 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
111 EVT_CHAR(wxWindow::OnChar
)
112 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
113 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
114 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
115 EVT_IDLE(wxWindow::OnIdle
)
118 // Find an item given the MS Windows id
119 wxWindow
*wxWindow::FindItem(int id
) const
121 // if (!GetChildren())
123 wxNode
*current
= GetChildren().First();
126 wxWindow
*childWin
= (wxWindow
*)current
->Data();
128 wxWindow
*wnd
= childWin
->FindItem(id
) ;
132 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
134 wxControl
*item
= (wxControl
*)childWin
;
135 if (item
->GetId() == id
)
139 // In case it's a 'virtual' control (e.g. radiobox)
140 if (item
->GetSubcontrols().Member((wxObject
*)id
))
144 current
= current
->Next();
149 // Find an item given the MS Windows handle
150 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
152 // if (!GetChildren())
154 wxNode
*current
= GetChildren().First();
157 wxObject
*obj
= (wxObject
*)current
->Data() ;
158 // Do a recursive search.
159 wxWindow
*parent
= (wxWindow
*)obj
;
160 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
164 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
166 wxWindow
*item
= (wxWindow
*)current
->Data();
167 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
171 if ( item
->ContainsHWND(hWnd
) )
175 current
= current
->Next();
180 // Default command handler
181 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
186 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
188 WXLPARAM
* WXUNUSED(result
))
191 NMHDR
* hdr
= (NMHDR
*)lParam
;
192 if ( hdr
->code
== TTN_NEEDTEXT
&& m_tooltip
)
194 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
195 ttt
->lpszText
= (char *)m_tooltip
->GetTip().c_str();
205 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
209 WXHWND
wxWindow::GetHWND(void) const
211 return (WXHWND
) m_hWnd
;
214 void wxWindow::SetHWND(WXHWND hWnd
)
219 // ----------------------------------------------------------------------------
220 // constructors and such
221 // ----------------------------------------------------------------------------
223 void wxWindow::Init()
229 m_windowParent
= NULL
;
230 m_windowEventHandler
= this;
231 m_windowCursor
= *wxSTANDARD_CURSOR
;
232 m_children
= new wxList
;
233 m_doubleClickAllowed
= 0 ;
234 m_winCaptured
= FALSE
;
235 m_constraints
= NULL
;
236 m_constraintsInvolvedIn
= NULL
;
237 m_windowSizer
= NULL
;
238 m_sizerParent
= NULL
;
239 m_autoLayout
= FALSE
;
240 m_windowValidator
= NULL
;
245 m_caretWidth
= m_caretHeight
= 0;
247 m_caretShown
= FALSE
;
254 m_isBeingDeleted
= FALSE
;
260 m_mouseInWindow
= FALSE
;
262 m_windowParent
= NULL
;
263 m_defaultItem
= NULL
;
265 wxSystemSettings settings
;
267 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
268 m_foregroundColour
= *wxBLACK
;
278 m_backgroundTransparent
= FALSE
;
280 m_lastXPos
= (float)-1.0;
281 m_lastYPos
= (float)-1.0;
285 #if wxUSE_DRAG_AND_DROP
286 m_pDropTarget
= NULL
;
298 wxWindow::~wxWindow()
300 m_isBeingDeleted
= TRUE
;
302 // first of all, delete the things on which nothing else depends
306 // JACS - if behaviour is odd, restore this
307 // to the start of ~wxWindow. Vadim has changed
308 // it to nearer the end. Unsure of side-effects
309 // e.g. when deleting associated global data.
310 // Restore old Window proc, if required
313 // Have to delete constraints/sizer FIRST otherwise
314 // sizers may try to look at deleted windows as they
315 // delete themselves.
316 #if wxUSE_CONSTRAINTS
317 DeleteRelatedConstraints();
321 // This removes any dangling pointers to this window
322 // in other windows' constraintsInvolvedIn lists.
323 UnsetConstraints(m_constraints
);
324 delete m_constraints
;
325 m_constraints
= NULL
;
328 wxDELETE(m_windowSizer
);
330 // If this is a child of a sizer, remove self from parent
332 m_sizerParent
->RemoveChild((wxWindow
*)this);
336 MSWDetachWindowMenu();
339 m_windowParent
->RemoveChild(this);
344 ::DestroyWindow((HWND
)m_hWnd
);
346 wxRemoveHandleAssociation(this);
351 GlobalFree((HGLOBAL
) m_globalHandle
);
359 // Just in case the window has been Closed, but
360 // we're then deleting immediately: don't leave
361 // dangling pointers.
362 wxPendingDelete
.DeleteObject(this);
364 // Just in case we've loaded a top-level window via
365 // wxWindow::LoadNativeDialog but we weren't a dialog
367 wxTopLevelWindows
.DeleteObject(this);
369 if ( m_windowValidator
)
370 delete m_windowValidator
;
372 // Restore old Window proc, if required
373 // and remove hWnd <-> wxWindow association
377 // Destroy the window (delayed, if a managed window)
378 bool wxWindow::Destroy()
384 extern char wxCanvasClassName
[];
386 // real construction (Init() must have been called before!)
387 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
391 const wxString
& name
)
393 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
395 parent
->AddChild(this);
400 m_windowId
= (int)NewControlId();
409 // To be consistent with wxGTK
415 wxSystemSettings settings
;
417 m_windowStyle
= style
;
420 if (style
& wxBORDER
)
421 msflags
|= WS_BORDER
;
422 if (style
& wxTHICK_FRAME
)
423 msflags
|= WS_THICKFRAME
;
425 msflags
|= WS_CHILD
| WS_VISIBLE
;
426 if (style
& wxCLIP_CHILDREN
)
427 msflags
|= WS_CLIPCHILDREN
;
430 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
432 // Even with extended styles, need to combine with WS_BORDER
433 // for them to look right.
434 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
435 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
436 msflags
|= WS_BORDER
;
438 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
439 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
444 void wxWindow::SetFocus()
446 HWND hWnd
= (HWND
) GetHWND();
451 void wxWindow::Enable(bool enable
)
453 m_winEnabled
= enable
;
454 HWND hWnd
= (HWND
) GetHWND();
456 ::EnableWindow(hWnd
, (BOOL
)enable
);
459 void wxWindow::CaptureMouse()
461 HWND hWnd
= (HWND
) GetHWND();
462 if (hWnd
&& !m_winCaptured
)
465 m_winCaptured
= TRUE
;
469 void wxWindow::ReleaseMouse()
474 m_winCaptured
= FALSE
;
478 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
480 m_acceleratorTable
= accel
;
484 // Push/pop event handler (i.e. allow a chain of event handlers
486 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
488 handler
->SetNextHandler(GetEventHandler());
489 SetEventHandler(handler
);
492 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
494 if ( GetEventHandler() )
496 wxEvtHandler
*handlerA
= GetEventHandler();
497 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
498 handlerA
->SetNextHandler(NULL
);
499 SetEventHandler(handlerB
);
512 #if wxUSE_DRAG_AND_DROP
514 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
516 if ( m_pDropTarget
!= 0 ) {
517 m_pDropTarget
->Revoke(m_hWnd
);
518 delete m_pDropTarget
;
521 m_pDropTarget
= pDropTarget
;
522 if ( m_pDropTarget
!= 0 )
523 m_pDropTarget
->Register(m_hWnd
);
526 #endif // wxUSE_DRAG_AND_DROP
529 //old style file-manager drag&drop support
530 // I think we should retain the old-style
531 // DragAcceptFiles in parallel with SetDropTarget.
533 void wxWindow::DragAcceptFiles(bool accept
)
535 HWND hWnd
= (HWND
) GetHWND();
537 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
540 // ----------------------------------------------------------------------------
542 // ----------------------------------------------------------------------------
544 void wxWindow::SetToolTip(const wxString
&tip
)
546 SetToolTip(new wxToolTip(tip
));
549 void wxWindow::SetToolTip(wxToolTip
*tooltip
)
555 m_tooltip
->SetWindow(this);
559 void wxWindow::GetSize(int *x
, int *y
) const
561 HWND hWnd
= (HWND
) GetHWND();
563 GetWindowRect(hWnd
, &rect
);
564 *x
= rect
.right
- rect
.left
;
565 *y
= rect
.bottom
- rect
.top
;
568 void wxWindow::GetPosition(int *x
, int *y
) const
570 HWND hWnd
= (HWND
) GetHWND();
573 hParentWnd
= (HWND
) GetParent()->GetHWND();
576 GetWindowRect(hWnd
, &rect
);
578 // Since we now have the absolute screen coords,
579 // if there's a parent we must subtract its top left corner
585 ::ScreenToClient(hParentWnd
, &point
);
588 // We may be faking the client origin.
589 // So a window that's really at (0, 30) may appear
590 // (to wxWin apps) to be at (0, 0).
593 wxPoint
pt(GetParent()->GetClientAreaOrigin());
601 void wxWindow::ScreenToClient(int *x
, int *y
) const
603 HWND hWnd
= (HWND
) GetHWND();
608 ::ScreenToClient(hWnd
, &pt
);
614 void wxWindow::ClientToScreen(int *x
, int *y
) const
616 HWND hWnd
= (HWND
) GetHWND();
621 ::ClientToScreen(hWnd
, &pt
);
627 void wxWindow::SetCursor(const wxCursor
& cursor
)
629 m_windowCursor
= cursor
;
630 if (m_windowCursor
.Ok())
632 HWND hWnd
= (HWND
) GetHWND();
634 // Change the cursor NOW if we're within the correct window
636 ::GetCursorPos(&point
);
639 ::GetWindowRect(hWnd
, &rect
);
641 if (::PtInRect(&rect
, point
) && !wxIsBusy())
642 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
645 // This will cause big reentrancy problems if wxFlushEvents is implemented.
647 // return old_cursor;
651 // Get size *available for subwindows* i.e. excluding menu bar etc.
652 void wxWindow::GetClientSize(int *x
, int *y
) const
654 HWND hWnd
= (HWND
) GetHWND();
656 GetClientRect(hWnd
, &rect
);
661 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
663 int currentX
, currentY
;
664 GetPosition(¤tX
, ¤tY
);
665 int currentW
,currentH
;
666 GetSize(¤tW
, ¤tH
);
668 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
671 int actualWidth
= width
;
672 int actualHeight
= height
;
675 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
677 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
680 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
683 actualWidth
= currentW
;
685 actualHeight
= currentH
;
687 HWND hWnd
= (HWND
) GetHWND();
689 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
692 void wxWindow::SetClientSize(int width
, int height
)
694 wxWindow
*parent
= GetParent();
695 HWND hWnd
= (HWND
) GetHWND();
696 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
699 GetClientRect(hWnd
, &rect
);
702 GetWindowRect(hWnd
, &rect2
);
704 // Find the difference between the entire window (title bar and all)
705 // and the client area; add this to the new client size to move the
707 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
708 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
710 // If there's a parent, must subtract the parent's top left corner
711 // since MoveWindow moves relative to the parent
714 point
.x
= rect2
.left
;
718 ::ScreenToClient(hParentWnd
, &point
);
721 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
723 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
724 event
.SetEventObject(this);
725 GetEventHandler()->ProcessEvent(event
);
728 // For implementation purposes - sometimes decorations make the client area
730 wxPoint
wxWindow::GetClientAreaOrigin() const
732 return wxPoint(0, 0);
735 // Makes an adjustment to the window position (for example, a frame that has
736 // a toolbar that it manages itself).
737 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
739 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
741 wxPoint
pt(GetParent()->GetClientAreaOrigin());
742 x
+= pt
.x
; y
+= pt
.y
;
746 bool wxWindow::Show(bool show
)
748 HWND hWnd
= (HWND
) GetHWND();
754 ShowWindow(hWnd
, (BOOL
)cshow
);
757 BringWindowToTop(hWnd
);
758 // Next line causes a crash on NT, apparently.
759 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
764 bool wxWindow::IsShown(void) const
766 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
769 int wxWindow::GetCharHeight(void) const
771 TEXTMETRIC lpTextMetric
;
772 HWND hWnd
= (HWND
) GetHWND();
773 HDC dc
= ::GetDC(hWnd
);
775 GetTextMetrics(dc
, &lpTextMetric
);
776 ::ReleaseDC(hWnd
, dc
);
778 return lpTextMetric
.tmHeight
;
781 int wxWindow::GetCharWidth(void) const
783 TEXTMETRIC lpTextMetric
;
784 HWND hWnd
= (HWND
) GetHWND();
785 HDC dc
= ::GetDC(hWnd
);
787 GetTextMetrics(dc
, &lpTextMetric
);
788 ::ReleaseDC(hWnd
, dc
);
790 return lpTextMetric
.tmAveCharWidth
;
793 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
794 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
796 wxFont
*fontToUse
= (wxFont
*)theFont
;
798 fontToUse
= (wxFont
*) & m_windowFont
;
800 HWND hWnd
= (HWND
) GetHWND();
801 HDC dc
= ::GetDC(hWnd
);
805 if (fontToUse
&& fontToUse
->Ok())
807 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
809 was
= (HFONT
) SelectObject(dc
,fnt
) ;
814 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
815 GetTextMetrics(dc
, &tm
);
817 if (fontToUse
&& fnt
&& was
)
818 SelectObject(dc
,was
) ;
824 if (descent
) *descent
= tm
.tmDescent
;
825 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
828 // fontToUse->ReleaseResource();
831 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
833 HWND hWnd
= (HWND
) GetHWND();
839 mswRect
.left
= rect
->x
;
840 mswRect
.top
= rect
->y
;
841 mswRect
.right
= rect
->x
+ rect
->width
;
842 mswRect
.bottom
= rect
->y
+ rect
->height
;
844 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
847 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
851 bool wxWindow::ProcessEvent(wxEvent
& event
)
853 // we save here the information about the last message because it might be
854 // overwritten if the event handler sends any messages to our window (case
855 // in point: wxNotebook::OnSize) - and then if we call Default() later
856 // (which is done quite often if the message is not processed) it will use
857 // incorrect values for m_lastXXX variables
858 WXUINT lastMsg
= m_lastMsg
;
859 WXWPARAM lastWParam
= m_lastWParam
;
860 WXLPARAM lastLParam
= m_lastLParam
;
862 // call the base version
863 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
867 m_lastWParam
= lastWParam
;
868 m_lastLParam
= lastLParam
;
873 // Hook for new window just as it's being created,
874 // when the window isn't yet associated with the handle
875 wxWindow
*wxWndHook
= NULL
;
878 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
880 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
882 if (!wnd
&& wxWndHook
)
884 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
887 wnd
->m_hWnd
= (WXHWND
) hWnd
;
890 // Stop right here if we don't have a valid handle
891 // in our wxWnd object.
892 if (wnd
&& !wnd
->m_hWnd
) {
893 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
894 wnd
->m_hWnd
= (WXHWND
) hWnd
;
895 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
901 wnd
->m_lastMsg
= message
;
902 wnd
->m_lastWParam
= wParam
;
903 wnd
->m_lastLParam
= lParam
;
906 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
908 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
911 // Should probably have a test for 'genuine' NT
912 #if defined(__WIN32__)
913 #define DIMENSION_TYPE short
915 #define DIMENSION_TYPE int
918 // Main Windows 3 window proc
919 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
921 wxASSERT( m_lastMsg
== message
&&
922 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
925 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
926 wxGetMessageName(message
), wParam
, lParam
);
927 #endif // __WXDEBUG__
929 HWND hWnd
= (HWND
)m_hWnd
;
936 WORD state
= LOWORD(wParam
);
937 WORD minimized
= HIWORD(wParam
);
938 HWND hwnd
= (HWND
)lParam
;
940 WORD state
= (WORD
)wParam
;
941 WORD minimized
= LOWORD(lParam
);
942 HWND hwnd
= (HWND
)HIWORD(lParam
);
944 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
950 HWND hwnd
= (HWND
)wParam
;
951 // return OnSetFocus(hwnd);
953 if (MSWOnSetFocus((WXHWND
) hwnd
))
955 else return MSWDefWindowProc(message
, wParam
, lParam
);
960 HWND hwnd
= (HWND
)lParam
;
961 // return OnKillFocus(hwnd);
962 if (MSWOnKillFocus((WXHWND
) hwnd
))
965 return MSWDefWindowProc(message
, wParam
, lParam
);
970 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
976 MSWOnShow((wParam
!= 0), (int) lParam
);
983 else return MSWDefWindowProc(message
, wParam
, lParam
);
986 case WM_QUERYDRAGICON
:
988 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
992 return MSWDefWindowProc(message
, wParam
, lParam
);
998 int width
= LOWORD(lParam
);
999 int height
= HIWORD(lParam
);
1000 MSWOnSize(width
, height
, wParam
);
1006 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1008 event
.SetEventObject(this);
1009 if ( !GetEventHandler()->ProcessEvent(event
) )
1014 case WM_WINDOWPOSCHANGING
:
1016 MSWOnWindowPosChanging((void *)lParam
);
1020 case WM_RBUTTONDOWN
:
1022 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1023 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1024 MSWOnRButtonDown(x
, y
, wParam
);
1029 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1030 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1031 MSWOnRButtonUp(x
, y
, wParam
);
1034 case WM_RBUTTONDBLCLK
:
1036 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1037 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1038 MSWOnRButtonDClick(x
, y
, wParam
);
1041 case WM_MBUTTONDOWN
:
1043 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1044 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1045 MSWOnMButtonDown(x
, y
, wParam
);
1050 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1051 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1052 MSWOnMButtonUp(x
, y
, wParam
);
1055 case WM_MBUTTONDBLCLK
:
1057 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1058 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1059 MSWOnMButtonDClick(x
, y
, wParam
);
1062 case WM_LBUTTONDOWN
:
1064 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1065 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1066 MSWOnLButtonDown(x
, y
, wParam
);
1071 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1072 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1073 MSWOnLButtonUp(x
, y
, wParam
);
1076 case WM_LBUTTONDBLCLK
:
1078 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1079 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1080 MSWOnLButtonDClick(x
, y
, wParam
);
1085 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1086 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1087 MSWOnMouseMove(x
, y
, wParam
);
1090 case MM_JOY1BUTTONDOWN
:
1092 int x
= LOWORD(lParam
);
1093 int y
= HIWORD(lParam
);
1094 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1097 case MM_JOY2BUTTONDOWN
:
1099 int x
= LOWORD(lParam
);
1100 int y
= HIWORD(lParam
);
1101 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1104 case MM_JOY1BUTTONUP
:
1106 int x
= LOWORD(lParam
);
1107 int y
= HIWORD(lParam
);
1108 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1111 case MM_JOY2BUTTONUP
:
1113 int x
= LOWORD(lParam
);
1114 int y
= HIWORD(lParam
);
1115 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1120 int x
= LOWORD(lParam
);
1121 int y
= HIWORD(lParam
);
1122 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1127 int x
= LOWORD(lParam
);
1128 int y
= HIWORD(lParam
);
1129 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1134 int z
= LOWORD(lParam
);
1135 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1140 int z
= LOWORD(lParam
);
1141 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1148 else return MSWDefWindowProc(message
, wParam
, lParam
);
1153 return MSWOnSysCommand(wParam
, lParam
);
1159 WORD id
= LOWORD(wParam
);
1160 HWND hwnd
= (HWND
)lParam
;
1161 WORD cmd
= HIWORD(wParam
);
1163 WORD id
= (WORD
)wParam
;
1164 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1165 WORD cmd
= HIWORD(lParam
);
1167 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1168 return MSWDefWindowProc(message
, wParam
, lParam
);
1171 #if defined(__WIN95__)
1174 // for some messages (TVN_ITEMEXPANDING for example), the return
1175 // value of WM_NOTIFY handler is important, so don't just return 0
1176 // if we processed the message
1177 return MSWOnNotify(wParam
, lParam
);
1183 WORD flags
= HIWORD(wParam
);
1184 HMENU sysmenu
= (HMENU
)lParam
;
1186 WORD flags
= LOWORD(lParam
);
1187 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1189 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1192 case WM_INITMENUPOPUP
:
1194 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1199 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1202 case WM_MEASUREITEM
:
1204 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1210 MSWOnKeyDown((WORD
) wParam
, lParam
);
1211 // we consider these message "not interesting"
1212 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1215 // Avoid duplicate messages to OnChar
1216 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1217 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1218 (wParam
!= VK_TAB
) )
1220 MSWOnChar((WORD
)wParam
, lParam
);
1221 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1224 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1225 MSWOnChar((WORD
)wParam
, lParam
);
1233 MSWOnKeyUp((WORD
) wParam
, lParam
);
1236 case WM_CHAR
: // Always an ASCII character
1238 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1245 WORD code
= LOWORD(wParam
);
1246 WORD pos
= HIWORD(wParam
);
1247 HWND control
= (HWND
)lParam
;
1249 WORD code
= (WORD
)wParam
;
1250 WORD pos
= LOWORD(lParam
);
1251 HWND control
= (HWND
)HIWORD(lParam
);
1253 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1259 WORD code
= LOWORD(wParam
);
1260 WORD pos
= HIWORD(wParam
);
1261 HWND control
= (HWND
)lParam
;
1263 WORD code
= (WORD
)wParam
;
1264 WORD pos
= LOWORD(lParam
);
1265 HWND control
= (HWND
)HIWORD(lParam
);
1267 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1271 case WM_CTLCOLORBTN
:
1273 int nCtlColor
= CTLCOLOR_BTN
;
1274 HWND control
= (HWND
)lParam
;
1275 HDC pDC
= (HDC
)wParam
;
1276 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1277 message
, wParam
, lParam
);
1280 case WM_CTLCOLORDLG
:
1282 int nCtlColor
= CTLCOLOR_DLG
;
1283 HWND control
= (HWND
)lParam
;
1284 HDC pDC
= (HDC
)wParam
;
1285 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1286 message
, wParam
, lParam
);\
1289 case WM_CTLCOLORLISTBOX
:
1291 int nCtlColor
= CTLCOLOR_LISTBOX
;
1292 HWND control
= (HWND
)lParam
;
1293 HDC pDC
= (HDC
)wParam
;
1294 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1295 message
, wParam
, lParam
);
1298 case WM_CTLCOLORMSGBOX
:
1300 int nCtlColor
= CTLCOLOR_MSGBOX
;
1301 HWND control
= (HWND
)lParam
;
1302 HDC pDC
= (HDC
)wParam
;
1303 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1304 message
, wParam
, lParam
);
1307 case WM_CTLCOLORSCROLLBAR
:
1309 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1310 HWND control
= (HWND
)lParam
;
1311 HDC pDC
= (HDC
)wParam
;
1312 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1313 message
, wParam
, lParam
);
1316 case WM_CTLCOLORSTATIC
:
1318 int nCtlColor
= CTLCOLOR_STATIC
;
1319 HWND control
= (HWND
)lParam
;
1320 HDC pDC
= (HDC
)wParam
;
1321 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1322 message
, wParam
, lParam
);
1325 case WM_CTLCOLOREDIT
:
1327 int nCtlColor
= CTLCOLOR_EDIT
;
1328 HWND control
= (HWND
)lParam
;
1329 HDC pDC
= (HDC
)wParam
;
1330 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1331 message
, wParam
, lParam
);
1337 HWND control
= (HWND
)LOWORD(lParam
);
1338 int nCtlColor
= (int)HIWORD(lParam
);
1339 HDC pDC
= (HDC
)wParam
;
1340 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1341 message
, wParam
, lParam
);
1345 case WM_SYSCOLORCHANGE
:
1347 // Return value of 0 means, we processed it.
1348 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1351 return MSWDefWindowProc(message
, wParam
, lParam
);
1354 case WM_PALETTECHANGED
:
1356 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1359 case WM_QUERYNEWPALETTE
:
1361 return MSWOnQueryNewPalette();
1366 // Prevents flicker when dragging
1367 if (IsIconic(hWnd
)) return 1;
1369 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1370 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1374 case WM_MDIACTIVATE
:
1377 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1378 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1379 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1380 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1382 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1383 (HWND
)HIWORD(lParam
));
1388 MSWOnDropFiles(wParam
);
1393 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1396 case WM_QUERYENDSESSION
:
1398 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1399 // return MSWOnClose();
1401 return MSWOnQueryEndSession(lParam
);
1406 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1407 MSWOnEndSession((wParam
!= 0), lParam
);
1420 case WM_GETMINMAXINFO
:
1422 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1423 if (m_minSizeX
!= -1)
1424 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1425 if (m_minSizeY
!= -1)
1426 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1427 if (m_maxSizeX
!= -1)
1428 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1429 if (m_maxSizeY
!= -1)
1430 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1431 return MSWDefWindowProc(message
, wParam
, lParam
);
1436 return MSWGetDlgCode();
1439 return MSWDefWindowProc(message
, wParam
, lParam
);
1441 return 0; // Success: we processed this command.
1444 // Dialog window proc
1445 LONG APIENTRY _EXPORT
1446 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1451 wxList
*wxWinHandleList
= NULL
;
1452 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1454 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1457 return (wxWindow
*)node
->Data();
1460 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1462 // adding NULL hWnd is (first) surely a result of an error and
1463 // (secondly) breaks menu command processing
1464 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1466 if ( !wxWinHandleList
->Find((long)hWnd
) )
1467 wxWinHandleList
->Append((long)hWnd
, win
);
1470 void wxRemoveHandleAssociation(wxWindow
*win
)
1472 wxWinHandleList
->DeleteObject(win
);
1475 // Default destroyer - override if you destroy it in some other way
1476 // (e.g. with MDI child windows)
1477 void wxWindow::MSWDestroyWindow()
1481 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1482 int x
, int y
, int width
, int height
,
1483 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1485 bool is_dialog
= (dialog_template
!= NULL
);
1486 int x1
= CW_USEDEFAULT
;
1488 int width1
= CW_USEDEFAULT
;
1491 // Find parent's size, if it exists, to set up a possible default
1492 // panel size the size of the parent window
1496 // Was GetWindowRect: JACS 5/5/95
1497 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1499 width1
= parent_rect
.right
- parent_rect
.left
;
1500 height1
= parent_rect
.bottom
- parent_rect
.top
;
1505 if (width
> -1) width1
= width
;
1506 if (height
> -1) height1
= height
;
1508 HWND hParent
= NULL
;
1510 hParent
= (HWND
) parent
->GetHWND();
1516 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1517 // other compilers???
1518 // VZ: it's always needed for Win16 and never for Win32
1520 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1521 (DLGPROC
)wxDlgProc
);
1523 // N.B.: if we _don't_ use this form,
1524 // then with VC++ 1.5, it crashes horribly.
1526 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1527 (DLGPROC
)wxDlgProc
);
1529 // Crashes when we use this.
1530 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1532 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1538 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1539 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1540 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1545 if (style
& WS_CHILD
)
1550 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1555 hParent
, (HMENU
)controlId
, wxGetInstance(),
1559 wxLogError("Can't create window of class %s!\n"
1560 "Possible Windows 3.x compatibility problem?", wclass
);
1565 wxWinHandleList
->Append((long)m_hWnd
, this);
1568 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1572 bool wxWindow::MSWOnClose()
1577 // Some compilers don't define this
1578 #ifndef ENDSESSION_LOGOFF
1579 #define ENDSESSION_LOGOFF 0x80000000
1582 // Return TRUE to end session, FALSE to veto end session.
1583 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1585 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1586 event
.SetEventObject(wxTheApp
);
1587 event
.SetCanVeto(TRUE
);
1588 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1589 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1590 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1592 return FALSE
; // Veto!
1596 return TRUE
; // Don't veto
1600 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1602 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1603 event
.SetEventObject(wxTheApp
);
1604 event
.SetCanVeto(FALSE
);
1605 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1606 if (endSession
&& // No need to send if the session isn't ending
1607 (this == wxTheApp
->GetTopWindow()) && // Only send once
1608 wxTheApp
->ProcessEvent(event
))
1614 bool wxWindow::MSWOnDestroy()
1616 // delete our drop target if we've got one
1617 #if wxUSE_DRAG_AND_DROP
1618 if ( m_pDropTarget
!= NULL
) {
1619 m_pDropTarget
->Revoke(m_hWnd
);
1621 delete m_pDropTarget
;
1622 m_pDropTarget
= NULL
;
1629 // Deal with child commands from buttons etc.
1631 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1633 #if defined(__WIN95__)
1634 // Find a child window to send the notification to, e.g. a toolbar.
1635 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1636 // handle of the toolbar; it's probably the handle of the tooltip
1637 // window (anyway, it's parent is also the toolbar's parent).
1638 // So, since we don't know which hWnd or wxWindow originated the
1639 // WM_NOTIFY, we'll need to go through all the children of this window
1640 // trying out MSWNotify.
1641 // This won't work now, though, because any number of controls
1642 // could respond to the same generic messages :-(
1644 /* This doesn't work for toolbars, but try for other controls first.
1646 NMHDR
*hdr
= (NMHDR
*)lParam
;
1647 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1648 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1650 WXLPARAM result
= 0;
1654 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1659 // Rely on MSWNotify to check whether the message
1660 // belongs to the window or not
1661 wxNode
*node
= GetChildren().First();
1664 wxWindow
*child
= (wxWindow
*)node
->Data();
1665 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1667 node
= node
->Next();
1670 // finally try this window too (catches toolbar case)
1671 if ( MSWNotify(wParam
, lParam
, &result
) )
1680 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1684 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1688 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1690 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1692 event
.SetEventObject(this);
1693 GetEventHandler()->ProcessEvent(event
);
1697 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1700 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1702 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1704 ::ShowCaret((HWND
) GetHWND());
1707 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1708 event
.SetEventObject(this);
1709 if (!GetEventHandler()->ProcessEvent(event
))
1714 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1722 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1723 event
.SetEventObject(this);
1724 if (!GetEventHandler()->ProcessEvent(event
))
1729 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1732 HDROP hFilesInfo
= (HDROP
) wParam
;
1734 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1736 // Get the total number of files dropped
1737 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1742 wxString
*files
= new wxString
[gwFilesDropped
];
1744 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1746 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1747 files
[wIndex
] = wxBuffer
;
1749 DragFinish (hFilesInfo
);
1751 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1752 event
.m_eventObject
= this;
1753 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1755 if (!GetEventHandler()->ProcessEvent(event
))
1761 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1763 #if wxUSE_OWNER_DRAWN
1764 if ( id
== 0 ) { // is it a menu item?
1765 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1766 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1767 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1769 // prepare to call OnDrawItem()
1771 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1772 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1773 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1774 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1775 return pMenuItem
->OnDrawItem(
1777 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1778 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1781 #endif // owner-drawn menus
1783 wxWindow
*item
= FindItem(id
);
1784 #if wxUSE_DYNAMIC_CLASSES
1785 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1787 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1794 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1796 #if wxUSE_OWNER_DRAWN
1797 if ( id
== 0 ) { // is it a menu item?
1798 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1799 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1800 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1802 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1803 &pMeasureStruct
->itemHeight
);
1805 #endif // owner-drawn menus
1807 wxWindow
*item
= FindItem(id
);
1808 #if wxUSE_DYNAMIC_CLASSES
1809 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1811 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1818 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1819 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1821 if (nCtlColor
== CTLCOLOR_DLG
)
1823 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1826 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1828 WXHBRUSH hBrush
= 0;
1831 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1833 // I think that even for dialogs, we may need to call DefWindowProc (?)
1834 // Or maybe just rely on the usual default behaviour.
1836 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1841 // Define for each class of dialog and control
1842 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1843 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1845 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1848 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1850 wxSysColourChangedEvent event
;
1851 event
.SetEventObject(this);
1853 // Check if app handles this.
1854 if (GetEventHandler()->ProcessEvent(event
))
1857 // We didn't process it
1861 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1863 wxPaletteChangedEvent
event(GetId());
1864 event
.SetEventObject(this);
1865 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1866 GetEventHandler()->ProcessEvent(event
);
1870 long wxWindow::MSWOnQueryNewPalette()
1872 wxQueryNewPaletteEvent
event(GetId());
1873 event
.SetEventObject(this);
1874 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1876 return (long) FALSE
;
1882 // Responds to colour changes: passes event on to children.
1883 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1885 wxNode
*node
= GetChildren().First();
1888 // Only propagate to non-top-level windows
1889 wxWindow
*win
= (wxWindow
*)node
->Data();
1890 if ( win
->GetParent() )
1892 wxSysColourChangedEvent event2
;
1893 event
.m_eventObject
= win
;
1894 win
->GetEventHandler()->ProcessEvent(event2
);
1897 node
= node
->Next();
1901 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1904 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1906 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1909 long wxWindow::Default()
1911 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1916 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1917 wxGetMessageName(m_lastMsg
));
1918 #endif // __WXDEBUG__
1920 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1923 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1925 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1926 // intercept dialog navigation keys
1927 MSG
*msg
= (MSG
*)pMsg
;
1928 bool bProcess
= TRUE
;
1929 if ( msg
->message
!= WM_KEYDOWN
)
1932 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1935 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1937 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1938 // (except for Ctrl-Tab/Enter combinations which are always processed)
1940 if ( bProcess
&& !bCtrlDown
) {
1941 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1944 bool bForward
= TRUE
,
1945 bWindowChange
= FALSE
;
1947 switch ( msg
->wParam
) {
1949 if ( lDlgCode
& DLGC_WANTTAB
) {
1953 // Ctrl-Tab cycles thru notebook pages
1954 bWindowChange
= bCtrlDown
;
1955 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1961 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1969 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1974 // if there is a default button, Enter should press it
1975 if ( !GetDefaultItem() ) {
1976 // but if there is not it makes sense to make it work
1978 if ( bCtrlDown
|| (lDlgCode
& DLGC_WANTMESSAGE
== 0) )
1980 // nothing to do - all variables are already set
1986 // control wants to process Enter itself, don't
1987 // call IsDialogMessage() which would interpret
1992 //else: fall through and don't process the message
2000 wxNavigationKeyEvent event
;
2001 event
.SetDirection(bForward
);
2002 event
.SetWindowChange(bWindowChange
);
2003 event
.SetEventObject(this);
2005 if ( GetEventHandler()->ProcessEvent(event
) )
2009 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
2012 else if ( m_tooltip
) {
2013 // relay mouse move events to the tooltip control
2014 MSG
*msg
= (MSG
*)pMsg
;
2015 if ( msg
->message
== WM_MOUSEMOVE
)
2016 m_tooltip
->RelayEvent(pMsg
);
2018 #endif // wxUSE_TOOLTIPS
2023 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2025 if (m_acceleratorTable
.Ok() &&
2026 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2032 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2037 void wxWindow::MSWDetachWindowMenu()
2041 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2043 for (i
= 0; i
< N
; i
++)
2046 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2047 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2049 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2056 bool wxWindow::MSWOnPaint()
2059 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2060 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2062 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2065 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2067 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2068 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2071 wxPaintEvent
event(m_windowId
);
2072 event
.SetEventObject(this);
2073 if (!GetEventHandler()->ProcessEvent(event
))
2078 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2088 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2089 event
.SetEventObject(this);
2090 if (!GetEventHandler()->ProcessEvent(event
))
2096 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2101 // Deal with child commands from buttons etc.
2102 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2104 if (wxCurrentPopupMenu
)
2106 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2107 wxCurrentPopupMenu
= NULL
;
2108 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2112 wxWindow
*item
= FindItem(id
);
2115 bool value
= item
->MSWCommand(cmd
, id
);
2120 wxWindow
*win
= wxFindWinFromHandle(control
);
2122 return win
->MSWCommand(cmd
, id
);
2127 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2133 wxMaximizeEvent
event(m_windowId
);
2134 event
.SetEventObject(this);
2135 if (!GetEventHandler()->ProcessEvent(event
))
2143 wxIconizeEvent
event(m_windowId
);
2144 event
.SetEventObject(this);
2145 if (!GetEventHandler()->ProcessEvent(event
))
2157 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2159 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2161 event
.m_x
= x
; event
.m_y
= y
;
2162 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2163 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2164 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2165 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2166 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2167 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2168 event
.m_eventObject
= this;
2170 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2172 if (!GetEventHandler()->ProcessEvent(event
))
2176 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2178 wxMouseEvent
event(wxEVT_LEFT_UP
);
2180 event
.m_x
= x
; event
.m_y
= y
;
2181 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2182 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2183 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2184 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2185 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2186 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2187 event
.m_eventObject
= this;
2189 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2191 if (!GetEventHandler()->ProcessEvent(event
))
2195 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2197 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2199 event
.m_x
= x
; event
.m_y
= y
;
2200 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2201 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2202 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2203 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2204 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2205 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2206 event
.m_eventObject
= this;
2208 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2210 if (!GetEventHandler()->ProcessEvent(event
))
2214 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2216 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2218 event
.m_x
= x
; event
.m_y
= y
;
2219 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2220 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2221 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2222 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2223 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2224 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2225 event
.m_eventObject
= this;
2227 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2229 if (!GetEventHandler()->ProcessEvent(event
))
2233 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2235 //wxDebugMsg("MButtonUp\n") ;
2236 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2238 event
.m_x
= x
; event
.m_y
= y
;
2239 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2240 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2241 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2242 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2243 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2244 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2245 event
.m_eventObject
= this;
2247 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2249 if (!GetEventHandler()->ProcessEvent(event
))
2253 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2255 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2257 event
.m_x
= x
; event
.m_y
= y
;
2258 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2259 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2260 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2261 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2262 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2263 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2264 event
.m_eventObject
= this;
2266 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2268 if (!GetEventHandler()->ProcessEvent(event
))
2272 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2274 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2276 event
.m_x
= x
; event
.m_y
= y
;
2277 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2278 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2279 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2280 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2281 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2282 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2283 event
.m_eventObject
= this;
2285 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2287 if (!GetEventHandler()->ProcessEvent(event
))
2291 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2293 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2295 event
.m_x
= x
; event
.m_y
= y
;
2296 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2297 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2298 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2299 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2300 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2301 event
.m_eventObject
= this;
2302 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2304 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2306 if (!GetEventHandler()->ProcessEvent(event
))
2310 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2312 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2314 event
.m_x
= x
; event
.m_y
= y
;
2315 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2316 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2317 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2318 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2319 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2320 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2321 event
.m_eventObject
= this;
2323 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2325 if (!GetEventHandler()->ProcessEvent(event
))
2329 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2331 // 'normal' move event...
2332 // Set cursor, but only if we're not in 'busy' mode
2334 // Trouble with this is that it sets the cursor for controls too :-(
2335 if (m_windowCursor
.Ok() && !wxIsBusy())
2336 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2338 if (!m_mouseInWindow
)
2340 // Generate an ENTER event
2341 m_mouseInWindow
= TRUE
;
2342 MSWOnMouseEnter(x
, y
, flags
);
2345 wxMouseEvent
event(wxEVT_MOTION
);
2347 event
.m_x
= x
; event
.m_y
= y
;
2348 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2349 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2350 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2351 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2352 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2353 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2354 event
.m_eventObject
= this;
2356 // Window gets a click down message followed by a mouse move
2357 // message even if position isn't changed! We want to discard
2358 // the trailing move event if x and y are the same.
2359 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2360 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2361 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2363 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2364 m_lastEvent
= wxEVT_MOTION
;
2368 m_lastEvent
= wxEVT_MOTION
;
2369 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2371 if (!GetEventHandler()->ProcessEvent(event
))
2375 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2377 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
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
.SetTimestamp(wxApp::sm_lastMessageTime
);
2386 event
.m_eventObject
= this;
2388 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2389 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2390 // No message - ensure we don't try to call the default behaviour accidentally.
2392 GetEventHandler()->ProcessEvent(event
);
2395 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2397 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2399 event
.m_x
= x
; event
.m_y
= y
;
2400 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2401 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2402 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2403 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2404 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2405 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2406 event
.m_eventObject
= this;
2408 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2409 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2410 // No message - ensure we don't try to call the default behaviour accidentally.
2412 GetEventHandler()->ProcessEvent(event
);
2415 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2418 bool tempControlDown
= FALSE
;
2421 // If 1 -> 26, translate to CTRL plus a letter.
2423 if ((id
> 0) && (id
< 27))
2444 tempControlDown
= TRUE
;
2450 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2451 // it's ASCII and will be processed here only when called from
2452 // WM_CHAR (i.e. when isASCII = TRUE)
2458 wxKeyEvent
event(wxEVT_CHAR
);
2459 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2460 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2461 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2462 event
.m_altDown
= TRUE
;
2464 event
.m_eventObject
= this;
2465 event
.m_keyCode
= id
;
2466 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2471 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2475 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2477 if (!GetEventHandler()->ProcessEvent(event
))
2482 void wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2486 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2492 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2493 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2494 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2495 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2496 event
.m_altDown
= TRUE
;
2498 event
.m_eventObject
= this;
2499 event
.m_keyCode
= id
;
2500 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2505 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2509 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2511 if (!GetEventHandler()->ProcessEvent(event
))
2516 void wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2520 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2526 wxKeyEvent
event(wxEVT_KEY_UP
);
2527 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2528 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2529 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2530 event
.m_altDown
= TRUE
;
2532 event
.m_eventObject
= this;
2533 event
.m_keyCode
= id
;
2534 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2539 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2543 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2545 if (!GetEventHandler()->ProcessEvent(event
))
2550 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2554 if (flags
& JOY_BUTTON1CHG
)
2555 change
= wxJOY_BUTTON1
;
2556 if (flags
& JOY_BUTTON2CHG
)
2557 change
= wxJOY_BUTTON2
;
2558 if (flags
& JOY_BUTTON3CHG
)
2559 change
= wxJOY_BUTTON3
;
2560 if (flags
& JOY_BUTTON4CHG
)
2561 change
= wxJOY_BUTTON4
;
2563 if (flags
& JOY_BUTTON1
)
2564 buttons
|= wxJOY_BUTTON1
;
2565 if (flags
& JOY_BUTTON2
)
2566 buttons
|= wxJOY_BUTTON2
;
2567 if (flags
& JOY_BUTTON3
)
2568 buttons
|= wxJOY_BUTTON3
;
2569 if (flags
& JOY_BUTTON4
)
2570 buttons
|= wxJOY_BUTTON4
;
2572 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2573 event
.SetPosition(wxPoint(x
, y
));
2574 event
.SetEventObject(this);
2576 GetEventHandler()->ProcessEvent(event
);
2579 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2583 if (flags
& JOY_BUTTON1CHG
)
2584 change
= wxJOY_BUTTON1
;
2585 if (flags
& JOY_BUTTON2CHG
)
2586 change
= wxJOY_BUTTON2
;
2587 if (flags
& JOY_BUTTON3CHG
)
2588 change
= wxJOY_BUTTON3
;
2589 if (flags
& JOY_BUTTON4CHG
)
2590 change
= wxJOY_BUTTON4
;
2592 if (flags
& JOY_BUTTON1
)
2593 buttons
|= wxJOY_BUTTON1
;
2594 if (flags
& JOY_BUTTON2
)
2595 buttons
|= wxJOY_BUTTON2
;
2596 if (flags
& JOY_BUTTON3
)
2597 buttons
|= wxJOY_BUTTON3
;
2598 if (flags
& JOY_BUTTON4
)
2599 buttons
|= wxJOY_BUTTON4
;
2601 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2602 event
.SetPosition(wxPoint(x
, y
));
2603 event
.SetEventObject(this);
2605 GetEventHandler()->ProcessEvent(event
);
2608 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2611 if (flags
& JOY_BUTTON1
)
2612 buttons
|= wxJOY_BUTTON1
;
2613 if (flags
& JOY_BUTTON2
)
2614 buttons
|= wxJOY_BUTTON2
;
2615 if (flags
& JOY_BUTTON3
)
2616 buttons
|= wxJOY_BUTTON3
;
2617 if (flags
& JOY_BUTTON4
)
2618 buttons
|= wxJOY_BUTTON4
;
2620 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2621 event
.SetPosition(wxPoint(x
, y
));
2622 event
.SetEventObject(this);
2624 GetEventHandler()->ProcessEvent(event
);
2627 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2630 if (flags
& JOY_BUTTON1
)
2631 buttons
|= wxJOY_BUTTON1
;
2632 if (flags
& JOY_BUTTON2
)
2633 buttons
|= wxJOY_BUTTON2
;
2634 if (flags
& JOY_BUTTON3
)
2635 buttons
|= wxJOY_BUTTON3
;
2636 if (flags
& JOY_BUTTON4
)
2637 buttons
|= wxJOY_BUTTON4
;
2639 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2640 event
.SetZPosition(z
);
2641 event
.SetEventObject(this);
2643 GetEventHandler()->ProcessEvent(event
);
2646 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2650 wxWindow
*child
= wxFindWinFromHandle(control
);
2652 child
->MSWOnVScroll(wParam
, pos
, control
);
2656 wxScrollEvent event
;
2657 event
.SetPosition(pos
);
2658 event
.SetOrientation(wxVERTICAL
);
2659 event
.m_eventObject
= this;
2664 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2668 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2672 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2676 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2680 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2684 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2688 case SB_THUMBPOSITION
:
2689 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2697 if (!GetEventHandler()->ProcessEvent(event
))
2701 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2705 wxWindow
*child
= wxFindWinFromHandle(control
);
2707 child
->MSWOnHScroll(wParam
, pos
, control
);
2713 wxScrollEvent event
;
2714 event
.SetPosition(pos
);
2715 event
.SetOrientation(wxHORIZONTAL
);
2716 event
.m_eventObject
= this;
2721 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2725 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2729 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2733 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2737 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2741 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2745 case SB_THUMBPOSITION
:
2746 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2753 if ( GetEventHandler()->ProcessEvent(event
) )
2757 // call the default WM_HSCROLL handler: it's non trivial in some common
2758 // controls (up-down control for example)
2762 void wxWindow::MSWOnShow(bool show
, int status
)
2764 wxShowEvent
event(GetId(), show
);
2765 event
.m_eventObject
= this;
2766 GetEventHandler()->ProcessEvent(event
);
2769 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2771 wxInitDialogEvent
event(GetId());
2772 event
.m_eventObject
= this;
2773 GetEventHandler()->ProcessEvent(event
);
2777 void wxWindow::InitDialog()
2779 wxInitDialogEvent
event(GetId());
2780 event
.SetEventObject( this );
2781 GetEventHandler()->ProcessEvent(event
);
2784 // Default init dialog behaviour is to transfer data to window
2785 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2787 TransferDataToWindow();
2790 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2793 HDC dc
= ::GetDC((HWND
) wnd
);
2798 // the_font->UseResource();
2799 // the_font->RealizeResource();
2800 fnt
= (HFONT
)the_font
->GetResourceHandle();
2802 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2804 GetTextMetrics(dc
, &tm
);
2805 if (the_font
&& fnt
&& was
)
2807 SelectObject(dc
,was
) ;
2809 ReleaseDC((HWND
)wnd
, dc
);
2810 *x
= tm
.tmAveCharWidth
;
2811 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2814 // the_font->ReleaseResource();
2817 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2818 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2819 int wxCharCodeMSWToWX(int keySym
)
2824 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2825 case VK_BACK
: id
= WXK_BACK
; break;
2826 case VK_TAB
: id
= WXK_TAB
; break;
2827 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2828 case VK_RETURN
: id
= WXK_RETURN
; break;
2829 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2830 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2831 case VK_MENU
: id
= WXK_MENU
; break;
2832 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2833 case VK_SPACE
: id
= WXK_SPACE
; break;
2834 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2835 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2836 case VK_NEXT
: id
= WXK_NEXT
; break;
2837 case VK_END
: id
= WXK_END
; break;
2838 case VK_HOME
: id
= WXK_HOME
; break;
2839 case VK_LEFT
: id
= WXK_LEFT
; break;
2840 case VK_UP
: id
= WXK_UP
; break;
2841 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2842 case VK_DOWN
: id
= WXK_DOWN
; break;
2843 case VK_SELECT
: id
= WXK_SELECT
; break;
2844 case VK_PRINT
: id
= WXK_PRINT
; break;
2845 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2846 case VK_INSERT
: id
= WXK_INSERT
; break;
2847 case VK_DELETE
: id
= WXK_DELETE
; break;
2848 case VK_HELP
: id
= WXK_HELP
; break;
2849 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2850 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2851 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2852 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2853 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2854 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2855 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2856 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2857 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2858 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2859 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2860 case VK_ADD
: id
= WXK_ADD
; break;
2861 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2862 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2863 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2864 case VK_F1
: id
= WXK_F1
; break;
2865 case VK_F2
: id
= WXK_F2
; break;
2866 case VK_F3
: id
= WXK_F3
; break;
2867 case VK_F4
: id
= WXK_F4
; break;
2868 case VK_F5
: id
= WXK_F5
; break;
2869 case VK_F6
: id
= WXK_F6
; break;
2870 case VK_F7
: id
= WXK_F7
; break;
2871 case VK_F8
: id
= WXK_F8
; break;
2872 case VK_F9
: id
= WXK_F9
; break;
2873 case VK_F10
: id
= WXK_F10
; break;
2874 case VK_F11
: id
= WXK_F11
; break;
2875 case VK_F12
: id
= WXK_F12
; break;
2876 case VK_F13
: id
= WXK_F13
; break;
2877 case VK_F14
: id
= WXK_F14
; break;
2878 case VK_F15
: id
= WXK_F15
; break;
2879 case VK_F16
: id
= WXK_F16
; break;
2880 case VK_F17
: id
= WXK_F17
; break;
2881 case VK_F18
: id
= WXK_F18
; break;
2882 case VK_F19
: id
= WXK_F19
; break;
2883 case VK_F20
: id
= WXK_F20
; break;
2884 case VK_F21
: id
= WXK_F21
; break;
2885 case VK_F22
: id
= WXK_F22
; break;
2886 case VK_F23
: id
= WXK_F23
; break;
2887 case VK_F24
: id
= WXK_F24
; break;
2888 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2889 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2898 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2904 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2905 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2906 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2907 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2908 case WXK_MENU
: keySym
= VK_MENU
; break;
2909 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2910 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2911 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2912 case WXK_END
: keySym
= VK_END
; break;
2913 case WXK_HOME
: keySym
= VK_HOME
; break;
2914 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2915 case WXK_UP
: keySym
= VK_UP
; break;
2916 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2917 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2918 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2919 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2920 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2921 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2922 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2923 case WXK_HELP
: keySym
= VK_HELP
; break;
2924 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2925 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2926 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2927 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2928 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2929 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2930 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2931 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2932 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2933 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2934 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2935 case WXK_ADD
: keySym
= VK_ADD
; break;
2936 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2937 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2938 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2939 case WXK_F1
: keySym
= VK_F1
; break;
2940 case WXK_F2
: keySym
= VK_F2
; break;
2941 case WXK_F3
: keySym
= VK_F3
; break;
2942 case WXK_F4
: keySym
= VK_F4
; break;
2943 case WXK_F5
: keySym
= VK_F5
; break;
2944 case WXK_F6
: keySym
= VK_F6
; break;
2945 case WXK_F7
: keySym
= VK_F7
; break;
2946 case WXK_F8
: keySym
= VK_F8
; break;
2947 case WXK_F9
: keySym
= VK_F9
; break;
2948 case WXK_F10
: keySym
= VK_F10
; break;
2949 case WXK_F11
: keySym
= VK_F11
; break;
2950 case WXK_F12
: keySym
= VK_F12
; break;
2951 case WXK_F13
: keySym
= VK_F13
; break;
2952 case WXK_F14
: keySym
= VK_F14
; break;
2953 case WXK_F15
: keySym
= VK_F15
; break;
2954 case WXK_F16
: keySym
= VK_F16
; break;
2955 case WXK_F17
: keySym
= VK_F17
; break;
2956 case WXK_F18
: keySym
= VK_F18
; break;
2957 case WXK_F19
: keySym
= VK_F19
; break;
2958 case WXK_F20
: keySym
= VK_F20
; break;
2959 case WXK_F21
: keySym
= VK_F21
; break;
2960 case WXK_F22
: keySym
= VK_F22
; break;
2961 case WXK_F23
: keySym
= VK_F23
; break;
2962 case WXK_F24
: keySym
= VK_F24
; break;
2963 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2964 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2975 // Caret manipulation
2976 void wxWindow::CreateCaret(int w
, int h
)
2980 m_caretEnabled
= TRUE
;
2983 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2988 void wxWindow::ShowCaret(bool show
)
2993 ::ShowCaret((HWND
) GetHWND());
2995 ::HideCaret((HWND
) GetHWND());
2996 m_caretShown
= show
;
3000 void wxWindow::DestroyCaret()
3002 m_caretEnabled
= FALSE
;
3005 void wxWindow::SetCaretPos(int x
, int y
)
3007 ::SetCaretPos(x
, y
);
3010 void wxWindow::GetCaretPos(int *x
, int *y
) const
3013 ::GetCaretPos(&point
);
3018 wxWindow
*wxGetActiveWindow()
3020 HWND hWnd
= GetActiveWindow();
3023 return wxFindWinFromHandle((WXHWND
) hWnd
);
3028 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
3029 // in active frames and dialogs, regardless of where the focus is.
3030 static HHOOK wxTheKeyboardHook
= 0;
3031 static FARPROC wxTheKeyboardHookProc
= 0;
3032 int APIENTRY _EXPORT
3033 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
3035 void wxSetKeyboardHook(bool doIt
)
3039 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3040 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3041 #if defined(__WIN32__) && !defined(__TWIN32__)
3042 GetCurrentThreadId());
3043 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3050 UnhookWindowsHookEx(wxTheKeyboardHook
);
3051 FreeProcInstance(wxTheKeyboardHookProc
);
3055 int APIENTRY _EXPORT
3056 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3058 DWORD hiWord
= HIWORD(lParam
);
3059 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3062 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3064 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3065 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3066 event
.m_altDown
= TRUE
;
3068 event
.m_eventObject
= NULL
;
3069 event
.m_keyCode
= id
;
3070 /* begin Albert's fix for control and shift key 26.5 */
3071 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3072 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3073 /* end Albert's fix for control and shift key 26.5 */
3074 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3076 wxWindow
*win
= wxGetActiveWindow();
3079 if (win
->GetEventHandler()->ProcessEvent(event
))
3084 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3089 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3092 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3100 void wxWindow::Centre(int direction
)
3102 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3104 wxWindow
*father
= (wxWindow
*)GetParent();
3108 father
->GetClientSize(&panel_width
, &panel_height
);
3109 GetSize(&width
, &height
);
3110 GetPosition(&x
, &y
);
3115 if (direction
& wxHORIZONTAL
)
3116 new_x
= (int)((panel_width
- width
)/2);
3118 if (direction
& wxVERTICAL
)
3119 new_y
= (int)((panel_height
- height
)/2);
3121 SetSize(new_x
, new_y
, -1, -1);
3125 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3127 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3128 // pixel coordinates, relatives to the canvas -- So, we first need to
3129 // substract origin of the window, then convert to screen position
3131 int x
= x_pos
; int y
= y_pos
;
3133 GetWindowRect ((HWND
) GetHWND(), &rect
);
3138 SetCursorPos (x
, y
);
3141 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3145 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3153 wxEraseEvent
event(m_windowId
, &dc
);
3154 event
.m_eventObject
= this;
3155 if (!GetEventHandler()->ProcessEvent(event
))
3158 dc
.SelectOldObjects(pDC
);
3164 dc
.SelectOldObjects(pDC
);
3167 dc
.SetHDC((WXHDC
) NULL
);
3171 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3177 ::GetClientRect((HWND
) GetHWND(), &rect
);
3179 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3180 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3181 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3183 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3184 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3185 ::DeleteObject(hBrush
);
3186 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3188 // Less efficient version (and doesn't account for scrolling)
3190 GetClientSize(& w, & h);
3191 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3192 event.GetDC()->SetBrush(brush);
3193 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3195 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3199 #if WXWIN_COMPATIBILITY
3200 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3202 #if defined(__WIN95__)
3206 // Try to adjust the range to cope with page size > 1
3207 // - a Windows API quirk
3208 int pageSize
= GetScrollPage(orient
);
3209 if ( pageSize
> 1 && range
> 0)
3211 range1
+= (pageSize
- 1);
3217 if (orient
== wxHORIZONTAL
) {
3223 info
.cbSize
= sizeof(SCROLLINFO
);
3224 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3228 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3230 HWND hWnd
= (HWND
) GetHWND();
3232 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3235 if (orient
== wxHORIZONTAL
)
3240 HWND hWnd
= (HWND
) GetHWND();
3242 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3246 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3248 #if defined(__WIN95__)
3252 if (orient
== wxHORIZONTAL
) {
3254 m_xThumbSize
= page
;
3257 m_yThumbSize
= page
;
3260 info
.cbSize
= sizeof(SCROLLINFO
);
3263 info
.fMask
= SIF_PAGE
;
3265 HWND hWnd
= (HWND
) GetHWND();
3267 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3269 if (orient
== wxHORIZONTAL
)
3270 m_xThumbSize
= page
;
3272 m_yThumbSize
= page
;
3276 int wxWindow::OldGetScrollRange(int orient
) const
3279 if (orient
== wxHORIZONTAL
)
3284 #if __WATCOMC__ && defined(__WINDOWS_386__)
3285 short minPos
, maxPos
;
3289 HWND hWnd
= (HWND
) GetHWND();
3292 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3293 #if defined(__WIN95__)
3294 // Try to adjust the range to cope with page size > 1
3295 // - a Windows API quirk
3296 int pageSize
= GetScrollPage(orient
);
3299 maxPos
-= (pageSize
- 1);
3308 int wxWindow::GetScrollPage(int orient
) const
3310 if (orient
== wxHORIZONTAL
)
3311 return m_xThumbSize
;
3313 return m_yThumbSize
;
3317 int wxWindow::GetScrollPos(int orient
) const
3320 if (orient
== wxHORIZONTAL
)
3324 HWND hWnd
= (HWND
) GetHWND();
3327 return ::GetScrollPos(hWnd
, wOrient
);
3333 // This now returns the whole range, not just the number
3334 // of positions that we can scroll.
3335 int wxWindow::GetScrollRange(int orient
) const
3338 if (orient
== wxHORIZONTAL
)
3343 #if __WATCOMC__ && defined(__WINDOWS_386__)
3344 short minPos
, maxPos
;
3348 HWND hWnd
= (HWND
) GetHWND();
3351 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3352 #if defined(__WIN95__)
3353 // Try to adjust the range to cope with page size > 1
3354 // - a Windows API quirk
3355 int pageSize
= GetScrollThumb(orient
);
3358 maxPos
-= (pageSize
- 1);
3360 // October 10th: new range concept.
3370 int wxWindow::GetScrollThumb(int orient
) const
3372 if (orient
== wxHORIZONTAL
)
3373 return m_xThumbSize
;
3375 return m_yThumbSize
;
3378 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3380 #if defined(__WIN95__)
3384 if (orient
== wxHORIZONTAL
) {
3390 info
.cbSize
= sizeof(SCROLLINFO
);
3394 info
.fMask
= SIF_POS
;
3396 HWND hWnd
= (HWND
) GetHWND();
3398 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3401 if (orient
== wxHORIZONTAL
)
3406 HWND hWnd
= (HWND
) GetHWND();
3408 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3412 // New function that will replace some of the above.
3413 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3414 int range
, bool refresh
)
3417 SetScrollPage(orient, thumbVisible, FALSE);
3419 int oldRange = range - thumbVisible ;
3420 SetScrollRange(orient, oldRange, FALSE);
3422 SetScrollPos(orient, pos, refresh);
3424 #if defined(__WIN95__)
3425 int oldRange
= range
- thumbVisible
;
3427 int range1
= oldRange
;
3429 // Try to adjust the range to cope with page size > 1
3430 // - a Windows API quirk
3431 int pageSize
= thumbVisible
;
3432 if ( pageSize
> 1 && range
> 0)
3434 range1
+= (pageSize
- 1);
3440 if (orient
== wxHORIZONTAL
) {
3446 info
.cbSize
= sizeof(SCROLLINFO
);
3447 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3451 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3453 HWND hWnd
= (HWND
) GetHWND();
3455 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3458 if (orient
== wxHORIZONTAL
)
3463 HWND hWnd
= (HWND
) GetHWND();
3466 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3467 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3470 if (orient
== wxHORIZONTAL
) {
3471 m_xThumbSize
= thumbVisible
;
3473 m_yThumbSize
= thumbVisible
;
3477 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3482 rect2
.left
= rect
->x
;
3483 rect2
.top
= rect
->y
;
3484 rect2
.right
= rect
->x
+ rect
->width
;
3485 rect2
.bottom
= rect
->y
+ rect
->height
;
3489 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3491 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3494 void wxWindow::SetFont(const wxFont
& font
)
3496 m_windowFont
= font
;
3498 if (!m_windowFont
.Ok())
3501 HWND hWnd
= (HWND
) GetHWND();
3504 if (m_windowFont
.GetResourceHandle())
3505 SendMessage(hWnd
, WM_SETFONT
,
3506 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3510 void wxWindow::SubclassWin(WXHWND hWnd
)
3512 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3514 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3516 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3517 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3520 void wxWindow::UnsubclassWin()
3522 wxRemoveHandleAssociation(this);
3524 // Restore old Window proc
3525 if ((HWND
) GetHWND())
3527 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3528 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3530 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3536 // Make a Windows extended style from the given wxWindows window style
3537 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3539 WXDWORD exStyle
= 0;
3540 if ( style
& wxTRANSPARENT_WINDOW
)
3541 exStyle
|= WS_EX_TRANSPARENT
;
3543 if ( !eliminateBorders
)
3545 if ( style
& wxSUNKEN_BORDER
)
3546 exStyle
|= WS_EX_CLIENTEDGE
;
3547 if ( style
& wxDOUBLE_BORDER
)
3548 exStyle
|= WS_EX_DLGMODALFRAME
;
3549 #if defined(__WIN95__)
3550 if ( style
& wxRAISED_BORDER
)
3551 exStyle
|= WS_EX_WINDOWEDGE
;
3552 if ( style
& wxSTATIC_BORDER
)
3553 exStyle
|= WS_EX_STATICEDGE
;
3559 // Determines whether native 3D effects or CTL3D should be used,
3560 // applying a default border style if required, and returning an extended
3561 // style to pass to CreateWindowEx.
3562 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3564 // If matches certain criteria, then assume no 3D effects
3565 // unless specifically requested (dealt with in MakeExtendedStyle)
3566 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3569 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3572 // Determine whether we should be using 3D effects or not.
3573 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3575 // 1) App can specify global 3D effects
3576 *want3D
= wxTheApp
->GetAuto3D();
3578 // 2) If the parent is being drawn with user colours, or simple border specified,
3579 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3580 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3583 // 3) Control can override this global setting by defining
3584 // a border style, e.g. wxSUNKEN_BORDER
3585 if (m_windowStyle
& wxSUNKEN_BORDER
)
3588 // 4) If it's a special border, CTL3D can't cope so we want a native border
3589 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3590 (m_windowStyle
& wxSTATIC_BORDER
) )
3593 nativeBorder
= TRUE
;
3596 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3597 // effects from extended style
3600 nativeBorder
= FALSE
;
3603 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3605 // If we want 3D, but haven't specified a border here,
3606 // apply the default border style specified.
3607 // TODO what about non-Win95 WIN32? Does it have borders?
3608 #if defined(__WIN95__) && !wxUSE_CTL3D
3609 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3610 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3611 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3617 void wxWindow::OnChar(wxKeyEvent
& event
)
3620 if ( event
.KeyCode() == WXK_TAB
) {
3621 // propagate the TABs to the parent - it's up to it to decide what
3623 wxWindow
*parent
= GetParent();
3625 if ( parent
->GetEventHandler()->ProcessEvent(event
) )
3632 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3637 if ( !event
.ControlDown() )
3638 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3641 bool wxWindow::IsEnabled(void) const
3643 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3646 // Dialog support: override these and call
3647 // base class members to add functionality
3648 // that can't be done using validators.
3649 // NOTE: these functions assume that controls
3650 // are direct children of this window, not grandchildren
3651 // or other levels of descendant.
3653 // Transfer values to controls. If returns FALSE,
3654 // it's an application error (pops up a dialog)
3655 bool wxWindow::TransferDataToWindow()
3657 wxNode
*node
= GetChildren().First();
3660 wxWindow
*child
= (wxWindow
*)node
->Data();
3661 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3662 !child
->GetValidator()->TransferToWindow() )
3664 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3668 node
= node
->Next();
3673 // Transfer values from controls. If returns FALSE,
3674 // validation failed: don't quit
3675 bool wxWindow::TransferDataFromWindow()
3677 wxNode
*node
= GetChildren().First();
3680 wxWindow
*child
= (wxWindow
*)node
->Data();
3681 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3686 node
= node
->Next();
3691 bool wxWindow::Validate()
3693 wxNode
*node
= GetChildren().First();
3696 wxWindow
*child
= (wxWindow
*)node
->Data();
3697 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3702 node
= node
->Next();
3707 // Get the window with the focus
3708 wxWindow
*wxWindow::FindFocus()
3710 HWND hWnd
= ::GetFocus();
3713 return wxFindWinFromHandle((WXHWND
) hWnd
);
3718 void wxWindow::AddChild(wxWindow
*child
)
3720 GetChildren().Append(child
);
3721 child
->m_windowParent
= this;
3724 void wxWindow::RemoveChild(wxWindow
*child
)
3726 // if (GetChildren())
3727 GetChildren().DeleteObject(child
);
3728 child
->m_windowParent
= NULL
;
3731 void wxWindow::DestroyChildren()
3734 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3736 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3738 if ( GetChildren().Member(child
) )
3744 void wxWindow::MakeModal(bool modal
)
3746 // Disable all other windows
3747 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3749 wxNode
*node
= wxTopLevelWindows
.First();
3752 wxWindow
*win
= (wxWindow
*)node
->Data();
3754 win
->Enable(!modal
);
3756 node
= node
->Next();
3761 // If nothing defined for this, try the parent.
3762 // E.g. we may be a button loaded from a resource, with no callback function
3764 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3766 if (GetEventHandler()->ProcessEvent(event
) )
3769 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3772 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3776 UnsetConstraints(m_constraints
);
3777 delete m_constraints
;
3782 // Make sure other windows know they're part of a 'meaningful relationship'
3783 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3784 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3785 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3786 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3787 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3788 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3789 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3790 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3791 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3792 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3793 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3794 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3795 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3796 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3797 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3798 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3802 // This removes any dangling pointers to this window
3803 // in other windows' constraintsInvolvedIn lists.
3804 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3808 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3809 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3810 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3811 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3812 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3813 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3814 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3815 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3816 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3817 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3818 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3819 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3820 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3821 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3822 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3823 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3827 // Back-pointer to other windows we're involved with, so if we delete
3828 // this window, we must delete any constraints we're involved with.
3829 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3831 if (!m_constraintsInvolvedIn
)
3832 m_constraintsInvolvedIn
= new wxList
;
3833 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3834 m_constraintsInvolvedIn
->Append(otherWin
);
3837 // REMOVE back-pointer to other windows we're involved with.
3838 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3840 if (m_constraintsInvolvedIn
)
3841 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3844 // Reset any constraints that mention this window
3845 void wxWindow::DeleteRelatedConstraints()
3847 if (m_constraintsInvolvedIn
)
3849 wxNode
*node
= m_constraintsInvolvedIn
->First();
3852 wxWindow
*win
= (wxWindow
*)node
->Data();
3853 wxNode
*next
= node
->Next();
3854 wxLayoutConstraints
*constr
= win
->GetConstraints();
3856 // Reset any constraints involving this window
3859 constr
->left
.ResetIfWin((wxWindow
*)this);
3860 constr
->top
.ResetIfWin((wxWindow
*)this);
3861 constr
->right
.ResetIfWin((wxWindow
*)this);
3862 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3863 constr
->width
.ResetIfWin((wxWindow
*)this);
3864 constr
->height
.ResetIfWin((wxWindow
*)this);
3865 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3866 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3871 delete m_constraintsInvolvedIn
;
3872 m_constraintsInvolvedIn
= NULL
;
3876 void wxWindow::SetSizer(wxSizer
*sizer
)
3878 m_windowSizer
= sizer
;
3880 sizer
->SetSizerParent((wxWindow
*)this);
3887 bool wxWindow::Layout()
3889 if (GetConstraints())
3892 GetClientSize(&w
, &h
);
3893 GetConstraints()->width
.SetValue(w
);
3894 GetConstraints()->height
.SetValue(h
);
3897 // If top level (one sizer), evaluate the sizer's constraints.
3901 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3902 GetSizer()->LayoutPhase1(&noChanges
);
3903 GetSizer()->LayoutPhase2(&noChanges
);
3904 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3909 // Otherwise, evaluate child constraints
3910 ResetConstraints(); // Mark all constraints as unevaluated
3911 DoPhase(1); // Just one phase need if no sizers involved
3913 SetConstraintSizes(); // Recursively set the real window sizes
3919 // Do a phase of evaluating constraints:
3920 // the default behaviour. wxSizers may do a similar
3921 // thing, but also impose their own 'constraints'
3922 // and order the evaluation differently.
3923 bool wxWindow::LayoutPhase1(int *noChanges
)
3925 wxLayoutConstraints
*constr
= GetConstraints();
3928 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3934 bool wxWindow::LayoutPhase2(int *noChanges
)
3944 // Do a phase of evaluating child constraints
3945 bool wxWindow::DoPhase(int phase
)
3947 int noIterations
= 0;
3948 int maxIterations
= 500;
3952 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3956 wxNode
*node
= GetChildren().First();
3959 wxWindow
*child
= (wxWindow
*)node
->Data();
3960 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3962 wxLayoutConstraints
*constr
= child
->GetConstraints();
3965 if (succeeded
.Member(child
))
3970 int tempNoChanges
= 0;
3971 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3972 noChanges
+= tempNoChanges
;
3975 succeeded
.Append(child
);
3980 node
= node
->Next();
3987 void wxWindow::ResetConstraints()
3989 wxLayoutConstraints
*constr
= GetConstraints();
3992 constr
->left
.SetDone(FALSE
);
3993 constr
->top
.SetDone(FALSE
);
3994 constr
->right
.SetDone(FALSE
);
3995 constr
->bottom
.SetDone(FALSE
);
3996 constr
->width
.SetDone(FALSE
);
3997 constr
->height
.SetDone(FALSE
);
3998 constr
->centreX
.SetDone(FALSE
);
3999 constr
->centreY
.SetDone(FALSE
);
4001 wxNode
*node
= GetChildren().First();
4004 wxWindow
*win
= (wxWindow
*)node
->Data();
4005 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4006 win
->ResetConstraints();
4007 node
= node
->Next();
4011 // Need to distinguish between setting the 'fake' size for
4012 // windows and sizers, and setting the real values.
4013 void wxWindow::SetConstraintSizes(bool recurse
)
4015 wxLayoutConstraints
*constr
= GetConstraints();
4016 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
4017 constr
->width
.GetDone() && constr
->height
.GetDone())
4019 int x
= constr
->left
.GetValue();
4020 int y
= constr
->top
.GetValue();
4021 int w
= constr
->width
.GetValue();
4022 int h
= constr
->height
.GetValue();
4024 // If we don't want to resize this window, just move it...
4025 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
4026 (constr
->height
.GetRelationship() != wxAsIs
))
4028 // Calls Layout() recursively. AAAGH. How can we stop that.
4029 // Simply take Layout() out of non-top level OnSizes.
4030 SizerSetSize(x
, y
, w
, h
);
4039 char *windowClass
= this->GetClassInfo()->GetClassName();
4042 if (GetName() == "")
4043 winName
= "unnamed";
4045 winName
= GetName();
4046 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
4047 if (!constr
->left
.GetDone())
4048 wxDebugMsg(" unsatisfied 'left' constraint.\n");
4049 if (!constr
->right
.GetDone())
4050 wxDebugMsg(" unsatisfied 'right' constraint.\n");
4051 if (!constr
->width
.GetDone())
4052 wxDebugMsg(" unsatisfied 'width' constraint.\n");
4053 if (!constr
->height
.GetDone())
4054 wxDebugMsg(" unsatisfied 'height' constraint.\n");
4055 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
4060 wxNode
*node
= GetChildren().First();
4063 wxWindow
*win
= (wxWindow
*)node
->Data();
4064 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4065 win
->SetConstraintSizes();
4066 node
= node
->Next();
4071 // This assumes that all sizers are 'on' the same
4072 // window, i.e. the parent of this window.
4073 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4075 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4076 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4080 m_sizerParent
->GetPosition(&xp
, &yp
);
4081 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4086 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4090 TransformSizerToActual(&xx
, &yy
);
4091 SetSize(xx
, yy
, w
, h
);
4094 void wxWindow::SizerMove(int x
, int y
)
4098 TransformSizerToActual(&xx
, &yy
);
4102 // Only set the size/position of the constraint (if any)
4103 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4105 wxLayoutConstraints
*constr
= GetConstraints();
4110 constr
->left
.SetValue(x
);
4111 constr
->left
.SetDone(TRUE
);
4115 constr
->top
.SetValue(y
);
4116 constr
->top
.SetDone(TRUE
);
4120 constr
->width
.SetValue(w
);
4121 constr
->width
.SetDone(TRUE
);
4125 constr
->height
.SetValue(h
);
4126 constr
->height
.SetDone(TRUE
);
4131 void wxWindow::MoveConstraint(int x
, int y
)
4133 wxLayoutConstraints
*constr
= GetConstraints();
4138 constr
->left
.SetValue(x
);
4139 constr
->left
.SetDone(TRUE
);
4143 constr
->top
.SetValue(y
);
4144 constr
->top
.SetDone(TRUE
);
4149 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4151 wxLayoutConstraints
*constr
= GetConstraints();
4154 *w
= constr
->width
.GetValue();
4155 *h
= constr
->height
.GetValue();
4161 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4163 wxLayoutConstraints
*constr
= GetConstraints();
4166 *w
= constr
->width
.GetValue();
4167 *h
= constr
->height
.GetValue();
4170 GetClientSize(w
, h
);
4173 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4175 wxLayoutConstraints
*constr
= GetConstraints();
4178 *x
= constr
->left
.GetValue();
4179 *y
= constr
->top
.GetValue();
4185 bool wxWindow::Close(bool force
)
4187 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4188 event
.SetEventObject(this);
4189 event
.SetForce(force
);
4190 event
.SetCanVeto(!force
);
4192 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4195 wxObject
* wxWindow::GetChild(int number
) const
4197 // Return a pointer to the Nth object in the Panel
4198 // if (!GetChildren())
4200 wxNode
*node
= GetChildren().First();
4203 node
= node
->Next() ;
4206 wxObject
*obj
= (wxObject
*)node
->Data();
4213 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4215 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4216 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4219 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4221 wxListBox *lbox = (wxListBox *)initiatingItem;
4222 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4223 event.m_commandInt = -1;
4224 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4226 event.m_commandString = copystring(lbox->GetStringSelection());
4227 event.m_commandInt = lbox->GetSelection();
4228 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4230 event.m_eventObject = lbox;
4232 lbox->ProcessCommand(event);
4234 if (event.m_commandString)
4235 delete[] event.m_commandString;
4239 wxButton *but = GetDefaultItem();
4242 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4243 event.SetEventObject(but);
4244 but->Command(event);
4249 void wxWindow::Clear()
4251 wxClientDC
dc(this);
4252 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4253 dc
.SetBackground(brush
);
4257 // Fits the panel around the items
4258 void wxWindow::Fit()
4262 wxNode
*node
= GetChildren().First();
4265 wxWindow
*win
= (wxWindow
*)node
->Data();
4267 win
->GetPosition(&wx
, &wy
);
4268 win
->GetSize(&ww
, &wh
);
4269 if ( wx
+ ww
> maxX
)
4271 if ( wy
+ wh
> maxY
)
4274 node
= node
->Next();
4276 SetClientSize(maxX
+ 5, maxY
+ 5);
4279 void wxWindow::SetValidator(const wxValidator
& validator
)
4281 if ( m_windowValidator
)
4282 delete m_windowValidator
;
4283 m_windowValidator
= validator
.Clone();
4285 if ( m_windowValidator
)
4286 m_windowValidator
->SetWindow(this) ;
4289 // Find a window by id or name
4290 wxWindow
*wxWindow::FindWindow(long id
)
4295 wxNode
*node
= GetChildren().First();
4298 wxWindow
*child
= (wxWindow
*)node
->Data();
4299 wxWindow
*found
= child
->FindWindow(id
);
4302 node
= node
->Next();
4307 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4309 if ( GetName() == name
)
4312 wxNode
*node
= GetChildren().First();
4315 wxWindow
*child
= (wxWindow
*)node
->Data();
4316 wxWindow
*found
= child
->FindWindow(name
);
4319 node
= node
->Next();
4325 // Default input behaviour for a scrolling canvas should be to scroll
4326 // according to the cursor keys pressed
4327 void wxWindow::OnChar(wxKeyEvent& event)
4339 GetScrollUnitsPerPage(&x_page, &y_page);
4341 GetVirtualSize(&v_width,&v_height);
4343 ViewStart(&start_x, &start_y);
4346 y_pages = (int)(v_height/vert_units) - y_page;
4354 switch (event.keyCode)
4361 if (start_y - y_page > 0)
4362 Scroll(start_x, start_y - y_page);
4372 if ((y_page > 0) && (start_y <= y_pages-y-1))
4374 if (y_pages + y < start_y + y_page)
4375 Scroll(start_x, y_pages + y);
4377 Scroll(start_x, start_y + y_page);
4384 if ((y_page > 0) && (start_y >= 1))
4385 Scroll(start_x, start_y - 1);
4391 if ((y_page > 0) && (start_y <= y_pages-y-1))
4394 Scroll(start_x, start_y + 1);
4400 if ((x_page > 0) && (start_x >= 1))
4401 Scroll(start_x - 1, start_y);
4407 Scroll(start_x + 1, start_y);
4418 Scroll(start_x, y_pages+y);
4426 // Setup background and foreground colours correctly
4427 void wxWindow::SetupColours()
4430 SetBackgroundColour(GetParent()->GetBackgroundColour());
4433 void wxWindow::OnIdle(wxIdleEvent
& event
)
4435 // Check if we need to send a LEAVE event
4436 if (m_mouseInWindow
)
4439 ::GetCursorPos(&pt
);
4440 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4442 // Generate a LEAVE event
4443 m_mouseInWindow
= FALSE
;
4446 if (::GetKeyState(VK_SHIFT
) != 0)
4448 if (::GetKeyState(VK_CONTROL
) != 0)
4449 state
|= MK_CONTROL
;
4451 // Unfortunately the mouse button and keyboard state may have changed
4452 // by the time the OnIdle function is called, so 'state' may be
4455 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4461 // Raise the window to the top of the Z order
4462 void wxWindow::Raise()
4464 ::BringWindowToTop((HWND
) GetHWND());
4467 // Lower the window to the bottom of the Z order
4468 void wxWindow::Lower()
4470 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4473 long wxWindow::MSWGetDlgCode()
4475 // default: just forward to def window proc (the msg has no parameters)
4476 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4479 bool wxWindow::AcceptsFocus() const
4481 // invisible and disabled controls don't need focus
4482 return IsShown() && IsEnabled();
4485 // Update region access
4486 wxRegion
wxWindow::GetUpdateRegion() const
4488 return m_updateRegion
;
4491 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4493 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4496 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4498 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4501 bool wxWindow::IsExposed(const wxRect
& rect
) const
4503 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4506 // Set this window to be the child of 'parent'.
4507 bool wxWindow::Reparent(wxWindow
*parent
)
4509 if (parent
== GetParent())
4512 // Unlink this window from the existing parent.
4515 GetParent()->RemoveChild(this);
4518 wxTopLevelWindows
.DeleteObject(this);
4520 HWND hWndParent
= 0;
4521 HWND hWndChild
= (HWND
) GetHWND();
4522 if (parent
!= (wxWindow
*) NULL
)
4524 parent
->AddChild(this);
4525 hWndParent
= (HWND
) parent
->GetHWND();
4528 wxTopLevelWindows
.Append(this);
4530 ::SetParent(hWndChild
, hWndParent
);
4536 const char *wxGetMessageName(int message
)
4538 switch ( message
) {
4539 case 0x0000: return "WM_NULL";
4540 case 0x0001: return "WM_CREATE";
4541 case 0x0002: return "WM_DESTROY";
4542 case 0x0003: return "WM_MOVE";
4543 case 0x0005: return "WM_SIZE";
4544 case 0x0006: return "WM_ACTIVATE";
4545 case 0x0007: return "WM_SETFOCUS";
4546 case 0x0008: return "WM_KILLFOCUS";
4547 case 0x000A: return "WM_ENABLE";
4548 case 0x000B: return "WM_SETREDRAW";
4549 case 0x000C: return "WM_SETTEXT";
4550 case 0x000D: return "WM_GETTEXT";
4551 case 0x000E: return "WM_GETTEXTLENGTH";
4552 case 0x000F: return "WM_PAINT";
4553 case 0x0010: return "WM_CLOSE";
4554 case 0x0011: return "WM_QUERYENDSESSION";
4555 case 0x0012: return "WM_QUIT";
4556 case 0x0013: return "WM_QUERYOPEN";
4557 case 0x0014: return "WM_ERASEBKGND";
4558 case 0x0015: return "WM_SYSCOLORCHANGE";
4559 case 0x0016: return "WM_ENDSESSION";
4560 case 0x0017: return "WM_SYSTEMERROR";
4561 case 0x0018: return "WM_SHOWWINDOW";
4562 case 0x0019: return "WM_CTLCOLOR";
4563 case 0x001A: return "WM_WININICHANGE";
4564 case 0x001B: return "WM_DEVMODECHANGE";
4565 case 0x001C: return "WM_ACTIVATEAPP";
4566 case 0x001D: return "WM_FONTCHANGE";
4567 case 0x001E: return "WM_TIMECHANGE";
4568 case 0x001F: return "WM_CANCELMODE";
4569 case 0x0020: return "WM_SETCURSOR";
4570 case 0x0021: return "WM_MOUSEACTIVATE";
4571 case 0x0022: return "WM_CHILDACTIVATE";
4572 case 0x0023: return "WM_QUEUESYNC";
4573 case 0x0024: return "WM_GETMINMAXINFO";
4574 case 0x0026: return "WM_PAINTICON";
4575 case 0x0027: return "WM_ICONERASEBKGND";
4576 case 0x0028: return "WM_NEXTDLGCTL";
4577 case 0x002A: return "WM_SPOOLERSTATUS";
4578 case 0x002B: return "WM_DRAWITEM";
4579 case 0x002C: return "WM_MEASUREITEM";
4580 case 0x002D: return "WM_DELETEITEM";
4581 case 0x002E: return "WM_VKEYTOITEM";
4582 case 0x002F: return "WM_CHARTOITEM";
4583 case 0x0030: return "WM_SETFONT";
4584 case 0x0031: return "WM_GETFONT";
4585 case 0x0037: return "WM_QUERYDRAGICON";
4586 case 0x0039: return "WM_COMPAREITEM";
4587 case 0x0041: return "WM_COMPACTING";
4588 case 0x0044: return "WM_COMMNOTIFY";
4589 case 0x0046: return "WM_WINDOWPOSCHANGING";
4590 case 0x0047: return "WM_WINDOWPOSCHANGED";
4591 case 0x0048: return "WM_POWER";
4594 case 0x004A: return "WM_COPYDATA";
4595 case 0x004B: return "WM_CANCELJOURNAL";
4596 case 0x004E: return "WM_NOTIFY";
4597 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4598 case 0x0051: return "WM_INPUTLANGCHANGE";
4599 case 0x0052: return "WM_TCARD";
4600 case 0x0053: return "WM_HELP";
4601 case 0x0054: return "WM_USERCHANGED";
4602 case 0x0055: return "WM_NOTIFYFORMAT";
4603 case 0x007B: return "WM_CONTEXTMENU";
4604 case 0x007C: return "WM_STYLECHANGING";
4605 case 0x007D: return "WM_STYLECHANGED";
4606 case 0x007E: return "WM_DISPLAYCHANGE";
4607 case 0x007F: return "WM_GETICON";
4608 case 0x0080: return "WM_SETICON";
4611 case 0x0081: return "WM_NCCREATE";
4612 case 0x0082: return "WM_NCDESTROY";
4613 case 0x0083: return "WM_NCCALCSIZE";
4614 case 0x0084: return "WM_NCHITTEST";
4615 case 0x0085: return "WM_NCPAINT";
4616 case 0x0086: return "WM_NCACTIVATE";
4617 case 0x0087: return "WM_GETDLGCODE";
4618 case 0x00A0: return "WM_NCMOUSEMOVE";
4619 case 0x00A1: return "WM_NCLBUTTONDOWN";
4620 case 0x00A2: return "WM_NCLBUTTONUP";
4621 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4622 case 0x00A4: return "WM_NCRBUTTONDOWN";
4623 case 0x00A5: return "WM_NCRBUTTONUP";
4624 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4625 case 0x00A7: return "WM_NCMBUTTONDOWN";
4626 case 0x00A8: return "WM_NCMBUTTONUP";
4627 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4628 case 0x0100: return "WM_KEYDOWN";
4629 case 0x0101: return "WM_KEYUP";
4630 case 0x0102: return "WM_CHAR";
4631 case 0x0103: return "WM_DEADCHAR";
4632 case 0x0104: return "WM_SYSKEYDOWN";
4633 case 0x0105: return "WM_SYSKEYUP";
4634 case 0x0106: return "WM_SYSCHAR";
4635 case 0x0107: return "WM_SYSDEADCHAR";
4636 case 0x0108: return "WM_KEYLAST";
4639 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4640 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4641 case 0x010F: return "WM_IME_COMPOSITION";
4644 case 0x0110: return "WM_INITDIALOG";
4645 case 0x0111: return "WM_COMMAND";
4646 case 0x0112: return "WM_SYSCOMMAND";
4647 case 0x0113: return "WM_TIMER";
4648 case 0x0114: return "WM_HSCROLL";
4649 case 0x0115: return "WM_VSCROLL";
4650 case 0x0116: return "WM_INITMENU";
4651 case 0x0117: return "WM_INITMENUPOPUP";
4652 case 0x011F: return "WM_MENUSELECT";
4653 case 0x0120: return "WM_MENUCHAR";
4654 case 0x0121: return "WM_ENTERIDLE";
4655 case 0x0200: return "WM_MOUSEMOVE";
4656 case 0x0201: return "WM_LBUTTONDOWN";
4657 case 0x0202: return "WM_LBUTTONUP";
4658 case 0x0203: return "WM_LBUTTONDBLCLK";
4659 case 0x0204: return "WM_RBUTTONDOWN";
4660 case 0x0205: return "WM_RBUTTONUP";
4661 case 0x0206: return "WM_RBUTTONDBLCLK";
4662 case 0x0207: return "WM_MBUTTONDOWN";
4663 case 0x0208: return "WM_MBUTTONUP";
4664 case 0x0209: return "WM_MBUTTONDBLCLK";
4665 case 0x0210: return "WM_PARENTNOTIFY";
4666 case 0x0211: return "WM_ENTERMENULOOP";
4667 case 0x0212: return "WM_EXITMENULOOP";
4670 case 0x0213: return "WM_NEXTMENU";
4671 case 0x0214: return "WM_SIZING";
4672 case 0x0215: return "WM_CAPTURECHANGED";
4673 case 0x0216: return "WM_MOVING";
4674 case 0x0218: return "WM_POWERBROADCAST";
4675 case 0x0219: return "WM_DEVICECHANGE";
4678 case 0x0220: return "WM_MDICREATE";
4679 case 0x0221: return "WM_MDIDESTROY";
4680 case 0x0222: return "WM_MDIACTIVATE";
4681 case 0x0223: return "WM_MDIRESTORE";
4682 case 0x0224: return "WM_MDINEXT";
4683 case 0x0225: return "WM_MDIMAXIMIZE";
4684 case 0x0226: return "WM_MDITILE";
4685 case 0x0227: return "WM_MDICASCADE";
4686 case 0x0228: return "WM_MDIICONARRANGE";
4687 case 0x0229: return "WM_MDIGETACTIVE";
4688 case 0x0230: return "WM_MDISETMENU";
4689 case 0x0233: return "WM_DROPFILES";
4692 case 0x0281: return "WM_IME_SETCONTEXT";
4693 case 0x0282: return "WM_IME_NOTIFY";
4694 case 0x0283: return "WM_IME_CONTROL";
4695 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4696 case 0x0285: return "WM_IME_SELECT";
4697 case 0x0286: return "WM_IME_CHAR";
4698 case 0x0290: return "WM_IME_KEYDOWN";
4699 case 0x0291: return "WM_IME_KEYUP";
4702 case 0x0300: return "WM_CUT";
4703 case 0x0301: return "WM_COPY";
4704 case 0x0302: return "WM_PASTE";
4705 case 0x0303: return "WM_CLEAR";
4706 case 0x0304: return "WM_UNDO";
4707 case 0x0305: return "WM_RENDERFORMAT";
4708 case 0x0306: return "WM_RENDERALLFORMATS";
4709 case 0x0307: return "WM_DESTROYCLIPBOARD";
4710 case 0x0308: return "WM_DRAWCLIPBOARD";
4711 case 0x0309: return "WM_PAINTCLIPBOARD";
4712 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4713 case 0x030B: return "WM_SIZECLIPBOARD";
4714 case 0x030C: return "WM_ASKCBFORMATNAME";
4715 case 0x030D: return "WM_CHANGECBCHAIN";
4716 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4717 case 0x030F: return "WM_QUERYNEWPALETTE";
4718 case 0x0310: return "WM_PALETTEISCHANGING";
4719 case 0x0311: return "WM_PALETTECHANGED";
4722 // common controls messages - although they're not strictly speaking
4723 // standard, it's nice to decode them nevertheless
4726 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4727 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4728 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4729 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4730 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4731 case 0x1000 + 5: return "LVM_GETITEMA";
4732 case 0x1000 + 75: return "LVM_GETITEMW";
4733 case 0x1000 + 6: return "LVM_SETITEMA";
4734 case 0x1000 + 76: return "LVM_SETITEMW";
4735 case 0x1000 + 7: return "LVM_INSERTITEMA";
4736 case 0x1000 + 77: return "LVM_INSERTITEMW";
4737 case 0x1000 + 8: return "LVM_DELETEITEM";
4738 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4739 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4740 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4741 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4742 case 0x1000 + 13: return "LVM_FINDITEMA";
4743 case 0x1000 + 83: return "LVM_FINDITEMW";
4744 case 0x1000 + 14: return "LVM_GETITEMRECT";
4745 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4746 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4747 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4748 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4749 case 0x1000 + 18: return "LVM_HITTEST";
4750 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4751 case 0x1000 + 20: return "LVM_SCROLL";
4752 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4753 case 0x1000 + 22: return "LVM_ARRANGE";
4754 case 0x1000 + 23: return "LVM_EDITLABELA";
4755 case 0x1000 + 118: return "LVM_EDITLABELW";
4756 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4757 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4758 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4759 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4760 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4761 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4762 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4763 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4764 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4765 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4766 case 0x1000 + 31: return "LVM_GETHEADER";
4767 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4768 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4769 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4770 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4771 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4772 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4773 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4774 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4775 case 0x1000 + 41: return "LVM_GETORIGIN";
4776 case 0x1000 + 42: return "LVM_UPDATE";
4777 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4778 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4779 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4780 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4781 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4782 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4783 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4784 case 0x1000 + 48: return "LVM_SORTITEMS";
4785 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4786 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4787 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4788 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4789 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4790 case 0x1000 + 53: return "LVM_SETICONSPACING";
4791 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4792 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4793 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4794 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4795 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4796 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4797 case 0x1000 + 60: return "LVM_SETHOTITEM";
4798 case 0x1000 + 61: return "LVM_GETHOTITEM";
4799 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4800 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4801 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4802 case 0x1000 + 65: return "LVM_SETWORKAREA";
4805 case 0x1100 + 0: return "TVM_INSERTITEMA";
4806 case 0x1100 + 50: return "TVM_INSERTITEMW";
4807 case 0x1100 + 1: return "TVM_DELETEITEM";
4808 case 0x1100 + 2: return "TVM_EXPAND";
4809 case 0x1100 + 4: return "TVM_GETITEMRECT";
4810 case 0x1100 + 5: return "TVM_GETCOUNT";
4811 case 0x1100 + 6: return "TVM_GETINDENT";
4812 case 0x1100 + 7: return "TVM_SETINDENT";
4813 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4814 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4815 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4816 case 0x1100 + 11: return "TVM_SELECTITEM";
4817 case 0x1100 + 12: return "TVM_GETITEMA";
4818 case 0x1100 + 62: return "TVM_GETITEMW";
4819 case 0x1100 + 13: return "TVM_SETITEMA";
4820 case 0x1100 + 63: return "TVM_SETITEMW";
4821 case 0x1100 + 14: return "TVM_EDITLABELA";
4822 case 0x1100 + 65: return "TVM_EDITLABELW";
4823 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4824 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4825 case 0x1100 + 17: return "TVM_HITTEST";
4826 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4827 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4828 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4829 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4830 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4831 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4832 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4833 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4834 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4837 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4838 case 0x1200 + 1: return "HDM_INSERTITEMA";
4839 case 0x1200 + 10: return "HDM_INSERTITEMW";
4840 case 0x1200 + 2: return "HDM_DELETEITEM";
4841 case 0x1200 + 3: return "HDM_GETITEMA";
4842 case 0x1200 + 11: return "HDM_GETITEMW";
4843 case 0x1200 + 4: return "HDM_SETITEMA";
4844 case 0x1200 + 12: return "HDM_SETITEMW";
4845 case 0x1200 + 5: return "HDM_LAYOUT";
4846 case 0x1200 + 6: return "HDM_HITTEST";
4847 case 0x1200 + 7: return "HDM_GETITEMRECT";
4848 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4849 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4850 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4851 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4852 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4853 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4854 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4857 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4858 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4859 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4860 case 0x1300 + 5: return "TCM_GETITEMA";
4861 case 0x1300 + 60: return "TCM_GETITEMW";
4862 case 0x1300 + 6: return "TCM_SETITEMA";
4863 case 0x1300 + 61: return "TCM_SETITEMW";
4864 case 0x1300 + 7: return "TCM_INSERTITEMA";
4865 case 0x1300 + 62: return "TCM_INSERTITEMW";
4866 case 0x1300 + 8: return "TCM_DELETEITEM";
4867 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4868 case 0x1300 + 10: return "TCM_GETITEMRECT";
4869 case 0x1300 + 11: return "TCM_GETCURSEL";
4870 case 0x1300 + 12: return "TCM_SETCURSEL";
4871 case 0x1300 + 13: return "TCM_HITTEST";
4872 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4873 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4874 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4875 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4876 case 0x1300 + 43: return "TCM_SETPADDING";
4877 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4878 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4879 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4880 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4881 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4882 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4883 case 0x1300 + 50: return "TCM_DESELECTALL";
4886 case WM_USER
+1: return "TB_ENABLEBUTTON";
4887 case WM_USER
+2: return "TB_CHECKBUTTON";
4888 case WM_USER
+3: return "TB_PRESSBUTTON";
4889 case WM_USER
+4: return "TB_HIDEBUTTON";
4890 case WM_USER
+5: return "TB_INDETERMINATE";
4891 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4892 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4893 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4894 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4895 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4896 case WM_USER
+17: return "TB_SETSTATE";
4897 case WM_USER
+18: return "TB_GETSTATE";
4898 case WM_USER
+19: return "TB_ADDBITMAP";
4899 case WM_USER
+20: return "TB_ADDBUTTONS";
4900 case WM_USER
+21: return "TB_INSERTBUTTON";
4901 case WM_USER
+22: return "TB_DELETEBUTTON";
4902 case WM_USER
+23: return "TB_GETBUTTON";
4903 case WM_USER
+24: return "TB_BUTTONCOUNT";
4904 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4905 case WM_USER
+26: return "TB_SAVERESTOREA";
4906 case WM_USER
+76: return "TB_SAVERESTOREW";
4907 case WM_USER
+27: return "TB_CUSTOMIZE";
4908 case WM_USER
+28: return "TB_ADDSTRINGA";
4909 case WM_USER
+77: return "TB_ADDSTRINGW";
4910 case WM_USER
+29: return "TB_GETITEMRECT";
4911 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4912 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4913 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4914 case WM_USER
+33: return "TB_AUTOSIZE";
4915 case WM_USER
+35: return "TB_GETTOOLTIPS";
4916 case WM_USER
+36: return "TB_SETTOOLTIPS";
4917 case WM_USER
+37: return "TB_SETPARENT";
4918 case WM_USER
+39: return "TB_SETROWS";
4919 case WM_USER
+40: return "TB_GETROWS";
4920 case WM_USER
+42: return "TB_SETCMDID";
4921 case WM_USER
+43: return "TB_CHANGEBITMAP";
4922 case WM_USER
+44: return "TB_GETBITMAP";
4923 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4924 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4925 case WM_USER
+46: return "TB_REPLACEBITMAP";
4926 case WM_USER
+47: return "TB_SETINDENT";
4927 case WM_USER
+48: return "TB_SETIMAGELIST";
4928 case WM_USER
+49: return "TB_GETIMAGELIST";
4929 case WM_USER
+50: return "TB_LOADIMAGES";
4930 case WM_USER
+51: return "TB_GETRECT";
4931 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4932 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4933 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4934 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4935 case WM_USER
+56: return "TB_SETSTYLE";
4936 case WM_USER
+57: return "TB_GETSTYLE";
4937 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4938 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4939 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4940 case WM_USER
+61: return "TB_GETTEXTROWS";
4941 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4946 static char s_szBuf
[128];
4947 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4951 #endif //__WXDEBUG__