1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/dcclient.h"
32 #include "wx/layout.h"
33 #include "wx/dialog.h"
35 #include "wx/listbox.h"
36 #include "wx/button.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
46 #include "wx/msw/ole/droptgt.h"
49 #include "wx/menuitem.h"
51 #include "wx/msw/private.h"
65 #include <wx/msw/gnuwin32/extra.h>
85 const char *wxGetMessageName(int message
);
88 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
90 wxMenu
*wxCurrentPopupMenu
= NULL
;
91 extern wxList WXDLLEXPORT wxPendingDelete
;
93 void wxRemoveHandleAssociation(wxWindow
*win
);
94 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
95 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
97 #if !USE_SHARED_LIBRARY
98 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
101 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
102 EVT_CHAR(wxWindow::OnChar
)
103 EVT_KEY_DOWN(wxWindow::OnKeyDown
)
104 EVT_KEY_UP(wxWindow::OnKeyUp
)
105 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
106 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
107 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
108 EVT_IDLE(wxWindow::OnIdle
)
111 // Find an item given the MS Windows id
112 wxWindow
*wxWindow::FindItem(int id
) const
114 // if (!GetChildren())
116 wxNode
*current
= GetChildren().First();
119 wxWindow
*childWin
= (wxWindow
*)current
->Data();
121 wxWindow
*wnd
= childWin
->FindItem(id
) ;
125 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
127 wxControl
*item
= (wxControl
*)childWin
;
128 if (item
->m_windowId
== id
)
132 // In case it's a 'virtual' control (e.g. radiobox)
133 if (item
->GetSubcontrols().Member((wxObject
*)id
))
137 current
= current
->Next();
142 // Find an item given the MS Windows handle
143 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
145 // if (!GetChildren())
147 wxNode
*current
= GetChildren().First();
150 wxObject
*obj
= (wxObject
*)current
->Data() ;
151 // Do a recursive search.
152 wxWindow
*parent
= (wxWindow
*)obj
;
153 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
157 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
159 wxWindow
*item
= (wxWindow
*)current
->Data();
160 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
164 if ( item
->ContainsHWND(hWnd
) )
168 current
= current
->Next();
173 // Default command handler
174 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
179 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
180 WXLPARAM
WXUNUSED(lParam
),
181 WXLPARAM
* WXUNUSED(result
))
186 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
190 WXHWND
wxWindow::GetHWND(void) const
192 return (WXHWND
) m_hWnd
;
195 void wxWindow::SetHWND(WXHWND hWnd
)
200 // ----------------------------------------------------------------------------
201 // constructors and such
202 // ----------------------------------------------------------------------------
204 void wxWindow::Init()
210 m_windowParent
= NULL
;
211 m_windowEventHandler
= this;
212 m_windowCursor
= *wxSTANDARD_CURSOR
;
213 m_children
= new wxList
;
214 m_doubleClickAllowed
= 0 ;
215 m_winCaptured
= FALSE
;
216 m_constraints
= NULL
;
217 m_constraintsInvolvedIn
= NULL
;
218 m_windowSizer
= NULL
;
219 m_sizerParent
= NULL
;
220 m_autoLayout
= FALSE
;
221 m_windowValidator
= NULL
;
226 m_caretWidth
= m_caretHeight
= 0;
228 m_caretShown
= FALSE
;
235 m_isBeingDeleted
= FALSE
;
241 m_mouseInWindow
= FALSE
;
243 m_windowParent
= NULL
;
244 m_defaultItem
= NULL
;
246 wxSystemSettings settings
;
248 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
249 m_foregroundColour
= *wxBLACK
;
259 m_backgroundTransparent
= FALSE
;
261 m_lastXPos
= (float)-1.0;
262 m_lastYPos
= (float)-1.0;
266 #if wxUSE_DRAG_AND_DROP
267 m_pDropTarget
= NULL
;
277 wxWindow::~wxWindow()
279 m_isBeingDeleted
= TRUE
;
281 // JACS - if behaviour is odd, restore this
282 // to the start of ~wxWindow. Vadim has changed
283 // it to nearer the end. Unsure of side-effects
284 // e.g. when deleting associated global data.
285 // Restore old Window proc, if required
288 // Have to delete constraints/sizer FIRST otherwise
289 // sizers may try to look at deleted windows as they
290 // delete themselves.
291 #if wxUSE_CONSTRAINTS
292 DeleteRelatedConstraints();
295 // This removes any dangling pointers to this window
296 // in other windows' constraintsInvolvedIn lists.
297 UnsetConstraints(m_constraints
);
298 delete m_constraints
;
299 m_constraints
= NULL
;
303 delete m_windowSizer
;
304 m_windowSizer
= NULL
;
306 // If this is a child of a sizer, remove self from parent
308 m_sizerParent
->RemoveChild((wxWindow
*)this);
312 MSWDetachWindowMenu();
315 m_windowParent
->RemoveChild(this);
320 ::DestroyWindow((HWND
)m_hWnd
);
322 wxRemoveHandleAssociation(this);
327 GlobalFree((HGLOBAL
) m_globalHandle
);
335 // Just in case the window has been Closed, but
336 // we're then deleting immediately: don't leave
337 // dangling pointers.
338 wxPendingDelete
.DeleteObject(this);
340 // Just in case we've loaded a top-level window via
341 // wxWindow::LoadNativeDialog but we weren't a dialog
343 wxTopLevelWindows
.DeleteObject(this);
345 if ( m_windowValidator
)
346 delete m_windowValidator
;
348 // Restore old Window proc, if required
349 // and remove hWnd <-> wxWindow association
353 // Destroy the window (delayed, if a managed window)
354 bool wxWindow::Destroy()
360 extern char wxCanvasClassName
[];
362 // real construction (Init() must have been called before!)
363 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
367 const wxString
& name
)
369 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
371 parent
->AddChild(this);
376 m_windowId
= (int)NewControlId();
385 // To be consistent with wxGTK
391 wxSystemSettings settings
;
393 m_windowStyle
= style
;
396 if (style
& wxBORDER
)
397 msflags
|= WS_BORDER
;
398 if (style
& wxTHICK_FRAME
)
399 msflags
|= WS_THICKFRAME
;
401 msflags
|= WS_CHILD
| WS_VISIBLE
;
402 if (style
& wxCLIP_CHILDREN
)
403 msflags
|= WS_CLIPCHILDREN
;
406 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
408 // Even with extended styles, need to combine with WS_BORDER
409 // for them to look right.
410 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
411 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
412 msflags
|= WS_BORDER
;
414 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
415 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
420 void wxWindow::SetFocus()
422 HWND hWnd
= (HWND
) GetHWND();
427 void wxWindow::Enable(bool enable
)
429 m_winEnabled
= enable
;
430 HWND hWnd
= (HWND
) GetHWND();
432 ::EnableWindow(hWnd
, (BOOL
)enable
);
435 void wxWindow::CaptureMouse()
437 HWND hWnd
= (HWND
) GetHWND();
438 if (hWnd
&& !m_winCaptured
)
441 m_winCaptured
= TRUE
;
445 void wxWindow::ReleaseMouse()
450 m_winCaptured
= FALSE
;
454 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
456 m_acceleratorTable
= accel
;
460 // Push/pop event handler (i.e. allow a chain of event handlers
462 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
464 handler
->SetNextHandler(GetEventHandler());
465 SetEventHandler(handler
);
468 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
470 if ( GetEventHandler() )
472 wxEvtHandler
*handlerA
= GetEventHandler();
473 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
474 handlerA
->SetNextHandler(NULL
);
475 SetEventHandler(handlerB
);
488 #if wxUSE_DRAG_AND_DROP
490 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
492 if ( m_pDropTarget
!= 0 ) {
493 m_pDropTarget
->Revoke(m_hWnd
);
494 delete m_pDropTarget
;
497 m_pDropTarget
= pDropTarget
;
498 if ( m_pDropTarget
!= 0 )
499 m_pDropTarget
->Register(m_hWnd
);
504 //old style file-manager drag&drop support
505 // I think we should retain the old-style
506 // DragAcceptFiles in parallel with SetDropTarget.
508 void wxWindow::DragAcceptFiles(bool accept
)
510 HWND hWnd
= (HWND
) GetHWND();
512 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
516 void wxWindow::GetSize(int *x
, int *y
) const
518 HWND hWnd
= (HWND
) GetHWND();
520 GetWindowRect(hWnd
, &rect
);
521 *x
= rect
.right
- rect
.left
;
522 *y
= rect
.bottom
- rect
.top
;
525 void wxWindow::GetPosition(int *x
, int *y
) const
527 HWND hWnd
= (HWND
) GetHWND();
530 hParentWnd
= (HWND
) GetParent()->GetHWND();
533 GetWindowRect(hWnd
, &rect
);
535 // Since we now have the absolute screen coords,
536 // if there's a parent we must subtract its top left corner
542 ::ScreenToClient(hParentWnd
, &point
);
545 // We may be faking the client origin.
546 // So a window that's really at (0, 30) may appear
547 // (to wxWin apps) to be at (0, 0).
550 wxPoint
pt(GetParent()->GetClientAreaOrigin());
558 void wxWindow::ScreenToClient(int *x
, int *y
) const
560 HWND hWnd
= (HWND
) GetHWND();
565 ::ScreenToClient(hWnd
, &pt
);
571 void wxWindow::ClientToScreen(int *x
, int *y
) const
573 HWND hWnd
= (HWND
) GetHWND();
578 ::ClientToScreen(hWnd
, &pt
);
584 void wxWindow::SetCursor(const wxCursor
& cursor
)
586 m_windowCursor
= cursor
;
587 if (m_windowCursor
.Ok())
589 HWND hWnd
= (HWND
) GetHWND();
591 // Change the cursor NOW if we're within the correct window
593 ::GetCursorPos(&point
);
596 ::GetWindowRect(hWnd
, &rect
);
598 if (::PtInRect(&rect
, point
) && !wxIsBusy())
599 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
602 // This will cause big reentrancy problems if wxFlushEvents is implemented.
604 // return old_cursor;
608 // Get size *available for subwindows* i.e. excluding menu bar etc.
609 void wxWindow::GetClientSize(int *x
, int *y
) const
611 HWND hWnd
= (HWND
) GetHWND();
613 GetClientRect(hWnd
, &rect
);
618 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
620 int currentX
, currentY
;
621 GetPosition(¤tX
, ¤tY
);
622 int currentW
,currentH
;
623 GetSize(¤tW
, ¤tH
);
625 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
628 int actualWidth
= width
;
629 int actualHeight
= height
;
632 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
634 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
637 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
640 actualWidth
= currentW
;
642 actualHeight
= currentH
;
644 HWND hWnd
= (HWND
) GetHWND();
646 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
649 void wxWindow::SetClientSize(int width
, int height
)
651 wxWindow
*parent
= GetParent();
652 HWND hWnd
= (HWND
) GetHWND();
653 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
656 GetClientRect(hWnd
, &rect
);
659 GetWindowRect(hWnd
, &rect2
);
661 // Find the difference between the entire window (title bar and all)
662 // and the client area; add this to the new client size to move the
664 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
665 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
667 // If there's a parent, must subtract the parent's top left corner
668 // since MoveWindow moves relative to the parent
671 point
.x
= rect2
.left
;
675 ::ScreenToClient(hParentWnd
, &point
);
678 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
680 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
681 event
.SetEventObject(this);
682 GetEventHandler()->ProcessEvent(event
);
685 // For implementation purposes - sometimes decorations make the client area
687 wxPoint
wxWindow::GetClientAreaOrigin() const
689 return wxPoint(0, 0);
692 // Makes an adjustment to the window position (for example, a frame that has
693 // a toolbar that it manages itself).
694 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
696 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
698 wxPoint
pt(GetParent()->GetClientAreaOrigin());
699 x
+= pt
.x
; y
+= pt
.y
;
703 bool wxWindow::Show(bool show
)
705 HWND hWnd
= (HWND
) GetHWND();
711 ShowWindow(hWnd
, (BOOL
)cshow
);
714 BringWindowToTop(hWnd
);
715 // Next line causes a crash on NT, apparently.
716 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
721 bool wxWindow::IsShown(void) const
723 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
726 int wxWindow::GetCharHeight(void) const
728 TEXTMETRIC lpTextMetric
;
729 HWND hWnd
= (HWND
) GetHWND();
730 HDC dc
= ::GetDC(hWnd
);
732 GetTextMetrics(dc
, &lpTextMetric
);
733 ::ReleaseDC(hWnd
, dc
);
735 return lpTextMetric
.tmHeight
;
738 int wxWindow::GetCharWidth(void) const
740 TEXTMETRIC lpTextMetric
;
741 HWND hWnd
= (HWND
) GetHWND();
742 HDC dc
= ::GetDC(hWnd
);
744 GetTextMetrics(dc
, &lpTextMetric
);
745 ::ReleaseDC(hWnd
, dc
);
747 return lpTextMetric
.tmAveCharWidth
;
750 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
751 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
753 wxFont
*fontToUse
= (wxFont
*)theFont
;
755 fontToUse
= (wxFont
*) & m_windowFont
;
757 HWND hWnd
= (HWND
) GetHWND();
758 HDC dc
= ::GetDC(hWnd
);
762 if (fontToUse
&& fontToUse
->Ok())
764 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
766 was
= (HFONT
) SelectObject(dc
,fnt
) ;
771 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
772 GetTextMetrics(dc
, &tm
);
774 if (fontToUse
&& fnt
&& was
)
775 SelectObject(dc
,was
) ;
781 if (descent
) *descent
= tm
.tmDescent
;
782 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
785 // fontToUse->ReleaseResource();
788 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
790 HWND hWnd
= (HWND
) GetHWND();
796 mswRect
.left
= rect
->x
;
797 mswRect
.top
= rect
->y
;
798 mswRect
.right
= rect
->x
+ rect
->width
;
799 mswRect
.bottom
= rect
->y
+ rect
->height
;
801 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
804 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
808 bool wxWindow::ProcessEvent(wxEvent
& event
)
810 // we save here the information about the last message because it might be
811 // overwritten if the event handler sends any messages to our window (case
812 // in point: wxNotebook::OnSize) - and then if we call Default() later
813 // (which is done quite often if the message is not processed) it will use
814 // incorrect values for m_lastXXX variables
815 WXUINT lastMsg
= m_lastMsg
;
816 WXWPARAM lastWParam
= m_lastWParam
;
817 WXLPARAM lastLParam
= m_lastLParam
;
819 // call the base version
820 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
824 m_lastWParam
= lastWParam
;
825 m_lastLParam
= lastLParam
;
830 // Hook for new window just as it's being created,
831 // when the window isn't yet associated with the handle
832 wxWindow
*wxWndHook
= NULL
;
835 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
837 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
839 if (!wnd
&& wxWndHook
)
841 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
844 wnd
->m_hWnd
= (WXHWND
) hWnd
;
847 // Stop right here if we don't have a valid handle
848 // in our wxWnd object.
849 if (wnd
&& !wnd
->m_hWnd
) {
850 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
851 wnd
->m_hWnd
= (WXHWND
) hWnd
;
852 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
858 wnd
->m_lastMsg
= message
;
859 wnd
->m_lastWParam
= wParam
;
860 wnd
->m_lastLParam
= lParam
;
863 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
865 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
868 // Should probably have a test for 'genuine' NT
869 #if defined(__WIN32__)
870 #define DIMENSION_TYPE short
872 #define DIMENSION_TYPE int
875 // Main Windows 3 window proc
876 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
878 wxASSERT( m_lastMsg
== message
&&
879 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
882 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
883 wxGetMessageName(message
), wParam
, lParam
);
884 #endif // __WXDEBUG__
886 HWND hWnd
= (HWND
)m_hWnd
;
893 WORD state
= LOWORD(wParam
);
894 WORD minimized
= HIWORD(wParam
);
895 HWND hwnd
= (HWND
)lParam
;
897 WORD state
= (WORD
)wParam
;
898 WORD minimized
= LOWORD(lParam
);
899 HWND hwnd
= (HWND
)HIWORD(lParam
);
901 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
907 HWND hwnd
= (HWND
)wParam
;
908 // return OnSetFocus(hwnd);
910 if (MSWOnSetFocus((WXHWND
) hwnd
))
912 else return MSWDefWindowProc(message
, wParam
, lParam
);
917 HWND hwnd
= (HWND
)lParam
;
918 // return OnKillFocus(hwnd);
919 if (MSWOnKillFocus((WXHWND
) hwnd
))
922 return MSWDefWindowProc(message
, wParam
, lParam
);
927 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
933 MSWOnShow((wParam
!= 0), (int) lParam
);
940 else return MSWDefWindowProc(message
, wParam
, lParam
);
943 case WM_QUERYDRAGICON
:
945 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
949 return MSWDefWindowProc(message
, wParam
, lParam
);
955 int width
= LOWORD(lParam
);
956 int height
= HIWORD(lParam
);
957 MSWOnSize(width
, height
, wParam
);
963 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
965 event
.SetEventObject(this);
966 if ( !GetEventHandler()->ProcessEvent(event
) )
971 case WM_WINDOWPOSCHANGING
:
973 MSWOnWindowPosChanging((void *)lParam
);
979 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
980 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
981 MSWOnRButtonDown(x
, y
, wParam
);
986 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
987 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
988 MSWOnRButtonUp(x
, y
, wParam
);
991 case WM_RBUTTONDBLCLK
:
993 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
994 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
995 MSWOnRButtonDClick(x
, y
, wParam
);
1000 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1001 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1002 MSWOnMButtonDown(x
, y
, wParam
);
1007 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1008 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1009 MSWOnMButtonUp(x
, y
, wParam
);
1012 case WM_MBUTTONDBLCLK
:
1014 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1015 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1016 MSWOnMButtonDClick(x
, y
, wParam
);
1019 case WM_LBUTTONDOWN
:
1021 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1022 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1023 MSWOnLButtonDown(x
, y
, wParam
);
1028 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1029 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1030 MSWOnLButtonUp(x
, y
, wParam
);
1033 case WM_LBUTTONDBLCLK
:
1035 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1036 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1037 MSWOnLButtonDClick(x
, y
, wParam
);
1042 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1043 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1044 MSWOnMouseMove(x
, y
, wParam
);
1047 case MM_JOY1BUTTONDOWN
:
1049 int x
= LOWORD(lParam
);
1050 int y
= HIWORD(lParam
);
1051 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1054 case MM_JOY2BUTTONDOWN
:
1056 int x
= LOWORD(lParam
);
1057 int y
= HIWORD(lParam
);
1058 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1061 case MM_JOY1BUTTONUP
:
1063 int x
= LOWORD(lParam
);
1064 int y
= HIWORD(lParam
);
1065 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1068 case MM_JOY2BUTTONUP
:
1070 int x
= LOWORD(lParam
);
1071 int y
= HIWORD(lParam
);
1072 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1077 int x
= LOWORD(lParam
);
1078 int y
= HIWORD(lParam
);
1079 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1084 int x
= LOWORD(lParam
);
1085 int y
= HIWORD(lParam
);
1086 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1091 int z
= LOWORD(lParam
);
1092 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1097 int z
= LOWORD(lParam
);
1098 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1105 else return MSWDefWindowProc(message
, wParam
, lParam
);
1110 return MSWOnSysCommand(wParam
, lParam
);
1116 WORD id
= LOWORD(wParam
);
1117 HWND hwnd
= (HWND
)lParam
;
1118 WORD cmd
= HIWORD(wParam
);
1120 WORD id
= (WORD
)wParam
;
1121 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1122 WORD cmd
= HIWORD(lParam
);
1124 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1125 return MSWDefWindowProc(message
, wParam
, lParam
);
1128 #if defined(__WIN95__)
1131 // for some messages (TVN_ITEMEXPANDING for example), the return
1132 // value of WM_NOTIFY handler is important, so don't just return 0
1133 // if we processed the message
1134 return MSWOnNotify(wParam
, lParam
);
1140 WORD flags
= HIWORD(wParam
);
1141 HMENU sysmenu
= (HMENU
)lParam
;
1143 WORD flags
= LOWORD(lParam
);
1144 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1146 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1149 case WM_INITMENUPOPUP
:
1151 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1156 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1159 case WM_MEASUREITEM
:
1161 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1167 MSWOnKeyDown((WORD
) wParam
, lParam
);
1169 // we consider these message "not interesting"
1170 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1173 // Avoid duplicate messages to OnChar
1174 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1175 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1176 (wParam
!= VK_TAB
) )
1178 MSWOnChar((WORD
)wParam
, lParam
);
1179 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1182 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1183 MSWOnChar((WORD
)wParam
, lParam
);
1192 MSWOnKeyUp((WORD
) wParam
, lParam
);
1195 case WM_CHAR
: // Always an ASCII character
1197 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1204 WORD code
= LOWORD(wParam
);
1205 WORD pos
= HIWORD(wParam
);
1206 HWND control
= (HWND
)lParam
;
1208 WORD code
= (WORD
)wParam
;
1209 WORD pos
= LOWORD(lParam
);
1210 HWND control
= (HWND
)HIWORD(lParam
);
1212 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1218 WORD code
= LOWORD(wParam
);
1219 WORD pos
= HIWORD(wParam
);
1220 HWND control
= (HWND
)lParam
;
1222 WORD code
= (WORD
)wParam
;
1223 WORD pos
= LOWORD(lParam
);
1224 HWND control
= (HWND
)HIWORD(lParam
);
1226 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1230 case WM_CTLCOLORBTN
:
1232 int nCtlColor
= CTLCOLOR_BTN
;
1233 HWND control
= (HWND
)lParam
;
1234 HDC pDC
= (HDC
)wParam
;
1235 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1236 message
, wParam
, lParam
);
1239 case WM_CTLCOLORDLG
:
1241 int nCtlColor
= CTLCOLOR_DLG
;
1242 HWND control
= (HWND
)lParam
;
1243 HDC pDC
= (HDC
)wParam
;
1244 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1245 message
, wParam
, lParam
);\
1248 case WM_CTLCOLORLISTBOX
:
1250 int nCtlColor
= CTLCOLOR_LISTBOX
;
1251 HWND control
= (HWND
)lParam
;
1252 HDC pDC
= (HDC
)wParam
;
1253 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1254 message
, wParam
, lParam
);
1257 case WM_CTLCOLORMSGBOX
:
1259 int nCtlColor
= CTLCOLOR_MSGBOX
;
1260 HWND control
= (HWND
)lParam
;
1261 HDC pDC
= (HDC
)wParam
;
1262 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1263 message
, wParam
, lParam
);
1266 case WM_CTLCOLORSCROLLBAR
:
1268 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1269 HWND control
= (HWND
)lParam
;
1270 HDC pDC
= (HDC
)wParam
;
1271 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1272 message
, wParam
, lParam
);
1275 case WM_CTLCOLORSTATIC
:
1277 int nCtlColor
= CTLCOLOR_STATIC
;
1278 HWND control
= (HWND
)lParam
;
1279 HDC pDC
= (HDC
)wParam
;
1280 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1281 message
, wParam
, lParam
);
1284 case WM_CTLCOLOREDIT
:
1286 int nCtlColor
= CTLCOLOR_EDIT
;
1287 HWND control
= (HWND
)lParam
;
1288 HDC pDC
= (HDC
)wParam
;
1289 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1290 message
, wParam
, lParam
);
1296 HWND control
= (HWND
)LOWORD(lParam
);
1297 int nCtlColor
= (int)HIWORD(lParam
);
1298 HDC pDC
= (HDC
)wParam
;
1299 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1300 message
, wParam
, lParam
);
1304 case WM_SYSCOLORCHANGE
:
1306 // Return value of 0 means, we processed it.
1307 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1310 return MSWDefWindowProc(message
, wParam
, lParam
);
1313 case WM_PALETTECHANGED
:
1315 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1318 case WM_QUERYNEWPALETTE
:
1320 return MSWOnQueryNewPalette();
1325 // Prevents flicker when dragging
1326 if (IsIconic(hWnd
)) return 1;
1328 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1329 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1333 case WM_MDIACTIVATE
:
1336 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1337 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1338 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1339 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1341 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1342 (HWND
)HIWORD(lParam
));
1347 MSWOnDropFiles(wParam
);
1352 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1355 case WM_QUERYENDSESSION
:
1357 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1358 // return MSWOnClose();
1360 return MSWOnQueryEndSession(lParam
);
1365 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1366 MSWOnEndSession((wParam
!= 0), lParam
);
1379 case WM_GETMINMAXINFO
:
1381 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1382 if (m_minSizeX
!= -1)
1383 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1384 if (m_minSizeY
!= -1)
1385 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1386 if (m_maxSizeX
!= -1)
1387 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1388 if (m_maxSizeY
!= -1)
1389 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1390 return MSWDefWindowProc(message
, wParam
, lParam
);
1395 return MSWGetDlgCode();
1398 return MSWDefWindowProc(message
, wParam
, lParam
);
1400 return 0; // Success: we processed this command.
1403 // Dialog window proc
1404 LONG APIENTRY _EXPORT
1405 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1410 wxList
*wxWinHandleList
= NULL
;
1411 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1413 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1416 return (wxWindow
*)node
->Data();
1419 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1421 // adding NULL hWnd is (first) surely a result of an error and
1422 // (secondly) breaks menu command processing
1423 wxCHECK_RET( hWnd
!= NULL
, "attempt to add a NULL hWnd to window list" );
1425 if ( !wxWinHandleList
->Find((long)hWnd
) )
1426 wxWinHandleList
->Append((long)hWnd
, win
);
1429 void wxRemoveHandleAssociation(wxWindow
*win
)
1431 wxWinHandleList
->DeleteObject(win
);
1434 // Default destroyer - override if you destroy it in some other way
1435 // (e.g. with MDI child windows)
1436 void wxWindow::MSWDestroyWindow()
1440 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1441 int x
, int y
, int width
, int height
,
1442 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1444 bool is_dialog
= (dialog_template
!= NULL
);
1445 int x1
= CW_USEDEFAULT
;
1447 int width1
= CW_USEDEFAULT
;
1450 // Find parent's size, if it exists, to set up a possible default
1451 // panel size the size of the parent window
1455 // Was GetWindowRect: JACS 5/5/95
1456 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1458 width1
= parent_rect
.right
- parent_rect
.left
;
1459 height1
= parent_rect
.bottom
- parent_rect
.top
;
1464 if (width
> -1) width1
= width
;
1465 if (height
> -1) height1
= height
;
1467 HWND hParent
= NULL
;
1469 hParent
= (HWND
) parent
->GetHWND();
1475 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1476 // other compilers???
1477 // VZ: it's always needed for Win16 and never for Win32
1479 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1480 (DLGPROC
)wxDlgProc
);
1482 // N.B.: if we _don't_ use this form,
1483 // then with VC++ 1.5, it crashes horribly.
1485 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1486 (DLGPROC
)wxDlgProc
);
1488 // Crashes when we use this.
1489 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1491 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1497 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1498 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1499 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1504 if (style
& WS_CHILD
)
1509 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1514 hParent
, (HMENU
)controlId
, wxGetInstance(),
1518 wxLogError("Can't create window of class %s!\n"
1519 "Possible Windows 3.x compatibility problem?", wclass
);
1524 wxWinHandleList
->Append((long)m_hWnd
, this);
1527 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1531 bool wxWindow::MSWOnClose()
1536 // Some compilers don't define this
1537 #ifndef ENDSESSION_LOGOFF
1538 #define ENDSESSION_LOGOFF 0x80000000
1541 // Return TRUE to end session, FALSE to veto end session.
1542 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1544 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1545 event
.SetEventObject(wxTheApp
);
1546 event
.SetCanVeto(TRUE
);
1547 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1548 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1549 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1551 return FALSE
; // Veto!
1555 return TRUE
; // Don't veto
1559 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1561 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1562 event
.SetEventObject(wxTheApp
);
1563 event
.SetCanVeto(FALSE
);
1564 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1565 if (endSession
&& // No need to send if the session isn't ending
1566 (this == wxTheApp
->GetTopWindow()) && // Only send once
1567 wxTheApp
->ProcessEvent(event
))
1573 bool wxWindow::MSWOnDestroy()
1575 // delete our drop target if we've got one
1576 #if wxUSE_DRAG_AND_DROP
1577 if ( m_pDropTarget
!= NULL
) {
1578 m_pDropTarget
->Revoke(m_hWnd
);
1580 delete m_pDropTarget
;
1581 m_pDropTarget
= NULL
;
1588 // Deal with child commands from buttons etc.
1590 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1592 #if defined(__WIN95__)
1593 // Find a child window to send the notification to, e.g. a toolbar.
1594 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1595 // handle of the toolbar; it's probably the handle of the tooltip
1596 // window (anyway, it's parent is also the toolbar's parent).
1597 // So, since we don't know which hWnd or wxWindow originated the
1598 // WM_NOTIFY, we'll need to go through all the children of this window
1599 // trying out MSWNotify.
1600 // This won't work now, though, because any number of controls
1601 // could respond to the same generic messages :-(
1603 /* This doesn't work for toolbars, but try for other controls first.
1605 NMHDR
*hdr
= (NMHDR
*)lParam
;
1606 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1607 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1609 WXLPARAM result
= 0;
1613 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1618 // Rely on MSWNotify to check whether the message
1619 // belongs to the window or not
1620 wxNode
*node
= GetChildren().First();
1623 wxWindow
*child
= (wxWindow
*)node
->Data();
1624 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1626 node
= node
->Next();
1629 // finally try this window too (catches toolbar case)
1630 if ( MSWNotify(wParam
, lParam
, &result
) )
1639 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1643 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1647 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1649 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1651 event
.SetEventObject(this);
1652 GetEventHandler()->ProcessEvent(event
);
1656 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1659 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1661 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1663 ::ShowCaret((HWND
) GetHWND());
1666 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1667 event
.SetEventObject(this);
1668 if (!GetEventHandler()->ProcessEvent(event
))
1673 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1681 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1682 event
.SetEventObject(this);
1683 if (!GetEventHandler()->ProcessEvent(event
))
1688 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1691 HDROP hFilesInfo
= (HDROP
) wParam
;
1693 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1695 // Get the total number of files dropped
1696 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1701 wxString
*files
= new wxString
[gwFilesDropped
];
1703 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1705 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1706 files
[wIndex
] = wxBuffer
;
1708 DragFinish (hFilesInfo
);
1710 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1711 event
.m_eventObject
= this;
1712 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1714 if (!GetEventHandler()->ProcessEvent(event
))
1720 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1722 #if wxUSE_OWNER_DRAWN
1723 if ( id
== 0 ) { // is it a menu item?
1724 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1725 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1726 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1728 // prepare to call OnDrawItem()
1730 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1731 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1732 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1733 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1734 return pMenuItem
->OnDrawItem(
1736 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1737 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1740 #endif // owner-drawn menus
1742 wxWindow
*item
= FindItem(id
);
1743 #if wxUSE_DYNAMIC_CLASSES
1744 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1746 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1753 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1755 #if wxUSE_OWNER_DRAWN
1756 if ( id
== 0 ) { // is it a menu item?
1757 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1758 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1759 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1761 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1762 &pMeasureStruct
->itemHeight
);
1764 #endif // owner-drawn menus
1766 wxWindow
*item
= FindItem(id
);
1767 #if wxUSE_DYNAMIC_CLASSES
1768 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1770 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1777 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1778 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1780 if (nCtlColor
== CTLCOLOR_DLG
)
1782 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1785 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1787 WXHBRUSH hBrush
= 0;
1790 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1792 // I think that even for dialogs, we may need to call DefWindowProc (?)
1793 // Or maybe just rely on the usual default behaviour.
1795 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1800 // Define for each class of dialog and control
1801 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1802 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1804 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1807 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1809 wxSysColourChangedEvent event
;
1810 event
.SetEventObject(this);
1812 // Check if app handles this.
1813 if (GetEventHandler()->ProcessEvent(event
))
1816 // We didn't process it
1820 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1822 wxPaletteChangedEvent
event(GetId());
1823 event
.SetEventObject(this);
1824 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1825 GetEventHandler()->ProcessEvent(event
);
1829 long wxWindow::MSWOnQueryNewPalette()
1831 wxQueryNewPaletteEvent
event(GetId());
1832 event
.SetEventObject(this);
1833 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1835 return (long) FALSE
;
1841 // Responds to colour changes: passes event on to children.
1842 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1844 wxNode
*node
= GetChildren().First();
1847 // Only propagate to non-top-level windows
1848 wxWindow
*win
= (wxWindow
*)node
->Data();
1849 if ( win
->GetParent() )
1851 wxSysColourChangedEvent event2
;
1852 event
.m_eventObject
= win
;
1853 win
->GetEventHandler()->ProcessEvent(event2
);
1856 node
= node
->Next();
1860 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1863 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1865 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1868 long wxWindow::Default()
1870 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1875 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1876 wxGetMessageName(m_lastMsg
));
1877 #endif // __WXDEBUG__
1879 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1882 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1884 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1885 // intercept dialog navigation keys
1886 MSG
*msg
= (MSG
*)pMsg
;
1887 bool bProcess
= TRUE
;
1888 if ( msg
->message
!= WM_KEYDOWN
)
1891 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1894 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1896 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1897 // (except for Ctrl-Tab combination which is always processed)
1899 if ( bProcess
&& !bCtrlDown
) {
1900 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1903 bool bForward
= TRUE
;
1905 switch ( msg
->wParam
) {
1907 if ( lDlgCode
& DLGC_WANTTAB
) // FALSE for Ctrl-Tab
1910 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1915 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1923 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1933 wxNavigationKeyEvent event
;
1934 event
.SetDirection(bForward
);
1935 event
.SetWindowChange(bCtrlDown
);
1936 event
.SetEventObject(this);
1938 if ( GetEventHandler()->ProcessEvent(event
) )
1942 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
1948 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
1950 if (m_acceleratorTable
.Ok() &&
1951 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
1957 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
1962 void wxWindow::MSWDetachWindowMenu()
1966 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
1968 for (i
= 0; i
< N
; i
++)
1971 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
1972 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
1974 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
1981 bool wxWindow::MSWOnPaint()
1984 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
1985 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
1987 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
1990 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
1992 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
1993 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
1996 wxPaintEvent
event(m_windowId
);
1997 event
.SetEventObject(this);
1998 if (!GetEventHandler()->ProcessEvent(event
))
2003 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2013 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2014 event
.SetEventObject(this);
2015 if (!GetEventHandler()->ProcessEvent(event
))
2021 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2026 // Deal with child commands from buttons etc.
2027 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2029 if (wxCurrentPopupMenu
)
2031 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2032 wxCurrentPopupMenu
= NULL
;
2033 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2037 wxWindow
*item
= FindItem(id
);
2040 bool value
= item
->MSWCommand(cmd
, id
);
2045 wxWindow
*win
= wxFindWinFromHandle(control
);
2047 return win
->MSWCommand(cmd
, id
);
2052 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2058 wxMaximizeEvent
event(m_windowId
);
2059 event
.SetEventObject(this);
2060 if (!GetEventHandler()->ProcessEvent(event
))
2068 wxIconizeEvent
event(m_windowId
);
2069 event
.SetEventObject(this);
2070 if (!GetEventHandler()->ProcessEvent(event
))
2082 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2084 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2086 event
.m_x
= x
; event
.m_y
= y
;
2087 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2088 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2089 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2090 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2091 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2092 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2093 event
.m_eventObject
= this;
2095 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2097 if (!GetEventHandler()->ProcessEvent(event
))
2101 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2103 wxMouseEvent
event(wxEVT_LEFT_UP
);
2105 event
.m_x
= x
; event
.m_y
= y
;
2106 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2107 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2108 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2109 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2110 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2111 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2112 event
.m_eventObject
= this;
2114 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2116 if (!GetEventHandler()->ProcessEvent(event
))
2120 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2122 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2124 event
.m_x
= x
; event
.m_y
= y
;
2125 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2126 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2127 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2128 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2129 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2130 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2131 event
.m_eventObject
= this;
2133 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2135 if (!GetEventHandler()->ProcessEvent(event
))
2139 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2141 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2143 event
.m_x
= x
; event
.m_y
= y
;
2144 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2145 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2146 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2147 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2148 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2149 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2150 event
.m_eventObject
= this;
2152 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2154 if (!GetEventHandler()->ProcessEvent(event
))
2158 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2160 //wxDebugMsg("MButtonUp\n") ;
2161 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2163 event
.m_x
= x
; event
.m_y
= y
;
2164 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2165 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2166 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2167 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2168 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2169 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2170 event
.m_eventObject
= this;
2172 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2174 if (!GetEventHandler()->ProcessEvent(event
))
2178 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2180 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2182 event
.m_x
= x
; event
.m_y
= y
;
2183 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2184 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2185 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2186 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2187 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2188 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2189 event
.m_eventObject
= this;
2191 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2193 if (!GetEventHandler()->ProcessEvent(event
))
2197 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2199 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2201 event
.m_x
= x
; event
.m_y
= y
;
2202 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2203 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2204 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2205 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2206 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2207 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2208 event
.m_eventObject
= this;
2210 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2212 if (!GetEventHandler()->ProcessEvent(event
))
2216 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2218 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2220 event
.m_x
= x
; event
.m_y
= y
;
2221 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2222 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2223 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2224 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2225 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2226 event
.m_eventObject
= this;
2227 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2229 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2231 if (!GetEventHandler()->ProcessEvent(event
))
2235 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2237 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2239 event
.m_x
= x
; event
.m_y
= y
;
2240 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2241 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2242 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2243 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2244 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2245 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2246 event
.m_eventObject
= this;
2248 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2250 if (!GetEventHandler()->ProcessEvent(event
))
2254 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2256 // 'normal' move event...
2257 // Set cursor, but only if we're not in 'busy' mode
2259 // Trouble with this is that it sets the cursor for controls too :-(
2260 if (m_windowCursor
.Ok() && !wxIsBusy())
2261 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2263 if (!m_mouseInWindow
)
2265 // Generate an ENTER event
2266 m_mouseInWindow
= TRUE
;
2267 MSWOnMouseEnter(x
, y
, flags
);
2270 wxMouseEvent
event(wxEVT_MOTION
);
2272 event
.m_x
= x
; event
.m_y
= y
;
2273 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2274 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2275 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2276 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2277 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2278 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2279 event
.m_eventObject
= this;
2281 // Window gets a click down message followed by a mouse move
2282 // message even if position isn't changed! We want to discard
2283 // the trailing move event if x and y are the same.
2284 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2285 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2286 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2288 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2289 m_lastEvent
= wxEVT_MOTION
;
2293 m_lastEvent
= wxEVT_MOTION
;
2294 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2296 if (!GetEventHandler()->ProcessEvent(event
))
2300 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2302 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2304 event
.m_x
= x
; event
.m_y
= y
;
2305 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2306 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2307 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2308 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2309 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2310 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2311 event
.m_eventObject
= this;
2313 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2314 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2315 // No message - ensure we don't try to call the default behaviour accidentally.
2317 GetEventHandler()->ProcessEvent(event
);
2320 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2322 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2324 event
.m_x
= x
; event
.m_y
= y
;
2325 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2326 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2327 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2328 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2329 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2330 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2331 event
.m_eventObject
= this;
2333 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2334 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2335 // No message - ensure we don't try to call the default behaviour accidentally.
2337 GetEventHandler()->ProcessEvent(event
);
2340 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2343 bool tempControlDown
= FALSE
;
2346 // If 1 -> 26, translate to CTRL plus a letter.
2348 if ((id
> 0) && (id
< 27))
2369 tempControlDown
= TRUE
;
2375 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2376 // it's ASCII and will be processed here only when called from
2377 // WM_CHAR (i.e. when isASCII = TRUE)
2383 wxKeyEvent
event(wxEVT_CHAR
);
2384 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2385 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2386 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2387 event
.m_altDown
= TRUE
;
2389 event
.m_eventObject
= this;
2390 event
.m_keyCode
= id
;
2391 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2396 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2400 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2402 if (!GetEventHandler()->ProcessEvent(event
))
2407 void wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2411 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2417 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2418 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2419 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2420 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2421 event
.m_altDown
= TRUE
;
2423 event
.m_eventObject
= this;
2424 event
.m_keyCode
= id
;
2425 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2430 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2434 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2436 if (!GetEventHandler()->ProcessEvent(event
))
2441 void wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2445 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2451 wxKeyEvent
event(wxEVT_KEY_UP
);
2452 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2453 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2454 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2455 event
.m_altDown
= TRUE
;
2457 event
.m_eventObject
= this;
2458 event
.m_keyCode
= id
;
2459 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2464 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2468 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2470 if (!GetEventHandler()->ProcessEvent(event
))
2475 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2479 if (flags
& JOY_BUTTON1CHG
)
2480 change
= wxJOY_BUTTON1
;
2481 if (flags
& JOY_BUTTON2CHG
)
2482 change
= wxJOY_BUTTON2
;
2483 if (flags
& JOY_BUTTON3CHG
)
2484 change
= wxJOY_BUTTON3
;
2485 if (flags
& JOY_BUTTON4CHG
)
2486 change
= wxJOY_BUTTON4
;
2488 if (flags
& JOY_BUTTON1
)
2489 buttons
|= wxJOY_BUTTON1
;
2490 if (flags
& JOY_BUTTON2
)
2491 buttons
|= wxJOY_BUTTON2
;
2492 if (flags
& JOY_BUTTON3
)
2493 buttons
|= wxJOY_BUTTON3
;
2494 if (flags
& JOY_BUTTON4
)
2495 buttons
|= wxJOY_BUTTON4
;
2497 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2498 event
.SetPosition(wxPoint(x
, y
));
2499 event
.SetEventObject(this);
2501 GetEventHandler()->ProcessEvent(event
);
2504 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2508 if (flags
& JOY_BUTTON1CHG
)
2509 change
= wxJOY_BUTTON1
;
2510 if (flags
& JOY_BUTTON2CHG
)
2511 change
= wxJOY_BUTTON2
;
2512 if (flags
& JOY_BUTTON3CHG
)
2513 change
= wxJOY_BUTTON3
;
2514 if (flags
& JOY_BUTTON4CHG
)
2515 change
= wxJOY_BUTTON4
;
2517 if (flags
& JOY_BUTTON1
)
2518 buttons
|= wxJOY_BUTTON1
;
2519 if (flags
& JOY_BUTTON2
)
2520 buttons
|= wxJOY_BUTTON2
;
2521 if (flags
& JOY_BUTTON3
)
2522 buttons
|= wxJOY_BUTTON3
;
2523 if (flags
& JOY_BUTTON4
)
2524 buttons
|= wxJOY_BUTTON4
;
2526 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2527 event
.SetPosition(wxPoint(x
, y
));
2528 event
.SetEventObject(this);
2530 GetEventHandler()->ProcessEvent(event
);
2533 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2536 if (flags
& JOY_BUTTON1
)
2537 buttons
|= wxJOY_BUTTON1
;
2538 if (flags
& JOY_BUTTON2
)
2539 buttons
|= wxJOY_BUTTON2
;
2540 if (flags
& JOY_BUTTON3
)
2541 buttons
|= wxJOY_BUTTON3
;
2542 if (flags
& JOY_BUTTON4
)
2543 buttons
|= wxJOY_BUTTON4
;
2545 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2546 event
.SetPosition(wxPoint(x
, y
));
2547 event
.SetEventObject(this);
2549 GetEventHandler()->ProcessEvent(event
);
2552 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2555 if (flags
& JOY_BUTTON1
)
2556 buttons
|= wxJOY_BUTTON1
;
2557 if (flags
& JOY_BUTTON2
)
2558 buttons
|= wxJOY_BUTTON2
;
2559 if (flags
& JOY_BUTTON3
)
2560 buttons
|= wxJOY_BUTTON3
;
2561 if (flags
& JOY_BUTTON4
)
2562 buttons
|= wxJOY_BUTTON4
;
2564 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2565 event
.SetZPosition(z
);
2566 event
.SetEventObject(this);
2568 GetEventHandler()->ProcessEvent(event
);
2571 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2575 wxWindow
*child
= wxFindWinFromHandle(control
);
2577 child
->MSWOnVScroll(wParam
, pos
, control
);
2581 wxScrollEvent event
;
2582 event
.SetPosition(pos
);
2583 event
.SetOrientation(wxVERTICAL
);
2584 event
.m_eventObject
= this;
2589 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2593 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2597 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2601 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2605 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2609 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2613 case SB_THUMBPOSITION
:
2614 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2622 if (!GetEventHandler()->ProcessEvent(event
))
2626 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2630 wxWindow
*child
= wxFindWinFromHandle(control
);
2632 child
->MSWOnHScroll(wParam
, pos
, control
);
2638 wxScrollEvent event
;
2639 event
.SetPosition(pos
);
2640 event
.SetOrientation(wxHORIZONTAL
);
2641 event
.m_eventObject
= this;
2646 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2650 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2654 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2658 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2662 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2666 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2670 case SB_THUMBPOSITION
:
2671 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2678 if ( GetEventHandler()->ProcessEvent(event
) )
2682 // call the default WM_HSCROLL handler: it's non trivial in some common
2683 // controls (up-down control for example)
2687 void wxWindow::MSWOnShow(bool show
, int status
)
2689 wxShowEvent
event(GetId(), show
);
2690 event
.m_eventObject
= this;
2691 GetEventHandler()->ProcessEvent(event
);
2694 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2696 wxInitDialogEvent
event(GetId());
2697 event
.m_eventObject
= this;
2698 GetEventHandler()->ProcessEvent(event
);
2702 void wxWindow::InitDialog()
2704 wxInitDialogEvent
event(GetId());
2705 event
.SetEventObject( this );
2706 GetEventHandler()->ProcessEvent(event
);
2709 // Default init dialog behaviour is to transfer data to window
2710 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2712 TransferDataToWindow();
2715 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2718 HDC dc
= ::GetDC((HWND
) wnd
);
2723 // the_font->UseResource();
2724 // the_font->RealizeResource();
2725 fnt
= (HFONT
)the_font
->GetResourceHandle();
2727 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2729 GetTextMetrics(dc
, &tm
);
2730 if (the_font
&& fnt
&& was
)
2732 SelectObject(dc
,was
) ;
2734 ReleaseDC((HWND
)wnd
, dc
);
2735 *x
= tm
.tmAveCharWidth
;
2736 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2739 // the_font->ReleaseResource();
2742 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2743 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2744 int wxCharCodeMSWToWX(int keySym
)
2749 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2750 case VK_BACK
: id
= WXK_BACK
; break;
2751 case VK_TAB
: id
= WXK_TAB
; break;
2752 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2753 case VK_RETURN
: id
= WXK_RETURN
; break;
2754 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2755 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2756 case VK_MENU
: id
= WXK_MENU
; break;
2757 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2758 case VK_SPACE
: id
= WXK_SPACE
; break;
2759 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2760 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2761 case VK_NEXT
: id
= WXK_NEXT
; break;
2762 case VK_END
: id
= WXK_END
; break;
2763 case VK_HOME
: id
= WXK_HOME
; break;
2764 case VK_LEFT
: id
= WXK_LEFT
; break;
2765 case VK_UP
: id
= WXK_UP
; break;
2766 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2767 case VK_DOWN
: id
= WXK_DOWN
; break;
2768 case VK_SELECT
: id
= WXK_SELECT
; break;
2769 case VK_PRINT
: id
= WXK_PRINT
; break;
2770 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2771 case VK_INSERT
: id
= WXK_INSERT
; break;
2772 case VK_DELETE
: id
= WXK_DELETE
; break;
2773 case VK_HELP
: id
= WXK_HELP
; break;
2774 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2775 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2776 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2777 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2778 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2779 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2780 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2781 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2782 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2783 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2784 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2785 case VK_ADD
: id
= WXK_ADD
; break;
2786 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2787 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2788 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2789 case VK_F1
: id
= WXK_F1
; break;
2790 case VK_F2
: id
= WXK_F2
; break;
2791 case VK_F3
: id
= WXK_F3
; break;
2792 case VK_F4
: id
= WXK_F4
; break;
2793 case VK_F5
: id
= WXK_F5
; break;
2794 case VK_F6
: id
= WXK_F6
; break;
2795 case VK_F7
: id
= WXK_F7
; break;
2796 case VK_F8
: id
= WXK_F8
; break;
2797 case VK_F9
: id
= WXK_F9
; break;
2798 case VK_F10
: id
= WXK_F10
; break;
2799 case VK_F11
: id
= WXK_F11
; break;
2800 case VK_F12
: id
= WXK_F12
; break;
2801 case VK_F13
: id
= WXK_F13
; break;
2802 case VK_F14
: id
= WXK_F14
; break;
2803 case VK_F15
: id
= WXK_F15
; break;
2804 case VK_F16
: id
= WXK_F16
; break;
2805 case VK_F17
: id
= WXK_F17
; break;
2806 case VK_F18
: id
= WXK_F18
; break;
2807 case VK_F19
: id
= WXK_F19
; break;
2808 case VK_F20
: id
= WXK_F20
; break;
2809 case VK_F21
: id
= WXK_F21
; break;
2810 case VK_F22
: id
= WXK_F22
; break;
2811 case VK_F23
: id
= WXK_F23
; break;
2812 case VK_F24
: id
= WXK_F24
; break;
2813 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2814 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2823 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2829 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2830 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2831 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2832 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2833 case WXK_MENU
: keySym
= VK_MENU
; break;
2834 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2835 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2836 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2837 case WXK_END
: keySym
= VK_END
; break;
2838 case WXK_HOME
: keySym
= VK_HOME
; break;
2839 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2840 case WXK_UP
: keySym
= VK_UP
; break;
2841 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2842 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2843 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2844 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2845 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2846 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2847 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2848 case WXK_HELP
: keySym
= VK_HELP
; break;
2849 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2850 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2851 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2852 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2853 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2854 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2855 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2856 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2857 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2858 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2859 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2860 case WXK_ADD
: keySym
= VK_ADD
; break;
2861 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2862 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2863 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2864 case WXK_F1
: keySym
= VK_F1
; break;
2865 case WXK_F2
: keySym
= VK_F2
; break;
2866 case WXK_F3
: keySym
= VK_F3
; break;
2867 case WXK_F4
: keySym
= VK_F4
; break;
2868 case WXK_F5
: keySym
= VK_F5
; break;
2869 case WXK_F6
: keySym
= VK_F6
; break;
2870 case WXK_F7
: keySym
= VK_F7
; break;
2871 case WXK_F8
: keySym
= VK_F8
; break;
2872 case WXK_F9
: keySym
= VK_F9
; break;
2873 case WXK_F10
: keySym
= VK_F10
; break;
2874 case WXK_F11
: keySym
= VK_F11
; break;
2875 case WXK_F12
: keySym
= VK_F12
; break;
2876 case WXK_F13
: keySym
= VK_F13
; break;
2877 case WXK_F14
: keySym
= VK_F14
; break;
2878 case WXK_F15
: keySym
= VK_F15
; break;
2879 case WXK_F16
: keySym
= VK_F16
; break;
2880 case WXK_F17
: keySym
= VK_F17
; break;
2881 case WXK_F18
: keySym
= VK_F18
; break;
2882 case WXK_F19
: keySym
= VK_F19
; break;
2883 case WXK_F20
: keySym
= VK_F20
; break;
2884 case WXK_F21
: keySym
= VK_F21
; break;
2885 case WXK_F22
: keySym
= VK_F22
; break;
2886 case WXK_F23
: keySym
= VK_F23
; break;
2887 case WXK_F24
: keySym
= VK_F24
; break;
2888 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2889 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2900 // Caret manipulation
2901 void wxWindow::CreateCaret(int w
, int h
)
2905 m_caretEnabled
= TRUE
;
2908 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2913 void wxWindow::ShowCaret(bool show
)
2918 ::ShowCaret((HWND
) GetHWND());
2920 ::HideCaret((HWND
) GetHWND());
2921 m_caretShown
= show
;
2925 void wxWindow::DestroyCaret()
2927 m_caretEnabled
= FALSE
;
2930 void wxWindow::SetCaretPos(int x
, int y
)
2932 ::SetCaretPos(x
, y
);
2935 void wxWindow::GetCaretPos(int *x
, int *y
) const
2938 ::GetCaretPos(&point
);
2943 wxWindow
*wxGetActiveWindow()
2945 HWND hWnd
= GetActiveWindow();
2948 return wxFindWinFromHandle((WXHWND
) hWnd
);
2953 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2954 // in active frames and dialogs, regardless of where the focus is.
2955 static HHOOK wxTheKeyboardHook
= 0;
2956 static FARPROC wxTheKeyboardHookProc
= 0;
2957 int APIENTRY _EXPORT
2958 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2960 void wxSetKeyboardHook(bool doIt
)
2964 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
2965 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
2967 GetCurrentThreadId());
2968 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2975 UnhookWindowsHookEx(wxTheKeyboardHook
);
2976 FreeProcInstance(wxTheKeyboardHookProc
);
2980 int APIENTRY _EXPORT
2981 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
2983 DWORD hiWord
= HIWORD(lParam
);
2984 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
2987 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
2989 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
2990 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2991 event
.m_altDown
= TRUE
;
2993 event
.m_eventObject
= NULL
;
2994 event
.m_keyCode
= id
;
2995 /* begin Albert's fix for control and shift key 26.5 */
2996 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2997 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2998 /* end Albert's fix for control and shift key 26.5 */
2999 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3001 wxWindow
*win
= wxGetActiveWindow();
3004 if (win
->GetEventHandler()->ProcessEvent(event
))
3009 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3014 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3017 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3025 void wxWindow::Centre(int direction
)
3027 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3029 wxWindow
*father
= (wxWindow
*)GetParent();
3033 father
->GetClientSize(&panel_width
, &panel_height
);
3034 GetSize(&width
, &height
);
3035 GetPosition(&x
, &y
);
3040 if (direction
& wxHORIZONTAL
)
3041 new_x
= (int)((panel_width
- width
)/2);
3043 if (direction
& wxVERTICAL
)
3044 new_y
= (int)((panel_height
- height
)/2);
3046 SetSize(new_x
, new_y
, -1, -1);
3051 void wxWindow::OnPaint()
3053 PaintSelectionHandles();
3057 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3059 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3060 // pixel coordinates, relatives to the canvas -- So, we first need to
3061 // substract origin of the window, then convert to screen position
3063 int x
= x_pos
; int y
= y_pos
;
3065 GetWindowRect ((HWND
) GetHWND(), &rect
);
3070 SetCursorPos (x
, y
);
3073 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3077 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3085 wxEraseEvent
event(m_windowId
, &dc
);
3086 event
.m_eventObject
= this;
3087 if (!GetEventHandler()->ProcessEvent(event
))
3090 dc
.SelectOldObjects(pDC
);
3096 dc
.SelectOldObjects(pDC
);
3099 dc
.SetHDC((WXHDC
) NULL
);
3103 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3106 ::GetClientRect((HWND
) GetHWND(), &rect
);
3108 HBRUSH hBrush
= ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
3109 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3111 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3112 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3113 ::DeleteObject(hBrush
);
3114 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3116 // Less efficient version (and doesn't account for scrolling)
3118 GetClientSize(& w, & h);
3119 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3120 event.GetDC()->SetBrush(brush);
3121 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3123 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3127 #if WXWIN_COMPATIBILITY
3128 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3130 #if defined(__WIN95__)
3134 // Try to adjust the range to cope with page size > 1
3135 // - a Windows API quirk
3136 int pageSize
= GetScrollPage(orient
);
3137 if ( pageSize
> 1 && range
> 0)
3139 range1
+= (pageSize
- 1);
3145 if (orient
== wxHORIZONTAL
) {
3151 info
.cbSize
= sizeof(SCROLLINFO
);
3152 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3156 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3158 HWND hWnd
= (HWND
) GetHWND();
3160 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3163 if (orient
== wxHORIZONTAL
)
3168 HWND hWnd
= (HWND
) GetHWND();
3170 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3174 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3176 #if defined(__WIN95__)
3180 if (orient
== wxHORIZONTAL
) {
3182 m_xThumbSize
= page
;
3185 m_yThumbSize
= page
;
3188 info
.cbSize
= sizeof(SCROLLINFO
);
3191 info
.fMask
= SIF_PAGE
;
3193 HWND hWnd
= (HWND
) GetHWND();
3195 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3197 if (orient
== wxHORIZONTAL
)
3198 m_xThumbSize
= page
;
3200 m_yThumbSize
= page
;
3204 int wxWindow::OldGetScrollRange(int orient
) const
3207 if (orient
== wxHORIZONTAL
)
3212 #if __WATCOMC__ && defined(__WINDOWS_386__)
3213 short minPos
, maxPos
;
3217 HWND hWnd
= (HWND
) GetHWND();
3220 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3221 #if defined(__WIN95__)
3222 // Try to adjust the range to cope with page size > 1
3223 // - a Windows API quirk
3224 int pageSize
= GetScrollPage(orient
);
3227 maxPos
-= (pageSize
- 1);
3236 int wxWindow::GetScrollPage(int orient
) const
3238 if (orient
== wxHORIZONTAL
)
3239 return m_xThumbSize
;
3241 return m_yThumbSize
;
3245 int wxWindow::GetScrollPos(int orient
) const
3248 if (orient
== wxHORIZONTAL
)
3252 HWND hWnd
= (HWND
) GetHWND();
3255 return ::GetScrollPos(hWnd
, wOrient
);
3261 // This now returns the whole range, not just the number
3262 // of positions that we can scroll.
3263 int wxWindow::GetScrollRange(int orient
) const
3266 if (orient
== wxHORIZONTAL
)
3271 #if __WATCOMC__ && defined(__WINDOWS_386__)
3272 short minPos
, maxPos
;
3276 HWND hWnd
= (HWND
) GetHWND();
3279 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3280 #if defined(__WIN95__)
3281 // Try to adjust the range to cope with page size > 1
3282 // - a Windows API quirk
3283 int pageSize
= GetScrollThumb(orient
);
3286 maxPos
-= (pageSize
- 1);
3288 // October 10th: new range concept.
3298 int wxWindow::GetScrollThumb(int orient
) const
3300 if (orient
== wxHORIZONTAL
)
3301 return m_xThumbSize
;
3303 return m_yThumbSize
;
3306 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3308 #if defined(__WIN95__)
3312 if (orient
== wxHORIZONTAL
) {
3318 info
.cbSize
= sizeof(SCROLLINFO
);
3322 info
.fMask
= SIF_POS
;
3324 HWND hWnd
= (HWND
) GetHWND();
3326 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3329 if (orient
== wxHORIZONTAL
)
3334 HWND hWnd
= (HWND
) GetHWND();
3336 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3340 // New function that will replace some of the above.
3341 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3342 int range
, bool refresh
)
3345 SetScrollPage(orient, thumbVisible, FALSE);
3347 int oldRange = range - thumbVisible ;
3348 SetScrollRange(orient, oldRange, FALSE);
3350 SetScrollPos(orient, pos, refresh);
3352 #if defined(__WIN95__)
3353 int oldRange
= range
- thumbVisible
;
3355 int range1
= oldRange
;
3357 // Try to adjust the range to cope with page size > 1
3358 // - a Windows API quirk
3359 int pageSize
= thumbVisible
;
3360 if ( pageSize
> 1 && range
> 0)
3362 range1
+= (pageSize
- 1);
3368 if (orient
== wxHORIZONTAL
) {
3374 info
.cbSize
= sizeof(SCROLLINFO
);
3375 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3379 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3381 HWND hWnd
= (HWND
) GetHWND();
3383 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3386 if (orient
== wxHORIZONTAL
)
3391 HWND hWnd
= (HWND
) GetHWND();
3394 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3395 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3398 if (orient
== wxHORIZONTAL
) {
3399 m_xThumbSize
= thumbVisible
;
3401 m_yThumbSize
= thumbVisible
;
3405 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3410 rect2
.left
= rect
->x
;
3411 rect2
.top
= rect
->y
;
3412 rect2
.right
= rect
->x
+ rect
->width
;
3413 rect2
.bottom
= rect
->y
+ rect
->height
;
3417 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3419 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3422 void wxWindow::SetFont(const wxFont
& font
)
3424 m_windowFont
= font
;
3426 if (!m_windowFont
.Ok())
3429 HWND hWnd
= (HWND
) GetHWND();
3432 if (m_windowFont
.GetResourceHandle())
3433 SendMessage(hWnd
, WM_SETFONT
,
3434 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3438 void wxWindow::SubclassWin(WXHWND hWnd
)
3440 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3442 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3444 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3445 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3448 void wxWindow::UnsubclassWin()
3450 wxRemoveHandleAssociation(this);
3452 // Restore old Window proc
3453 if ((HWND
) GetHWND())
3455 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3456 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3458 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3464 // Make a Windows extended style from the given wxWindows window style
3465 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3467 WXDWORD exStyle
= 0;
3468 if ( style
& wxTRANSPARENT_WINDOW
)
3469 exStyle
|= WS_EX_TRANSPARENT
;
3471 if ( !eliminateBorders
)
3473 if ( style
& wxSUNKEN_BORDER
)
3474 exStyle
|= WS_EX_CLIENTEDGE
;
3475 if ( style
& wxDOUBLE_BORDER
)
3476 exStyle
|= WS_EX_DLGMODALFRAME
;
3477 #if defined(__WIN95__)
3478 if ( style
& wxRAISED_BORDER
)
3479 exStyle
|= WS_EX_WINDOWEDGE
;
3480 if ( style
& wxSTATIC_BORDER
)
3481 exStyle
|= WS_EX_STATICEDGE
;
3487 // Determines whether native 3D effects or CTL3D should be used,
3488 // applying a default border style if required, and returning an extended
3489 // style to pass to CreateWindowEx.
3490 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3492 // If matches certain criteria, then assume no 3D effects
3493 // unless specifically requested (dealt with in MakeExtendedStyle)
3494 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3497 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3500 // Determine whether we should be using 3D effects or not.
3501 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3503 // 1) App can specify global 3D effects
3504 *want3D
= wxTheApp
->GetAuto3D();
3506 // 2) If the parent is being drawn with user colours, or simple border specified,
3507 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3508 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3511 // 3) Control can override this global setting by defining
3512 // a border style, e.g. wxSUNKEN_BORDER
3513 if (m_windowStyle
& wxSUNKEN_BORDER
)
3516 // 4) If it's a special border, CTL3D can't cope so we want a native border
3517 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3518 (m_windowStyle
& wxSTATIC_BORDER
) )
3521 nativeBorder
= TRUE
;
3524 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3525 // effects from extended style
3528 nativeBorder
= FALSE
;
3531 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3533 // If we want 3D, but haven't specified a border here,
3534 // apply the default border style specified.
3535 // TODO what about non-Win95 WIN32? Does it have borders?
3536 #if defined(__WIN95__) && !CTL3D
3537 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3538 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3539 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3545 void wxWindow::OnChar(wxKeyEvent
& event
)
3547 /* I'm commenting this out because otherwise, we lose tabs in e.g. a text window (see MDI sample)
3549 if ( event.KeyCode() == WXK_TAB ) {
3550 // propagate the TABs to the parent - it's up to it to decide what
3552 if ( GetParent() ) {
3553 if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
3560 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3565 if ( !event
.ControlDown() )
3566 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3569 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3574 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3579 void wxWindow::OnPaint(wxPaintEvent
& event
)
3584 bool wxWindow::IsEnabled(void) const
3586 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3589 // Dialog support: override these and call
3590 // base class members to add functionality
3591 // that can't be done using validators.
3592 // NOTE: these functions assume that controls
3593 // are direct children of this window, not grandchildren
3594 // or other levels of descendant.
3596 // Transfer values to controls. If returns FALSE,
3597 // it's an application error (pops up a dialog)
3598 bool wxWindow::TransferDataToWindow()
3600 wxNode
*node
= GetChildren().First();
3603 wxWindow
*child
= (wxWindow
*)node
->Data();
3604 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3605 !child
->GetValidator()->TransferToWindow() )
3607 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3611 node
= node
->Next();
3616 // Transfer values from controls. If returns FALSE,
3617 // validation failed: don't quit
3618 bool wxWindow::TransferDataFromWindow()
3620 wxNode
*node
= GetChildren().First();
3623 wxWindow
*child
= (wxWindow
*)node
->Data();
3624 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3629 node
= node
->Next();
3634 bool wxWindow::Validate()
3636 wxNode
*node
= GetChildren().First();
3639 wxWindow
*child
= (wxWindow
*)node
->Data();
3640 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3645 node
= node
->Next();
3650 // Get the window with the focus
3651 wxWindow
*wxWindow::FindFocus()
3653 HWND hWnd
= ::GetFocus();
3656 return wxFindWinFromHandle((WXHWND
) hWnd
);
3661 void wxWindow::AddChild(wxWindow
*child
)
3663 GetChildren().Append(child
);
3664 child
->m_windowParent
= this;
3667 void wxWindow::RemoveChild(wxWindow
*child
)
3669 // if (GetChildren())
3670 GetChildren().DeleteObject(child
);
3671 child
->m_windowParent
= NULL
;
3674 void wxWindow::DestroyChildren()
3677 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3679 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3681 if ( GetChildren().Member(child
) )
3687 void wxWindow::MakeModal(bool modal
)
3689 // Disable all other windows
3690 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3692 wxNode
*node
= wxTopLevelWindows
.First();
3695 wxWindow
*win
= (wxWindow
*)node
->Data();
3697 win
->Enable(!modal
);
3699 node
= node
->Next();
3704 // If nothing defined for this, try the parent.
3705 // E.g. we may be a button loaded from a resource, with no callback function
3707 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3709 if (GetEventHandler()->ProcessEvent(event
) )
3712 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3715 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3719 UnsetConstraints(m_constraints
);
3720 delete m_constraints
;
3725 // Make sure other windows know they're part of a 'meaningful relationship'
3726 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3727 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3728 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3729 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3730 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3731 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3732 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3733 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3734 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3735 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3736 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3737 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3738 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3739 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3740 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3741 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3745 // This removes any dangling pointers to this window
3746 // in other windows' constraintsInvolvedIn lists.
3747 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3751 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3752 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3753 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3754 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3755 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3756 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3757 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3758 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3759 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3760 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3761 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3762 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3763 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3764 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3765 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3766 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3770 // Back-pointer to other windows we're involved with, so if we delete
3771 // this window, we must delete any constraints we're involved with.
3772 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3774 if (!m_constraintsInvolvedIn
)
3775 m_constraintsInvolvedIn
= new wxList
;
3776 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3777 m_constraintsInvolvedIn
->Append(otherWin
);
3780 // REMOVE back-pointer to other windows we're involved with.
3781 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3783 if (m_constraintsInvolvedIn
)
3784 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3787 // Reset any constraints that mention this window
3788 void wxWindow::DeleteRelatedConstraints()
3790 if (m_constraintsInvolvedIn
)
3792 wxNode
*node
= m_constraintsInvolvedIn
->First();
3795 wxWindow
*win
= (wxWindow
*)node
->Data();
3796 wxNode
*next
= node
->Next();
3797 wxLayoutConstraints
*constr
= win
->GetConstraints();
3799 // Reset any constraints involving this window
3802 constr
->left
.ResetIfWin((wxWindow
*)this);
3803 constr
->top
.ResetIfWin((wxWindow
*)this);
3804 constr
->right
.ResetIfWin((wxWindow
*)this);
3805 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3806 constr
->width
.ResetIfWin((wxWindow
*)this);
3807 constr
->height
.ResetIfWin((wxWindow
*)this);
3808 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3809 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3814 delete m_constraintsInvolvedIn
;
3815 m_constraintsInvolvedIn
= NULL
;
3819 void wxWindow::SetSizer(wxSizer
*sizer
)
3821 m_windowSizer
= sizer
;
3823 sizer
->SetSizerParent((wxWindow
*)this);
3830 bool wxWindow::Layout()
3832 if (GetConstraints())
3835 GetClientSize(&w
, &h
);
3836 GetConstraints()->width
.SetValue(w
);
3837 GetConstraints()->height
.SetValue(h
);
3840 // If top level (one sizer), evaluate the sizer's constraints.
3844 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3845 GetSizer()->LayoutPhase1(&noChanges
);
3846 GetSizer()->LayoutPhase2(&noChanges
);
3847 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3852 // Otherwise, evaluate child constraints
3853 ResetConstraints(); // Mark all constraints as unevaluated
3854 DoPhase(1); // Just one phase need if no sizers involved
3856 SetConstraintSizes(); // Recursively set the real window sizes
3862 // Do a phase of evaluating constraints:
3863 // the default behaviour. wxSizers may do a similar
3864 // thing, but also impose their own 'constraints'
3865 // and order the evaluation differently.
3866 bool wxWindow::LayoutPhase1(int *noChanges
)
3868 wxLayoutConstraints
*constr
= GetConstraints();
3871 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3877 bool wxWindow::LayoutPhase2(int *noChanges
)
3887 // Do a phase of evaluating child constraints
3888 bool wxWindow::DoPhase(int phase
)
3890 int noIterations
= 0;
3891 int maxIterations
= 500;
3895 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3899 wxNode
*node
= GetChildren().First();
3902 wxWindow
*child
= (wxWindow
*)node
->Data();
3903 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3905 wxLayoutConstraints
*constr
= child
->GetConstraints();
3908 if (succeeded
.Member(child
))
3913 int tempNoChanges
= 0;
3914 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3915 noChanges
+= tempNoChanges
;
3918 succeeded
.Append(child
);
3923 node
= node
->Next();
3930 void wxWindow::ResetConstraints()
3932 wxLayoutConstraints
*constr
= GetConstraints();
3935 constr
->left
.SetDone(FALSE
);
3936 constr
->top
.SetDone(FALSE
);
3937 constr
->right
.SetDone(FALSE
);
3938 constr
->bottom
.SetDone(FALSE
);
3939 constr
->width
.SetDone(FALSE
);
3940 constr
->height
.SetDone(FALSE
);
3941 constr
->centreX
.SetDone(FALSE
);
3942 constr
->centreY
.SetDone(FALSE
);
3944 wxNode
*node
= GetChildren().First();
3947 wxWindow
*win
= (wxWindow
*)node
->Data();
3948 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3949 win
->ResetConstraints();
3950 node
= node
->Next();
3954 // Need to distinguish between setting the 'fake' size for
3955 // windows and sizers, and setting the real values.
3956 void wxWindow::SetConstraintSizes(bool recurse
)
3958 wxLayoutConstraints
*constr
= GetConstraints();
3959 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3960 constr
->width
.GetDone() && constr
->height
.GetDone())
3962 int x
= constr
->left
.GetValue();
3963 int y
= constr
->top
.GetValue();
3964 int w
= constr
->width
.GetValue();
3965 int h
= constr
->height
.GetValue();
3967 // If we don't want to resize this window, just move it...
3968 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3969 (constr
->height
.GetRelationship() != wxAsIs
))
3971 // Calls Layout() recursively. AAAGH. How can we stop that.
3972 // Simply take Layout() out of non-top level OnSizes.
3973 SizerSetSize(x
, y
, w
, h
);
3982 char *windowClass
= this->GetClassInfo()->GetClassName();
3985 if (GetName() == "")
3986 winName
= "unnamed";
3988 winName
= GetName();
3989 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
3990 if (!constr
->left
.GetDone())
3991 wxDebugMsg(" unsatisfied 'left' constraint.\n");
3992 if (!constr
->right
.GetDone())
3993 wxDebugMsg(" unsatisfied 'right' constraint.\n");
3994 if (!constr
->width
.GetDone())
3995 wxDebugMsg(" unsatisfied 'width' constraint.\n");
3996 if (!constr
->height
.GetDone())
3997 wxDebugMsg(" unsatisfied 'height' constraint.\n");
3998 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
4003 wxNode
*node
= GetChildren().First();
4006 wxWindow
*win
= (wxWindow
*)node
->Data();
4007 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4008 win
->SetConstraintSizes();
4009 node
= node
->Next();
4014 // This assumes that all sizers are 'on' the same
4015 // window, i.e. the parent of this window.
4016 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4018 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4019 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4023 m_sizerParent
->GetPosition(&xp
, &yp
);
4024 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4029 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4033 TransformSizerToActual(&xx
, &yy
);
4034 SetSize(xx
, yy
, w
, h
);
4037 void wxWindow::SizerMove(int x
, int y
)
4041 TransformSizerToActual(&xx
, &yy
);
4045 // Only set the size/position of the constraint (if any)
4046 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4048 wxLayoutConstraints
*constr
= GetConstraints();
4053 constr
->left
.SetValue(x
);
4054 constr
->left
.SetDone(TRUE
);
4058 constr
->top
.SetValue(y
);
4059 constr
->top
.SetDone(TRUE
);
4063 constr
->width
.SetValue(w
);
4064 constr
->width
.SetDone(TRUE
);
4068 constr
->height
.SetValue(h
);
4069 constr
->height
.SetDone(TRUE
);
4074 void wxWindow::MoveConstraint(int x
, int y
)
4076 wxLayoutConstraints
*constr
= GetConstraints();
4081 constr
->left
.SetValue(x
);
4082 constr
->left
.SetDone(TRUE
);
4086 constr
->top
.SetValue(y
);
4087 constr
->top
.SetDone(TRUE
);
4092 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4094 wxLayoutConstraints
*constr
= GetConstraints();
4097 *w
= constr
->width
.GetValue();
4098 *h
= constr
->height
.GetValue();
4104 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4106 wxLayoutConstraints
*constr
= GetConstraints();
4109 *w
= constr
->width
.GetValue();
4110 *h
= constr
->height
.GetValue();
4113 GetClientSize(w
, h
);
4116 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4118 wxLayoutConstraints
*constr
= GetConstraints();
4121 *x
= constr
->left
.GetValue();
4122 *y
= constr
->top
.GetValue();
4128 bool wxWindow::Close(bool force
)
4130 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4131 event
.SetEventObject(this);
4132 event
.SetForce(force
);
4133 event
.SetCanVeto(!force
);
4135 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4138 wxObject
* wxWindow::GetChild(int number
) const
4140 // Return a pointer to the Nth object in the Panel
4141 // if (!GetChildren())
4143 wxNode
*node
= GetChildren().First();
4146 node
= node
->Next() ;
4149 wxObject
*obj
= (wxObject
*)node
->Data();
4156 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4158 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4159 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4162 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4164 wxListBox *lbox = (wxListBox *)initiatingItem;
4165 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4166 event.m_commandInt = -1;
4167 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4169 event.m_commandString = copystring(lbox->GetStringSelection());
4170 event.m_commandInt = lbox->GetSelection();
4171 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4173 event.m_eventObject = lbox;
4175 lbox->ProcessCommand(event);
4177 if (event.m_commandString)
4178 delete[] event.m_commandString;
4182 wxButton *but = GetDefaultItem();
4185 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4186 event.SetEventObject(but);
4187 but->Command(event);
4192 void wxWindow::Clear()
4194 wxClientDC
dc(this);
4195 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4196 dc
.SetBackground(brush
);
4200 // Fits the panel around the items
4201 void wxWindow::Fit()
4205 wxNode
*node
= GetChildren().First();
4208 wxWindow
*win
= (wxWindow
*)node
->Data();
4210 win
->GetPosition(&wx
, &wy
);
4211 win
->GetSize(&ww
, &wh
);
4212 if ( wx
+ ww
> maxX
)
4214 if ( wy
+ wh
> maxY
)
4217 node
= node
->Next();
4219 SetClientSize(maxX
+ 5, maxY
+ 5);
4222 void wxWindow::SetValidator(const wxValidator
& validator
)
4224 if ( m_windowValidator
)
4225 delete m_windowValidator
;
4226 m_windowValidator
= validator
.Clone();
4228 if ( m_windowValidator
)
4229 m_windowValidator
->SetWindow(this) ;
4232 // Find a window by id or name
4233 wxWindow
*wxWindow::FindWindow(long id
)
4238 wxNode
*node
= GetChildren().First();
4241 wxWindow
*child
= (wxWindow
*)node
->Data();
4242 wxWindow
*found
= child
->FindWindow(id
);
4245 node
= node
->Next();
4250 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4252 if ( GetName() == name
)
4255 wxNode
*node
= GetChildren().First();
4258 wxWindow
*child
= (wxWindow
*)node
->Data();
4259 wxWindow
*found
= child
->FindWindow(name
);
4262 node
= node
->Next();
4268 // Default input behaviour for a scrolling canvas should be to scroll
4269 // according to the cursor keys pressed
4270 void wxWindow::OnChar(wxKeyEvent& event)
4282 GetScrollUnitsPerPage(&x_page, &y_page);
4284 GetVirtualSize(&v_width,&v_height);
4286 ViewStart(&start_x, &start_y);
4289 y_pages = (int)(v_height/vert_units) - y_page;
4297 switch (event.keyCode)
4304 if (start_y - y_page > 0)
4305 Scroll(start_x, start_y - y_page);
4315 if ((y_page > 0) && (start_y <= y_pages-y-1))
4317 if (y_pages + y < start_y + y_page)
4318 Scroll(start_x, y_pages + y);
4320 Scroll(start_x, start_y + y_page);
4327 if ((y_page > 0) && (start_y >= 1))
4328 Scroll(start_x, start_y - 1);
4334 if ((y_page > 0) && (start_y <= y_pages-y-1))
4337 Scroll(start_x, start_y + 1);
4343 if ((x_page > 0) && (start_x >= 1))
4344 Scroll(start_x - 1, start_y);
4350 Scroll(start_x + 1, start_y);
4361 Scroll(start_x, y_pages+y);
4369 // Setup background and foreground colours correctly
4370 void wxWindow::SetupColours()
4373 SetBackgroundColour(GetParent()->GetBackgroundColour());
4376 void wxWindow::OnIdle(wxIdleEvent
& event
)
4378 // Check if we need to send a LEAVE event
4379 if (m_mouseInWindow
)
4382 ::GetCursorPos(&pt
);
4383 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4385 // Generate a LEAVE event
4386 m_mouseInWindow
= FALSE
;
4389 if (::GetKeyState(VK_SHIFT
) != 0)
4391 if (::GetKeyState(VK_CONTROL
) != 0)
4392 state
|= MK_CONTROL
;
4394 // Unfortunately the mouse button and keyboard state may have changed
4395 // by the time the OnIdle function is called, so 'state' may be
4398 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4404 // Raise the window to the top of the Z order
4405 void wxWindow::Raise()
4407 ::BringWindowToTop((HWND
) GetHWND());
4410 // Lower the window to the bottom of the Z order
4411 void wxWindow::Lower()
4413 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4416 long wxWindow::MSWGetDlgCode()
4418 // default: just forward to def window proc (the msg has no parameters)
4419 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4422 bool wxWindow::AcceptsFocus() const
4424 return IsShown() && IsEnabled();
4427 // Update region access
4428 wxRegion
wxWindow::GetUpdateRegion() const
4430 return m_updateRegion
;
4433 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4435 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4438 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4440 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4443 bool wxWindow::IsExposed(const wxRect
& rect
) const
4445 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4448 // Set this window to be the child of 'parent'.
4449 bool wxWindow::Reparent(wxWindow
*parent
)
4451 if (parent
== GetParent())
4454 // Unlink this window from the existing parent.
4457 GetParent()->RemoveChild(this);
4460 wxTopLevelWindows
.DeleteObject(this);
4462 HWND hWndParent
= 0;
4463 HWND hWndChild
= (HWND
) GetHWND();
4464 if (parent
!= (wxWindow
*) NULL
)
4466 parent
->AddChild(this);
4467 hWndParent
= (HWND
) parent
->GetHWND();
4470 wxTopLevelWindows
.Append(this);
4472 ::SetParent(hWndChild
, hWndParent
);
4478 const char *wxGetMessageName(int message
)
4480 switch ( message
) {
4481 case 0x0000: return "WM_NULL";
4482 case 0x0001: return "WM_CREATE";
4483 case 0x0002: return "WM_DESTROY";
4484 case 0x0003: return "WM_MOVE";
4485 case 0x0005: return "WM_SIZE";
4486 case 0x0006: return "WM_ACTIVATE";
4487 case 0x0007: return "WM_SETFOCUS";
4488 case 0x0008: return "WM_KILLFOCUS";
4489 case 0x000A: return "WM_ENABLE";
4490 case 0x000B: return "WM_SETREDRAW";
4491 case 0x000C: return "WM_SETTEXT";
4492 case 0x000D: return "WM_GETTEXT";
4493 case 0x000E: return "WM_GETTEXTLENGTH";
4494 case 0x000F: return "WM_PAINT";
4495 case 0x0010: return "WM_CLOSE";
4496 case 0x0011: return "WM_QUERYENDSESSION";
4497 case 0x0012: return "WM_QUIT";
4498 case 0x0013: return "WM_QUERYOPEN";
4499 case 0x0014: return "WM_ERASEBKGND";
4500 case 0x0015: return "WM_SYSCOLORCHANGE";
4501 case 0x0016: return "WM_ENDSESSION";
4502 case 0x0017: return "WM_SYSTEMERROR";
4503 case 0x0018: return "WM_SHOWWINDOW";
4504 case 0x0019: return "WM_CTLCOLOR";
4505 case 0x001A: return "WM_WININICHANGE";
4506 case 0x001B: return "WM_DEVMODECHANGE";
4507 case 0x001C: return "WM_ACTIVATEAPP";
4508 case 0x001D: return "WM_FONTCHANGE";
4509 case 0x001E: return "WM_TIMECHANGE";
4510 case 0x001F: return "WM_CANCELMODE";
4511 case 0x0020: return "WM_SETCURSOR";
4512 case 0x0021: return "WM_MOUSEACTIVATE";
4513 case 0x0022: return "WM_CHILDACTIVATE";
4514 case 0x0023: return "WM_QUEUESYNC";
4515 case 0x0024: return "WM_GETMINMAXINFO";
4516 case 0x0026: return "WM_PAINTICON";
4517 case 0x0027: return "WM_ICONERASEBKGND";
4518 case 0x0028: return "WM_NEXTDLGCTL";
4519 case 0x002A: return "WM_SPOOLERSTATUS";
4520 case 0x002B: return "WM_DRAWITEM";
4521 case 0x002C: return "WM_MEASUREITEM";
4522 case 0x002D: return "WM_DELETEITEM";
4523 case 0x002E: return "WM_VKEYTOITEM";
4524 case 0x002F: return "WM_CHARTOITEM";
4525 case 0x0030: return "WM_SETFONT";
4526 case 0x0031: return "WM_GETFONT";
4527 case 0x0037: return "WM_QUERYDRAGICON";
4528 case 0x0039: return "WM_COMPAREITEM";
4529 case 0x0041: return "WM_COMPACTING";
4530 case 0x0044: return "WM_COMMNOTIFY";
4531 case 0x0046: return "WM_WINDOWPOSCHANGING";
4532 case 0x0047: return "WM_WINDOWPOSCHANGED";
4533 case 0x0048: return "WM_POWER";
4536 case 0x004A: return "WM_COPYDATA";
4537 case 0x004B: return "WM_CANCELJOURNAL";
4538 case 0x004E: return "WM_NOTIFY";
4539 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4540 case 0x0051: return "WM_INPUTLANGCHANGE";
4541 case 0x0052: return "WM_TCARD";
4542 case 0x0053: return "WM_HELP";
4543 case 0x0054: return "WM_USERCHANGED";
4544 case 0x0055: return "WM_NOTIFYFORMAT";
4545 case 0x007B: return "WM_CONTEXTMENU";
4546 case 0x007C: return "WM_STYLECHANGING";
4547 case 0x007D: return "WM_STYLECHANGED";
4548 case 0x007E: return "WM_DISPLAYCHANGE";
4549 case 0x007F: return "WM_GETICON";
4550 case 0x0080: return "WM_SETICON";
4553 case 0x0081: return "WM_NCCREATE";
4554 case 0x0082: return "WM_NCDESTROY";
4555 case 0x0083: return "WM_NCCALCSIZE";
4556 case 0x0084: return "WM_NCHITTEST";
4557 case 0x0085: return "WM_NCPAINT";
4558 case 0x0086: return "WM_NCACTIVATE";
4559 case 0x0087: return "WM_GETDLGCODE";
4560 case 0x00A0: return "WM_NCMOUSEMOVE";
4561 case 0x00A1: return "WM_NCLBUTTONDOWN";
4562 case 0x00A2: return "WM_NCLBUTTONUP";
4563 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4564 case 0x00A4: return "WM_NCRBUTTONDOWN";
4565 case 0x00A5: return "WM_NCRBUTTONUP";
4566 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4567 case 0x00A7: return "WM_NCMBUTTONDOWN";
4568 case 0x00A8: return "WM_NCMBUTTONUP";
4569 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4570 case 0x0100: return "WM_KEYDOWN";
4571 case 0x0101: return "WM_KEYUP";
4572 case 0x0102: return "WM_CHAR";
4573 case 0x0103: return "WM_DEADCHAR";
4574 case 0x0104: return "WM_SYSKEYDOWN";
4575 case 0x0105: return "WM_SYSKEYUP";
4576 case 0x0106: return "WM_SYSCHAR";
4577 case 0x0107: return "WM_SYSDEADCHAR";
4578 case 0x0108: return "WM_KEYLAST";
4581 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4582 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4583 case 0x010F: return "WM_IME_COMPOSITION";
4586 case 0x0110: return "WM_INITDIALOG";
4587 case 0x0111: return "WM_COMMAND";
4588 case 0x0112: return "WM_SYSCOMMAND";
4589 case 0x0113: return "WM_TIMER";
4590 case 0x0114: return "WM_HSCROLL";
4591 case 0x0115: return "WM_VSCROLL";
4592 case 0x0116: return "WM_INITMENU";
4593 case 0x0117: return "WM_INITMENUPOPUP";
4594 case 0x011F: return "WM_MENUSELECT";
4595 case 0x0120: return "WM_MENUCHAR";
4596 case 0x0121: return "WM_ENTERIDLE";
4597 case 0x0200: return "WM_MOUSEMOVE";
4598 case 0x0201: return "WM_LBUTTONDOWN";
4599 case 0x0202: return "WM_LBUTTONUP";
4600 case 0x0203: return "WM_LBUTTONDBLCLK";
4601 case 0x0204: return "WM_RBUTTONDOWN";
4602 case 0x0205: return "WM_RBUTTONUP";
4603 case 0x0206: return "WM_RBUTTONDBLCLK";
4604 case 0x0207: return "WM_MBUTTONDOWN";
4605 case 0x0208: return "WM_MBUTTONUP";
4606 case 0x0209: return "WM_MBUTTONDBLCLK";
4607 case 0x0210: return "WM_PARENTNOTIFY";
4608 case 0x0211: return "WM_ENTERMENULOOP";
4609 case 0x0212: return "WM_EXITMENULOOP";
4612 case 0x0213: return "WM_NEXTMENU";
4613 case 0x0214: return "WM_SIZING";
4614 case 0x0215: return "WM_CAPTURECHANGED";
4615 case 0x0216: return "WM_MOVING";
4616 case 0x0218: return "WM_POWERBROADCAST";
4617 case 0x0219: return "WM_DEVICECHANGE";
4620 case 0x0220: return "WM_MDICREATE";
4621 case 0x0221: return "WM_MDIDESTROY";
4622 case 0x0222: return "WM_MDIACTIVATE";
4623 case 0x0223: return "WM_MDIRESTORE";
4624 case 0x0224: return "WM_MDINEXT";
4625 case 0x0225: return "WM_MDIMAXIMIZE";
4626 case 0x0226: return "WM_MDITILE";
4627 case 0x0227: return "WM_MDICASCADE";
4628 case 0x0228: return "WM_MDIICONARRANGE";
4629 case 0x0229: return "WM_MDIGETACTIVE";
4630 case 0x0230: return "WM_MDISETMENU";
4631 case 0x0233: return "WM_DROPFILES";
4634 case 0x0281: return "WM_IME_SETCONTEXT";
4635 case 0x0282: return "WM_IME_NOTIFY";
4636 case 0x0283: return "WM_IME_CONTROL";
4637 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4638 case 0x0285: return "WM_IME_SELECT";
4639 case 0x0286: return "WM_IME_CHAR";
4640 case 0x0290: return "WM_IME_KEYDOWN";
4641 case 0x0291: return "WM_IME_KEYUP";
4644 case 0x0300: return "WM_CUT";
4645 case 0x0301: return "WM_COPY";
4646 case 0x0302: return "WM_PASTE";
4647 case 0x0303: return "WM_CLEAR";
4648 case 0x0304: return "WM_UNDO";
4649 case 0x0305: return "WM_RENDERFORMAT";
4650 case 0x0306: return "WM_RENDERALLFORMATS";
4651 case 0x0307: return "WM_DESTROYCLIPBOARD";
4652 case 0x0308: return "WM_DRAWCLIPBOARD";
4653 case 0x0309: return "WM_PAINTCLIPBOARD";
4654 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4655 case 0x030B: return "WM_SIZECLIPBOARD";
4656 case 0x030C: return "WM_ASKCBFORMATNAME";
4657 case 0x030D: return "WM_CHANGECBCHAIN";
4658 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4659 case 0x030F: return "WM_QUERYNEWPALETTE";
4660 case 0x0310: return "WM_PALETTEISCHANGING";
4661 case 0x0311: return "WM_PALETTECHANGED";
4664 // common controls messages - although they're not strictly speaking
4665 // standard, it's nice to decode them nevertheless
4668 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4669 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4670 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4671 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4672 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4673 case 0x1000 + 5: return "LVM_GETITEMA";
4674 case 0x1000 + 75: return "LVM_GETITEMW";
4675 case 0x1000 + 6: return "LVM_SETITEMA";
4676 case 0x1000 + 76: return "LVM_SETITEMW";
4677 case 0x1000 + 7: return "LVM_INSERTITEMA";
4678 case 0x1000 + 77: return "LVM_INSERTITEMW";
4679 case 0x1000 + 8: return "LVM_DELETEITEM";
4680 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4681 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4682 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4683 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4684 case 0x1000 + 13: return "LVM_FINDITEMA";
4685 case 0x1000 + 83: return "LVM_FINDITEMW";
4686 case 0x1000 + 14: return "LVM_GETITEMRECT";
4687 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4688 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4689 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4690 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4691 case 0x1000 + 18: return "LVM_HITTEST";
4692 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4693 case 0x1000 + 20: return "LVM_SCROLL";
4694 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4695 case 0x1000 + 22: return "LVM_ARRANGE";
4696 case 0x1000 + 23: return "LVM_EDITLABELA";
4697 case 0x1000 + 118: return "LVM_EDITLABELW";
4698 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4699 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4700 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4701 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4702 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4703 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4704 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4705 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4706 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4707 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4708 case 0x1000 + 31: return "LVM_GETHEADER";
4709 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4710 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4711 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4712 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4713 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4714 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4715 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4716 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4717 case 0x1000 + 41: return "LVM_GETORIGIN";
4718 case 0x1000 + 42: return "LVM_UPDATE";
4719 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4720 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4721 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4722 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4723 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4724 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4725 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4726 case 0x1000 + 48: return "LVM_SORTITEMS";
4727 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4728 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4729 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4730 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4731 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4732 case 0x1000 + 53: return "LVM_SETICONSPACING";
4733 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4734 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4735 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4736 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4737 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4738 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4739 case 0x1000 + 60: return "LVM_SETHOTITEM";
4740 case 0x1000 + 61: return "LVM_GETHOTITEM";
4741 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4742 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4743 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4744 case 0x1000 + 65: return "LVM_SETWORKAREA";
4747 case 0x1100 + 0: return "TVM_INSERTITEMA";
4748 case 0x1100 + 50: return "TVM_INSERTITEMW";
4749 case 0x1100 + 1: return "TVM_DELETEITEM";
4750 case 0x1100 + 2: return "TVM_EXPAND";
4751 case 0x1100 + 4: return "TVM_GETITEMRECT";
4752 case 0x1100 + 5: return "TVM_GETCOUNT";
4753 case 0x1100 + 6: return "TVM_GETINDENT";
4754 case 0x1100 + 7: return "TVM_SETINDENT";
4755 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4756 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4757 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4758 case 0x1100 + 11: return "TVM_SELECTITEM";
4759 case 0x1100 + 12: return "TVM_GETITEMA";
4760 case 0x1100 + 62: return "TVM_GETITEMW";
4761 case 0x1100 + 13: return "TVM_SETITEMA";
4762 case 0x1100 + 63: return "TVM_SETITEMW";
4763 case 0x1100 + 14: return "TVM_EDITLABELA";
4764 case 0x1100 + 65: return "TVM_EDITLABELW";
4765 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4766 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4767 case 0x1100 + 17: return "TVM_HITTEST";
4768 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4769 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4770 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4771 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4772 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4773 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4774 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4775 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4776 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4779 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4780 case 0x1200 + 1: return "HDM_INSERTITEMA";
4781 case 0x1200 + 10: return "HDM_INSERTITEMW";
4782 case 0x1200 + 2: return "HDM_DELETEITEM";
4783 case 0x1200 + 3: return "HDM_GETITEMA";
4784 case 0x1200 + 11: return "HDM_GETITEMW";
4785 case 0x1200 + 4: return "HDM_SETITEMA";
4786 case 0x1200 + 12: return "HDM_SETITEMW";
4787 case 0x1200 + 5: return "HDM_LAYOUT";
4788 case 0x1200 + 6: return "HDM_HITTEST";
4789 case 0x1200 + 7: return "HDM_GETITEMRECT";
4790 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4791 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4792 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4793 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4794 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4795 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4796 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4799 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4800 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4801 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4802 case 0x1300 + 5: return "TCM_GETITEMA";
4803 case 0x1300 + 60: return "TCM_GETITEMW";
4804 case 0x1300 + 6: return "TCM_SETITEMA";
4805 case 0x1300 + 61: return "TCM_SETITEMW";
4806 case 0x1300 + 7: return "TCM_INSERTITEMA";
4807 case 0x1300 + 62: return "TCM_INSERTITEMW";
4808 case 0x1300 + 8: return "TCM_DELETEITEM";
4809 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4810 case 0x1300 + 10: return "TCM_GETITEMRECT";
4811 case 0x1300 + 11: return "TCM_GETCURSEL";
4812 case 0x1300 + 12: return "TCM_SETCURSEL";
4813 case 0x1300 + 13: return "TCM_HITTEST";
4814 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4815 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4816 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4817 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4818 case 0x1300 + 43: return "TCM_SETPADDING";
4819 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4820 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4821 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4822 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4823 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4824 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4825 case 0x1300 + 50: return "TCM_DESELECTALL";
4828 case WM_USER
+1: return "TB_ENABLEBUTTON";
4829 case WM_USER
+2: return "TB_CHECKBUTTON";
4830 case WM_USER
+3: return "TB_PRESSBUTTON";
4831 case WM_USER
+4: return "TB_HIDEBUTTON";
4832 case WM_USER
+5: return "TB_INDETERMINATE";
4833 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4834 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4835 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4836 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4837 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4838 case WM_USER
+17: return "TB_SETSTATE";
4839 case WM_USER
+18: return "TB_GETSTATE";
4840 case WM_USER
+19: return "TB_ADDBITMAP";
4841 case WM_USER
+20: return "TB_ADDBUTTONS";
4842 case WM_USER
+21: return "TB_INSERTBUTTON";
4843 case WM_USER
+22: return "TB_DELETEBUTTON";
4844 case WM_USER
+23: return "TB_GETBUTTON";
4845 case WM_USER
+24: return "TB_BUTTONCOUNT";
4846 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4847 case WM_USER
+26: return "TB_SAVERESTOREA";
4848 case WM_USER
+76: return "TB_SAVERESTOREW";
4849 case WM_USER
+27: return "TB_CUSTOMIZE";
4850 case WM_USER
+28: return "TB_ADDSTRINGA";
4851 case WM_USER
+77: return "TB_ADDSTRINGW";
4852 case WM_USER
+29: return "TB_GETITEMRECT";
4853 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4854 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4855 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4856 case WM_USER
+33: return "TB_AUTOSIZE";
4857 case WM_USER
+35: return "TB_GETTOOLTIPS";
4858 case WM_USER
+36: return "TB_SETTOOLTIPS";
4859 case WM_USER
+37: return "TB_SETPARENT";
4860 case WM_USER
+39: return "TB_SETROWS";
4861 case WM_USER
+40: return "TB_GETROWS";
4862 case WM_USER
+42: return "TB_SETCMDID";
4863 case WM_USER
+43: return "TB_CHANGEBITMAP";
4864 case WM_USER
+44: return "TB_GETBITMAP";
4865 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4866 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4867 case WM_USER
+46: return "TB_REPLACEBITMAP";
4868 case WM_USER
+47: return "TB_SETINDENT";
4869 case WM_USER
+48: return "TB_SETIMAGELIST";
4870 case WM_USER
+49: return "TB_GETIMAGELIST";
4871 case WM_USER
+50: return "TB_LOADIMAGES";
4872 case WM_USER
+51: return "TB_GETRECT";
4873 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4874 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4875 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4876 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4877 case WM_USER
+56: return "TB_SETSTYLE";
4878 case WM_USER
+57: return "TB_GETSTYLE";
4879 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4880 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4881 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4882 case WM_USER
+61: return "TB_GETTEXTROWS";
4883 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4888 static char s_szBuf
[128];
4889 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4893 #endif //__WXDEBUG__