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"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/settings.h"
37 #include "wx/msgdlg.h"
41 #include "wx/ownerdrw.h"
45 #include "wx/msw/ole/droptgt.h"
48 #include "wx/menuitem.h"
50 #include "wx/msw/private.h"
64 #include <wx/msw/gnuwin32/extra.h>
84 const char *wxGetMessageName(int message
);
87 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
89 wxMenu
*wxCurrentPopupMenu
= NULL
;
90 extern wxList wxPendingDelete
;
92 void wxRemoveHandleAssociation(wxWindow
*win
);
93 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
94 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
96 #if !USE_SHARED_LIBRARY
97 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
99 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
100 EVT_CHAR(wxWindow::OnChar
)
101 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
102 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
103 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
104 EVT_IDLE(wxWindow::OnIdle
)
109 // Find an item given the MS Windows id
110 wxWindow
*wxWindow::FindItem(int id
) const
114 wxNode
*current
= GetChildren()->First();
117 wxWindow
*childWin
= (wxWindow
*)current
->Data();
119 wxWindow
*wnd
= childWin
->FindItem(id
) ;
123 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
125 wxControl
*item
= (wxControl
*)childWin
;
126 if (item
->m_windowId
== id
)
130 // In case it's a 'virtual' control (e.g. radiobox)
131 if (item
->GetSubcontrols().Member((wxObject
*)id
))
135 current
= current
->Next();
140 // Find an item given the MS Windows handle
141 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
145 wxNode
*current
= GetChildren()->First();
148 wxObject
*obj
= (wxObject
*)current
->Data() ;
149 // Do a recursive search.
150 wxWindow
*parent
= (wxWindow
*)obj
;
151 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
155 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
157 wxWindow
*item
= (wxWindow
*)current
->Data();
158 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
162 if ( item
->ContainsHWND(hWnd
) )
166 current
= current
->Next();
171 // Default command handler
172 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
177 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
), WXLPARAM
WXUNUSED(lParam
))
182 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
186 WXHWND
wxWindow::GetHWND(void) const
188 return (WXHWND
) m_hWnd
;
191 void wxWindow::SetHWND(WXHWND hWnd
)
197 wxWindow::wxWindow(void)
203 m_windowParent
= NULL
;
204 m_windowEventHandler
= this;
206 m_windowCursor
= *wxSTANDARD_CURSOR
;
207 m_children
= new wxList
;
208 m_doubleClickAllowed
= 0 ;
209 m_winCaptured
= FALSE
;
210 m_constraints
= NULL
;
211 m_constraintsInvolvedIn
= NULL
;
212 m_windowSizer
= NULL
;
213 m_sizerParent
= NULL
;
214 m_autoLayout
= FALSE
;
215 m_windowValidator
= NULL
;
220 m_caretWidth
= 0; m_caretHeight
= 0;
221 m_caretEnabled
= FALSE
;
222 m_caretShown
= FALSE
;
230 m_isBeingDeleted
= FALSE
;
237 m_defaultItem
= NULL
;
239 wxSystemSettings settings
;
241 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
) ; ;
242 m_foregroundColour
= *wxBLACK
;
243 m_defaultForegroundColour
= *wxBLACK
;
244 m_defaultBackgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
247 wxColour(GetRValue(GetSysColor(COLOR_WINDOW)),
248 GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
255 // m_acceleratorTable = 0;
260 m_backgroundTransparent
= FALSE
;
262 m_lastXPos
= (float)-1.0;
263 m_lastYPos
= (float)-1.0;
267 #if USE_DRAG_AND_DROP
268 m_pDropTarget
= NULL
;
273 wxWindow::~wxWindow(void)
275 m_isBeingDeleted
= TRUE
;
277 // JACS - if behaviour is odd, restore this
278 // to the start of ~wxWindow. Vadim has changed
279 // it to nearer the end. Unsure of side-effects
280 // e.g. when deleting associated global data.
281 // Restore old Window proc, if required
284 // Have to delete constraints/sizer FIRST otherwise
285 // sizers may try to look at deleted windows as they
286 // delete themselves.
288 DeleteRelatedConstraints();
291 // This removes any dangling pointers to this window
292 // in other windows' constraintsInvolvedIn lists.
293 UnsetConstraints(m_constraints
);
294 delete m_constraints
;
295 m_constraints
= NULL
;
299 delete m_windowSizer
;
300 m_windowSizer
= NULL
;
302 // If this is a child of a sizer, remove self from parent
304 m_sizerParent
->RemoveChild((wxWindow
*)this);
308 MSWDetachWindowMenu();
311 m_windowParent
->RemoveChild(this);
316 ::DestroyWindow((HWND
)m_hWnd
);
318 wxRemoveHandleAssociation(this);
323 GlobalFree((HGLOBAL
) m_globalHandle
);
331 // Just in case the window has been Closed, but
332 // we're then deleting immediately: don't leave
333 // dangling pointers.
334 wxPendingDelete
.DeleteObject(this);
336 // Just in case we've loaded a top-level window via
337 // wxWindow::LoadNativeDialog but we weren't a dialog
339 wxTopLevelWindows
.DeleteObject(this);
341 if ( m_windowValidator
)
342 delete m_windowValidator
;
344 // Restore old Window proc, if required
345 // and remove hWnd <-> wxWindow association
349 // Destroy the window (delayed, if a managed window)
350 bool wxWindow::Destroy(void)
356 extern char wxCanvasClassName
[];
359 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
363 const wxString
& name
)
366 m_isBeingDeleted
= FALSE
;
370 m_windowParent
= NULL
;
371 m_windowEventHandler
= this;
373 m_windowCursor
= *wxSTANDARD_CURSOR
;
374 m_doubleClickAllowed
= 0 ;
375 m_winCaptured
= FALSE
;
376 m_constraints
= NULL
;
377 m_constraintsInvolvedIn
= NULL
;
378 m_windowSizer
= NULL
;
379 m_sizerParent
= NULL
;
380 m_autoLayout
= FALSE
;
381 m_windowValidator
= NULL
;
382 #if USE_DRAG_AND_DROP
383 m_pDropTarget
= NULL
;
389 m_caretWidth
= 0; m_caretHeight
= 0;
390 m_caretEnabled
= FALSE
;
391 m_caretShown
= FALSE
;
402 m_defaultItem
= NULL
;
403 m_windowParent
= NULL
;
404 m_mouseInWindow
= FALSE
;
408 if (parent
) parent
->AddChild(this);
418 m_backgroundTransparent
= FALSE
;
420 m_lastXPos
= (float)-1.0;
421 m_lastYPos
= (float)-1.0;
428 m_windowId
= (int)NewControlId();
437 wxSystemSettings settings
;
439 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
) ; ;
440 m_foregroundColour
= *wxBLACK
;
441 m_defaultForegroundColour
= *wxBLACK
;
442 m_defaultBackgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
444 m_windowStyle
= style
;
447 if (style
& wxBORDER
)
448 msflags
|= WS_BORDER
;
449 if (style
& wxTHICK_FRAME
)
450 msflags
|= WS_THICKFRAME
;
452 msflags
|= WS_CHILD
| WS_VISIBLE
;
453 if (style
& wxCLIP_CHILDREN
)
454 msflags
|= WS_CLIPCHILDREN
;
457 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
459 // Even with extended styles, need to combine with WS_BORDER
460 // for them to look right.
461 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
462 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
463 msflags
|= WS_BORDER
;
465 m_mouseInWindow
= FALSE
;
467 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
468 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
473 void wxWindow::SetFocus(void)
475 HWND hWnd
= (HWND
) GetHWND();
480 void wxWindow::Enable(bool enable
)
482 m_winEnabled
= enable
;
483 HWND hWnd
= (HWND
) GetHWND();
485 ::EnableWindow(hWnd
, (BOOL
)enable
);
488 void wxWindow::CaptureMouse(void)
490 HWND hWnd
= (HWND
) GetHWND();
491 if (hWnd
&& !m_winCaptured
)
494 m_winCaptured
= TRUE
;
498 void wxWindow::ReleaseMouse(void)
503 m_winCaptured
= FALSE
;
507 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
509 m_acceleratorTable
= accel
;
513 // Push/pop event handler (i.e. allow a chain of event handlers
515 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
517 handler
->SetNextHandler(GetEventHandler());
518 SetEventHandler(handler
);
521 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
523 if ( GetEventHandler() )
525 wxEvtHandler
*handlerA
= GetEventHandler();
526 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
527 handlerA
->SetNextHandler(NULL
);
528 SetEventHandler(handlerB
);
541 #if USE_DRAG_AND_DROP
543 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
545 if ( m_pDropTarget
!= 0 ) {
546 m_pDropTarget
->Revoke(m_hWnd
);
547 delete m_pDropTarget
;
550 m_pDropTarget
= pDropTarget
;
551 if ( m_pDropTarget
!= 0 )
552 m_pDropTarget
->Register(m_hWnd
);
557 //old style file-manager drag&drop support
558 // I think we should retain the old-style
559 // DragAcceptFiles in parallel with SetDropTarget.
561 void wxWindow::DragAcceptFiles(bool accept
)
563 HWND hWnd
= (HWND
) GetHWND();
565 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
569 void wxWindow::GetSize(int *x
, int *y
) const
571 HWND hWnd
= (HWND
) GetHWND();
573 GetWindowRect(hWnd
, &rect
);
574 *x
= rect
.right
- rect
.left
;
575 *y
= rect
.bottom
- rect
.top
;
578 void wxWindow::GetPosition(int *x
, int *y
) const
580 HWND hWnd
= (HWND
) GetHWND();
583 hParentWnd
= (HWND
) GetParent()->GetHWND();
586 GetWindowRect(hWnd
, &rect
);
588 // Since we now have the absolute screen coords,
589 // if there's a parent we must subtract its top left corner
595 ::ScreenToClient(hParentWnd
, &point
);
598 // We may be faking the client origin.
599 // So a window that's really at (0, 30) may appear
600 // (to wxWin apps) to be at (0, 0).
603 wxPoint
pt(GetParent()->GetClientAreaOrigin());
611 void wxWindow::ScreenToClient(int *x
, int *y
) const
613 HWND hWnd
= (HWND
) GetHWND();
617 ::ScreenToClient(hWnd
, &pt
);
620 // We may be faking the client origin.
621 // So a window that's really at (0, 30) may appear
622 // (to wxWin apps) to be at (0, 0).
625 wxPoint pt1(GetParent()->GetClientAreaOrigin());
635 void wxWindow::ClientToScreen(int *x
, int *y
) const
637 HWND hWnd
= (HWND
) GetHWND();
643 // We may be faking the client origin.
644 // So a window that's really at (0, 30) may appear
645 // (to wxWin apps) to be at (0, 0).
648 wxPoint pt1(GetParent()->GetClientAreaOrigin());
654 ::ClientToScreen(hWnd
, &pt
);
660 void wxWindow::SetCursor(const wxCursor
& cursor
)
662 m_windowCursor
= cursor
;
663 if (m_windowCursor
.Ok())
665 HWND hWnd
= (HWND
) GetHWND();
667 // Change the cursor NOW if we're within the correct window
669 ::GetCursorPos(&point
);
672 ::GetWindowRect(hWnd
, &rect
);
674 if (::PtInRect(&rect
, point
) && !wxIsBusy())
675 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
678 // This will cause big reentrancy problems if wxFlushEvents is implemented.
680 // return old_cursor;
684 // Get size *available for subwindows* i.e. excluding menu bar etc.
685 void wxWindow::GetClientSize(int *x
, int *y
) const
687 HWND hWnd
= (HWND
) GetHWND();
689 GetClientRect(hWnd
, &rect
);
694 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
696 int currentX
, currentY
;
697 GetPosition(¤tX
, ¤tY
);
698 int actualWidth
= width
;
699 int actualHeight
= height
;
702 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
704 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
707 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
709 int currentW
,currentH
;
710 GetSize(¤tW
, ¤tH
);
712 actualWidth
= currentW
;
714 actualHeight
= currentH
;
716 HWND hWnd
= (HWND
) GetHWND();
718 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
721 void wxWindow::SetClientSize(int width
, int height
)
723 wxWindow
*parent
= GetParent();
724 HWND hWnd
= (HWND
) GetHWND();
725 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
728 GetClientRect(hWnd
, &rect
);
731 GetWindowRect(hWnd
, &rect2
);
733 // Find the difference between the entire window (title bar and all)
734 // and the client area; add this to the new client size to move the
736 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
737 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
739 // If there's a parent, must subtract the parent's top left corner
740 // since MoveWindow moves relative to the parent
743 point
.x
= rect2
.left
;
747 ::ScreenToClient(hParentWnd
, &point
);
750 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
752 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
753 event
.SetEventObject(this);
754 GetEventHandler()->ProcessEvent(event
);
757 // For implementation purposes - sometimes decorations make the client area
759 wxPoint
wxWindow::GetClientAreaOrigin() const
761 return wxPoint(0, 0);
764 // Makes an adjustment to the window position (for example, a frame that has
765 // a toolbar that it manages itself).
766 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
768 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
770 wxPoint
pt(GetParent()->GetClientAreaOrigin());
771 x
+= pt
.x
; y
+= pt
.y
;
775 bool wxWindow::Show(bool show
)
777 HWND hWnd
= (HWND
) GetHWND();
783 ShowWindow(hWnd
, (BOOL
)cshow
);
786 BringWindowToTop(hWnd
);
787 // Next line causes a crash on NT, apparently.
788 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
793 bool wxWindow::IsShown(void) const
795 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
798 int wxWindow::GetCharHeight(void) const
800 TEXTMETRIC lpTextMetric
;
801 HWND hWnd
= (HWND
) GetHWND();
802 HDC dc
= ::GetDC(hWnd
);
804 GetTextMetrics(dc
, &lpTextMetric
);
805 ::ReleaseDC(hWnd
, dc
);
807 return lpTextMetric
.tmHeight
;
810 int wxWindow::GetCharWidth(void) const
812 TEXTMETRIC lpTextMetric
;
813 HWND hWnd
= (HWND
) GetHWND();
814 HDC dc
= ::GetDC(hWnd
);
816 GetTextMetrics(dc
, &lpTextMetric
);
817 ::ReleaseDC(hWnd
, dc
);
819 return lpTextMetric
.tmAveCharWidth
;
822 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
823 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
825 wxFont
*fontToUse
= (wxFont
*)theFont
;
827 fontToUse
= (wxFont
*) & m_windowFont
;
829 HWND hWnd
= (HWND
) GetHWND();
830 HDC dc
= ::GetDC(hWnd
);
834 if (fontToUse
&& fontToUse
->Ok())
836 if ((fnt
=(HFONT
) fontToUse
->GetResourceHandle()))
837 was
= (HFONT
) SelectObject(dc
,fnt
) ;
842 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
843 GetTextMetrics(dc
, &tm
);
845 if (fontToUse
&& fnt
&& was
)
846 SelectObject(dc
,was
) ;
852 if (descent
) *descent
= tm
.tmDescent
;
853 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
856 // fontToUse->ReleaseResource();
859 void wxWindow::Refresh(bool eraseBack
, const wxRectangle
*rect
)
861 HWND hWnd
= (HWND
) GetHWND();
867 mswRect
.left
= rect
->x
;
868 mswRect
.top
= rect
->y
;
869 mswRect
.right
= rect
->x
+ rect
->width
;
870 mswRect
.bottom
= rect
->y
+ rect
->height
;
872 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
875 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
879 bool wxWindow::ProcessEvent(wxEvent
& event
)
881 // we save here the information about the last message because it might be
882 // overwritten if the event handler sends any messages to our window (case
883 // in point: wxNotebook::OnSize) - and then if we call Default() later
884 // (which is done quite often if the message is not processed) it will use
885 // incorrect values for m_lastXXX variables
886 WXUINT lastMsg
= m_lastMsg
;
887 WXWPARAM lastWParam
= m_lastWParam
;
888 WXLPARAM lastLParam
= m_lastLParam
;
890 // call the base version
891 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
895 m_lastWParam
= lastWParam
;
896 m_lastLParam
= lastLParam
;
901 // Hook for new window just as it's being created,
902 // when the window isn't yet associated with the handle
903 wxWindow
*wxWndHook
= NULL
;
906 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
908 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
910 if (!wnd
&& wxWndHook
)
912 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
915 wnd
->m_hWnd
= (WXHWND
) hWnd
;
918 wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd
, m_hWnd
, message
);
920 // Stop right here if we don't have a valid handle
921 // in our wxWnd object.
922 if (wnd
&& !wnd
->m_hWnd
) {
923 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
924 wnd
->m_hWnd
= (WXHWND
) hWnd
;
925 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
931 wnd
->m_lastMsg
= message
;
932 wnd
->m_lastWParam
= wParam
;
933 wnd
->m_lastLParam
= lParam
;
936 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
938 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
941 // Should probably have a test for 'genuine' NT
942 #if defined(__WIN32__)
943 #define DIMENSION_TYPE short
945 #define DIMENSION_TYPE int
948 // Main Windows 3 window proc
949 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
951 wxASSERT( m_lastMsg
== message
&&
952 m_lastWParam
== wParam
&&
953 m_lastLParam
== lParam
);
956 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
957 wxGetMessageName(message
), wParam
, lParam
);
960 HWND hWnd
= (HWND
)m_hWnd
;
967 WORD state
= LOWORD(wParam
);
968 WORD minimized
= HIWORD(wParam
);
969 HWND hwnd
= (HWND
)lParam
;
971 WORD state
= (WORD
)wParam
;
972 WORD minimized
= LOWORD(lParam
);
973 HWND hwnd
= (HWND
)HIWORD(lParam
);
975 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
981 HWND hwnd
= (HWND
)wParam
;
982 // return OnSetFocus(hwnd);
984 if (MSWOnSetFocus((WXHWND
) hwnd
))
986 else return MSWDefWindowProc(message
, wParam
, lParam
);
991 HWND hwnd
= (HWND
)lParam
;
992 // return OnKillFocus(hwnd);
993 if (MSWOnKillFocus((WXHWND
) hwnd
))
996 return MSWDefWindowProc(message
, wParam
, lParam
);
1001 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
1007 MSWOnShow((wParam
!= 0), (int) lParam
);
1014 else return MSWDefWindowProc(message
, wParam
, lParam
);
1017 case WM_QUERYDRAGICON
:
1020 if ((hIcon
= (HICON
) MSWOnQueryDragIcon()))
1022 else return MSWDefWindowProc(message
, wParam
, lParam
);
1028 int width
= LOWORD(lParam
);
1029 int height
= HIWORD(lParam
);
1030 MSWOnSize(width
, height
, wParam
);
1036 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1038 event
.SetEventObject(this);
1039 if ( !GetEventHandler()->ProcessEvent(event
) )
1044 case WM_WINDOWPOSCHANGING
:
1046 MSWOnWindowPosChanging((void *)lParam
);
1050 case WM_RBUTTONDOWN
:
1052 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1053 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1054 MSWOnRButtonDown(x
, y
, wParam
);
1059 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1060 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1061 MSWOnRButtonUp(x
, y
, wParam
);
1064 case WM_RBUTTONDBLCLK
:
1066 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1067 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1068 MSWOnRButtonDClick(x
, y
, wParam
);
1071 case WM_MBUTTONDOWN
:
1073 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1074 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1075 MSWOnMButtonDown(x
, y
, wParam
);
1080 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1081 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1082 MSWOnMButtonUp(x
, y
, wParam
);
1085 case WM_MBUTTONDBLCLK
:
1087 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1088 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1089 MSWOnMButtonDClick(x
, y
, wParam
);
1092 case WM_LBUTTONDOWN
:
1094 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1095 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1096 MSWOnLButtonDown(x
, y
, wParam
);
1101 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1102 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1103 MSWOnLButtonUp(x
, y
, wParam
);
1106 case WM_LBUTTONDBLCLK
:
1108 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1109 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1110 MSWOnLButtonDClick(x
, y
, wParam
);
1115 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1116 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1117 MSWOnMouseMove(x
, y
, wParam
);
1120 case MM_JOY1BUTTONDOWN
:
1122 int x
= LOWORD(lParam
);
1123 int y
= HIWORD(lParam
);
1124 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1127 case MM_JOY2BUTTONDOWN
:
1129 int x
= LOWORD(lParam
);
1130 int y
= HIWORD(lParam
);
1131 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1134 case MM_JOY1BUTTONUP
:
1136 int x
= LOWORD(lParam
);
1137 int y
= HIWORD(lParam
);
1138 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1141 case MM_JOY2BUTTONUP
:
1143 int x
= LOWORD(lParam
);
1144 int y
= HIWORD(lParam
);
1145 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1150 int x
= LOWORD(lParam
);
1151 int y
= HIWORD(lParam
);
1152 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1157 int x
= LOWORD(lParam
);
1158 int y
= HIWORD(lParam
);
1159 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1164 int z
= LOWORD(lParam
);
1165 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1170 int z
= LOWORD(lParam
);
1171 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1178 else return MSWDefWindowProc(message
, wParam
, lParam
);
1183 return MSWOnSysCommand(wParam
, lParam
);
1189 WORD id
= LOWORD(wParam
);
1190 HWND hwnd
= (HWND
)lParam
;
1191 WORD cmd
= HIWORD(wParam
);
1193 WORD id
= (WORD
)wParam
;
1194 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1195 WORD cmd
= HIWORD(lParam
);
1197 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1198 return MSWDefWindowProc(message
, wParam
, lParam
);
1201 #if defined(__WIN95__)
1204 if (!MSWOnNotify(wParam
, lParam
))
1205 return MSWDefWindowProc(message
, wParam
, lParam
);
1212 WORD flags
= HIWORD(wParam
);
1213 HMENU sysmenu
= (HMENU
)lParam
;
1215 WORD flags
= LOWORD(lParam
);
1216 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1218 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1221 case WM_INITMENUPOPUP
:
1223 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1228 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1231 case WM_MEASUREITEM
:
1233 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1238 // we consider these message "not interesting"
1239 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1242 // Avoid duplicate messages to OnChar
1243 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1244 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1245 (wParam
!= VK_TAB
) )
1247 MSWOnChar((WORD
)wParam
, lParam
);
1248 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1251 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1252 MSWOnChar((WORD
)wParam
, lParam
);
1257 case WM_CHAR
: // Always an ASCII character
1259 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1266 WORD code
= LOWORD(wParam
);
1267 WORD pos
= HIWORD(wParam
);
1268 HWND control
= (HWND
)lParam
;
1270 WORD code
= (WORD
)wParam
;
1271 WORD pos
= LOWORD(lParam
);
1272 HWND control
= (HWND
)HIWORD(lParam
);
1274 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1280 WORD code
= LOWORD(wParam
);
1281 WORD pos
= HIWORD(wParam
);
1282 HWND control
= (HWND
)lParam
;
1284 WORD code
= (WORD
)wParam
;
1285 WORD pos
= LOWORD(lParam
);
1286 HWND control
= (HWND
)HIWORD(lParam
);
1288 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1292 case WM_CTLCOLORBTN
:
1294 int nCtlColor
= CTLCOLOR_BTN
;
1295 HWND control
= (HWND
)lParam
;
1296 HDC pDC
= (HDC
)wParam
;
1297 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1298 message
, wParam
, lParam
);
1301 case WM_CTLCOLORDLG
:
1303 int nCtlColor
= CTLCOLOR_DLG
;
1304 HWND control
= (HWND
)lParam
;
1305 HDC pDC
= (HDC
)wParam
;
1306 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1307 message
, wParam
, lParam
);\
1310 case WM_CTLCOLORLISTBOX
:
1312 int nCtlColor
= CTLCOLOR_LISTBOX
;
1313 HWND control
= (HWND
)lParam
;
1314 HDC pDC
= (HDC
)wParam
;
1315 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1316 message
, wParam
, lParam
);
1319 case WM_CTLCOLORMSGBOX
:
1321 int nCtlColor
= CTLCOLOR_MSGBOX
;
1322 HWND control
= (HWND
)lParam
;
1323 HDC pDC
= (HDC
)wParam
;
1324 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1325 message
, wParam
, lParam
);
1328 case WM_CTLCOLORSCROLLBAR
:
1330 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1331 HWND control
= (HWND
)lParam
;
1332 HDC pDC
= (HDC
)wParam
;
1333 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1334 message
, wParam
, lParam
);
1337 case WM_CTLCOLORSTATIC
:
1339 int nCtlColor
= CTLCOLOR_STATIC
;
1340 HWND control
= (HWND
)lParam
;
1341 HDC pDC
= (HDC
)wParam
;
1342 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1343 message
, wParam
, lParam
);
1346 case WM_CTLCOLOREDIT
:
1348 int nCtlColor
= CTLCOLOR_EDIT
;
1349 HWND control
= (HWND
)lParam
;
1350 HDC pDC
= (HDC
)wParam
;
1351 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1352 message
, wParam
, lParam
);
1358 HWND control
= (HWND
)LOWORD(lParam
);
1359 int nCtlColor
= (int)HIWORD(lParam
);
1360 HDC pDC
= (HDC
)wParam
;
1361 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1362 message
, wParam
, lParam
);
1366 case WM_SYSCOLORCHANGE
:
1368 // Return value of 0 means, we processed it.
1369 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1372 return MSWDefWindowProc(message
, wParam
, lParam
);
1375 case WM_PALETTECHANGED
:
1377 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1380 case WM_QUERYNEWPALETTE
:
1382 return MSWOnQueryNewPalette();
1387 // Prevents flicker when dragging
1388 if (IsIconic(hWnd
)) return 1;
1390 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1391 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1395 case WM_MDIACTIVATE
:
1398 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1399 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1400 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1401 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1403 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1404 (HWND
)HIWORD(lParam
));
1409 MSWOnDropFiles(wParam
);
1414 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1417 case WM_QUERYENDSESSION
:
1419 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1420 return MSWOnClose();
1432 case WM_GETMINMAXINFO
:
1434 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1435 if (m_minSizeX
!= -1)
1436 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1437 if (m_minSizeY
!= -1)
1438 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1439 if (m_maxSizeX
!= -1)
1440 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1441 if (m_maxSizeY
!= -1)
1442 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1443 return MSWDefWindowProc(message
, wParam
, lParam
);
1448 return MSWGetDlgCode();
1451 return MSWDefWindowProc(message
, wParam
, lParam
);
1453 return 0; // Success: we processed this command.
1456 // Dialog window proc
1457 LONG APIENTRY _EXPORT
1458 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1463 wxList
*wxWinHandleList
= NULL
;
1464 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1466 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1469 return (wxWindow
*)node
->Data();
1472 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1474 // adding NULL hWnd is (first) surely a result of an error and
1475 // (secondly) breaks menu command processing
1476 wxCHECK_RET( hWnd
!= NULL
, "attempt to add a NULL hWnd to window list" );
1478 if ( !wxWinHandleList
->Find((long)hWnd
) )
1479 wxWinHandleList
->Append((long)hWnd
, win
);
1482 void wxRemoveHandleAssociation(wxWindow
*win
)
1484 wxWinHandleList
->DeleteObject(win
);
1487 // Default destroyer - override if you destroy it in some other way
1488 // (e.g. with MDI child windows)
1489 void wxWindow::MSWDestroyWindow(void)
1493 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1494 int x
, int y
, int width
, int height
,
1495 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1497 bool is_dialog
= (dialog_template
!= NULL
);
1498 int x1
= CW_USEDEFAULT
;
1500 int width1
= CW_USEDEFAULT
;
1503 // Find parent's size, if it exists, to set up a possible default
1504 // panel size the size of the parent window
1508 // Was GetWindowRect: JACS 5/5/95
1509 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1511 width1
= parent_rect
.right
- parent_rect
.left
;
1512 height1
= parent_rect
.bottom
- parent_rect
.top
;
1517 if (width
> -1) width1
= width
;
1518 if (height
> -1) height1
= height
;
1520 HWND hParent
= NULL
;
1522 hParent
= (HWND
) parent
->GetHWND();
1528 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1529 // other compilers???
1530 // VZ: it's always needed for Win16 and never for Win32
1532 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1533 (DLGPROC
)wxDlgProc
);
1535 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1537 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1542 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1543 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1544 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1549 if (style
& WS_CHILD
)
1554 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1559 hParent
, (HMENU
)controlId
, wxGetInstance(),
1563 wxLogError("Can't create window of class %s!\n"
1564 "Possible Windows 3.x compatibility problem?", wclass
);
1569 wxWinHandleList
->Append((long)m_hWnd
, this);
1572 wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd
);
1576 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1580 bool wxWindow::MSWOnClose(void)
1583 wxDebugMsg("wxWindow::MSWOnClose %d\n", handle
);
1588 bool wxWindow::MSWOnDestroy(void)
1591 wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle
);
1593 // delete our drop target if we've got one
1594 #if USE_DRAG_AND_DROP
1595 if ( m_pDropTarget
!= NULL
) {
1596 m_pDropTarget
->Revoke(m_hWnd
);
1598 delete m_pDropTarget
;
1599 m_pDropTarget
= NULL
;
1606 // Deal with child commands from buttons etc.
1608 bool wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1610 #if defined(__WIN95__)
1611 // Find a child window to send the notification to, e.g. a toolbar.
1612 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1613 // handle of the toolbar; it's probably the handle of the tooltip
1614 // window (anyway, it's parent is also the toolbar's parent).
1615 // So, since we don't know which hWnd or wxWindow originated the
1616 // WM_NOTIFY, we'll need to go through all the children of this window
1617 // trying out MSWNotify.
1618 // This won't work now, though, because any number of controls
1619 // could respond to the same generic messages :-(
1621 /* This doesn't work for toolbars, but try for other controls first.
1623 NMHDR
*hdr
= (NMHDR
*)lParam
;
1624 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1625 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1628 return win
->MSWNotify(wParam
, lParam
);
1631 // Rely on MSWNotify to check whether the message
1632 // belongs to the window or not
1633 wxNode
*node
= GetChildren()->First();
1636 wxWindow
*child
= (wxWindow
*)node
->Data();
1637 if ( child
->MSWNotify(wParam
, lParam
) )
1639 node
= node
->Next();
1649 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1652 wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle
);
1656 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1660 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1663 wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle
);
1666 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1668 event
.SetEventObject(this);
1669 GetEventHandler()->ProcessEvent(event
);
1673 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1676 wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd
);
1679 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1681 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1683 ::ShowCaret((HWND
) GetHWND());
1686 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1687 event
.SetEventObject(this);
1688 if (!GetEventHandler()->ProcessEvent(event
))
1693 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1696 wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd
);
1704 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1705 event
.SetEventObject(this);
1706 if (!GetEventHandler()->ProcessEvent(event
))
1711 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1714 wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd
);
1717 HDROP hFilesInfo
= (HDROP
) wParam
;
1719 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1721 // Get the total number of files dropped
1722 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1727 wxString
*files
= new wxString
[gwFilesDropped
];
1729 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1731 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1732 files
[wIndex
] = wxBuffer
;
1734 DragFinish (hFilesInfo
);
1736 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1737 event
.m_eventObject
= this;
1738 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1740 if (!GetEventHandler()->ProcessEvent(event
))
1746 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1749 if ( id
== 0 ) { // is it a menu item?
1750 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1751 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1752 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1754 // prepare to call OnDrawItem()
1756 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1757 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1758 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1759 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1760 return pMenuItem
->OnDrawItem(
1762 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1763 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1766 #endif // owner-drawn menus
1768 wxWindow
*item
= FindItem(id
);
1769 #if USE_DYNAMIC_CLASSES
1770 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1772 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1779 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1782 if ( id
== 0 ) { // is it a menu item?
1783 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1784 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1785 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1787 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1788 &pMeasureStruct
->itemHeight
);
1790 #endif // owner-drawn menus
1792 wxWindow
*item
= FindItem(id
);
1793 #if USE_DYNAMIC_CLASSES
1794 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1796 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1803 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1804 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1807 wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd
);
1809 if (nCtlColor
== CTLCOLOR_DLG
)
1811 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1814 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1816 WXHBRUSH hBrush
= 0;
1819 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1821 // I think that even for dialogs, we may need to call DefWindowProc (?)
1822 // Or maybe just rely on the usual default behaviour.
1824 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1829 // Define for each class of dialog and control
1830 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1831 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1833 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1836 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1838 wxSysColourChangedEvent event
;
1839 event
.SetEventObject(this);
1841 // Check if app handles this.
1842 if (GetEventHandler()->ProcessEvent(event
))
1845 // We didn't process it
1849 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1851 wxPaletteChangedEvent
event(GetId());
1852 event
.SetEventObject(this);
1853 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1854 GetEventHandler()->ProcessEvent(event
);
1858 long wxWindow::MSWOnQueryNewPalette()
1860 wxQueryNewPaletteEvent
event(GetId());
1861 event
.SetEventObject(this);
1862 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1864 return (long) FALSE
;
1870 // Responds to colour changes: passes event on to children.
1871 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1873 wxNode
*node
= GetChildren()->First();
1876 // Only propagate to non-top-level windows
1877 wxWindow
*win
= (wxWindow
*)node
->Data();
1878 if ( win
->GetParent() )
1880 wxSysColourChangedEvent event2
;
1881 event
.m_eventObject
= win
;
1882 win
->GetEventHandler()->ProcessEvent(event2
);
1885 node
= node
->Next();
1889 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1892 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1894 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1897 long wxWindow::Default()
1899 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1904 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1905 wxGetMessageName(m_lastMsg
));
1908 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1911 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1913 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1914 // intercept dialog navigation keys
1915 MSG
*msg
= (MSG
*)pMsg
;
1916 bool bProcess
= TRUE
;
1917 if ( msg
->message
!= WM_KEYDOWN
)
1920 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1923 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1925 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1926 // (except for Ctrl-Tab combination which is always processed)
1928 if ( bProcess
&& !bCtrlDown
) {
1929 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1934 switch ( msg
->wParam
) {
1936 if ( lDlgCode
& DLGC_WANTTAB
) // this is FALSE for Ctrl-Tab
1939 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1944 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1952 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1964 wxNavigationKeyEvent event
;
1965 event
.SetDirection(bForward
);
1966 event
.SetWindowChange(bCtrlDown
);
1967 event
.SetEventObject(this);
1969 if ( GetEventHandler()->ProcessEvent(event
) )
1973 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
1979 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
1981 if (m_acceleratorTable
.Ok() &&
1982 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
1988 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
1991 wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd
);
1996 void wxWindow::MSWDetachWindowMenu(void)
2000 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2002 for (i
= 0; i
< N
; i
++)
2005 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2006 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2008 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2015 bool wxWindow::MSWOnPaint(void)
2018 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2019 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2021 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2024 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2026 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2027 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2030 wxPaintEvent
event(m_windowId
);
2031 event
.SetEventObject(this);
2032 if (!GetEventHandler()->ProcessEvent(event
))
2037 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2043 wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd
);
2050 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2051 event
.SetEventObject(this);
2052 if (!GetEventHandler()->ProcessEvent(event
))
2058 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2063 // Deal with child commands from buttons etc.
2064 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2067 wxDebugMsg("wxWindow::MSWOnCommand\n");
2069 if (wxCurrentPopupMenu
)
2071 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2072 wxCurrentPopupMenu
= NULL
;
2073 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2078 sprintf(buf
, "Looking for item %d...\n", id
);
2082 wxWindow
*item
= FindItem(id
);
2085 bool value
= item
->MSWCommand(cmd
, id
);
2088 wxDebugMsg("MSWCommand succeeded\n");
2090 wxDebugMsg("MSWCommand failed\n");
2096 wxWindow
*win
= wxFindWinFromHandle(control
);
2098 return win
->MSWCommand(cmd
, id
);
2103 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2109 wxMaximizeEvent
event(m_windowId
);
2110 event
.SetEventObject(this);
2111 if (!GetEventHandler()->ProcessEvent(event
))
2119 wxIconizeEvent
event(m_windowId
);
2120 event
.SetEventObject(this);
2121 if (!GetEventHandler()->ProcessEvent(event
))
2133 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2135 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2137 event
.m_x
= x
; event
.m_y
= y
;
2138 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2139 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2140 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2141 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2142 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2143 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2144 event
.m_eventObject
= this;
2146 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVENT_TYPE_LEFT_DOWN
;
2148 if (!GetEventHandler()->ProcessEvent(event
))
2152 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2154 wxMouseEvent
event(wxEVT_LEFT_UP
);
2156 event
.m_x
= x
; event
.m_y
= y
;
2157 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2158 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2159 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2160 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2161 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2162 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2163 event
.m_eventObject
= this;
2165 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2167 if (!GetEventHandler()->ProcessEvent(event
))
2171 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2173 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2175 event
.m_x
= x
; event
.m_y
= y
;
2176 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2177 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2178 event
.m_leftDown
= ((flags
& MK_LBUTTON
!= 0));
2179 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2180 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2181 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2182 event
.m_eventObject
= this;
2184 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2186 if (!GetEventHandler()->ProcessEvent(event
))
2190 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2192 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2194 event
.m_x
= x
; event
.m_y
= y
;
2195 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2196 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2197 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2198 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2199 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2200 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2201 event
.m_eventObject
= this;
2203 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2205 if (!GetEventHandler()->ProcessEvent(event
))
2209 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2211 //wxDebugMsg("MButtonUp\n") ;
2212 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2214 event
.m_x
= x
; event
.m_y
= y
;
2215 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2216 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2217 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2218 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2219 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2220 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2221 event
.m_eventObject
= this;
2223 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2225 if (!GetEventHandler()->ProcessEvent(event
))
2229 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2231 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2233 event
.m_x
= x
; event
.m_y
= y
;
2234 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2235 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2236 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2237 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2238 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2239 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2240 event
.m_eventObject
= this;
2242 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2244 if (!GetEventHandler()->ProcessEvent(event
))
2248 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2250 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2252 event
.m_x
= x
; event
.m_y
= y
;
2253 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2254 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2255 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2256 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2257 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2258 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2259 event
.m_eventObject
= this;
2261 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2263 if (!GetEventHandler()->ProcessEvent(event
))
2267 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2269 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2271 event
.m_x
= x
; event
.m_y
= y
;
2272 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2273 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2274 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2275 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2276 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2277 event
.m_eventObject
= this;
2278 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2280 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2282 if (!GetEventHandler()->ProcessEvent(event
))
2286 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2288 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2290 event
.m_x
= x
; event
.m_y
= y
;
2291 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2292 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2293 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2294 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2295 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2296 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2297 event
.m_eventObject
= this;
2299 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2301 if (!GetEventHandler()->ProcessEvent(event
))
2305 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2307 // 'normal' move event...
2308 // Set cursor, but only if we're not in 'busy' mode
2310 // Trouble with this is that it sets the cursor for controls too :-(
2311 if (m_windowCursor
.Ok() && !wxIsBusy())
2312 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2314 if (!m_mouseInWindow
)
2316 // Generate an ENTER event
2317 m_mouseInWindow
= TRUE
;
2318 MSWOnMouseEnter(x
, y
, flags
);
2321 wxMouseEvent
event(wxEVT_MOTION
);
2323 event
.m_x
= x
; event
.m_y
= y
;
2324 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2325 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2326 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2327 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2328 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2329 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2330 event
.m_eventObject
= this;
2332 // Window gets a click down message followed by a mouse move
2333 // message even if position isn't changed! We want to discard
2334 // the trailing move event if x and y are the same.
2335 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2336 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2337 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2339 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2340 m_lastEvent
= wxEVT_MOTION
;
2344 m_lastEvent
= wxEVT_MOTION
;
2345 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2347 if (!GetEventHandler()->ProcessEvent(event
))
2351 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2353 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2355 event
.m_x
= x
; event
.m_y
= y
;
2356 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2357 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2358 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2359 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2360 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2361 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2362 event
.m_eventObject
= this;
2364 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2365 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2366 // No message - ensure we don't try to call the default behaviour accidentally.
2368 GetEventHandler()->ProcessEvent(event
);
2371 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2373 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2375 event
.m_x
= x
; event
.m_y
= y
;
2376 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2377 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2378 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2379 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2380 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2381 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2382 event
.m_eventObject
= this;
2384 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2385 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2386 // No message - ensure we don't try to call the default behaviour accidentally.
2388 GetEventHandler()->ProcessEvent(event
);
2391 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2394 bool tempControlDown
= FALSE
;
2397 // If 1 -> 26, translate to CTRL plus a letter.
2399 if ((id
> 0) && (id
< 27))
2420 tempControlDown
= TRUE
;
2426 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2427 // it's ASCII and will be processed here only when called from
2428 // WM_CHAR (i.e. when isASCII = TRUE)
2434 wxKeyEvent
event(wxEVT_CHAR
);
2435 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2436 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2437 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2438 event
.m_altDown
= TRUE
;
2440 event
.m_eventObject
= this;
2441 event
.m_keyCode
= id
;
2442 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2447 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2451 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2453 if (!GetEventHandler()->ProcessEvent(event
))
2458 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2462 if (flags
& JOY_BUTTON1CHG
)
2463 change
= wxJOY_BUTTON1
;
2464 if (flags
& JOY_BUTTON2CHG
)
2465 change
= wxJOY_BUTTON2
;
2466 if (flags
& JOY_BUTTON3CHG
)
2467 change
= wxJOY_BUTTON3
;
2468 if (flags
& JOY_BUTTON4CHG
)
2469 change
= wxJOY_BUTTON4
;
2471 if (flags
& JOY_BUTTON1
)
2472 buttons
|= wxJOY_BUTTON1
;
2473 if (flags
& JOY_BUTTON2
)
2474 buttons
|= wxJOY_BUTTON2
;
2475 if (flags
& JOY_BUTTON3
)
2476 buttons
|= wxJOY_BUTTON3
;
2477 if (flags
& JOY_BUTTON4
)
2478 buttons
|= wxJOY_BUTTON4
;
2480 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2481 event
.SetPosition(wxPoint(x
, y
));
2482 event
.SetEventObject(this);
2484 GetEventHandler()->ProcessEvent(event
);
2487 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2491 if (flags
& JOY_BUTTON1CHG
)
2492 change
= wxJOY_BUTTON1
;
2493 if (flags
& JOY_BUTTON2CHG
)
2494 change
= wxJOY_BUTTON2
;
2495 if (flags
& JOY_BUTTON3CHG
)
2496 change
= wxJOY_BUTTON3
;
2497 if (flags
& JOY_BUTTON4CHG
)
2498 change
= wxJOY_BUTTON4
;
2500 if (flags
& JOY_BUTTON1
)
2501 buttons
|= wxJOY_BUTTON1
;
2502 if (flags
& JOY_BUTTON2
)
2503 buttons
|= wxJOY_BUTTON2
;
2504 if (flags
& JOY_BUTTON3
)
2505 buttons
|= wxJOY_BUTTON3
;
2506 if (flags
& JOY_BUTTON4
)
2507 buttons
|= wxJOY_BUTTON4
;
2509 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2510 event
.SetPosition(wxPoint(x
, y
));
2511 event
.SetEventObject(this);
2513 GetEventHandler()->ProcessEvent(event
);
2516 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2519 if (flags
& JOY_BUTTON1
)
2520 buttons
|= wxJOY_BUTTON1
;
2521 if (flags
& JOY_BUTTON2
)
2522 buttons
|= wxJOY_BUTTON2
;
2523 if (flags
& JOY_BUTTON3
)
2524 buttons
|= wxJOY_BUTTON3
;
2525 if (flags
& JOY_BUTTON4
)
2526 buttons
|= wxJOY_BUTTON4
;
2528 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2529 event
.SetPosition(wxPoint(x
, y
));
2530 event
.SetEventObject(this);
2532 GetEventHandler()->ProcessEvent(event
);
2535 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2538 if (flags
& JOY_BUTTON1
)
2539 buttons
|= wxJOY_BUTTON1
;
2540 if (flags
& JOY_BUTTON2
)
2541 buttons
|= wxJOY_BUTTON2
;
2542 if (flags
& JOY_BUTTON3
)
2543 buttons
|= wxJOY_BUTTON3
;
2544 if (flags
& JOY_BUTTON4
)
2545 buttons
|= wxJOY_BUTTON4
;
2547 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2548 event
.SetZPosition(z
);
2549 event
.SetEventObject(this);
2551 GetEventHandler()->ProcessEvent(event
);
2554 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2558 wxWindow
*child
= wxFindWinFromHandle(control
);
2560 child
->MSWOnVScroll(wParam
, pos
, control
);
2564 wxScrollEvent event
;
2565 event
.SetPosition(pos
);
2566 event
.SetOrientation(wxVERTICAL
);
2567 event
.m_eventObject
= this;
2572 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2576 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2580 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2584 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2588 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2592 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2596 case SB_THUMBPOSITION
:
2597 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2605 if (!GetEventHandler()->ProcessEvent(event
))
2609 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2613 wxWindow
*child
= wxFindWinFromHandle(control
);
2615 child
->MSWOnHScroll(wParam
, pos
, control
);
2621 wxScrollEvent event
;
2622 event
.SetPosition(pos
);
2623 event
.SetOrientation(wxHORIZONTAL
);
2624 event
.m_eventObject
= this;
2629 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2633 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2637 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2641 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2645 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2649 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2653 case SB_THUMBPOSITION
:
2654 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2661 if ( GetEventHandler()->ProcessEvent(event
) )
2665 // call the default WM_HSCROLL handler: it's non trivial in some common
2666 // controls (up-down control for example)
2670 void wxWindow::MSWOnShow(bool show
, int status
)
2672 wxShowEvent
event(GetId(), show
);
2673 event
.m_eventObject
= this;
2674 GetEventHandler()->ProcessEvent(event
);
2677 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2679 wxInitDialogEvent
event(GetId());
2680 event
.m_eventObject
= this;
2681 GetEventHandler()->ProcessEvent(event
);
2685 void wxWindow::InitDialog(void)
2687 wxInitDialogEvent
event(GetId());
2688 event
.SetEventObject( this );
2689 GetEventHandler()->ProcessEvent(event
);
2692 // Default init dialog behaviour is to transfer data to window
2693 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2695 TransferDataToWindow();
2698 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2701 HDC dc
= ::GetDC((HWND
) wnd
);
2707 wxDebugMsg("wxGetCharSize: Selecting HFONT %X\n", fnt
);
2709 // the_font->UseResource();
2710 // the_font->RealizeResource();
2711 if ((fnt
=(HFONT
) the_font
->GetResourceHandle()))
2712 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2714 GetTextMetrics(dc
, &tm
);
2715 if (the_font
&& fnt
&& was
)
2718 wxDebugMsg("wxGetCharSize: Selecting old HFONT %X\n", was
);
2720 SelectObject(dc
,was
) ;
2722 ReleaseDC((HWND
)wnd
, dc
);
2723 *x
= tm
.tmAveCharWidth
;
2724 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2727 // the_font->ReleaseResource();
2730 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2731 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2732 int wxCharCodeMSWToWX(int keySym
)
2737 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2738 case VK_BACK
: id
= WXK_BACK
; break;
2739 case VK_TAB
: id
= WXK_TAB
; break;
2740 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2741 case VK_RETURN
: id
= WXK_RETURN
; break;
2742 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2743 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2744 case VK_MENU
: id
= WXK_MENU
; break;
2745 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2746 case VK_SPACE
: id
= WXK_SPACE
; break;
2747 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2748 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2749 case VK_NEXT
: id
= WXK_NEXT
; break;
2750 case VK_END
: id
= WXK_END
; break;
2751 case VK_HOME
: id
= WXK_HOME
; break;
2752 case VK_LEFT
: id
= WXK_LEFT
; break;
2753 case VK_UP
: id
= WXK_UP
; break;
2754 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2755 case VK_DOWN
: id
= WXK_DOWN
; break;
2756 case VK_SELECT
: id
= WXK_SELECT
; break;
2757 case VK_PRINT
: id
= WXK_PRINT
; break;
2758 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2759 case VK_INSERT
: id
= WXK_INSERT
; break;
2760 case VK_DELETE
: id
= WXK_DELETE
; break;
2761 case VK_HELP
: id
= WXK_HELP
; break;
2762 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2763 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2764 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2765 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2766 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2767 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2768 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2769 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2770 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2771 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2772 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2773 case VK_ADD
: id
= WXK_ADD
; break;
2774 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2775 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2776 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2777 case VK_F1
: id
= WXK_F1
; break;
2778 case VK_F2
: id
= WXK_F2
; break;
2779 case VK_F3
: id
= WXK_F3
; break;
2780 case VK_F4
: id
= WXK_F4
; break;
2781 case VK_F5
: id
= WXK_F5
; break;
2782 case VK_F6
: id
= WXK_F6
; break;
2783 case VK_F7
: id
= WXK_F7
; break;
2784 case VK_F8
: id
= WXK_F8
; break;
2785 case VK_F9
: id
= WXK_F9
; break;
2786 case VK_F10
: id
= WXK_F10
; break;
2787 case VK_F11
: id
= WXK_F11
; break;
2788 case VK_F12
: id
= WXK_F12
; break;
2789 case VK_F13
: id
= WXK_F13
; break;
2790 case VK_F14
: id
= WXK_F14
; break;
2791 case VK_F15
: id
= WXK_F15
; break;
2792 case VK_F16
: id
= WXK_F16
; break;
2793 case VK_F17
: id
= WXK_F17
; break;
2794 case VK_F18
: id
= WXK_F18
; break;
2795 case VK_F19
: id
= WXK_F19
; break;
2796 case VK_F20
: id
= WXK_F20
; break;
2797 case VK_F21
: id
= WXK_F21
; break;
2798 case VK_F22
: id
= WXK_F22
; break;
2799 case VK_F23
: id
= WXK_F23
; break;
2800 case VK_F24
: id
= WXK_F24
; break;
2801 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2802 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2811 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2817 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2818 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2819 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2820 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2821 case WXK_MENU
: keySym
= VK_MENU
; break;
2822 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2823 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2824 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2825 case WXK_END
: keySym
= VK_END
; break;
2826 case WXK_HOME
: keySym
= VK_HOME
; break;
2827 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2828 case WXK_UP
: keySym
= VK_UP
; break;
2829 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2830 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2831 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2832 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2833 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2834 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2835 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2836 case WXK_HELP
: keySym
= VK_HELP
; break;
2837 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2838 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2839 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2840 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2841 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2842 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2843 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2844 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2845 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2846 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2847 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2848 case WXK_ADD
: keySym
= VK_ADD
; break;
2849 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2850 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2851 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2852 case WXK_F1
: keySym
= VK_F1
; break;
2853 case WXK_F2
: keySym
= VK_F2
; break;
2854 case WXK_F3
: keySym
= VK_F3
; break;
2855 case WXK_F4
: keySym
= VK_F4
; break;
2856 case WXK_F5
: keySym
= VK_F5
; break;
2857 case WXK_F6
: keySym
= VK_F6
; break;
2858 case WXK_F7
: keySym
= VK_F7
; break;
2859 case WXK_F8
: keySym
= VK_F8
; break;
2860 case WXK_F9
: keySym
= VK_F9
; break;
2861 case WXK_F10
: keySym
= VK_F10
; break;
2862 case WXK_F11
: keySym
= VK_F11
; break;
2863 case WXK_F12
: keySym
= VK_F12
; break;
2864 case WXK_F13
: keySym
= VK_F13
; break;
2865 case WXK_F14
: keySym
= VK_F14
; break;
2866 case WXK_F15
: keySym
= VK_F15
; break;
2867 case WXK_F16
: keySym
= VK_F16
; break;
2868 case WXK_F17
: keySym
= VK_F17
; break;
2869 case WXK_F18
: keySym
= VK_F18
; break;
2870 case WXK_F19
: keySym
= VK_F19
; break;
2871 case WXK_F20
: keySym
= VK_F20
; break;
2872 case WXK_F21
: keySym
= VK_F21
; break;
2873 case WXK_F22
: keySym
= VK_F22
; break;
2874 case WXK_F23
: keySym
= VK_F23
; break;
2875 case WXK_F24
: keySym
= VK_F24
; break;
2876 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2877 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2888 // Caret manipulation
2889 void wxWindow::CreateCaret(int w
, int h
)
2893 m_caretEnabled
= TRUE
;
2896 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2901 void wxWindow::ShowCaret(bool show
)
2906 ::ShowCaret((HWND
) GetHWND());
2908 ::HideCaret((HWND
) GetHWND());
2909 m_caretShown
= show
;
2913 void wxWindow::DestroyCaret(void)
2915 m_caretEnabled
= FALSE
;
2918 void wxWindow::SetCaretPos(int x
, int y
)
2920 ::SetCaretPos(x
, y
);
2923 void wxWindow::GetCaretPos(int *x
, int *y
) const
2926 ::GetCaretPos(&point
);
2931 wxWindow
*wxGetActiveWindow(void)
2933 HWND hWnd
= GetActiveWindow();
2936 return wxFindWinFromHandle((WXHWND
) hWnd
);
2941 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2942 // in active frames and dialogs, regardless of where the focus is.
2943 static HHOOK wxTheKeyboardHook
= 0;
2944 static FARPROC wxTheKeyboardHookProc
= 0;
2945 int APIENTRY _EXPORT
2946 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2948 void wxSetKeyboardHook(bool doIt
)
2952 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
2953 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
2955 GetCurrentThreadId());
2956 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2963 UnhookWindowsHookEx(wxTheKeyboardHook
);
2964 FreeProcInstance(wxTheKeyboardHookProc
);
2968 int APIENTRY _EXPORT
2969 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
2971 DWORD hiWord
= HIWORD(lParam
);
2972 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
2975 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
2977 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
2978 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2979 event
.m_altDown
= TRUE
;
2981 event
.m_eventObject
= NULL
;
2982 event
.m_keyCode
= id
;
2983 /* begin Albert's fix for control and shift key 26.5 */
2984 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2985 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2986 /* end Albert's fix for control and shift key 26.5 */
2987 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2989 wxWindow
*win
= wxGetActiveWindow();
2992 if (win
->GetEventHandler()->ProcessEvent(event
))
2997 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3002 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3005 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3013 void wxWindow::Centre(int direction
)
3015 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3017 wxWindow
*father
= (wxWindow
*)GetParent();
3021 father
->GetClientSize(&panel_width
, &panel_height
);
3022 GetSize(&width
, &height
);
3023 GetPosition(&x
, &y
);
3028 if (direction
& wxHORIZONTAL
)
3029 new_x
= (int)((panel_width
- width
)/2);
3031 if (direction
& wxVERTICAL
)
3032 new_y
= (int)((panel_height
- height
)/2);
3034 SetSize(new_x
, new_y
, -1, -1);
3039 void wxWindow::OnPaint(void)
3041 PaintSelectionHandles();
3045 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3047 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3048 // pixel coordinates, relatives to the canvas -- So, we first need to
3049 // substract origin of the window, then convert to screen position
3051 int x
= x_pos
; int y
= y_pos
;
3053 GetWindowRect ((HWND
) GetHWND(), &rect
);
3058 SetCursorPos (x
, y
);
3061 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3065 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3073 wxEraseEvent
event(m_windowId
, &dc
);
3074 event
.m_eventObject
= this;
3075 if (!GetEventHandler()->ProcessEvent(event
))
3078 dc
.SelectOldObjects(pDC
);
3084 dc
.SelectOldObjects(pDC
);
3087 dc
.SetHDC((WXHDC
) NULL
);
3091 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3094 ::GetClientRect((HWND
) GetHWND(), &rect
);
3096 HBRUSH hBrush
= ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
3097 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3099 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3100 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3101 ::DeleteObject(hBrush
);
3102 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3104 // Less efficient version (and doesn't account for scrolling)
3106 GetClientSize(& w, & h);
3107 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3108 event.GetDC()->SetBrush(brush);
3109 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3111 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3115 #if WXWIN_COMPATIBILITY
3116 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3118 #if defined(__WIN95__)
3122 // Try to adjust the range to cope with page size > 1
3123 // - a Windows API quirk
3124 int pageSize
= GetScrollPage(orient
);
3125 if ( pageSize
> 1 && range
> 0)
3127 range1
+= (pageSize
- 1);
3133 if (orient
== wxHORIZONTAL
) {
3139 info
.cbSize
= sizeof(SCROLLINFO
);
3140 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3144 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3146 HWND hWnd
= (HWND
) GetHWND();
3148 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3151 if (orient
== wxHORIZONTAL
)
3156 HWND hWnd
= (HWND
) GetHWND();
3158 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3162 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3164 #if defined(__WIN95__)
3168 if (orient
== wxHORIZONTAL
) {
3170 m_xThumbSize
= page
;
3173 m_yThumbSize
= page
;
3176 info
.cbSize
= sizeof(SCROLLINFO
);
3179 info
.fMask
= SIF_PAGE
;
3181 HWND hWnd
= (HWND
) GetHWND();
3183 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3185 if (orient
== wxHORIZONTAL
)
3186 m_xThumbSize
= page
;
3188 m_yThumbSize
= page
;
3192 int wxWindow::OldGetScrollRange(int orient
) const
3195 if (orient
== wxHORIZONTAL
)
3200 #if __WATCOMC__ && defined(__WINDOWS_386__)
3201 short minPos
, maxPos
;
3205 HWND hWnd
= (HWND
) GetHWND();
3208 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3209 #if defined(__WIN95__)
3210 // Try to adjust the range to cope with page size > 1
3211 // - a Windows API quirk
3212 int pageSize
= GetScrollPage(orient
);
3215 maxPos
-= (pageSize
- 1);
3224 int wxWindow::GetScrollPage(int orient
) const
3226 if (orient
== wxHORIZONTAL
)
3227 return m_xThumbSize
;
3229 return m_yThumbSize
;
3233 int wxWindow::GetScrollPos(int orient
) const
3236 if (orient
== wxHORIZONTAL
)
3240 HWND hWnd
= (HWND
) GetHWND();
3243 return ::GetScrollPos(hWnd
, wOrient
);
3249 // This now returns the whole range, not just the number
3250 // of positions that we can scroll.
3251 int wxWindow::GetScrollRange(int orient
) const
3254 if (orient
== wxHORIZONTAL
)
3259 #if __WATCOMC__ && defined(__WINDOWS_386__)
3260 short minPos
, maxPos
;
3264 HWND hWnd
= (HWND
) GetHWND();
3267 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3268 #if defined(__WIN95__)
3269 // Try to adjust the range to cope with page size > 1
3270 // - a Windows API quirk
3271 int pageSize
= GetScrollPage(orient
);
3274 maxPos
-= (pageSize
- 1);
3276 // October 10th: new range concept.
3286 int wxWindow::GetScrollThumb(int orient
) const
3288 if (orient
== wxHORIZONTAL
)
3289 return m_xThumbSize
;
3291 return m_yThumbSize
;
3294 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3296 #if defined(__WIN95__)
3300 if (orient
== wxHORIZONTAL
) {
3306 info
.cbSize
= sizeof(SCROLLINFO
);
3310 info
.fMask
= SIF_POS
;
3312 HWND hWnd
= (HWND
) GetHWND();
3314 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3317 if (orient
== wxHORIZONTAL
)
3322 HWND hWnd
= (HWND
) GetHWND();
3324 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3328 // New function that will replace some of the above.
3329 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3330 int range
, bool refresh
)
3333 SetScrollPage(orient, thumbVisible, FALSE);
3335 int oldRange = range - thumbVisible ;
3336 SetScrollRange(orient, oldRange, FALSE);
3338 SetScrollPos(orient, pos, refresh);
3340 #if defined(__WIN95__)
3341 int oldRange
= range
- thumbVisible
;
3343 int range1
= oldRange
;
3345 // Try to adjust the range to cope with page size > 1
3346 // - a Windows API quirk
3347 int pageSize
= thumbVisible
;
3348 if ( pageSize
> 1 && range
> 0)
3350 range1
+= (pageSize
- 1);
3356 if (orient
== wxHORIZONTAL
) {
3362 info
.cbSize
= sizeof(SCROLLINFO
);
3363 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3367 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3369 HWND hWnd
= (HWND
) GetHWND();
3371 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3374 if (orient
== wxHORIZONTAL
)
3379 HWND hWnd
= (HWND
) GetHWND();
3382 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3383 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3386 if (orient
== wxHORIZONTAL
) {
3387 m_xThumbSize
= thumbVisible
;
3389 m_yThumbSize
= thumbVisible
;
3393 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRectangle
*rect
)
3398 rect2
.left
= rect
->x
;
3399 rect2
.top
= rect
->y
;
3400 rect2
.right
= rect
->x
+ rect
->width
;
3401 rect2
.bottom
= rect
->y
+ rect
->height
;
3405 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3407 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3410 void wxWindow::SetFont(const wxFont
& font
)
3412 m_windowFont
= font
;
3414 if (!m_windowFont
.Ok())
3417 HWND hWnd
= (HWND
) GetHWND();
3420 if (m_windowFont
.GetResourceHandle())
3421 SendMessage(hWnd
, WM_SETFONT
,
3422 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3426 void wxWindow::SubclassWin(WXHWND hWnd
)
3428 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3430 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3432 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3433 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3436 void wxWindow::UnsubclassWin(void)
3438 wxRemoveHandleAssociation(this);
3440 // Restore old Window proc
3441 if ((HWND
) GetHWND())
3443 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3444 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3446 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3452 // Make a Windows extended style from the given wxWindows window style
3453 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3455 WXDWORD exStyle
= 0;
3456 if ( style
& wxTRANSPARENT_WINDOW
)
3457 exStyle
|= WS_EX_TRANSPARENT
;
3459 if ( !eliminateBorders
)
3461 if ( style
& wxSUNKEN_BORDER
)
3462 exStyle
|= WS_EX_CLIENTEDGE
;
3463 if ( style
& wxDOUBLE_BORDER
)
3464 exStyle
|= WS_EX_DLGMODALFRAME
;
3465 #if defined(__WIN95__)
3466 if ( style
& wxRAISED_BORDER
)
3467 exStyle
|= WS_EX_WINDOWEDGE
;
3468 if ( style
& wxSTATIC_BORDER
)
3469 exStyle
|= WS_EX_STATICEDGE
;
3475 // Determines whether native 3D effects or CTL3D should be used,
3476 // applying a default border style if required, and returning an extended
3477 // style to pass to CreateWindowEx.
3478 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3480 // If matches certain criteria, then assume no 3D effects
3481 // unless specifically requested (dealt with in MakeExtendedStyle)
3482 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3485 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3488 // Determine whether we should be using 3D effects or not.
3489 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3491 // 1) App can specify global 3D effects
3492 *want3D
= wxTheApp
->GetAuto3D();
3494 // 2) If the parent is being drawn with user colours, or simple border specified,
3495 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3496 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3499 // 3) Control can override this global setting by defining
3500 // a border style, e.g. wxSUNKEN_BORDER
3501 if (m_windowStyle
& wxSUNKEN_BORDER
)
3504 // 4) If it's a special border, CTL3D can't cope so we want a native border
3505 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3506 (m_windowStyle
& wxSTATIC_BORDER
) )
3509 nativeBorder
= TRUE
;
3512 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3513 // effects from extended style
3516 nativeBorder
= FALSE
;
3519 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3521 // If we want 3D, but haven't specified a border here,
3522 // apply the default border style specified.
3523 // TODO what about non-Win95 WIN32? Does it have borders?
3524 #if defined(__WIN95__) && !CTL3D
3525 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3526 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3527 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3533 void wxWindow::OnChar(wxKeyEvent
& event
)
3535 if ( event
.KeyCode() == WXK_TAB
) {
3536 // propagate the TABs to the parent - it's up to it to decide what
3538 if ( GetParent() ) {
3539 if ( GetParent()->ProcessEvent(event
) )
3545 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3550 if ( !event
.ControlDown() )
3551 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3554 void wxWindow::OnPaint(wxPaintEvent
& event
)
3559 bool wxWindow::IsEnabled(void) const
3561 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3564 // Dialog support: override these and call
3565 // base class members to add functionality
3566 // that can't be done using validators.
3567 // NOTE: these functions assume that controls
3568 // are direct children of this window, not grandchildren
3569 // or other levels of descendant.
3571 // Transfer values to controls. If returns FALSE,
3572 // it's an application error (pops up a dialog)
3573 bool wxWindow::TransferDataToWindow(void)
3575 wxNode
*node
= GetChildren()->First();
3578 wxWindow
*child
= (wxWindow
*)node
->Data();
3579 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3580 !child
->GetValidator()->TransferToWindow() )
3582 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3586 node
= node
->Next();
3591 // Transfer values from controls. If returns FALSE,
3592 // validation failed: don't quit
3593 bool wxWindow::TransferDataFromWindow(void)
3595 wxNode
*node
= GetChildren()->First();
3598 wxWindow
*child
= (wxWindow
*)node
->Data();
3599 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3604 node
= node
->Next();
3609 bool wxWindow::Validate(void)
3611 wxNode
*node
= GetChildren()->First();
3614 wxWindow
*child
= (wxWindow
*)node
->Data();
3615 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3620 node
= node
->Next();
3625 // Get the window with the focus
3626 wxWindow
*wxWindow::FindFocus(void)
3628 HWND hWnd
= ::GetFocus();
3631 return wxFindWinFromHandle((WXHWND
) hWnd
);
3636 void wxWindow::AddChild(wxWindow
*child
)
3638 GetChildren()->Append(child
);
3639 child
->m_windowParent
= this;
3642 void wxWindow::RemoveChild(wxWindow
*child
)
3645 GetChildren()->DeleteObject(child
);
3646 child
->m_windowParent
= NULL
;
3649 void wxWindow::DestroyChildren(void)
3651 if (GetChildren()) {
3653 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
) {
3655 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3657 if ( GetChildren()->Member(child
) )
3664 void wxWindow::MakeModal(bool modal
)
3666 // Disable all other windows
3667 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3669 wxNode
*node
= wxTopLevelWindows
.First();
3672 wxWindow
*win
= (wxWindow
*)node
->Data();
3674 win
->Enable(!modal
);
3676 node
= node
->Next();
3681 // If nothing defined for this, try the parent.
3682 // E.g. we may be a button loaded from a resource, with no callback function
3684 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3686 if (GetEventHandler()->ProcessEvent(event
) )
3689 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3692 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3696 UnsetConstraints(m_constraints
);
3697 delete m_constraints
;
3702 // Make sure other windows know they're part of a 'meaningful relationship'
3703 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3704 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3705 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3706 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3707 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3708 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3709 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3710 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3711 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3712 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3713 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3714 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3715 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3716 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3717 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3718 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3722 // This removes any dangling pointers to this window
3723 // in other windows' constraintsInvolvedIn lists.
3724 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3728 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3729 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3730 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3731 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3732 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3733 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3734 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3735 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3736 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3737 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3738 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3739 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3740 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3741 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3742 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3743 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3747 // Back-pointer to other windows we're involved with, so if we delete
3748 // this window, we must delete any constraints we're involved with.
3749 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3751 if (!m_constraintsInvolvedIn
)
3752 m_constraintsInvolvedIn
= new wxList
;
3753 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3754 m_constraintsInvolvedIn
->Append(otherWin
);
3757 // REMOVE back-pointer to other windows we're involved with.
3758 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3760 if (m_constraintsInvolvedIn
)
3761 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3764 // Reset any constraints that mention this window
3765 void wxWindow::DeleteRelatedConstraints(void)
3767 if (m_constraintsInvolvedIn
)
3769 wxNode
*node
= m_constraintsInvolvedIn
->First();
3772 wxWindow
*win
= (wxWindow
*)node
->Data();
3773 wxNode
*next
= node
->Next();
3774 wxLayoutConstraints
*constr
= win
->GetConstraints();
3776 // Reset any constraints involving this window
3779 constr
->left
.ResetIfWin((wxWindow
*)this);
3780 constr
->top
.ResetIfWin((wxWindow
*)this);
3781 constr
->right
.ResetIfWin((wxWindow
*)this);
3782 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3783 constr
->width
.ResetIfWin((wxWindow
*)this);
3784 constr
->height
.ResetIfWin((wxWindow
*)this);
3785 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3786 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3791 delete m_constraintsInvolvedIn
;
3792 m_constraintsInvolvedIn
= NULL
;
3796 void wxWindow::SetSizer(wxSizer
*sizer
)
3798 m_windowSizer
= sizer
;
3800 sizer
->SetSizerParent((wxWindow
*)this);
3807 bool wxWindow::Layout(void)
3809 if (GetConstraints())
3812 GetClientSize(&w
, &h
);
3813 GetConstraints()->width
.SetValue(w
);
3814 GetConstraints()->height
.SetValue(h
);
3817 // If top level (one sizer), evaluate the sizer's constraints.
3821 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3822 GetSizer()->LayoutPhase1(&noChanges
);
3823 GetSizer()->LayoutPhase2(&noChanges
);
3824 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3829 // Otherwise, evaluate child constraints
3830 ResetConstraints(); // Mark all constraints as unevaluated
3831 DoPhase(1); // Just one phase need if no sizers involved
3833 SetConstraintSizes(); // Recursively set the real window sizes
3839 // Do a phase of evaluating constraints:
3840 // the default behaviour. wxSizers may do a similar
3841 // thing, but also impose their own 'constraints'
3842 // and order the evaluation differently.
3843 bool wxWindow::LayoutPhase1(int *noChanges
)
3845 wxLayoutConstraints
*constr
= GetConstraints();
3848 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3854 bool wxWindow::LayoutPhase2(int *noChanges
)
3864 // Do a phase of evaluating child constraints
3865 bool wxWindow::DoPhase(int phase
)
3867 int noIterations
= 0;
3868 int maxIterations
= 500;
3872 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3876 wxNode
*node
= GetChildren()->First();
3879 wxWindow
*child
= (wxWindow
*)node
->Data();
3880 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3882 wxLayoutConstraints
*constr
= child
->GetConstraints();
3885 if (succeeded
.Member(child
))
3890 int tempNoChanges
= 0;
3891 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3892 noChanges
+= tempNoChanges
;
3895 succeeded
.Append(child
);
3900 node
= node
->Next();
3907 void wxWindow::ResetConstraints(void)
3909 wxLayoutConstraints
*constr
= GetConstraints();
3912 constr
->left
.SetDone(FALSE
);
3913 constr
->top
.SetDone(FALSE
);
3914 constr
->right
.SetDone(FALSE
);
3915 constr
->bottom
.SetDone(FALSE
);
3916 constr
->width
.SetDone(FALSE
);
3917 constr
->height
.SetDone(FALSE
);
3918 constr
->centreX
.SetDone(FALSE
);
3919 constr
->centreY
.SetDone(FALSE
);
3921 wxNode
*node
= GetChildren()->First();
3924 wxWindow
*win
= (wxWindow
*)node
->Data();
3925 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3926 win
->ResetConstraints();
3927 node
= node
->Next();
3931 // Need to distinguish between setting the 'fake' size for
3932 // windows and sizers, and setting the real values.
3933 void wxWindow::SetConstraintSizes(bool recurse
)
3935 wxLayoutConstraints
*constr
= GetConstraints();
3936 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3937 constr
->width
.GetDone() && constr
->height
.GetDone())
3939 int x
= constr
->left
.GetValue();
3940 int y
= constr
->top
.GetValue();
3941 int w
= constr
->width
.GetValue();
3942 int h
= constr
->height
.GetValue();
3944 // If we don't want to resize this window, just move it...
3945 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3946 (constr
->height
.GetRelationship() != wxAsIs
))
3948 // Calls Layout() recursively. AAAGH. How can we stop that.
3949 // Simply take Layout() out of non-top level OnSizes.
3950 SizerSetSize(x
, y
, w
, h
);
3959 char *windowClass
= this->GetClassInfo()->GetClassName();
3962 if (GetName() == "")
3963 winName
= "unnamed";
3965 winName
= GetName();
3966 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
3967 if (!constr
->left
.GetDone())
3968 wxDebugMsg(" unsatisfied 'left' constraint.\n");
3969 if (!constr
->right
.GetDone())
3970 wxDebugMsg(" unsatisfied 'right' constraint.\n");
3971 if (!constr
->width
.GetDone())
3972 wxDebugMsg(" unsatisfied 'width' constraint.\n");
3973 if (!constr
->height
.GetDone())
3974 wxDebugMsg(" unsatisfied 'height' constraint.\n");
3975 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
3980 wxNode
*node
= GetChildren()->First();
3983 wxWindow
*win
= (wxWindow
*)node
->Data();
3984 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3985 win
->SetConstraintSizes();
3986 node
= node
->Next();
3991 // This assumes that all sizers are 'on' the same
3992 // window, i.e. the parent of this window.
3993 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
3995 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
3996 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4000 m_sizerParent
->GetPosition(&xp
, &yp
);
4001 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4006 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4010 TransformSizerToActual(&xx
, &yy
);
4011 SetSize(xx
, yy
, w
, h
);
4014 void wxWindow::SizerMove(int x
, int y
)
4018 TransformSizerToActual(&xx
, &yy
);
4022 // Only set the size/position of the constraint (if any)
4023 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4025 wxLayoutConstraints
*constr
= GetConstraints();
4030 constr
->left
.SetValue(x
);
4031 constr
->left
.SetDone(TRUE
);
4035 constr
->top
.SetValue(y
);
4036 constr
->top
.SetDone(TRUE
);
4040 constr
->width
.SetValue(w
);
4041 constr
->width
.SetDone(TRUE
);
4045 constr
->height
.SetValue(h
);
4046 constr
->height
.SetDone(TRUE
);
4051 void wxWindow::MoveConstraint(int x
, int y
)
4053 wxLayoutConstraints
*constr
= GetConstraints();
4058 constr
->left
.SetValue(x
);
4059 constr
->left
.SetDone(TRUE
);
4063 constr
->top
.SetValue(y
);
4064 constr
->top
.SetDone(TRUE
);
4069 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4071 wxLayoutConstraints
*constr
= GetConstraints();
4074 *w
= constr
->width
.GetValue();
4075 *h
= constr
->height
.GetValue();
4081 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4083 wxLayoutConstraints
*constr
= GetConstraints();
4086 *w
= constr
->width
.GetValue();
4087 *h
= constr
->height
.GetValue();
4090 GetClientSize(w
, h
);
4093 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4095 wxLayoutConstraints
*constr
= GetConstraints();
4098 *x
= constr
->left
.GetValue();
4099 *y
= constr
->top
.GetValue();
4105 bool wxWindow::Close(bool force
)
4107 // Let's generalise it to work the same for any window.
4109 if (!IsKindOf(CLASSINFO(wxDialog)) && !IsKindOf(CLASSINFO(wxFrame)))
4116 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4117 event
.SetEventObject(this);
4118 event
.SetForce(force
);
4120 return GetEventHandler()->ProcessEvent(event
);
4123 if ( !force && event.GetVeto() )
4128 if (!wxPendingDelete.Member(this))
4129 wxPendingDelete.Append(this);
4135 wxObject
* wxWindow::GetChild(int number
) const
4137 // Return a pointer to the Nth object in the Panel
4140 wxNode
*node
= GetChildren()->First();
4143 node
= node
->Next() ;
4146 wxObject
*obj
= (wxObject
*)node
->Data();
4153 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4155 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4156 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4159 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4161 wxListBox *lbox = (wxListBox *)initiatingItem;
4162 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4163 event.m_commandInt = -1;
4164 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4166 event.m_commandString = copystring(lbox->GetStringSelection());
4167 event.m_commandInt = lbox->GetSelection();
4168 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4170 event.m_eventObject = lbox;
4172 lbox->ProcessCommand(event);
4174 if (event.m_commandString)
4175 delete[] event.m_commandString;
4179 wxButton *but = GetDefaultItem();
4182 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4183 event.SetEventObject(but);
4184 but->Command(event);
4189 void wxWindow::Clear(void)
4191 wxClientDC
dc(this);
4192 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4193 dc
.SetBackground(brush
);
4197 // Fits the panel around the items
4198 void wxWindow::Fit(void)
4202 wxNode
*node
= GetChildren()->First();
4205 wxWindow
*win
= (wxWindow
*)node
->Data();
4207 win
->GetPosition(&wx
, &wy
);
4208 win
->GetSize(&ww
, &wh
);
4209 if ( wx
+ ww
> maxX
)
4211 if ( wy
+ wh
> maxY
)
4214 node
= node
->Next();
4216 SetClientSize(maxX
+ 5, maxY
+ 5);
4219 void wxWindow::SetValidator(const wxValidator
& validator
)
4221 if ( m_windowValidator
)
4222 delete m_windowValidator
;
4223 m_windowValidator
= validator
.Clone();
4225 if ( m_windowValidator
)
4226 m_windowValidator
->SetWindow(this) ;
4229 // Find a window by id or name
4230 wxWindow
*wxWindow::FindWindow(long id
)
4235 wxNode
*node
= GetChildren()->First();
4238 wxWindow
*child
= (wxWindow
*)node
->Data();
4239 wxWindow
*found
= child
->FindWindow(id
);
4242 node
= node
->Next();
4247 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4249 if ( GetName() == name
)
4252 wxNode
*node
= GetChildren()->First();
4255 wxWindow
*child
= (wxWindow
*)node
->Data();
4256 wxWindow
*found
= child
->FindWindow(name
);
4259 node
= node
->Next();
4265 // Default input behaviour for a scrolling canvas should be to scroll
4266 // according to the cursor keys pressed
4267 void wxWindow::OnChar(wxKeyEvent& event)
4279 GetScrollUnitsPerPage(&x_page, &y_page);
4281 GetVirtualSize(&v_width,&v_height);
4283 ViewStart(&start_x, &start_y);
4286 y_pages = (int)(v_height/vert_units) - y_page;
4294 switch (event.keyCode)
4301 if (start_y - y_page > 0)
4302 Scroll(start_x, start_y - y_page);
4312 if ((y_page > 0) && (start_y <= y_pages-y-1))
4314 if (y_pages + y < start_y + y_page)
4315 Scroll(start_x, y_pages + y);
4317 Scroll(start_x, start_y + y_page);
4324 if ((y_page > 0) && (start_y >= 1))
4325 Scroll(start_x, start_y - 1);
4331 if ((y_page > 0) && (start_y <= y_pages-y-1))
4334 Scroll(start_x, start_y + 1);
4340 if ((x_page > 0) && (start_x >= 1))
4341 Scroll(start_x - 1, start_y);
4347 Scroll(start_x + 1, start_y);
4358 Scroll(start_x, y_pages+y);
4366 // Setup background and foreground colours correctly
4367 void wxWindow::SetupColours(void)
4370 SetBackgroundColour(GetParent()->GetBackgroundColour());
4373 void wxWindow::OnIdle(wxIdleEvent
& event
)
4375 // Check if we need to send a LEAVE event
4376 if (m_mouseInWindow
)
4379 ::GetCursorPos(&pt
);
4380 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4382 // Generate a LEAVE event
4383 m_mouseInWindow
= FALSE
;
4386 if (::GetKeyState(VK_SHIFT
) != 0)
4388 if (::GetKeyState(VK_CONTROL
) != 0)
4389 state
|= MK_CONTROL
;
4391 // Unfortunately the mouse button and keyboard state may have changed
4392 // by the time the OnIdle function is called, so 'state' may be
4395 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4401 // Raise the window to the top of the Z order
4402 void wxWindow::Raise(void)
4404 ::BringWindowToTop((HWND
) GetHWND());
4407 // Lower the window to the bottom of the Z order
4408 void wxWindow::Lower(void)
4410 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4413 long wxWindow::MSWGetDlgCode()
4415 // default: just forward to def window proc (the msg has no parameters)
4416 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4419 bool wxWindow::AcceptsFocus() const
4421 return IsShown() && IsEnabled();
4424 // Update region access
4425 wxRegion
wxWindow::GetUpdateRegion() const
4427 return m_updateRegion
;
4430 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4432 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4435 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4437 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4440 bool wxWindow::IsExposed(const wxRect
& rect
) const
4442 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4446 const char *wxGetMessageName(int message
)
4448 switch ( message
) {
4449 case 0x0000: return "WM_NULL";
4450 case 0x0001: return "WM_CREATE";
4451 case 0x0002: return "WM_DESTROY";
4452 case 0x0003: return "WM_MOVE";
4453 case 0x0005: return "WM_SIZE";
4454 case 0x0006: return "WM_ACTIVATE";
4455 case 0x0007: return "WM_SETFOCUS";
4456 case 0x0008: return "WM_KILLFOCUS";
4457 case 0x000A: return "WM_ENABLE";
4458 case 0x000B: return "WM_SETREDRAW";
4459 case 0x000C: return "WM_SETTEXT";
4460 case 0x000D: return "WM_GETTEXT";
4461 case 0x000E: return "WM_GETTEXTLENGTH";
4462 case 0x000F: return "WM_PAINT";
4463 case 0x0010: return "WM_CLOSE";
4464 case 0x0011: return "WM_QUERYENDSESSION";
4465 case 0x0012: return "WM_QUIT";
4466 case 0x0013: return "WM_QUERYOPEN";
4467 case 0x0014: return "WM_ERASEBKGND";
4468 case 0x0015: return "WM_SYSCOLORCHANGE";
4469 case 0x0016: return "WM_ENDSESSION";
4470 case 0x0017: return "WM_SYSTEMERROR";
4471 case 0x0018: return "WM_SHOWWINDOW";
4472 case 0x0019: return "WM_CTLCOLOR";
4473 case 0x001A: return "WM_WININICHANGE";
4474 case 0x001B: return "WM_DEVMODECHANGE";
4475 case 0x001C: return "WM_ACTIVATEAPP";
4476 case 0x001D: return "WM_FONTCHANGE";
4477 case 0x001E: return "WM_TIMECHANGE";
4478 case 0x001F: return "WM_CANCELMODE";
4479 case 0x0020: return "WM_SETCURSOR";
4480 case 0x0021: return "WM_MOUSEACTIVATE";
4481 case 0x0022: return "WM_CHILDACTIVATE";
4482 case 0x0023: return "WM_QUEUESYNC";
4483 case 0x0024: return "WM_GETMINMAXINFO";
4484 case 0x0026: return "WM_PAINTICON";
4485 case 0x0027: return "WM_ICONERASEBKGND";
4486 case 0x0028: return "WM_NEXTDLGCTL";
4487 case 0x002A: return "WM_SPOOLERSTATUS";
4488 case 0x002B: return "WM_DRAWITEM";
4489 case 0x002C: return "WM_MEASUREITEM";
4490 case 0x002D: return "WM_DELETEITEM";
4491 case 0x002E: return "WM_VKEYTOITEM";
4492 case 0x002F: return "WM_CHARTOITEM";
4493 case 0x0030: return "WM_SETFONT";
4494 case 0x0031: return "WM_GETFONT";
4495 case 0x0037: return "WM_QUERYDRAGICON";
4496 case 0x0039: return "WM_COMPAREITEM";
4497 case 0x0041: return "WM_COMPACTING";
4498 case 0x0044: return "WM_COMMNOTIFY";
4499 case 0x0046: return "WM_WINDOWPOSCHANGING";
4500 case 0x0047: return "WM_WINDOWPOSCHANGED";
4501 case 0x0048: return "WM_POWER";
4504 case 0x004A: return "WM_COPYDATA";
4505 case 0x004B: return "WM_CANCELJOURNAL";
4506 case 0x004E: return "WM_NOTIFY";
4507 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4508 case 0x0051: return "WM_INPUTLANGCHANGE";
4509 case 0x0052: return "WM_TCARD";
4510 case 0x0053: return "WM_HELP";
4511 case 0x0054: return "WM_USERCHANGED";
4512 case 0x0055: return "WM_NOTIFYFORMAT";
4513 case 0x007B: return "WM_CONTEXTMENU";
4514 case 0x007C: return "WM_STYLECHANGING";
4515 case 0x007D: return "WM_STYLECHANGED";
4516 case 0x007E: return "WM_DISPLAYCHANGE";
4517 case 0x007F: return "WM_GETICON";
4518 case 0x0080: return "WM_SETICON";
4521 case 0x0081: return "WM_NCCREATE";
4522 case 0x0082: return "WM_NCDESTROY";
4523 case 0x0083: return "WM_NCCALCSIZE";
4524 case 0x0084: return "WM_NCHITTEST";
4525 case 0x0085: return "WM_NCPAINT";
4526 case 0x0086: return "WM_NCACTIVATE";
4527 case 0x0087: return "WM_GETDLGCODE";
4528 case 0x00A0: return "WM_NCMOUSEMOVE";
4529 case 0x00A1: return "WM_NCLBUTTONDOWN";
4530 case 0x00A2: return "WM_NCLBUTTONUP";
4531 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4532 case 0x00A4: return "WM_NCRBUTTONDOWN";
4533 case 0x00A5: return "WM_NCRBUTTONUP";
4534 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4535 case 0x00A7: return "WM_NCMBUTTONDOWN";
4536 case 0x00A8: return "WM_NCMBUTTONUP";
4537 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4538 case 0x0100: return "WM_KEYDOWN";
4539 case 0x0101: return "WM_KEYUP";
4540 case 0x0102: return "WM_CHAR";
4541 case 0x0103: return "WM_DEADCHAR";
4542 case 0x0104: return "WM_SYSKEYDOWN";
4543 case 0x0105: return "WM_SYSKEYUP";
4544 case 0x0106: return "WM_SYSCHAR";
4545 case 0x0107: return "WM_SYSDEADCHAR";
4546 case 0x0108: return "WM_KEYLAST";
4549 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4550 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4551 case 0x010F: return "WM_IME_COMPOSITION";
4554 case 0x0110: return "WM_INITDIALOG";
4555 case 0x0111: return "WM_COMMAND";
4556 case 0x0112: return "WM_SYSCOMMAND";
4557 case 0x0113: return "WM_TIMER";
4558 case 0x0114: return "WM_HSCROLL";
4559 case 0x0115: return "WM_VSCROLL";
4560 case 0x0116: return "WM_INITMENU";
4561 case 0x0117: return "WM_INITMENUPOPUP";
4562 case 0x011F: return "WM_MENUSELECT";
4563 case 0x0120: return "WM_MENUCHAR";
4564 case 0x0121: return "WM_ENTERIDLE";
4565 case 0x0200: return "WM_MOUSEMOVE";
4566 case 0x0201: return "WM_LBUTTONDOWN";
4567 case 0x0202: return "WM_LBUTTONUP";
4568 case 0x0203: return "WM_LBUTTONDBLCLK";
4569 case 0x0204: return "WM_RBUTTONDOWN";
4570 case 0x0205: return "WM_RBUTTONUP";
4571 case 0x0206: return "WM_RBUTTONDBLCLK";
4572 case 0x0207: return "WM_MBUTTONDOWN";
4573 case 0x0208: return "WM_MBUTTONUP";
4574 case 0x0209: return "WM_MBUTTONDBLCLK";
4575 case 0x0210: return "WM_PARENTNOTIFY";
4576 case 0x0211: return "WM_ENTERMENULOOP";
4577 case 0x0212: return "WM_EXITMENULOOP";
4580 case 0x0213: return "WM_NEXTMENU";
4581 case 0x0214: return "WM_SIZING";
4582 case 0x0215: return "WM_CAPTURECHANGED";
4583 case 0x0216: return "WM_MOVING";
4584 case 0x0218: return "WM_POWERBROADCAST";
4585 case 0x0219: return "WM_DEVICECHANGE";
4588 case 0x0220: return "WM_MDICREATE";
4589 case 0x0221: return "WM_MDIDESTROY";
4590 case 0x0222: return "WM_MDIACTIVATE";
4591 case 0x0223: return "WM_MDIRESTORE";
4592 case 0x0224: return "WM_MDINEXT";
4593 case 0x0225: return "WM_MDIMAXIMIZE";
4594 case 0x0226: return "WM_MDITILE";
4595 case 0x0227: return "WM_MDICASCADE";
4596 case 0x0228: return "WM_MDIICONARRANGE";
4597 case 0x0229: return "WM_MDIGETACTIVE";
4598 case 0x0230: return "WM_MDISETMENU";
4599 case 0x0233: return "WM_DROPFILES";
4602 case 0x0281: return "WM_IME_SETCONTEXT";
4603 case 0x0282: return "WM_IME_NOTIFY";
4604 case 0x0283: return "WM_IME_CONTROL";
4605 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4606 case 0x0285: return "WM_IME_SELECT";
4607 case 0x0286: return "WM_IME_CHAR";
4608 case 0x0290: return "WM_IME_KEYDOWN";
4609 case 0x0291: return "WM_IME_KEYUP";
4612 case 0x0300: return "WM_CUT";
4613 case 0x0301: return "WM_COPY";
4614 case 0x0302: return "WM_PASTE";
4615 case 0x0303: return "WM_CLEAR";
4616 case 0x0304: return "WM_UNDO";
4617 case 0x0305: return "WM_RENDERFORMAT";
4618 case 0x0306: return "WM_RENDERALLFORMATS";
4619 case 0x0307: return "WM_DESTROYCLIPBOARD";
4620 case 0x0308: return "WM_DRAWCLIPBOARD";
4621 case 0x0309: return "WM_PAINTCLIPBOARD";
4622 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4623 case 0x030B: return "WM_SIZECLIPBOARD";
4624 case 0x030C: return "WM_ASKCBFORMATNAME";
4625 case 0x030D: return "WM_CHANGECBCHAIN";
4626 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4627 case 0x030F: return "WM_QUERYNEWPALETTE";
4628 case 0x0310: return "WM_PALETTEISCHANGING";
4629 case 0x0311: return "WM_PALETTECHANGED";
4632 // common controls messages - although they're not strictly speaking
4633 // standard, it's nice to decode them nevertheless
4636 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4637 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4638 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4639 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4640 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4641 case 0x1000 + 5: return "LVM_GETITEMA";
4642 case 0x1000 + 75: return "LVM_GETITEMW";
4643 case 0x1000 + 6: return "LVM_SETITEMA";
4644 case 0x1000 + 76: return "LVM_SETITEMW";
4645 case 0x1000 + 7: return "LVM_INSERTITEMA";
4646 case 0x1000 + 77: return "LVM_INSERTITEMW";
4647 case 0x1000 + 8: return "LVM_DELETEITEM";
4648 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4649 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4650 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4651 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4652 case 0x1000 + 13: return "LVM_FINDITEMA";
4653 case 0x1000 + 83: return "LVM_FINDITEMW";
4654 case 0x1000 + 14: return "LVM_GETITEMRECT";
4655 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4656 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4657 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4658 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4659 case 0x1000 + 18: return "LVM_HITTEST";
4660 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4661 case 0x1000 + 20: return "LVM_SCROLL";
4662 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4663 case 0x1000 + 22: return "LVM_ARRANGE";
4664 case 0x1000 + 23: return "LVM_EDITLABELA";
4665 case 0x1000 + 118: return "LVM_EDITLABELW";
4666 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4667 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4668 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4669 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4670 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4671 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4672 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4673 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4674 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4675 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4676 case 0x1000 + 31: return "LVM_GETHEADER";
4677 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4678 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4679 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4680 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4681 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4682 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4683 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4684 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4685 case 0x1000 + 41: return "LVM_GETORIGIN";
4686 case 0x1000 + 42: return "LVM_UPDATE";
4687 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4688 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4689 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4690 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4691 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4692 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4693 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4694 case 0x1000 + 48: return "LVM_SORTITEMS";
4695 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4696 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4697 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4698 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4699 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4700 case 0x1000 + 53: return "LVM_SETICONSPACING";
4701 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4702 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4703 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4704 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4705 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4706 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4707 case 0x1000 + 60: return "LVM_SETHOTITEM";
4708 case 0x1000 + 61: return "LVM_GETHOTITEM";
4709 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4710 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4711 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4712 case 0x1000 + 65: return "LVM_SETWORKAREA";
4715 case 0x1100 + 0: return "TVM_INSERTITEMA";
4716 case 0x1100 + 50: return "TVM_INSERTITEMW";
4717 case 0x1100 + 1: return "TVM_DELETEITEM";
4718 case 0x1100 + 2: return "TVM_EXPAND";
4719 case 0x1100 + 4: return "TVM_GETITEMRECT";
4720 case 0x1100 + 5: return "TVM_GETCOUNT";
4721 case 0x1100 + 6: return "TVM_GETINDENT";
4722 case 0x1100 + 7: return "TVM_SETINDENT";
4723 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4724 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4725 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4726 case 0x1100 + 11: return "TVM_SELECTITEM";
4727 case 0x1100 + 12: return "TVM_GETITEMA";
4728 case 0x1100 + 62: return "TVM_GETITEMW";
4729 case 0x1100 + 13: return "TVM_SETITEMA";
4730 case 0x1100 + 63: return "TVM_SETITEMW";
4731 case 0x1100 + 14: return "TVM_EDITLABELA";
4732 case 0x1100 + 65: return "TVM_EDITLABELW";
4733 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4734 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4735 case 0x1100 + 17: return "TVM_HITTEST";
4736 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4737 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4738 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4739 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4740 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4741 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4742 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4743 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4744 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4747 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4748 case 0x1200 + 1: return "HDM_INSERTITEMA";
4749 case 0x1200 + 10: return "HDM_INSERTITEMW";
4750 case 0x1200 + 2: return "HDM_DELETEITEM";
4751 case 0x1200 + 3: return "HDM_GETITEMA";
4752 case 0x1200 + 11: return "HDM_GETITEMW";
4753 case 0x1200 + 4: return "HDM_SETITEMA";
4754 case 0x1200 + 12: return "HDM_SETITEMW";
4755 case 0x1200 + 5: return "HDM_LAYOUT";
4756 case 0x1200 + 6: return "HDM_HITTEST";
4757 case 0x1200 + 7: return "HDM_GETITEMRECT";
4758 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4759 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4760 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4761 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4762 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4763 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4764 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4767 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4768 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4769 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4770 case 0x1300 + 5: return "TCM_GETITEMA";
4771 case 0x1300 + 60: return "TCM_GETITEMW";
4772 case 0x1300 + 6: return "TCM_SETITEMA";
4773 case 0x1300 + 61: return "TCM_SETITEMW";
4774 case 0x1300 + 7: return "TCM_INSERTITEMA";
4775 case 0x1300 + 62: return "TCM_INSERTITEMW";
4776 case 0x1300 + 8: return "TCM_DELETEITEM";
4777 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4778 case 0x1300 + 10: return "TCM_GETITEMRECT";
4779 case 0x1300 + 11: return "TCM_GETCURSEL";
4780 case 0x1300 + 12: return "TCM_SETCURSEL";
4781 case 0x1300 + 13: return "TCM_HITTEST";
4782 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4783 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4784 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4785 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4786 case 0x1300 + 43: return "TCM_SETPADDING";
4787 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4788 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4789 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4790 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4791 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4792 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4793 case 0x1300 + 50: return "TCM_DESELECTALL";
4796 case WM_USER
+1: return "TB_ENABLEBUTTON";
4797 case WM_USER
+2: return "TB_CHECKBUTTON";
4798 case WM_USER
+3: return "TB_PRESSBUTTON";
4799 case WM_USER
+4: return "TB_HIDEBUTTON";
4800 case WM_USER
+5: return "TB_INDETERMINATE";
4801 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4802 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4803 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4804 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4805 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4806 case WM_USER
+17: return "TB_SETSTATE";
4807 case WM_USER
+18: return "TB_GETSTATE";
4808 case WM_USER
+19: return "TB_ADDBITMAP";
4809 case WM_USER
+20: return "TB_ADDBUTTONS";
4810 case WM_USER
+21: return "TB_INSERTBUTTON";
4811 case WM_USER
+22: return "TB_DELETEBUTTON";
4812 case WM_USER
+23: return "TB_GETBUTTON";
4813 case WM_USER
+24: return "TB_BUTTONCOUNT";
4814 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4815 case WM_USER
+26: return "TB_SAVERESTOREA";
4816 case WM_USER
+76: return "TB_SAVERESTOREW";
4817 case WM_USER
+27: return "TB_CUSTOMIZE";
4818 case WM_USER
+28: return "TB_ADDSTRINGA";
4819 case WM_USER
+77: return "TB_ADDSTRINGW";
4820 case WM_USER
+29: return "TB_GETITEMRECT";
4821 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4822 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4823 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4824 case WM_USER
+33: return "TB_AUTOSIZE";
4825 case WM_USER
+35: return "TB_GETTOOLTIPS";
4826 case WM_USER
+36: return "TB_SETTOOLTIPS";
4827 case WM_USER
+37: return "TB_SETPARENT";
4828 case WM_USER
+39: return "TB_SETROWS";
4829 case WM_USER
+40: return "TB_GETROWS";
4830 case WM_USER
+42: return "TB_SETCMDID";
4831 case WM_USER
+43: return "TB_CHANGEBITMAP";
4832 case WM_USER
+44: return "TB_GETBITMAP";
4833 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4834 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4835 case WM_USER
+46: return "TB_REPLACEBITMAP";
4836 case WM_USER
+47: return "TB_SETINDENT";
4837 case WM_USER
+48: return "TB_SETIMAGELIST";
4838 case WM_USER
+49: return "TB_GETIMAGELIST";
4839 case WM_USER
+50: return "TB_LOADIMAGES";
4840 case WM_USER
+51: return "TB_GETRECT";
4841 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4842 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4843 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4844 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4845 case WM_USER
+56: return "TB_SETSTYLE";
4846 case WM_USER
+57: return "TB_GETSTYLE";
4847 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4848 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4849 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4850 case WM_USER
+61: return "TB_GETTEXTROWS";
4851 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4856 static char s_szBuf
[128];
4857 sprintf(s_szBuf
, "<unknown message = %d>", message
);