1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/dcclient.h"
32 #include "wx/layout.h"
33 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/settings.h"
37 #include "wx/msgdlg.h"
41 #include "wx/ownerdrw.h"
44 #if wxUSE_DRAG_AND_DROP
45 #include "wx/msw/ole/droptgt.h"
48 #include "wx/menuitem.h"
50 #include "wx/msw/private.h"
64 #include <wx/msw/gnuwin32/extra.h>
84 const char *wxGetMessageName(int message
);
87 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
89 wxMenu
*wxCurrentPopupMenu
= NULL
;
90 extern wxList wxPendingDelete
;
92 void wxRemoveHandleAssociation(wxWindow
*win
);
93 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
94 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
96 #if !USE_SHARED_LIBRARY
97 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
99 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
100 EVT_CHAR(wxWindow::OnChar
)
101 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
102 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
103 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
104 EVT_IDLE(wxWindow::OnIdle
)
109 // Find an item given the MS Windows id
110 wxWindow
*wxWindow::FindItem(int id
) const
114 wxNode
*current
= GetChildren()->First();
117 wxWindow
*childWin
= (wxWindow
*)current
->Data();
119 wxWindow
*wnd
= childWin
->FindItem(id
) ;
123 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
125 wxControl
*item
= (wxControl
*)childWin
;
126 if (item
->m_windowId
== id
)
130 // In case it's a 'virtual' control (e.g. radiobox)
131 if (item
->GetSubcontrols().Member((wxObject
*)id
))
135 current
= current
->Next();
140 // Find an item given the MS Windows handle
141 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
145 wxNode
*current
= GetChildren()->First();
148 wxObject
*obj
= (wxObject
*)current
->Data() ;
149 // Do a recursive search.
150 wxWindow
*parent
= (wxWindow
*)obj
;
151 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
155 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
157 wxWindow
*item
= (wxWindow
*)current
->Data();
158 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
162 if ( item
->ContainsHWND(hWnd
) )
166 current
= current
->Next();
171 // Default command handler
172 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
177 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
), WXLPARAM
WXUNUSED(lParam
))
182 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
186 WXHWND
wxWindow::GetHWND(void) const
188 return (WXHWND
) m_hWnd
;
191 void wxWindow::SetHWND(WXHWND hWnd
)
197 wxWindow::wxWindow(void)
203 m_windowParent
= NULL
;
204 m_windowEventHandler
= this;
206 m_windowCursor
= *wxSTANDARD_CURSOR
;
207 m_children
= new wxList
;
208 m_doubleClickAllowed
= 0 ;
209 m_winCaptured
= FALSE
;
210 m_constraints
= NULL
;
211 m_constraintsInvolvedIn
= NULL
;
212 m_windowSizer
= NULL
;
213 m_sizerParent
= NULL
;
214 m_autoLayout
= FALSE
;
215 m_windowValidator
= NULL
;
220 m_caretWidth
= 0; m_caretHeight
= 0;
221 m_caretEnabled
= FALSE
;
222 m_caretShown
= FALSE
;
230 m_isBeingDeleted
= FALSE
;
237 m_defaultItem
= NULL
;
239 wxSystemSettings settings
;
241 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
242 // m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
243 m_foregroundColour
= *wxBLACK
;
246 wxColour(GetRValue(GetSysColor(COLOR_WINDOW)),
247 GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
254 // m_acceleratorTable = 0;
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
;
272 wxWindow::~wxWindow(void)
274 m_isBeingDeleted
= TRUE
;
276 // JACS - if behaviour is odd, restore this
277 // to the start of ~wxWindow. Vadim has changed
278 // it to nearer the end. Unsure of side-effects
279 // e.g. when deleting associated global data.
280 // Restore old Window proc, if required
283 // Have to delete constraints/sizer FIRST otherwise
284 // sizers may try to look at deleted windows as they
285 // delete themselves.
286 #if wxUSE_CONSTRAINTS
287 DeleteRelatedConstraints();
290 // This removes any dangling pointers to this window
291 // in other windows' constraintsInvolvedIn lists.
292 UnsetConstraints(m_constraints
);
293 delete m_constraints
;
294 m_constraints
= NULL
;
298 delete m_windowSizer
;
299 m_windowSizer
= NULL
;
301 // If this is a child of a sizer, remove self from parent
303 m_sizerParent
->RemoveChild((wxWindow
*)this);
307 MSWDetachWindowMenu();
310 m_windowParent
->RemoveChild(this);
315 ::DestroyWindow((HWND
)m_hWnd
);
317 wxRemoveHandleAssociation(this);
322 GlobalFree((HGLOBAL
) m_globalHandle
);
330 // Just in case the window has been Closed, but
331 // we're then deleting immediately: don't leave
332 // dangling pointers.
333 wxPendingDelete
.DeleteObject(this);
335 // Just in case we've loaded a top-level window via
336 // wxWindow::LoadNativeDialog but we weren't a dialog
338 wxTopLevelWindows
.DeleteObject(this);
340 if ( m_windowValidator
)
341 delete m_windowValidator
;
343 // Restore old Window proc, if required
344 // and remove hWnd <-> wxWindow association
348 // Destroy the window (delayed, if a managed window)
349 bool wxWindow::Destroy(void)
355 extern char wxCanvasClassName
[];
358 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
362 const wxString
& name
)
365 m_isBeingDeleted
= FALSE
;
369 m_windowParent
= NULL
;
370 m_windowEventHandler
= this;
372 m_windowCursor
= *wxSTANDARD_CURSOR
;
373 m_doubleClickAllowed
= 0 ;
374 m_winCaptured
= FALSE
;
375 m_constraints
= NULL
;
376 m_constraintsInvolvedIn
= NULL
;
377 m_windowSizer
= NULL
;
378 m_sizerParent
= NULL
;
379 m_autoLayout
= FALSE
;
380 m_windowValidator
= NULL
;
381 #if wxUSE_DRAG_AND_DROP
382 m_pDropTarget
= NULL
;
388 m_caretWidth
= 0; m_caretHeight
= 0;
389 m_caretEnabled
= FALSE
;
390 m_caretShown
= FALSE
;
401 m_defaultItem
= NULL
;
402 m_windowParent
= NULL
;
403 m_mouseInWindow
= FALSE
;
407 if (parent
) parent
->AddChild(this);
417 m_backgroundTransparent
= FALSE
;
419 m_lastXPos
= (float)-1.0;
420 m_lastYPos
= (float)-1.0;
427 m_windowId
= (int)NewControlId();
436 // To be consistent with wxGTK
442 wxSystemSettings settings
;
444 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
) ; ;
445 // m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ;
446 m_foregroundColour
= *wxBLACK
;
448 m_windowStyle
= style
;
451 if (style
& wxBORDER
)
452 msflags
|= WS_BORDER
;
453 if (style
& wxTHICK_FRAME
)
454 msflags
|= WS_THICKFRAME
;
456 msflags
|= WS_CHILD
| WS_VISIBLE
;
457 if (style
& wxCLIP_CHILDREN
)
458 msflags
|= WS_CLIPCHILDREN
;
461 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
463 // Even with extended styles, need to combine with WS_BORDER
464 // for them to look right.
465 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
466 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
467 msflags
|= WS_BORDER
;
469 m_mouseInWindow
= FALSE
;
471 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
472 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
477 void wxWindow::SetFocus(void)
479 HWND hWnd
= (HWND
) GetHWND();
484 void wxWindow::Enable(bool enable
)
486 m_winEnabled
= enable
;
487 HWND hWnd
= (HWND
) GetHWND();
489 ::EnableWindow(hWnd
, (BOOL
)enable
);
492 void wxWindow::CaptureMouse(void)
494 HWND hWnd
= (HWND
) GetHWND();
495 if (hWnd
&& !m_winCaptured
)
498 m_winCaptured
= TRUE
;
502 void wxWindow::ReleaseMouse(void)
507 m_winCaptured
= FALSE
;
511 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
513 m_acceleratorTable
= accel
;
517 // Push/pop event handler (i.e. allow a chain of event handlers
519 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
521 handler
->SetNextHandler(GetEventHandler());
522 SetEventHandler(handler
);
525 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
527 if ( GetEventHandler() )
529 wxEvtHandler
*handlerA
= GetEventHandler();
530 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
531 handlerA
->SetNextHandler(NULL
);
532 SetEventHandler(handlerB
);
545 #if wxUSE_DRAG_AND_DROP
547 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
549 if ( m_pDropTarget
!= 0 ) {
550 m_pDropTarget
->Revoke(m_hWnd
);
551 delete m_pDropTarget
;
554 m_pDropTarget
= pDropTarget
;
555 if ( m_pDropTarget
!= 0 )
556 m_pDropTarget
->Register(m_hWnd
);
561 //old style file-manager drag&drop support
562 // I think we should retain the old-style
563 // DragAcceptFiles in parallel with SetDropTarget.
565 void wxWindow::DragAcceptFiles(bool accept
)
567 HWND hWnd
= (HWND
) GetHWND();
569 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
573 void wxWindow::GetSize(int *x
, int *y
) const
575 HWND hWnd
= (HWND
) GetHWND();
577 GetWindowRect(hWnd
, &rect
);
578 *x
= rect
.right
- rect
.left
;
579 *y
= rect
.bottom
- rect
.top
;
582 void wxWindow::GetPosition(int *x
, int *y
) const
584 HWND hWnd
= (HWND
) GetHWND();
587 hParentWnd
= (HWND
) GetParent()->GetHWND();
590 GetWindowRect(hWnd
, &rect
);
592 // Since we now have the absolute screen coords,
593 // if there's a parent we must subtract its top left corner
599 ::ScreenToClient(hParentWnd
, &point
);
602 // We may be faking the client origin.
603 // So a window that's really at (0, 30) may appear
604 // (to wxWin apps) to be at (0, 0).
607 wxPoint
pt(GetParent()->GetClientAreaOrigin());
615 void wxWindow::ScreenToClient(int *x
, int *y
) const
617 HWND hWnd
= (HWND
) GetHWND();
621 ::ScreenToClient(hWnd
, &pt
);
624 // We may be faking the client origin.
625 // So a window that's really at (0, 30) may appear
626 // (to wxWin apps) to be at (0, 0).
629 wxPoint pt1(GetParent()->GetClientAreaOrigin());
639 void wxWindow::ClientToScreen(int *x
, int *y
) const
641 HWND hWnd
= (HWND
) GetHWND();
647 // We may be faking the client origin.
648 // So a window that's really at (0, 30) may appear
649 // (to wxWin apps) to be at (0, 0).
652 wxPoint pt1(GetParent()->GetClientAreaOrigin());
658 ::ClientToScreen(hWnd
, &pt
);
664 void wxWindow::SetCursor(const wxCursor
& cursor
)
666 m_windowCursor
= cursor
;
667 if (m_windowCursor
.Ok())
669 HWND hWnd
= (HWND
) GetHWND();
671 // Change the cursor NOW if we're within the correct window
673 ::GetCursorPos(&point
);
676 ::GetWindowRect(hWnd
, &rect
);
678 if (::PtInRect(&rect
, point
) && !wxIsBusy())
679 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
682 // This will cause big reentrancy problems if wxFlushEvents is implemented.
684 // return old_cursor;
688 // Get size *available for subwindows* i.e. excluding menu bar etc.
689 void wxWindow::GetClientSize(int *x
, int *y
) const
691 HWND hWnd
= (HWND
) GetHWND();
693 GetClientRect(hWnd
, &rect
);
698 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
700 int currentX
, currentY
;
701 GetPosition(¤tX
, ¤tY
);
702 int actualWidth
= width
;
703 int actualHeight
= height
;
706 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
708 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
711 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
713 int currentW
,currentH
;
714 GetSize(¤tW
, ¤tH
);
716 actualWidth
= currentW
;
718 actualHeight
= currentH
;
720 HWND hWnd
= (HWND
) GetHWND();
722 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
725 void wxWindow::SetClientSize(int width
, int height
)
727 wxWindow
*parent
= GetParent();
728 HWND hWnd
= (HWND
) GetHWND();
729 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
732 GetClientRect(hWnd
, &rect
);
735 GetWindowRect(hWnd
, &rect2
);
737 // Find the difference between the entire window (title bar and all)
738 // and the client area; add this to the new client size to move the
740 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
741 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
743 // If there's a parent, must subtract the parent's top left corner
744 // since MoveWindow moves relative to the parent
747 point
.x
= rect2
.left
;
751 ::ScreenToClient(hParentWnd
, &point
);
754 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
756 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
757 event
.SetEventObject(this);
758 GetEventHandler()->ProcessEvent(event
);
761 // For implementation purposes - sometimes decorations make the client area
763 wxPoint
wxWindow::GetClientAreaOrigin() const
765 return wxPoint(0, 0);
768 // Makes an adjustment to the window position (for example, a frame that has
769 // a toolbar that it manages itself).
770 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
772 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
774 wxPoint
pt(GetParent()->GetClientAreaOrigin());
775 x
+= pt
.x
; y
+= pt
.y
;
779 bool wxWindow::Show(bool show
)
781 HWND hWnd
= (HWND
) GetHWND();
787 ShowWindow(hWnd
, (BOOL
)cshow
);
790 BringWindowToTop(hWnd
);
791 // Next line causes a crash on NT, apparently.
792 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
797 bool wxWindow::IsShown(void) const
799 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
802 int wxWindow::GetCharHeight(void) const
804 TEXTMETRIC lpTextMetric
;
805 HWND hWnd
= (HWND
) GetHWND();
806 HDC dc
= ::GetDC(hWnd
);
808 GetTextMetrics(dc
, &lpTextMetric
);
809 ::ReleaseDC(hWnd
, dc
);
811 return lpTextMetric
.tmHeight
;
814 int wxWindow::GetCharWidth(void) const
816 TEXTMETRIC lpTextMetric
;
817 HWND hWnd
= (HWND
) GetHWND();
818 HDC dc
= ::GetDC(hWnd
);
820 GetTextMetrics(dc
, &lpTextMetric
);
821 ::ReleaseDC(hWnd
, dc
);
823 return lpTextMetric
.tmAveCharWidth
;
826 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
827 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
829 wxFont
*fontToUse
= (wxFont
*)theFont
;
831 fontToUse
= (wxFont
*) & m_windowFont
;
833 HWND hWnd
= (HWND
) GetHWND();
834 HDC dc
= ::GetDC(hWnd
);
838 if (fontToUse
&& fontToUse
->Ok())
840 if ((fnt
=(HFONT
) fontToUse
->GetResourceHandle()))
841 was
= (HFONT
) SelectObject(dc
,fnt
) ;
846 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
847 GetTextMetrics(dc
, &tm
);
849 if (fontToUse
&& fnt
&& was
)
850 SelectObject(dc
,was
) ;
856 if (descent
) *descent
= tm
.tmDescent
;
857 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
860 // fontToUse->ReleaseResource();
863 void wxWindow::Refresh(bool eraseBack
, const wxRectangle
*rect
)
865 HWND hWnd
= (HWND
) GetHWND();
871 mswRect
.left
= rect
->x
;
872 mswRect
.top
= rect
->y
;
873 mswRect
.right
= rect
->x
+ rect
->width
;
874 mswRect
.bottom
= rect
->y
+ rect
->height
;
876 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
879 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
883 bool wxWindow::ProcessEvent(wxEvent
& event
)
885 // we save here the information about the last message because it might be
886 // overwritten if the event handler sends any messages to our window (case
887 // in point: wxNotebook::OnSize) - and then if we call Default() later
888 // (which is done quite often if the message is not processed) it will use
889 // incorrect values for m_lastXXX variables
890 WXUINT lastMsg
= m_lastMsg
;
891 WXWPARAM lastWParam
= m_lastWParam
;
892 WXLPARAM lastLParam
= m_lastLParam
;
894 // call the base version
895 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
899 m_lastWParam
= lastWParam
;
900 m_lastLParam
= lastLParam
;
905 // Hook for new window just as it's being created,
906 // when the window isn't yet associated with the handle
907 wxWindow
*wxWndHook
= NULL
;
910 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
912 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
914 if (!wnd
&& wxWndHook
)
916 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
919 wnd
->m_hWnd
= (WXHWND
) hWnd
;
922 wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd
, m_hWnd
, message
);
924 // Stop right here if we don't have a valid handle
925 // in our wxWnd object.
926 if (wnd
&& !wnd
->m_hWnd
) {
927 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
928 wnd
->m_hWnd
= (WXHWND
) hWnd
;
929 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
935 wnd
->m_lastMsg
= message
;
936 wnd
->m_lastWParam
= wParam
;
937 wnd
->m_lastLParam
= lParam
;
940 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
942 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
945 // Should probably have a test for 'genuine' NT
946 #if defined(__WIN32__)
947 #define DIMENSION_TYPE short
949 #define DIMENSION_TYPE int
952 // Main Windows 3 window proc
953 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
955 wxASSERT( m_lastMsg
== message
&&
956 m_lastWParam
== wParam
&&
957 m_lastLParam
== lParam
);
960 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
961 wxGetMessageName(message
), wParam
, lParam
);
964 HWND hWnd
= (HWND
)m_hWnd
;
971 WORD state
= LOWORD(wParam
);
972 WORD minimized
= HIWORD(wParam
);
973 HWND hwnd
= (HWND
)lParam
;
975 WORD state
= (WORD
)wParam
;
976 WORD minimized
= LOWORD(lParam
);
977 HWND hwnd
= (HWND
)HIWORD(lParam
);
979 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
985 HWND hwnd
= (HWND
)wParam
;
986 // return OnSetFocus(hwnd);
988 if (MSWOnSetFocus((WXHWND
) hwnd
))
990 else return MSWDefWindowProc(message
, wParam
, lParam
);
995 HWND hwnd
= (HWND
)lParam
;
996 // return OnKillFocus(hwnd);
997 if (MSWOnKillFocus((WXHWND
) hwnd
))
1000 return MSWDefWindowProc(message
, wParam
, lParam
);
1005 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
1011 MSWOnShow((wParam
!= 0), (int) lParam
);
1018 else return MSWDefWindowProc(message
, wParam
, lParam
);
1021 case WM_QUERYDRAGICON
:
1024 if ((hIcon
= (HICON
) MSWOnQueryDragIcon()))
1026 else return MSWDefWindowProc(message
, wParam
, lParam
);
1032 int width
= LOWORD(lParam
);
1033 int height
= HIWORD(lParam
);
1034 MSWOnSize(width
, height
, wParam
);
1040 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
1042 event
.SetEventObject(this);
1043 if ( !GetEventHandler()->ProcessEvent(event
) )
1048 case WM_WINDOWPOSCHANGING
:
1050 MSWOnWindowPosChanging((void *)lParam
);
1054 case WM_RBUTTONDOWN
:
1056 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1057 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1058 MSWOnRButtonDown(x
, y
, wParam
);
1063 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1064 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1065 MSWOnRButtonUp(x
, y
, wParam
);
1068 case WM_RBUTTONDBLCLK
:
1070 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1071 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1072 MSWOnRButtonDClick(x
, y
, wParam
);
1075 case WM_MBUTTONDOWN
:
1077 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1078 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1079 MSWOnMButtonDown(x
, y
, wParam
);
1084 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1085 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1086 MSWOnMButtonUp(x
, y
, wParam
);
1089 case WM_MBUTTONDBLCLK
:
1091 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1092 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1093 MSWOnMButtonDClick(x
, y
, wParam
);
1096 case WM_LBUTTONDOWN
:
1098 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1099 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1100 MSWOnLButtonDown(x
, y
, wParam
);
1105 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1106 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1107 MSWOnLButtonUp(x
, y
, wParam
);
1110 case WM_LBUTTONDBLCLK
:
1112 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1113 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1114 MSWOnLButtonDClick(x
, y
, wParam
);
1119 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1120 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1121 MSWOnMouseMove(x
, y
, wParam
);
1124 case MM_JOY1BUTTONDOWN
:
1126 int x
= LOWORD(lParam
);
1127 int y
= HIWORD(lParam
);
1128 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1131 case MM_JOY2BUTTONDOWN
:
1133 int x
= LOWORD(lParam
);
1134 int y
= HIWORD(lParam
);
1135 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1138 case MM_JOY1BUTTONUP
:
1140 int x
= LOWORD(lParam
);
1141 int y
= HIWORD(lParam
);
1142 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1145 case MM_JOY2BUTTONUP
:
1147 int x
= LOWORD(lParam
);
1148 int y
= HIWORD(lParam
);
1149 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1154 int x
= LOWORD(lParam
);
1155 int y
= HIWORD(lParam
);
1156 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1161 int x
= LOWORD(lParam
);
1162 int y
= HIWORD(lParam
);
1163 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1168 int z
= LOWORD(lParam
);
1169 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1174 int z
= LOWORD(lParam
);
1175 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1182 else return MSWDefWindowProc(message
, wParam
, lParam
);
1187 return MSWOnSysCommand(wParam
, lParam
);
1193 WORD id
= LOWORD(wParam
);
1194 HWND hwnd
= (HWND
)lParam
;
1195 WORD cmd
= HIWORD(wParam
);
1197 WORD id
= (WORD
)wParam
;
1198 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1199 WORD cmd
= HIWORD(lParam
);
1201 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1202 return MSWDefWindowProc(message
, wParam
, lParam
);
1205 #if defined(__WIN95__)
1208 if (!MSWOnNotify(wParam
, lParam
))
1209 return MSWDefWindowProc(message
, wParam
, lParam
);
1216 WORD flags
= HIWORD(wParam
);
1217 HMENU sysmenu
= (HMENU
)lParam
;
1219 WORD flags
= LOWORD(lParam
);
1220 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1222 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1225 case WM_INITMENUPOPUP
:
1227 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1232 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1235 case WM_MEASUREITEM
:
1237 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1242 // we consider these message "not interesting"
1243 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1246 // Avoid duplicate messages to OnChar
1247 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1248 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1249 (wParam
!= VK_TAB
) )
1251 MSWOnChar((WORD
)wParam
, lParam
);
1252 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1255 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1256 MSWOnChar((WORD
)wParam
, lParam
);
1261 case WM_CHAR
: // Always an ASCII character
1263 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1270 WORD code
= LOWORD(wParam
);
1271 WORD pos
= HIWORD(wParam
);
1272 HWND control
= (HWND
)lParam
;
1274 WORD code
= (WORD
)wParam
;
1275 WORD pos
= LOWORD(lParam
);
1276 HWND control
= (HWND
)HIWORD(lParam
);
1278 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1284 WORD code
= LOWORD(wParam
);
1285 WORD pos
= HIWORD(wParam
);
1286 HWND control
= (HWND
)lParam
;
1288 WORD code
= (WORD
)wParam
;
1289 WORD pos
= LOWORD(lParam
);
1290 HWND control
= (HWND
)HIWORD(lParam
);
1292 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1296 case WM_CTLCOLORBTN
:
1298 int nCtlColor
= CTLCOLOR_BTN
;
1299 HWND control
= (HWND
)lParam
;
1300 HDC pDC
= (HDC
)wParam
;
1301 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1302 message
, wParam
, lParam
);
1305 case WM_CTLCOLORDLG
:
1307 int nCtlColor
= CTLCOLOR_DLG
;
1308 HWND control
= (HWND
)lParam
;
1309 HDC pDC
= (HDC
)wParam
;
1310 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1311 message
, wParam
, lParam
);\
1314 case WM_CTLCOLORLISTBOX
:
1316 int nCtlColor
= CTLCOLOR_LISTBOX
;
1317 HWND control
= (HWND
)lParam
;
1318 HDC pDC
= (HDC
)wParam
;
1319 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1320 message
, wParam
, lParam
);
1323 case WM_CTLCOLORMSGBOX
:
1325 int nCtlColor
= CTLCOLOR_MSGBOX
;
1326 HWND control
= (HWND
)lParam
;
1327 HDC pDC
= (HDC
)wParam
;
1328 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1329 message
, wParam
, lParam
);
1332 case WM_CTLCOLORSCROLLBAR
:
1334 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1335 HWND control
= (HWND
)lParam
;
1336 HDC pDC
= (HDC
)wParam
;
1337 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1338 message
, wParam
, lParam
);
1341 case WM_CTLCOLORSTATIC
:
1343 int nCtlColor
= CTLCOLOR_STATIC
;
1344 HWND control
= (HWND
)lParam
;
1345 HDC pDC
= (HDC
)wParam
;
1346 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1347 message
, wParam
, lParam
);
1350 case WM_CTLCOLOREDIT
:
1352 int nCtlColor
= CTLCOLOR_EDIT
;
1353 HWND control
= (HWND
)lParam
;
1354 HDC pDC
= (HDC
)wParam
;
1355 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1356 message
, wParam
, lParam
);
1362 HWND control
= (HWND
)LOWORD(lParam
);
1363 int nCtlColor
= (int)HIWORD(lParam
);
1364 HDC pDC
= (HDC
)wParam
;
1365 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1366 message
, wParam
, lParam
);
1370 case WM_SYSCOLORCHANGE
:
1372 // Return value of 0 means, we processed it.
1373 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1376 return MSWDefWindowProc(message
, wParam
, lParam
);
1379 case WM_PALETTECHANGED
:
1381 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1384 case WM_QUERYNEWPALETTE
:
1386 return MSWOnQueryNewPalette();
1391 // Prevents flicker when dragging
1392 if (IsIconic(hWnd
)) return 1;
1394 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1395 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1399 case WM_MDIACTIVATE
:
1402 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1403 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1404 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1405 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1407 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1408 (HWND
)HIWORD(lParam
));
1413 MSWOnDropFiles(wParam
);
1418 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1421 case WM_QUERYENDSESSION
:
1423 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1424 // return MSWOnClose();
1426 return MSWOnQueryEndSession(lParam
);
1431 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1432 MSWOnEndSession((wParam
!= 0), lParam
);
1445 case WM_GETMINMAXINFO
:
1447 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1448 if (m_minSizeX
!= -1)
1449 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1450 if (m_minSizeY
!= -1)
1451 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1452 if (m_maxSizeX
!= -1)
1453 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1454 if (m_maxSizeY
!= -1)
1455 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1456 return MSWDefWindowProc(message
, wParam
, lParam
);
1461 return MSWGetDlgCode();
1464 return MSWDefWindowProc(message
, wParam
, lParam
);
1466 return 0; // Success: we processed this command.
1469 // Dialog window proc
1470 LONG APIENTRY _EXPORT
1471 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1476 wxList
*wxWinHandleList
= NULL
;
1477 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1479 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1482 return (wxWindow
*)node
->Data();
1485 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1487 // adding NULL hWnd is (first) surely a result of an error and
1488 // (secondly) breaks menu command processing
1489 wxCHECK_RET( hWnd
!= NULL
, "attempt to add a NULL hWnd to window list" );
1491 if ( !wxWinHandleList
->Find((long)hWnd
) )
1492 wxWinHandleList
->Append((long)hWnd
, win
);
1495 void wxRemoveHandleAssociation(wxWindow
*win
)
1497 wxWinHandleList
->DeleteObject(win
);
1500 // Default destroyer - override if you destroy it in some other way
1501 // (e.g. with MDI child windows)
1502 void wxWindow::MSWDestroyWindow(void)
1506 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1507 int x
, int y
, int width
, int height
,
1508 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1510 bool is_dialog
= (dialog_template
!= NULL
);
1511 int x1
= CW_USEDEFAULT
;
1513 int width1
= CW_USEDEFAULT
;
1516 // Find parent's size, if it exists, to set up a possible default
1517 // panel size the size of the parent window
1521 // Was GetWindowRect: JACS 5/5/95
1522 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1524 width1
= parent_rect
.right
- parent_rect
.left
;
1525 height1
= parent_rect
.bottom
- parent_rect
.top
;
1530 if (width
> -1) width1
= width
;
1531 if (height
> -1) height1
= height
;
1533 HWND hParent
= NULL
;
1535 hParent
= (HWND
) parent
->GetHWND();
1541 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1542 // other compilers???
1543 // VZ: it's always needed for Win16 and never for Win32
1545 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1546 (DLGPROC
)wxDlgProc
);
1548 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1550 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1555 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1556 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1557 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1562 if (style
& WS_CHILD
)
1567 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1572 hParent
, (HMENU
)controlId
, wxGetInstance(),
1576 wxLogError("Can't create window of class %s!\n"
1577 "Possible Windows 3.x compatibility problem?", wclass
);
1582 wxWinHandleList
->Append((long)m_hWnd
, this);
1585 wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd
);
1589 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1593 bool wxWindow::MSWOnClose(void)
1596 wxDebugMsg("wxWindow::MSWOnClose %d\n", handle
);
1601 // Some compilers don't define this
1602 #ifndef ENDSESSION_LOGOFF
1603 #define ENDSESSION_LOGOFF 0x80000000
1606 // Return TRUE to end session, FALSE to veto end session.
1607 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1609 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1610 event
.SetEventObject(wxTheApp
);
1611 event
.SetCanVeto(TRUE
);
1612 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1613 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1614 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1616 return FALSE
; // Veto!
1620 return TRUE
; // Don't veto
1624 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1626 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1627 event
.SetEventObject(wxTheApp
);
1628 event
.SetCanVeto(FALSE
);
1629 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1630 if (endSession
&& // No need to send if the session isn't ending
1631 (this == wxTheApp
->GetTopWindow()) && // Only send once
1632 wxTheApp
->ProcessEvent(event
))
1638 bool wxWindow::MSWOnDestroy(void)
1641 wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle
);
1643 // delete our drop target if we've got one
1644 #if wxUSE_DRAG_AND_DROP
1645 if ( m_pDropTarget
!= NULL
) {
1646 m_pDropTarget
->Revoke(m_hWnd
);
1648 delete m_pDropTarget
;
1649 m_pDropTarget
= NULL
;
1656 // Deal with child commands from buttons etc.
1658 bool wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1660 #if defined(__WIN95__)
1661 // Find a child window to send the notification to, e.g. a toolbar.
1662 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1663 // handle of the toolbar; it's probably the handle of the tooltip
1664 // window (anyway, it's parent is also the toolbar's parent).
1665 // So, since we don't know which hWnd or wxWindow originated the
1666 // WM_NOTIFY, we'll need to go through all the children of this window
1667 // trying out MSWNotify.
1668 // This won't work now, though, because any number of controls
1669 // could respond to the same generic messages :-(
1671 /* This doesn't work for toolbars, but try for other controls first.
1673 NMHDR
*hdr
= (NMHDR
*)lParam
;
1674 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1675 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1678 return win
->MSWNotify(wParam
, lParam
);
1681 // Rely on MSWNotify to check whether the message
1682 // belongs to the window or not
1683 wxNode
*node
= GetChildren()->First();
1686 wxWindow
*child
= (wxWindow
*)node
->Data();
1687 if ( child
->MSWNotify(wParam
, lParam
) )
1689 node
= node
->Next();
1699 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1702 wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle
);
1706 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1710 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1713 wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle
);
1716 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1718 event
.SetEventObject(this);
1719 GetEventHandler()->ProcessEvent(event
);
1723 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1726 wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd
);
1729 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1731 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1733 ::ShowCaret((HWND
) GetHWND());
1736 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1737 event
.SetEventObject(this);
1738 if (!GetEventHandler()->ProcessEvent(event
))
1743 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1746 wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd
);
1754 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1755 event
.SetEventObject(this);
1756 if (!GetEventHandler()->ProcessEvent(event
))
1761 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1764 wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd
);
1767 HDROP hFilesInfo
= (HDROP
) wParam
;
1769 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1771 // Get the total number of files dropped
1772 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1777 wxString
*files
= new wxString
[gwFilesDropped
];
1779 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1781 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1782 files
[wIndex
] = wxBuffer
;
1784 DragFinish (hFilesInfo
);
1786 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1787 event
.m_eventObject
= this;
1788 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1790 if (!GetEventHandler()->ProcessEvent(event
))
1796 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1798 #if wxUSE_OWNER_DRAWN
1799 if ( id
== 0 ) { // is it a menu item?
1800 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1801 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1802 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1804 // prepare to call OnDrawItem()
1806 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1807 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1808 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1809 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1810 return pMenuItem
->OnDrawItem(
1812 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1813 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1816 #endif // owner-drawn menus
1818 wxWindow
*item
= FindItem(id
);
1819 #if wxUSE_DYNAMIC_CLASSES
1820 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1822 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1829 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1831 #if wxUSE_OWNER_DRAWN
1832 if ( id
== 0 ) { // is it a menu item?
1833 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1834 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1835 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1837 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1838 &pMeasureStruct
->itemHeight
);
1840 #endif // owner-drawn menus
1842 wxWindow
*item
= FindItem(id
);
1843 #if wxUSE_DYNAMIC_CLASSES
1844 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1846 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1853 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1854 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1857 wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd
);
1859 if (nCtlColor
== CTLCOLOR_DLG
)
1861 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1864 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1866 WXHBRUSH hBrush
= 0;
1869 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1871 // I think that even for dialogs, we may need to call DefWindowProc (?)
1872 // Or maybe just rely on the usual default behaviour.
1874 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1879 // Define for each class of dialog and control
1880 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1881 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1883 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1886 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1888 wxSysColourChangedEvent event
;
1889 event
.SetEventObject(this);
1891 // Check if app handles this.
1892 if (GetEventHandler()->ProcessEvent(event
))
1895 // We didn't process it
1899 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1901 wxPaletteChangedEvent
event(GetId());
1902 event
.SetEventObject(this);
1903 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1904 GetEventHandler()->ProcessEvent(event
);
1908 long wxWindow::MSWOnQueryNewPalette()
1910 wxQueryNewPaletteEvent
event(GetId());
1911 event
.SetEventObject(this);
1912 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1914 return (long) FALSE
;
1920 // Responds to colour changes: passes event on to children.
1921 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1923 wxNode
*node
= GetChildren()->First();
1926 // Only propagate to non-top-level windows
1927 wxWindow
*win
= (wxWindow
*)node
->Data();
1928 if ( win
->GetParent() )
1930 wxSysColourChangedEvent event2
;
1931 event
.m_eventObject
= win
;
1932 win
->GetEventHandler()->ProcessEvent(event2
);
1935 node
= node
->Next();
1939 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1942 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1944 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1947 long wxWindow::Default()
1949 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1954 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1955 wxGetMessageName(m_lastMsg
));
1958 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1961 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1963 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1964 // intercept dialog navigation keys
1965 MSG
*msg
= (MSG
*)pMsg
;
1966 bool bProcess
= TRUE
;
1967 if ( msg
->message
!= WM_KEYDOWN
)
1970 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1973 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1975 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1976 // (except for Ctrl-Tab combination which is always processed)
1978 if ( bProcess
&& !bCtrlDown
) {
1979 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1984 switch ( msg
->wParam
) {
1986 if ( lDlgCode
& DLGC_WANTTAB
) // this is FALSE for Ctrl-Tab
1989 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1994 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2002 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
2014 wxNavigationKeyEvent event
;
2015 event
.SetDirection(bForward
);
2016 event
.SetWindowChange(bCtrlDown
);
2017 event
.SetEventObject(this);
2019 if ( GetEventHandler()->ProcessEvent(event
) )
2023 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
2029 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
2031 if (m_acceleratorTable
.Ok() &&
2032 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
2038 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
2041 wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd
);
2046 void wxWindow::MSWDetachWindowMenu(void)
2050 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
2052 for (i
= 0; i
< N
; i
++)
2055 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
2056 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
2058 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
2065 bool wxWindow::MSWOnPaint(void)
2068 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2069 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2071 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2074 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2076 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2077 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2080 wxPaintEvent
event(m_windowId
);
2081 event
.SetEventObject(this);
2082 if (!GetEventHandler()->ProcessEvent(event
))
2087 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2093 wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd
);
2100 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2101 event
.SetEventObject(this);
2102 if (!GetEventHandler()->ProcessEvent(event
))
2108 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2113 // Deal with child commands from buttons etc.
2114 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2117 wxDebugMsg("wxWindow::MSWOnCommand\n");
2119 if (wxCurrentPopupMenu
)
2121 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2122 wxCurrentPopupMenu
= NULL
;
2123 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2128 sprintf(buf
, "Looking for item %d...\n", id
);
2132 wxWindow
*item
= FindItem(id
);
2135 bool value
= item
->MSWCommand(cmd
, id
);
2138 wxDebugMsg("MSWCommand succeeded\n");
2140 wxDebugMsg("MSWCommand failed\n");
2146 wxWindow
*win
= wxFindWinFromHandle(control
);
2148 return win
->MSWCommand(cmd
, id
);
2153 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2159 wxMaximizeEvent
event(m_windowId
);
2160 event
.SetEventObject(this);
2161 if (!GetEventHandler()->ProcessEvent(event
))
2169 wxIconizeEvent
event(m_windowId
);
2170 event
.SetEventObject(this);
2171 if (!GetEventHandler()->ProcessEvent(event
))
2183 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2185 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2187 event
.m_x
= x
; event
.m_y
= y
;
2188 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2189 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2190 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2191 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2192 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2193 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2194 event
.m_eventObject
= this;
2196 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVENT_TYPE_LEFT_DOWN
;
2198 if (!GetEventHandler()->ProcessEvent(event
))
2202 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2204 wxMouseEvent
event(wxEVT_LEFT_UP
);
2206 event
.m_x
= x
; event
.m_y
= y
;
2207 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2208 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2209 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2210 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2211 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2212 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2213 event
.m_eventObject
= this;
2215 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2217 if (!GetEventHandler()->ProcessEvent(event
))
2221 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2223 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2225 event
.m_x
= x
; event
.m_y
= y
;
2226 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2227 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2228 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2229 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2230 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2231 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2232 event
.m_eventObject
= this;
2234 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2236 if (!GetEventHandler()->ProcessEvent(event
))
2240 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2242 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2244 event
.m_x
= x
; event
.m_y
= y
;
2245 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2246 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2247 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2248 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2249 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2250 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2251 event
.m_eventObject
= this;
2253 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2255 if (!GetEventHandler()->ProcessEvent(event
))
2259 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2261 //wxDebugMsg("MButtonUp\n") ;
2262 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2264 event
.m_x
= x
; event
.m_y
= y
;
2265 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2266 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2267 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2268 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2269 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2270 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2271 event
.m_eventObject
= this;
2273 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2275 if (!GetEventHandler()->ProcessEvent(event
))
2279 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2281 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2283 event
.m_x
= x
; event
.m_y
= y
;
2284 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2285 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2286 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2287 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2288 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2289 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2290 event
.m_eventObject
= this;
2292 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2294 if (!GetEventHandler()->ProcessEvent(event
))
2298 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2300 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2302 event
.m_x
= x
; event
.m_y
= y
;
2303 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2304 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2305 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2306 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2307 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2308 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2309 event
.m_eventObject
= this;
2311 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2313 if (!GetEventHandler()->ProcessEvent(event
))
2317 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2319 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2321 event
.m_x
= x
; event
.m_y
= y
;
2322 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2323 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2324 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2325 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2326 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2327 event
.m_eventObject
= this;
2328 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2330 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2332 if (!GetEventHandler()->ProcessEvent(event
))
2336 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2338 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2340 event
.m_x
= x
; event
.m_y
= y
;
2341 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2342 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2343 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2344 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2345 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2346 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2347 event
.m_eventObject
= this;
2349 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2351 if (!GetEventHandler()->ProcessEvent(event
))
2355 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2357 // 'normal' move event...
2358 // Set cursor, but only if we're not in 'busy' mode
2360 // Trouble with this is that it sets the cursor for controls too :-(
2361 if (m_windowCursor
.Ok() && !wxIsBusy())
2362 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2364 if (!m_mouseInWindow
)
2366 // Generate an ENTER event
2367 m_mouseInWindow
= TRUE
;
2368 MSWOnMouseEnter(x
, y
, flags
);
2371 wxMouseEvent
event(wxEVT_MOTION
);
2373 event
.m_x
= x
; event
.m_y
= y
;
2374 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2375 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2376 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2377 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2378 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2379 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2380 event
.m_eventObject
= this;
2382 // Window gets a click down message followed by a mouse move
2383 // message even if position isn't changed! We want to discard
2384 // the trailing move event if x and y are the same.
2385 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2386 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2387 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2389 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2390 m_lastEvent
= wxEVT_MOTION
;
2394 m_lastEvent
= wxEVT_MOTION
;
2395 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2397 if (!GetEventHandler()->ProcessEvent(event
))
2401 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2403 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2405 event
.m_x
= x
; event
.m_y
= y
;
2406 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2407 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2408 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2409 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2410 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2411 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2412 event
.m_eventObject
= this;
2414 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2415 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2416 // No message - ensure we don't try to call the default behaviour accidentally.
2418 GetEventHandler()->ProcessEvent(event
);
2421 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2423 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2425 event
.m_x
= x
; event
.m_y
= y
;
2426 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2427 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2428 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2429 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2430 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2431 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2432 event
.m_eventObject
= this;
2434 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2435 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2436 // No message - ensure we don't try to call the default behaviour accidentally.
2438 GetEventHandler()->ProcessEvent(event
);
2441 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2444 bool tempControlDown
= FALSE
;
2447 // If 1 -> 26, translate to CTRL plus a letter.
2449 if ((id
> 0) && (id
< 27))
2470 tempControlDown
= TRUE
;
2476 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2477 // it's ASCII and will be processed here only when called from
2478 // WM_CHAR (i.e. when isASCII = TRUE)
2484 wxKeyEvent
event(wxEVT_CHAR
);
2485 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2486 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2487 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2488 event
.m_altDown
= TRUE
;
2490 event
.m_eventObject
= this;
2491 event
.m_keyCode
= id
;
2492 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2497 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2501 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2503 if (!GetEventHandler()->ProcessEvent(event
))
2508 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2512 if (flags
& JOY_BUTTON1CHG
)
2513 change
= wxJOY_BUTTON1
;
2514 if (flags
& JOY_BUTTON2CHG
)
2515 change
= wxJOY_BUTTON2
;
2516 if (flags
& JOY_BUTTON3CHG
)
2517 change
= wxJOY_BUTTON3
;
2518 if (flags
& JOY_BUTTON4CHG
)
2519 change
= wxJOY_BUTTON4
;
2521 if (flags
& JOY_BUTTON1
)
2522 buttons
|= wxJOY_BUTTON1
;
2523 if (flags
& JOY_BUTTON2
)
2524 buttons
|= wxJOY_BUTTON2
;
2525 if (flags
& JOY_BUTTON3
)
2526 buttons
|= wxJOY_BUTTON3
;
2527 if (flags
& JOY_BUTTON4
)
2528 buttons
|= wxJOY_BUTTON4
;
2530 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2531 event
.SetPosition(wxPoint(x
, y
));
2532 event
.SetEventObject(this);
2534 GetEventHandler()->ProcessEvent(event
);
2537 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2541 if (flags
& JOY_BUTTON1CHG
)
2542 change
= wxJOY_BUTTON1
;
2543 if (flags
& JOY_BUTTON2CHG
)
2544 change
= wxJOY_BUTTON2
;
2545 if (flags
& JOY_BUTTON3CHG
)
2546 change
= wxJOY_BUTTON3
;
2547 if (flags
& JOY_BUTTON4CHG
)
2548 change
= wxJOY_BUTTON4
;
2550 if (flags
& JOY_BUTTON1
)
2551 buttons
|= wxJOY_BUTTON1
;
2552 if (flags
& JOY_BUTTON2
)
2553 buttons
|= wxJOY_BUTTON2
;
2554 if (flags
& JOY_BUTTON3
)
2555 buttons
|= wxJOY_BUTTON3
;
2556 if (flags
& JOY_BUTTON4
)
2557 buttons
|= wxJOY_BUTTON4
;
2559 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2560 event
.SetPosition(wxPoint(x
, y
));
2561 event
.SetEventObject(this);
2563 GetEventHandler()->ProcessEvent(event
);
2566 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2569 if (flags
& JOY_BUTTON1
)
2570 buttons
|= wxJOY_BUTTON1
;
2571 if (flags
& JOY_BUTTON2
)
2572 buttons
|= wxJOY_BUTTON2
;
2573 if (flags
& JOY_BUTTON3
)
2574 buttons
|= wxJOY_BUTTON3
;
2575 if (flags
& JOY_BUTTON4
)
2576 buttons
|= wxJOY_BUTTON4
;
2578 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2579 event
.SetPosition(wxPoint(x
, y
));
2580 event
.SetEventObject(this);
2582 GetEventHandler()->ProcessEvent(event
);
2585 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2588 if (flags
& JOY_BUTTON1
)
2589 buttons
|= wxJOY_BUTTON1
;
2590 if (flags
& JOY_BUTTON2
)
2591 buttons
|= wxJOY_BUTTON2
;
2592 if (flags
& JOY_BUTTON3
)
2593 buttons
|= wxJOY_BUTTON3
;
2594 if (flags
& JOY_BUTTON4
)
2595 buttons
|= wxJOY_BUTTON4
;
2597 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2598 event
.SetZPosition(z
);
2599 event
.SetEventObject(this);
2601 GetEventHandler()->ProcessEvent(event
);
2604 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2608 wxWindow
*child
= wxFindWinFromHandle(control
);
2610 child
->MSWOnVScroll(wParam
, pos
, control
);
2614 wxScrollEvent event
;
2615 event
.SetPosition(pos
);
2616 event
.SetOrientation(wxVERTICAL
);
2617 event
.m_eventObject
= this;
2622 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2626 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2630 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2634 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2638 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2642 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2646 case SB_THUMBPOSITION
:
2647 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2655 if (!GetEventHandler()->ProcessEvent(event
))
2659 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2663 wxWindow
*child
= wxFindWinFromHandle(control
);
2665 child
->MSWOnHScroll(wParam
, pos
, control
);
2671 wxScrollEvent event
;
2672 event
.SetPosition(pos
);
2673 event
.SetOrientation(wxHORIZONTAL
);
2674 event
.m_eventObject
= this;
2679 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2683 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2687 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2691 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2695 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2699 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2703 case SB_THUMBPOSITION
:
2704 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2711 if ( GetEventHandler()->ProcessEvent(event
) )
2715 // call the default WM_HSCROLL handler: it's non trivial in some common
2716 // controls (up-down control for example)
2720 void wxWindow::MSWOnShow(bool show
, int status
)
2722 wxShowEvent
event(GetId(), show
);
2723 event
.m_eventObject
= this;
2724 GetEventHandler()->ProcessEvent(event
);
2727 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2729 wxInitDialogEvent
event(GetId());
2730 event
.m_eventObject
= this;
2731 GetEventHandler()->ProcessEvent(event
);
2735 void wxWindow::InitDialog(void)
2737 wxInitDialogEvent
event(GetId());
2738 event
.SetEventObject( this );
2739 GetEventHandler()->ProcessEvent(event
);
2742 // Default init dialog behaviour is to transfer data to window
2743 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2745 TransferDataToWindow();
2748 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2751 HDC dc
= ::GetDC((HWND
) wnd
);
2757 wxDebugMsg("wxGetCharSize: Selecting HFONT %X\n", fnt
);
2759 // the_font->UseResource();
2760 // the_font->RealizeResource();
2761 if ((fnt
=(HFONT
) the_font
->GetResourceHandle()))
2762 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2764 GetTextMetrics(dc
, &tm
);
2765 if (the_font
&& fnt
&& was
)
2768 wxDebugMsg("wxGetCharSize: Selecting old HFONT %X\n", was
);
2770 SelectObject(dc
,was
) ;
2772 ReleaseDC((HWND
)wnd
, dc
);
2773 *x
= tm
.tmAveCharWidth
;
2774 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2777 // the_font->ReleaseResource();
2780 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2781 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2782 int wxCharCodeMSWToWX(int keySym
)
2787 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2788 case VK_BACK
: id
= WXK_BACK
; break;
2789 case VK_TAB
: id
= WXK_TAB
; break;
2790 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2791 case VK_RETURN
: id
= WXK_RETURN
; break;
2792 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2793 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2794 case VK_MENU
: id
= WXK_MENU
; break;
2795 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2796 case VK_SPACE
: id
= WXK_SPACE
; break;
2797 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2798 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2799 case VK_NEXT
: id
= WXK_NEXT
; break;
2800 case VK_END
: id
= WXK_END
; break;
2801 case VK_HOME
: id
= WXK_HOME
; break;
2802 case VK_LEFT
: id
= WXK_LEFT
; break;
2803 case VK_UP
: id
= WXK_UP
; break;
2804 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2805 case VK_DOWN
: id
= WXK_DOWN
; break;
2806 case VK_SELECT
: id
= WXK_SELECT
; break;
2807 case VK_PRINT
: id
= WXK_PRINT
; break;
2808 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2809 case VK_INSERT
: id
= WXK_INSERT
; break;
2810 case VK_DELETE
: id
= WXK_DELETE
; break;
2811 case VK_HELP
: id
= WXK_HELP
; break;
2812 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2813 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2814 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2815 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2816 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2817 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2818 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2819 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2820 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2821 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2822 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2823 case VK_ADD
: id
= WXK_ADD
; break;
2824 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2825 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2826 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2827 case VK_F1
: id
= WXK_F1
; break;
2828 case VK_F2
: id
= WXK_F2
; break;
2829 case VK_F3
: id
= WXK_F3
; break;
2830 case VK_F4
: id
= WXK_F4
; break;
2831 case VK_F5
: id
= WXK_F5
; break;
2832 case VK_F6
: id
= WXK_F6
; break;
2833 case VK_F7
: id
= WXK_F7
; break;
2834 case VK_F8
: id
= WXK_F8
; break;
2835 case VK_F9
: id
= WXK_F9
; break;
2836 case VK_F10
: id
= WXK_F10
; break;
2837 case VK_F11
: id
= WXK_F11
; break;
2838 case VK_F12
: id
= WXK_F12
; break;
2839 case VK_F13
: id
= WXK_F13
; break;
2840 case VK_F14
: id
= WXK_F14
; break;
2841 case VK_F15
: id
= WXK_F15
; break;
2842 case VK_F16
: id
= WXK_F16
; break;
2843 case VK_F17
: id
= WXK_F17
; break;
2844 case VK_F18
: id
= WXK_F18
; break;
2845 case VK_F19
: id
= WXK_F19
; break;
2846 case VK_F20
: id
= WXK_F20
; break;
2847 case VK_F21
: id
= WXK_F21
; break;
2848 case VK_F22
: id
= WXK_F22
; break;
2849 case VK_F23
: id
= WXK_F23
; break;
2850 case VK_F24
: id
= WXK_F24
; break;
2851 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2852 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2861 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2867 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2868 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2869 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2870 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2871 case WXK_MENU
: keySym
= VK_MENU
; break;
2872 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2873 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2874 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2875 case WXK_END
: keySym
= VK_END
; break;
2876 case WXK_HOME
: keySym
= VK_HOME
; break;
2877 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2878 case WXK_UP
: keySym
= VK_UP
; break;
2879 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2880 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2881 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2882 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2883 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2884 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2885 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2886 case WXK_HELP
: keySym
= VK_HELP
; break;
2887 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2888 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2889 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2890 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2891 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2892 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2893 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2894 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2895 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2896 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2897 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2898 case WXK_ADD
: keySym
= VK_ADD
; break;
2899 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2900 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2901 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2902 case WXK_F1
: keySym
= VK_F1
; break;
2903 case WXK_F2
: keySym
= VK_F2
; break;
2904 case WXK_F3
: keySym
= VK_F3
; break;
2905 case WXK_F4
: keySym
= VK_F4
; break;
2906 case WXK_F5
: keySym
= VK_F5
; break;
2907 case WXK_F6
: keySym
= VK_F6
; break;
2908 case WXK_F7
: keySym
= VK_F7
; break;
2909 case WXK_F8
: keySym
= VK_F8
; break;
2910 case WXK_F9
: keySym
= VK_F9
; break;
2911 case WXK_F10
: keySym
= VK_F10
; break;
2912 case WXK_F11
: keySym
= VK_F11
; break;
2913 case WXK_F12
: keySym
= VK_F12
; break;
2914 case WXK_F13
: keySym
= VK_F13
; break;
2915 case WXK_F14
: keySym
= VK_F14
; break;
2916 case WXK_F15
: keySym
= VK_F15
; break;
2917 case WXK_F16
: keySym
= VK_F16
; break;
2918 case WXK_F17
: keySym
= VK_F17
; break;
2919 case WXK_F18
: keySym
= VK_F18
; break;
2920 case WXK_F19
: keySym
= VK_F19
; break;
2921 case WXK_F20
: keySym
= VK_F20
; break;
2922 case WXK_F21
: keySym
= VK_F21
; break;
2923 case WXK_F22
: keySym
= VK_F22
; break;
2924 case WXK_F23
: keySym
= VK_F23
; break;
2925 case WXK_F24
: keySym
= VK_F24
; break;
2926 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2927 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2938 // Caret manipulation
2939 void wxWindow::CreateCaret(int w
, int h
)
2943 m_caretEnabled
= TRUE
;
2946 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2951 void wxWindow::ShowCaret(bool show
)
2956 ::ShowCaret((HWND
) GetHWND());
2958 ::HideCaret((HWND
) GetHWND());
2959 m_caretShown
= show
;
2963 void wxWindow::DestroyCaret(void)
2965 m_caretEnabled
= FALSE
;
2968 void wxWindow::SetCaretPos(int x
, int y
)
2970 ::SetCaretPos(x
, y
);
2973 void wxWindow::GetCaretPos(int *x
, int *y
) const
2976 ::GetCaretPos(&point
);
2981 wxWindow
*wxGetActiveWindow(void)
2983 HWND hWnd
= GetActiveWindow();
2986 return wxFindWinFromHandle((WXHWND
) hWnd
);
2991 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2992 // in active frames and dialogs, regardless of where the focus is.
2993 static HHOOK wxTheKeyboardHook
= 0;
2994 static FARPROC wxTheKeyboardHookProc
= 0;
2995 int APIENTRY _EXPORT
2996 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2998 void wxSetKeyboardHook(bool doIt
)
3002 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
3003 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
3005 GetCurrentThreadId());
3006 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
3013 UnhookWindowsHookEx(wxTheKeyboardHook
);
3014 FreeProcInstance(wxTheKeyboardHookProc
);
3018 int APIENTRY _EXPORT
3019 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
3021 DWORD hiWord
= HIWORD(lParam
);
3022 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
3025 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
3027 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
3028 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
3029 event
.m_altDown
= TRUE
;
3031 event
.m_eventObject
= NULL
;
3032 event
.m_keyCode
= id
;
3033 /* begin Albert's fix for control and shift key 26.5 */
3034 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
3035 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3036 /* end Albert's fix for control and shift key 26.5 */
3037 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3039 wxWindow
*win
= wxGetActiveWindow();
3042 if (win
->GetEventHandler()->ProcessEvent(event
))
3047 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3052 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3055 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3063 void wxWindow::Centre(int direction
)
3065 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3067 wxWindow
*father
= (wxWindow
*)GetParent();
3071 father
->GetClientSize(&panel_width
, &panel_height
);
3072 GetSize(&width
, &height
);
3073 GetPosition(&x
, &y
);
3078 if (direction
& wxHORIZONTAL
)
3079 new_x
= (int)((panel_width
- width
)/2);
3081 if (direction
& wxVERTICAL
)
3082 new_y
= (int)((panel_height
- height
)/2);
3084 SetSize(new_x
, new_y
, -1, -1);
3089 void wxWindow::OnPaint(void)
3091 PaintSelectionHandles();
3095 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3097 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3098 // pixel coordinates, relatives to the canvas -- So, we first need to
3099 // substract origin of the window, then convert to screen position
3101 int x
= x_pos
; int y
= y_pos
;
3103 GetWindowRect ((HWND
) GetHWND(), &rect
);
3108 SetCursorPos (x
, y
);
3111 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3115 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3123 wxEraseEvent
event(m_windowId
, &dc
);
3124 event
.m_eventObject
= this;
3125 if (!GetEventHandler()->ProcessEvent(event
))
3128 dc
.SelectOldObjects(pDC
);
3134 dc
.SelectOldObjects(pDC
);
3137 dc
.SetHDC((WXHDC
) NULL
);
3141 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3144 ::GetClientRect((HWND
) GetHWND(), &rect
);
3146 HBRUSH hBrush
= ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
3147 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3149 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3150 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3151 ::DeleteObject(hBrush
);
3152 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3154 // Less efficient version (and doesn't account for scrolling)
3156 GetClientSize(& w, & h);
3157 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3158 event.GetDC()->SetBrush(brush);
3159 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3161 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3165 #if WXWIN_COMPATIBILITY
3166 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3168 #if defined(__WIN95__)
3172 // Try to adjust the range to cope with page size > 1
3173 // - a Windows API quirk
3174 int pageSize
= GetScrollPage(orient
);
3175 if ( pageSize
> 1 && range
> 0)
3177 range1
+= (pageSize
- 1);
3183 if (orient
== wxHORIZONTAL
) {
3189 info
.cbSize
= sizeof(SCROLLINFO
);
3190 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3194 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3196 HWND hWnd
= (HWND
) GetHWND();
3198 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3201 if (orient
== wxHORIZONTAL
)
3206 HWND hWnd
= (HWND
) GetHWND();
3208 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3212 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3214 #if defined(__WIN95__)
3218 if (orient
== wxHORIZONTAL
) {
3220 m_xThumbSize
= page
;
3223 m_yThumbSize
= page
;
3226 info
.cbSize
= sizeof(SCROLLINFO
);
3229 info
.fMask
= SIF_PAGE
;
3231 HWND hWnd
= (HWND
) GetHWND();
3233 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3235 if (orient
== wxHORIZONTAL
)
3236 m_xThumbSize
= page
;
3238 m_yThumbSize
= page
;
3242 int wxWindow::OldGetScrollRange(int orient
) const
3245 if (orient
== wxHORIZONTAL
)
3250 #if __WATCOMC__ && defined(__WINDOWS_386__)
3251 short minPos
, maxPos
;
3255 HWND hWnd
= (HWND
) GetHWND();
3258 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3259 #if defined(__WIN95__)
3260 // Try to adjust the range to cope with page size > 1
3261 // - a Windows API quirk
3262 int pageSize
= GetScrollPage(orient
);
3265 maxPos
-= (pageSize
- 1);
3274 int wxWindow::GetScrollPage(int orient
) const
3276 if (orient
== wxHORIZONTAL
)
3277 return m_xThumbSize
;
3279 return m_yThumbSize
;
3283 int wxWindow::GetScrollPos(int orient
) const
3286 if (orient
== wxHORIZONTAL
)
3290 HWND hWnd
= (HWND
) GetHWND();
3293 return ::GetScrollPos(hWnd
, wOrient
);
3299 // This now returns the whole range, not just the number
3300 // of positions that we can scroll.
3301 int wxWindow::GetScrollRange(int orient
) const
3304 if (orient
== wxHORIZONTAL
)
3309 #if __WATCOMC__ && defined(__WINDOWS_386__)
3310 short minPos
, maxPos
;
3314 HWND hWnd
= (HWND
) GetHWND();
3317 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3318 #if defined(__WIN95__)
3319 // Try to adjust the range to cope with page size > 1
3320 // - a Windows API quirk
3321 int pageSize
= GetScrollPage(orient
);
3324 maxPos
-= (pageSize
- 1);
3326 // October 10th: new range concept.
3336 int wxWindow::GetScrollThumb(int orient
) const
3338 if (orient
== wxHORIZONTAL
)
3339 return m_xThumbSize
;
3341 return m_yThumbSize
;
3344 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3346 #if defined(__WIN95__)
3350 if (orient
== wxHORIZONTAL
) {
3356 info
.cbSize
= sizeof(SCROLLINFO
);
3360 info
.fMask
= SIF_POS
;
3362 HWND hWnd
= (HWND
) GetHWND();
3364 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3367 if (orient
== wxHORIZONTAL
)
3372 HWND hWnd
= (HWND
) GetHWND();
3374 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3378 // New function that will replace some of the above.
3379 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3380 int range
, bool refresh
)
3383 SetScrollPage(orient, thumbVisible, FALSE);
3385 int oldRange = range - thumbVisible ;
3386 SetScrollRange(orient, oldRange, FALSE);
3388 SetScrollPos(orient, pos, refresh);
3390 #if defined(__WIN95__)
3391 int oldRange
= range
- thumbVisible
;
3393 int range1
= oldRange
;
3395 // Try to adjust the range to cope with page size > 1
3396 // - a Windows API quirk
3397 int pageSize
= thumbVisible
;
3398 if ( pageSize
> 1 && range
> 0)
3400 range1
+= (pageSize
- 1);
3406 if (orient
== wxHORIZONTAL
) {
3412 info
.cbSize
= sizeof(SCROLLINFO
);
3413 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3417 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3419 HWND hWnd
= (HWND
) GetHWND();
3421 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3424 if (orient
== wxHORIZONTAL
)
3429 HWND hWnd
= (HWND
) GetHWND();
3432 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3433 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3436 if (orient
== wxHORIZONTAL
) {
3437 m_xThumbSize
= thumbVisible
;
3439 m_yThumbSize
= thumbVisible
;
3443 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRectangle
*rect
)
3448 rect2
.left
= rect
->x
;
3449 rect2
.top
= rect
->y
;
3450 rect2
.right
= rect
->x
+ rect
->width
;
3451 rect2
.bottom
= rect
->y
+ rect
->height
;
3455 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3457 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3460 void wxWindow::SetFont(const wxFont
& font
)
3462 m_windowFont
= font
;
3464 if (!m_windowFont
.Ok())
3467 HWND hWnd
= (HWND
) GetHWND();
3470 if (m_windowFont
.GetResourceHandle())
3471 SendMessage(hWnd
, WM_SETFONT
,
3472 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3476 void wxWindow::SubclassWin(WXHWND hWnd
)
3478 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3480 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3482 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3483 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3486 void wxWindow::UnsubclassWin(void)
3488 wxRemoveHandleAssociation(this);
3490 // Restore old Window proc
3491 if ((HWND
) GetHWND())
3493 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3494 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3496 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3502 // Make a Windows extended style from the given wxWindows window style
3503 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3505 WXDWORD exStyle
= 0;
3506 if ( style
& wxTRANSPARENT_WINDOW
)
3507 exStyle
|= WS_EX_TRANSPARENT
;
3509 if ( !eliminateBorders
)
3511 if ( style
& wxSUNKEN_BORDER
)
3512 exStyle
|= WS_EX_CLIENTEDGE
;
3513 if ( style
& wxDOUBLE_BORDER
)
3514 exStyle
|= WS_EX_DLGMODALFRAME
;
3515 #if defined(__WIN95__)
3516 if ( style
& wxRAISED_BORDER
)
3517 exStyle
|= WS_EX_WINDOWEDGE
;
3518 if ( style
& wxSTATIC_BORDER
)
3519 exStyle
|= WS_EX_STATICEDGE
;
3525 // Determines whether native 3D effects or CTL3D should be used,
3526 // applying a default border style if required, and returning an extended
3527 // style to pass to CreateWindowEx.
3528 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3530 // If matches certain criteria, then assume no 3D effects
3531 // unless specifically requested (dealt with in MakeExtendedStyle)
3532 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3535 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3538 // Determine whether we should be using 3D effects or not.
3539 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3541 // 1) App can specify global 3D effects
3542 *want3D
= wxTheApp
->GetAuto3D();
3544 // 2) If the parent is being drawn with user colours, or simple border specified,
3545 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3546 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3549 // 3) Control can override this global setting by defining
3550 // a border style, e.g. wxSUNKEN_BORDER
3551 if (m_windowStyle
& wxSUNKEN_BORDER
)
3554 // 4) If it's a special border, CTL3D can't cope so we want a native border
3555 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3556 (m_windowStyle
& wxSTATIC_BORDER
) )
3559 nativeBorder
= TRUE
;
3562 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3563 // effects from extended style
3566 nativeBorder
= FALSE
;
3569 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3571 // If we want 3D, but haven't specified a border here,
3572 // apply the default border style specified.
3573 // TODO what about non-Win95 WIN32? Does it have borders?
3574 #if defined(__WIN95__) && !CTL3D
3575 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3576 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3577 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3583 void wxWindow::OnChar(wxKeyEvent
& event
)
3585 if ( event
.KeyCode() == WXK_TAB
) {
3586 // propagate the TABs to the parent - it's up to it to decide what
3588 if ( GetParent() ) {
3589 if ( GetParent()->GetEventHandler()->ProcessEvent(event
) )
3595 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3600 if ( !event
.ControlDown() )
3601 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3604 void wxWindow::OnPaint(wxPaintEvent
& event
)
3609 bool wxWindow::IsEnabled(void) const
3611 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3614 // Dialog support: override these and call
3615 // base class members to add functionality
3616 // that can't be done using validators.
3617 // NOTE: these functions assume that controls
3618 // are direct children of this window, not grandchildren
3619 // or other levels of descendant.
3621 // Transfer values to controls. If returns FALSE,
3622 // it's an application error (pops up a dialog)
3623 bool wxWindow::TransferDataToWindow(void)
3625 wxNode
*node
= GetChildren()->First();
3628 wxWindow
*child
= (wxWindow
*)node
->Data();
3629 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3630 !child
->GetValidator()->TransferToWindow() )
3632 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3636 node
= node
->Next();
3641 // Transfer values from controls. If returns FALSE,
3642 // validation failed: don't quit
3643 bool wxWindow::TransferDataFromWindow(void)
3645 wxNode
*node
= GetChildren()->First();
3648 wxWindow
*child
= (wxWindow
*)node
->Data();
3649 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3654 node
= node
->Next();
3659 bool wxWindow::Validate(void)
3661 wxNode
*node
= GetChildren()->First();
3664 wxWindow
*child
= (wxWindow
*)node
->Data();
3665 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3670 node
= node
->Next();
3675 // Get the window with the focus
3676 wxWindow
*wxWindow::FindFocus(void)
3678 HWND hWnd
= ::GetFocus();
3681 return wxFindWinFromHandle((WXHWND
) hWnd
);
3686 void wxWindow::AddChild(wxWindow
*child
)
3688 GetChildren()->Append(child
);
3689 child
->m_windowParent
= this;
3692 void wxWindow::RemoveChild(wxWindow
*child
)
3695 GetChildren()->DeleteObject(child
);
3696 child
->m_windowParent
= NULL
;
3699 void wxWindow::DestroyChildren(void)
3701 if (GetChildren()) {
3703 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
) {
3705 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3707 if ( GetChildren()->Member(child
) )
3714 void wxWindow::MakeModal(bool modal
)
3716 // Disable all other windows
3717 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3719 wxNode
*node
= wxTopLevelWindows
.First();
3722 wxWindow
*win
= (wxWindow
*)node
->Data();
3724 win
->Enable(!modal
);
3726 node
= node
->Next();
3731 // If nothing defined for this, try the parent.
3732 // E.g. we may be a button loaded from a resource, with no callback function
3734 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3736 if (GetEventHandler()->ProcessEvent(event
) )
3739 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3742 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3746 UnsetConstraints(m_constraints
);
3747 delete m_constraints
;
3752 // Make sure other windows know they're part of a 'meaningful relationship'
3753 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3754 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3755 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3756 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3757 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3758 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3759 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3760 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3761 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3762 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3763 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3764 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3765 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3766 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3767 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3768 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3772 // This removes any dangling pointers to this window
3773 // in other windows' constraintsInvolvedIn lists.
3774 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3778 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3779 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3780 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3781 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3782 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3783 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3784 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3785 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3786 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3787 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3788 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3789 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3790 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3791 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3792 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3793 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3797 // Back-pointer to other windows we're involved with, so if we delete
3798 // this window, we must delete any constraints we're involved with.
3799 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3801 if (!m_constraintsInvolvedIn
)
3802 m_constraintsInvolvedIn
= new wxList
;
3803 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3804 m_constraintsInvolvedIn
->Append(otherWin
);
3807 // REMOVE back-pointer to other windows we're involved with.
3808 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3810 if (m_constraintsInvolvedIn
)
3811 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3814 // Reset any constraints that mention this window
3815 void wxWindow::DeleteRelatedConstraints(void)
3817 if (m_constraintsInvolvedIn
)
3819 wxNode
*node
= m_constraintsInvolvedIn
->First();
3822 wxWindow
*win
= (wxWindow
*)node
->Data();
3823 wxNode
*next
= node
->Next();
3824 wxLayoutConstraints
*constr
= win
->GetConstraints();
3826 // Reset any constraints involving this window
3829 constr
->left
.ResetIfWin((wxWindow
*)this);
3830 constr
->top
.ResetIfWin((wxWindow
*)this);
3831 constr
->right
.ResetIfWin((wxWindow
*)this);
3832 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3833 constr
->width
.ResetIfWin((wxWindow
*)this);
3834 constr
->height
.ResetIfWin((wxWindow
*)this);
3835 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3836 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3841 delete m_constraintsInvolvedIn
;
3842 m_constraintsInvolvedIn
= NULL
;
3846 void wxWindow::SetSizer(wxSizer
*sizer
)
3848 m_windowSizer
= sizer
;
3850 sizer
->SetSizerParent((wxWindow
*)this);
3857 bool wxWindow::Layout(void)
3859 if (GetConstraints())
3862 GetClientSize(&w
, &h
);
3863 GetConstraints()->width
.SetValue(w
);
3864 GetConstraints()->height
.SetValue(h
);
3867 // If top level (one sizer), evaluate the sizer's constraints.
3871 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3872 GetSizer()->LayoutPhase1(&noChanges
);
3873 GetSizer()->LayoutPhase2(&noChanges
);
3874 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3879 // Otherwise, evaluate child constraints
3880 ResetConstraints(); // Mark all constraints as unevaluated
3881 DoPhase(1); // Just one phase need if no sizers involved
3883 SetConstraintSizes(); // Recursively set the real window sizes
3889 // Do a phase of evaluating constraints:
3890 // the default behaviour. wxSizers may do a similar
3891 // thing, but also impose their own 'constraints'
3892 // and order the evaluation differently.
3893 bool wxWindow::LayoutPhase1(int *noChanges
)
3895 wxLayoutConstraints
*constr
= GetConstraints();
3898 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3904 bool wxWindow::LayoutPhase2(int *noChanges
)
3914 // Do a phase of evaluating child constraints
3915 bool wxWindow::DoPhase(int phase
)
3917 int noIterations
= 0;
3918 int maxIterations
= 500;
3922 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3926 wxNode
*node
= GetChildren()->First();
3929 wxWindow
*child
= (wxWindow
*)node
->Data();
3930 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3932 wxLayoutConstraints
*constr
= child
->GetConstraints();
3935 if (succeeded
.Member(child
))
3940 int tempNoChanges
= 0;
3941 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3942 noChanges
+= tempNoChanges
;
3945 succeeded
.Append(child
);
3950 node
= node
->Next();
3957 void wxWindow::ResetConstraints(void)
3959 wxLayoutConstraints
*constr
= GetConstraints();
3962 constr
->left
.SetDone(FALSE
);
3963 constr
->top
.SetDone(FALSE
);
3964 constr
->right
.SetDone(FALSE
);
3965 constr
->bottom
.SetDone(FALSE
);
3966 constr
->width
.SetDone(FALSE
);
3967 constr
->height
.SetDone(FALSE
);
3968 constr
->centreX
.SetDone(FALSE
);
3969 constr
->centreY
.SetDone(FALSE
);
3971 wxNode
*node
= GetChildren()->First();
3974 wxWindow
*win
= (wxWindow
*)node
->Data();
3975 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3976 win
->ResetConstraints();
3977 node
= node
->Next();
3981 // Need to distinguish between setting the 'fake' size for
3982 // windows and sizers, and setting the real values.
3983 void wxWindow::SetConstraintSizes(bool recurse
)
3985 wxLayoutConstraints
*constr
= GetConstraints();
3986 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3987 constr
->width
.GetDone() && constr
->height
.GetDone())
3989 int x
= constr
->left
.GetValue();
3990 int y
= constr
->top
.GetValue();
3991 int w
= constr
->width
.GetValue();
3992 int h
= constr
->height
.GetValue();
3994 // If we don't want to resize this window, just move it...
3995 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3996 (constr
->height
.GetRelationship() != wxAsIs
))
3998 // Calls Layout() recursively. AAAGH. How can we stop that.
3999 // Simply take Layout() out of non-top level OnSizes.
4000 SizerSetSize(x
, y
, w
, h
);
4009 char *windowClass
= this->GetClassInfo()->GetClassName();
4012 if (GetName() == "")
4013 winName
= "unnamed";
4015 winName
= GetName();
4016 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
4017 if (!constr
->left
.GetDone())
4018 wxDebugMsg(" unsatisfied 'left' constraint.\n");
4019 if (!constr
->right
.GetDone())
4020 wxDebugMsg(" unsatisfied 'right' constraint.\n");
4021 if (!constr
->width
.GetDone())
4022 wxDebugMsg(" unsatisfied 'width' constraint.\n");
4023 if (!constr
->height
.GetDone())
4024 wxDebugMsg(" unsatisfied 'height' constraint.\n");
4025 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
4030 wxNode
*node
= GetChildren()->First();
4033 wxWindow
*win
= (wxWindow
*)node
->Data();
4034 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4035 win
->SetConstraintSizes();
4036 node
= node
->Next();
4041 // This assumes that all sizers are 'on' the same
4042 // window, i.e. the parent of this window.
4043 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4045 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4046 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4050 m_sizerParent
->GetPosition(&xp
, &yp
);
4051 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4056 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4060 TransformSizerToActual(&xx
, &yy
);
4061 SetSize(xx
, yy
, w
, h
);
4064 void wxWindow::SizerMove(int x
, int y
)
4068 TransformSizerToActual(&xx
, &yy
);
4072 // Only set the size/position of the constraint (if any)
4073 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4075 wxLayoutConstraints
*constr
= GetConstraints();
4080 constr
->left
.SetValue(x
);
4081 constr
->left
.SetDone(TRUE
);
4085 constr
->top
.SetValue(y
);
4086 constr
->top
.SetDone(TRUE
);
4090 constr
->width
.SetValue(w
);
4091 constr
->width
.SetDone(TRUE
);
4095 constr
->height
.SetValue(h
);
4096 constr
->height
.SetDone(TRUE
);
4101 void wxWindow::MoveConstraint(int x
, int y
)
4103 wxLayoutConstraints
*constr
= GetConstraints();
4108 constr
->left
.SetValue(x
);
4109 constr
->left
.SetDone(TRUE
);
4113 constr
->top
.SetValue(y
);
4114 constr
->top
.SetDone(TRUE
);
4119 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4121 wxLayoutConstraints
*constr
= GetConstraints();
4124 *w
= constr
->width
.GetValue();
4125 *h
= constr
->height
.GetValue();
4131 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4133 wxLayoutConstraints
*constr
= GetConstraints();
4136 *w
= constr
->width
.GetValue();
4137 *h
= constr
->height
.GetValue();
4140 GetClientSize(w
, h
);
4143 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4145 wxLayoutConstraints
*constr
= GetConstraints();
4148 *x
= constr
->left
.GetValue();
4149 *y
= constr
->top
.GetValue();
4155 bool wxWindow::Close(bool force
)
4157 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4158 event
.SetEventObject(this);
4159 event
.SetForce(force
);
4160 event
.SetCanVeto(!force
);
4162 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4165 wxObject
* wxWindow::GetChild(int number
) const
4167 // Return a pointer to the Nth object in the Panel
4170 wxNode
*node
= GetChildren()->First();
4173 node
= node
->Next() ;
4176 wxObject
*obj
= (wxObject
*)node
->Data();
4183 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4185 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4186 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4189 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4191 wxListBox *lbox = (wxListBox *)initiatingItem;
4192 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4193 event.m_commandInt = -1;
4194 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4196 event.m_commandString = copystring(lbox->GetStringSelection());
4197 event.m_commandInt = lbox->GetSelection();
4198 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4200 event.m_eventObject = lbox;
4202 lbox->ProcessCommand(event);
4204 if (event.m_commandString)
4205 delete[] event.m_commandString;
4209 wxButton *but = GetDefaultItem();
4212 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4213 event.SetEventObject(but);
4214 but->Command(event);
4219 void wxWindow::Clear(void)
4221 wxClientDC
dc(this);
4222 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4223 dc
.SetBackground(brush
);
4227 // Fits the panel around the items
4228 void wxWindow::Fit(void)
4232 wxNode
*node
= GetChildren()->First();
4235 wxWindow
*win
= (wxWindow
*)node
->Data();
4237 win
->GetPosition(&wx
, &wy
);
4238 win
->GetSize(&ww
, &wh
);
4239 if ( wx
+ ww
> maxX
)
4241 if ( wy
+ wh
> maxY
)
4244 node
= node
->Next();
4246 SetClientSize(maxX
+ 5, maxY
+ 5);
4249 void wxWindow::SetValidator(const wxValidator
& validator
)
4251 if ( m_windowValidator
)
4252 delete m_windowValidator
;
4253 m_windowValidator
= validator
.Clone();
4255 if ( m_windowValidator
)
4256 m_windowValidator
->SetWindow(this) ;
4259 // Find a window by id or name
4260 wxWindow
*wxWindow::FindWindow(long id
)
4265 wxNode
*node
= GetChildren()->First();
4268 wxWindow
*child
= (wxWindow
*)node
->Data();
4269 wxWindow
*found
= child
->FindWindow(id
);
4272 node
= node
->Next();
4277 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4279 if ( GetName() == name
)
4282 wxNode
*node
= GetChildren()->First();
4285 wxWindow
*child
= (wxWindow
*)node
->Data();
4286 wxWindow
*found
= child
->FindWindow(name
);
4289 node
= node
->Next();
4295 // Default input behaviour for a scrolling canvas should be to scroll
4296 // according to the cursor keys pressed
4297 void wxWindow::OnChar(wxKeyEvent& event)
4309 GetScrollUnitsPerPage(&x_page, &y_page);
4311 GetVirtualSize(&v_width,&v_height);
4313 ViewStart(&start_x, &start_y);
4316 y_pages = (int)(v_height/vert_units) - y_page;
4324 switch (event.keyCode)
4331 if (start_y - y_page > 0)
4332 Scroll(start_x, start_y - y_page);
4342 if ((y_page > 0) && (start_y <= y_pages-y-1))
4344 if (y_pages + y < start_y + y_page)
4345 Scroll(start_x, y_pages + y);
4347 Scroll(start_x, start_y + y_page);
4354 if ((y_page > 0) && (start_y >= 1))
4355 Scroll(start_x, start_y - 1);
4361 if ((y_page > 0) && (start_y <= y_pages-y-1))
4364 Scroll(start_x, start_y + 1);
4370 if ((x_page > 0) && (start_x >= 1))
4371 Scroll(start_x - 1, start_y);
4377 Scroll(start_x + 1, start_y);
4388 Scroll(start_x, y_pages+y);
4396 // Setup background and foreground colours correctly
4397 void wxWindow::SetupColours(void)
4400 SetBackgroundColour(GetParent()->GetBackgroundColour());
4403 void wxWindow::OnIdle(wxIdleEvent
& event
)
4405 // Check if we need to send a LEAVE event
4406 if (m_mouseInWindow
)
4409 ::GetCursorPos(&pt
);
4410 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4412 // Generate a LEAVE event
4413 m_mouseInWindow
= FALSE
;
4416 if (::GetKeyState(VK_SHIFT
) != 0)
4418 if (::GetKeyState(VK_CONTROL
) != 0)
4419 state
|= MK_CONTROL
;
4421 // Unfortunately the mouse button and keyboard state may have changed
4422 // by the time the OnIdle function is called, so 'state' may be
4425 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4431 // Raise the window to the top of the Z order
4432 void wxWindow::Raise(void)
4434 ::BringWindowToTop((HWND
) GetHWND());
4437 // Lower the window to the bottom of the Z order
4438 void wxWindow::Lower(void)
4440 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4443 long wxWindow::MSWGetDlgCode()
4445 // default: just forward to def window proc (the msg has no parameters)
4446 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4449 bool wxWindow::AcceptsFocus() const
4451 return IsShown() && IsEnabled();
4454 // Update region access
4455 wxRegion
wxWindow::GetUpdateRegion() const
4457 return m_updateRegion
;
4460 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4462 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4465 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4467 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4470 bool wxWindow::IsExposed(const wxRect
& rect
) const
4472 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4476 const char *wxGetMessageName(int message
)
4478 switch ( message
) {
4479 case 0x0000: return "WM_NULL";
4480 case 0x0001: return "WM_CREATE";
4481 case 0x0002: return "WM_DESTROY";
4482 case 0x0003: return "WM_MOVE";
4483 case 0x0005: return "WM_SIZE";
4484 case 0x0006: return "WM_ACTIVATE";
4485 case 0x0007: return "WM_SETFOCUS";
4486 case 0x0008: return "WM_KILLFOCUS";
4487 case 0x000A: return "WM_ENABLE";
4488 case 0x000B: return "WM_SETREDRAW";
4489 case 0x000C: return "WM_SETTEXT";
4490 case 0x000D: return "WM_GETTEXT";
4491 case 0x000E: return "WM_GETTEXTLENGTH";
4492 case 0x000F: return "WM_PAINT";
4493 case 0x0010: return "WM_CLOSE";
4494 case 0x0011: return "WM_QUERYENDSESSION";
4495 case 0x0012: return "WM_QUIT";
4496 case 0x0013: return "WM_QUERYOPEN";
4497 case 0x0014: return "WM_ERASEBKGND";
4498 case 0x0015: return "WM_SYSCOLORCHANGE";
4499 case 0x0016: return "WM_ENDSESSION";
4500 case 0x0017: return "WM_SYSTEMERROR";
4501 case 0x0018: return "WM_SHOWWINDOW";
4502 case 0x0019: return "WM_CTLCOLOR";
4503 case 0x001A: return "WM_WININICHANGE";
4504 case 0x001B: return "WM_DEVMODECHANGE";
4505 case 0x001C: return "WM_ACTIVATEAPP";
4506 case 0x001D: return "WM_FONTCHANGE";
4507 case 0x001E: return "WM_TIMECHANGE";
4508 case 0x001F: return "WM_CANCELMODE";
4509 case 0x0020: return "WM_SETCURSOR";
4510 case 0x0021: return "WM_MOUSEACTIVATE";
4511 case 0x0022: return "WM_CHILDACTIVATE";
4512 case 0x0023: return "WM_QUEUESYNC";
4513 case 0x0024: return "WM_GETMINMAXINFO";
4514 case 0x0026: return "WM_PAINTICON";
4515 case 0x0027: return "WM_ICONERASEBKGND";
4516 case 0x0028: return "WM_NEXTDLGCTL";
4517 case 0x002A: return "WM_SPOOLERSTATUS";
4518 case 0x002B: return "WM_DRAWITEM";
4519 case 0x002C: return "WM_MEASUREITEM";
4520 case 0x002D: return "WM_DELETEITEM";
4521 case 0x002E: return "WM_VKEYTOITEM";
4522 case 0x002F: return "WM_CHARTOITEM";
4523 case 0x0030: return "WM_SETFONT";
4524 case 0x0031: return "WM_GETFONT";
4525 case 0x0037: return "WM_QUERYDRAGICON";
4526 case 0x0039: return "WM_COMPAREITEM";
4527 case 0x0041: return "WM_COMPACTING";
4528 case 0x0044: return "WM_COMMNOTIFY";
4529 case 0x0046: return "WM_WINDOWPOSCHANGING";
4530 case 0x0047: return "WM_WINDOWPOSCHANGED";
4531 case 0x0048: return "WM_POWER";
4534 case 0x004A: return "WM_COPYDATA";
4535 case 0x004B: return "WM_CANCELJOURNAL";
4536 case 0x004E: return "WM_NOTIFY";
4537 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4538 case 0x0051: return "WM_INPUTLANGCHANGE";
4539 case 0x0052: return "WM_TCARD";
4540 case 0x0053: return "WM_HELP";
4541 case 0x0054: return "WM_USERCHANGED";
4542 case 0x0055: return "WM_NOTIFYFORMAT";
4543 case 0x007B: return "WM_CONTEXTMENU";
4544 case 0x007C: return "WM_STYLECHANGING";
4545 case 0x007D: return "WM_STYLECHANGED";
4546 case 0x007E: return "WM_DISPLAYCHANGE";
4547 case 0x007F: return "WM_GETICON";
4548 case 0x0080: return "WM_SETICON";
4551 case 0x0081: return "WM_NCCREATE";
4552 case 0x0082: return "WM_NCDESTROY";
4553 case 0x0083: return "WM_NCCALCSIZE";
4554 case 0x0084: return "WM_NCHITTEST";
4555 case 0x0085: return "WM_NCPAINT";
4556 case 0x0086: return "WM_NCACTIVATE";
4557 case 0x0087: return "WM_GETDLGCODE";
4558 case 0x00A0: return "WM_NCMOUSEMOVE";
4559 case 0x00A1: return "WM_NCLBUTTONDOWN";
4560 case 0x00A2: return "WM_NCLBUTTONUP";
4561 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4562 case 0x00A4: return "WM_NCRBUTTONDOWN";
4563 case 0x00A5: return "WM_NCRBUTTONUP";
4564 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4565 case 0x00A7: return "WM_NCMBUTTONDOWN";
4566 case 0x00A8: return "WM_NCMBUTTONUP";
4567 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4568 case 0x0100: return "WM_KEYDOWN";
4569 case 0x0101: return "WM_KEYUP";
4570 case 0x0102: return "WM_CHAR";
4571 case 0x0103: return "WM_DEADCHAR";
4572 case 0x0104: return "WM_SYSKEYDOWN";
4573 case 0x0105: return "WM_SYSKEYUP";
4574 case 0x0106: return "WM_SYSCHAR";
4575 case 0x0107: return "WM_SYSDEADCHAR";
4576 case 0x0108: return "WM_KEYLAST";
4579 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4580 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4581 case 0x010F: return "WM_IME_COMPOSITION";
4584 case 0x0110: return "WM_INITDIALOG";
4585 case 0x0111: return "WM_COMMAND";
4586 case 0x0112: return "WM_SYSCOMMAND";
4587 case 0x0113: return "WM_TIMER";
4588 case 0x0114: return "WM_HSCROLL";
4589 case 0x0115: return "WM_VSCROLL";
4590 case 0x0116: return "WM_INITMENU";
4591 case 0x0117: return "WM_INITMENUPOPUP";
4592 case 0x011F: return "WM_MENUSELECT";
4593 case 0x0120: return "WM_MENUCHAR";
4594 case 0x0121: return "WM_ENTERIDLE";
4595 case 0x0200: return "WM_MOUSEMOVE";
4596 case 0x0201: return "WM_LBUTTONDOWN";
4597 case 0x0202: return "WM_LBUTTONUP";
4598 case 0x0203: return "WM_LBUTTONDBLCLK";
4599 case 0x0204: return "WM_RBUTTONDOWN";
4600 case 0x0205: return "WM_RBUTTONUP";
4601 case 0x0206: return "WM_RBUTTONDBLCLK";
4602 case 0x0207: return "WM_MBUTTONDOWN";
4603 case 0x0208: return "WM_MBUTTONUP";
4604 case 0x0209: return "WM_MBUTTONDBLCLK";
4605 case 0x0210: return "WM_PARENTNOTIFY";
4606 case 0x0211: return "WM_ENTERMENULOOP";
4607 case 0x0212: return "WM_EXITMENULOOP";
4610 case 0x0213: return "WM_NEXTMENU";
4611 case 0x0214: return "WM_SIZING";
4612 case 0x0215: return "WM_CAPTURECHANGED";
4613 case 0x0216: return "WM_MOVING";
4614 case 0x0218: return "WM_POWERBROADCAST";
4615 case 0x0219: return "WM_DEVICECHANGE";
4618 case 0x0220: return "WM_MDICREATE";
4619 case 0x0221: return "WM_MDIDESTROY";
4620 case 0x0222: return "WM_MDIACTIVATE";
4621 case 0x0223: return "WM_MDIRESTORE";
4622 case 0x0224: return "WM_MDINEXT";
4623 case 0x0225: return "WM_MDIMAXIMIZE";
4624 case 0x0226: return "WM_MDITILE";
4625 case 0x0227: return "WM_MDICASCADE";
4626 case 0x0228: return "WM_MDIICONARRANGE";
4627 case 0x0229: return "WM_MDIGETACTIVE";
4628 case 0x0230: return "WM_MDISETMENU";
4629 case 0x0233: return "WM_DROPFILES";
4632 case 0x0281: return "WM_IME_SETCONTEXT";
4633 case 0x0282: return "WM_IME_NOTIFY";
4634 case 0x0283: return "WM_IME_CONTROL";
4635 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4636 case 0x0285: return "WM_IME_SELECT";
4637 case 0x0286: return "WM_IME_CHAR";
4638 case 0x0290: return "WM_IME_KEYDOWN";
4639 case 0x0291: return "WM_IME_KEYUP";
4642 case 0x0300: return "WM_CUT";
4643 case 0x0301: return "WM_COPY";
4644 case 0x0302: return "WM_PASTE";
4645 case 0x0303: return "WM_CLEAR";
4646 case 0x0304: return "WM_UNDO";
4647 case 0x0305: return "WM_RENDERFORMAT";
4648 case 0x0306: return "WM_RENDERALLFORMATS";
4649 case 0x0307: return "WM_DESTROYCLIPBOARD";
4650 case 0x0308: return "WM_DRAWCLIPBOARD";
4651 case 0x0309: return "WM_PAINTCLIPBOARD";
4652 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4653 case 0x030B: return "WM_SIZECLIPBOARD";
4654 case 0x030C: return "WM_ASKCBFORMATNAME";
4655 case 0x030D: return "WM_CHANGECBCHAIN";
4656 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4657 case 0x030F: return "WM_QUERYNEWPALETTE";
4658 case 0x0310: return "WM_PALETTEISCHANGING";
4659 case 0x0311: return "WM_PALETTECHANGED";
4662 // common controls messages - although they're not strictly speaking
4663 // standard, it's nice to decode them nevertheless
4666 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4667 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4668 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4669 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4670 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4671 case 0x1000 + 5: return "LVM_GETITEMA";
4672 case 0x1000 + 75: return "LVM_GETITEMW";
4673 case 0x1000 + 6: return "LVM_SETITEMA";
4674 case 0x1000 + 76: return "LVM_SETITEMW";
4675 case 0x1000 + 7: return "LVM_INSERTITEMA";
4676 case 0x1000 + 77: return "LVM_INSERTITEMW";
4677 case 0x1000 + 8: return "LVM_DELETEITEM";
4678 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4679 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4680 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4681 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4682 case 0x1000 + 13: return "LVM_FINDITEMA";
4683 case 0x1000 + 83: return "LVM_FINDITEMW";
4684 case 0x1000 + 14: return "LVM_GETITEMRECT";
4685 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4686 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4687 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4688 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4689 case 0x1000 + 18: return "LVM_HITTEST";
4690 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4691 case 0x1000 + 20: return "LVM_SCROLL";
4692 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4693 case 0x1000 + 22: return "LVM_ARRANGE";
4694 case 0x1000 + 23: return "LVM_EDITLABELA";
4695 case 0x1000 + 118: return "LVM_EDITLABELW";
4696 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4697 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4698 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4699 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4700 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4701 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4702 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4703 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4704 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4705 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4706 case 0x1000 + 31: return "LVM_GETHEADER";
4707 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4708 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4709 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4710 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4711 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4712 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4713 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4714 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4715 case 0x1000 + 41: return "LVM_GETORIGIN";
4716 case 0x1000 + 42: return "LVM_UPDATE";
4717 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4718 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4719 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4720 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4721 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4722 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4723 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4724 case 0x1000 + 48: return "LVM_SORTITEMS";
4725 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4726 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4727 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4728 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4729 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4730 case 0x1000 + 53: return "LVM_SETICONSPACING";
4731 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4732 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4733 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4734 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4735 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4736 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4737 case 0x1000 + 60: return "LVM_SETHOTITEM";
4738 case 0x1000 + 61: return "LVM_GETHOTITEM";
4739 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4740 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4741 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4742 case 0x1000 + 65: return "LVM_SETWORKAREA";
4745 case 0x1100 + 0: return "TVM_INSERTITEMA";
4746 case 0x1100 + 50: return "TVM_INSERTITEMW";
4747 case 0x1100 + 1: return "TVM_DELETEITEM";
4748 case 0x1100 + 2: return "TVM_EXPAND";
4749 case 0x1100 + 4: return "TVM_GETITEMRECT";
4750 case 0x1100 + 5: return "TVM_GETCOUNT";
4751 case 0x1100 + 6: return "TVM_GETINDENT";
4752 case 0x1100 + 7: return "TVM_SETINDENT";
4753 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4754 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4755 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4756 case 0x1100 + 11: return "TVM_SELECTITEM";
4757 case 0x1100 + 12: return "TVM_GETITEMA";
4758 case 0x1100 + 62: return "TVM_GETITEMW";
4759 case 0x1100 + 13: return "TVM_SETITEMA";
4760 case 0x1100 + 63: return "TVM_SETITEMW";
4761 case 0x1100 + 14: return "TVM_EDITLABELA";
4762 case 0x1100 + 65: return "TVM_EDITLABELW";
4763 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4764 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4765 case 0x1100 + 17: return "TVM_HITTEST";
4766 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4767 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4768 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4769 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4770 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4771 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4772 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4773 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4774 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4777 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4778 case 0x1200 + 1: return "HDM_INSERTITEMA";
4779 case 0x1200 + 10: return "HDM_INSERTITEMW";
4780 case 0x1200 + 2: return "HDM_DELETEITEM";
4781 case 0x1200 + 3: return "HDM_GETITEMA";
4782 case 0x1200 + 11: return "HDM_GETITEMW";
4783 case 0x1200 + 4: return "HDM_SETITEMA";
4784 case 0x1200 + 12: return "HDM_SETITEMW";
4785 case 0x1200 + 5: return "HDM_LAYOUT";
4786 case 0x1200 + 6: return "HDM_HITTEST";
4787 case 0x1200 + 7: return "HDM_GETITEMRECT";
4788 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4789 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4790 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4791 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4792 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4793 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4794 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4797 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4798 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4799 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4800 case 0x1300 + 5: return "TCM_GETITEMA";
4801 case 0x1300 + 60: return "TCM_GETITEMW";
4802 case 0x1300 + 6: return "TCM_SETITEMA";
4803 case 0x1300 + 61: return "TCM_SETITEMW";
4804 case 0x1300 + 7: return "TCM_INSERTITEMA";
4805 case 0x1300 + 62: return "TCM_INSERTITEMW";
4806 case 0x1300 + 8: return "TCM_DELETEITEM";
4807 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4808 case 0x1300 + 10: return "TCM_GETITEMRECT";
4809 case 0x1300 + 11: return "TCM_GETCURSEL";
4810 case 0x1300 + 12: return "TCM_SETCURSEL";
4811 case 0x1300 + 13: return "TCM_HITTEST";
4812 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4813 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4814 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4815 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4816 case 0x1300 + 43: return "TCM_SETPADDING";
4817 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4818 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4819 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4820 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4821 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4822 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4823 case 0x1300 + 50: return "TCM_DESELECTALL";
4826 case WM_USER
+1: return "TB_ENABLEBUTTON";
4827 case WM_USER
+2: return "TB_CHECKBUTTON";
4828 case WM_USER
+3: return "TB_PRESSBUTTON";
4829 case WM_USER
+4: return "TB_HIDEBUTTON";
4830 case WM_USER
+5: return "TB_INDETERMINATE";
4831 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4832 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4833 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4834 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4835 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4836 case WM_USER
+17: return "TB_SETSTATE";
4837 case WM_USER
+18: return "TB_GETSTATE";
4838 case WM_USER
+19: return "TB_ADDBITMAP";
4839 case WM_USER
+20: return "TB_ADDBUTTONS";
4840 case WM_USER
+21: return "TB_INSERTBUTTON";
4841 case WM_USER
+22: return "TB_DELETEBUTTON";
4842 case WM_USER
+23: return "TB_GETBUTTON";
4843 case WM_USER
+24: return "TB_BUTTONCOUNT";
4844 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4845 case WM_USER
+26: return "TB_SAVERESTOREA";
4846 case WM_USER
+76: return "TB_SAVERESTOREW";
4847 case WM_USER
+27: return "TB_CUSTOMIZE";
4848 case WM_USER
+28: return "TB_ADDSTRINGA";
4849 case WM_USER
+77: return "TB_ADDSTRINGW";
4850 case WM_USER
+29: return "TB_GETITEMRECT";
4851 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4852 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4853 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4854 case WM_USER
+33: return "TB_AUTOSIZE";
4855 case WM_USER
+35: return "TB_GETTOOLTIPS";
4856 case WM_USER
+36: return "TB_SETTOOLTIPS";
4857 case WM_USER
+37: return "TB_SETPARENT";
4858 case WM_USER
+39: return "TB_SETROWS";
4859 case WM_USER
+40: return "TB_GETROWS";
4860 case WM_USER
+42: return "TB_SETCMDID";
4861 case WM_USER
+43: return "TB_CHANGEBITMAP";
4862 case WM_USER
+44: return "TB_GETBITMAP";
4863 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4864 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4865 case WM_USER
+46: return "TB_REPLACEBITMAP";
4866 case WM_USER
+47: return "TB_SETINDENT";
4867 case WM_USER
+48: return "TB_SETIMAGELIST";
4868 case WM_USER
+49: return "TB_GETIMAGELIST";
4869 case WM_USER
+50: return "TB_LOADIMAGES";
4870 case WM_USER
+51: return "TB_GETRECT";
4871 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4872 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4873 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4874 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4875 case WM_USER
+56: return "TB_SETSTYLE";
4876 case WM_USER
+57: return "TB_GETSTYLE";
4877 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4878 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4879 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4880 case WM_USER
+61: return "TB_GETTEXTROWS";
4881 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4886 static char s_szBuf
[128];
4887 sprintf(s_szBuf
, "<unknown message = %d>", message
);