1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/dcclient.h"
32 #include "wx/layout.h"
33 #include "wx/dialog.h"
34 #include "wx/listbox.h"
35 #include "wx/button.h"
36 #include "wx/settings.h"
37 #include "wx/msgdlg.h"
41 #include "wx/ownerdrw.h"
45 #include "wx/msw/ole/droptgt.h"
48 #include "wx/menuitem.h"
50 #include "wx/msw/private.h"
64 #include <wx/msw/gnuwin32/extra.h>
84 const char *wxGetMessageName(int message
);
87 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
89 wxMenu
*wxCurrentPopupMenu
= NULL
;
90 extern wxList wxPendingDelete
;
92 void wxRemoveHandleAssociation(wxWindow
*win
);
93 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
94 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
96 #if !USE_SHARED_LIBRARY
97 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
99 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
100 EVT_CHAR(wxWindow::OnChar
)
101 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
102 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
103 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
104 EVT_IDLE(wxWindow::OnIdle
)
109 // Find an item given the MS Windows id
110 wxWindow
*wxWindow::FindItem(int id
) const
114 wxNode
*current
= GetChildren()->First();
117 wxWindow
*childWin
= (wxWindow
*)current
->Data();
119 wxWindow
*wnd
= childWin
->FindItem(id
) ;
123 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
125 wxControl
*item
= (wxControl
*)childWin
;
126 if (item
->m_windowId
== id
)
130 // In case it's a 'virtual' control (e.g. radiobox)
131 if (item
->GetSubcontrols().Member((wxObject
*)id
))
135 current
= current
->Next();
140 // Find an item given the MS Windows handle
141 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
145 wxNode
*current
= GetChildren()->First();
148 wxObject
*obj
= (wxObject
*)current
->Data() ;
149 // Do a recursive search.
150 wxWindow
*parent
= (wxWindow
*)obj
;
151 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
155 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
157 wxWindow
*item
= (wxWindow
*)current
->Data();
158 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
162 if ( item
->ContainsHWND(hWnd
) )
166 current
= current
->Next();
171 // Default command handler
172 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
177 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
), WXLPARAM
WXUNUSED(lParam
))
182 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
186 WXHWND
wxWindow::GetHWND(void) const
188 return (WXHWND
) m_hWnd
;
191 void wxWindow::SetHWND(WXHWND hWnd
)
197 wxWindow::wxWindow(void)
203 m_windowParent
= NULL
;
204 m_windowEventHandler
= this;
206 m_windowCursor
= *wxSTANDARD_CURSOR
;
207 m_children
= new wxList
;
208 m_doubleClickAllowed
= 0 ;
209 m_winCaptured
= FALSE
;
210 m_constraints
= NULL
;
211 m_constraintsInvolvedIn
= NULL
;
212 m_windowSizer
= NULL
;
213 m_sizerParent
= NULL
;
214 m_autoLayout
= FALSE
;
215 m_windowValidator
= NULL
;
220 m_caretWidth
= 0; m_caretHeight
= 0;
221 m_caretEnabled
= FALSE
;
222 m_caretShown
= FALSE
;
230 m_isBeingDeleted
= FALSE
;
237 m_defaultItem
= NULL
;
239 wxSystemSettings settings
;
241 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
) ; ;
242 m_foregroundColour
= *wxBLACK
;
243 m_defaultForegroundColour
= *wxBLACK
;
244 m_defaultBackgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
247 wxColour(GetRValue(GetSysColor(COLOR_WINDOW)),
248 GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
255 // m_acceleratorTable = 0;
260 m_backgroundTransparent
= FALSE
;
262 m_lastXPos
= (float)-1.0;
263 m_lastYPos
= (float)-1.0;
267 #if USE_DRAG_AND_DROP
268 m_pDropTarget
= NULL
;
273 wxWindow::~wxWindow(void)
275 m_isBeingDeleted
= TRUE
;
277 // JACS - if behaviour is odd, restore this
278 // to the start of ~wxWindow. Vadim has changed
279 // it to nearer the end. Unsure of side-effects
280 // e.g. when deleting associated global data.
281 // Restore old Window proc, if required
284 // Have to delete constraints/sizer FIRST otherwise
285 // sizers may try to look at deleted windows as they
286 // delete themselves.
288 DeleteRelatedConstraints();
291 // This removes any dangling pointers to this window
292 // in other windows' constraintsInvolvedIn lists.
293 UnsetConstraints(m_constraints
);
294 delete m_constraints
;
295 m_constraints
= NULL
;
299 delete m_windowSizer
;
300 m_windowSizer
= NULL
;
302 // If this is a child of a sizer, remove self from parent
304 m_sizerParent
->RemoveChild((wxWindow
*)this);
308 MSWDetachWindowMenu();
311 m_windowParent
->RemoveChild(this);
316 ::DestroyWindow((HWND
)m_hWnd
);
318 wxRemoveHandleAssociation(this);
323 GlobalFree((HGLOBAL
) m_globalHandle
);
331 // Just in case the window has been Closed, but
332 // we're then deleting immediately: don't leave
333 // dangling pointers.
334 wxPendingDelete
.DeleteObject(this);
336 // Just in case we've loaded a top-level window via
337 // wxWindow::LoadNativeDialog but we weren't a dialog
339 wxTopLevelWindows
.DeleteObject(this);
341 if ( m_windowValidator
)
342 delete m_windowValidator
;
344 // Restore old Window proc, if required
345 // and remove hWnd <-> wxWindow association
349 // Destroy the window (delayed, if a managed window)
350 bool wxWindow::Destroy(void)
356 extern char wxCanvasClassName
[];
359 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
363 const wxString
& name
)
366 m_isBeingDeleted
= FALSE
;
370 m_windowParent
= NULL
;
371 m_windowEventHandler
= this;
373 m_windowCursor
= *wxSTANDARD_CURSOR
;
374 m_doubleClickAllowed
= 0 ;
375 m_winCaptured
= FALSE
;
376 m_constraints
= NULL
;
377 m_constraintsInvolvedIn
= NULL
;
378 m_windowSizer
= NULL
;
379 m_sizerParent
= NULL
;
380 m_autoLayout
= FALSE
;
381 m_windowValidator
= NULL
;
382 #if USE_DRAG_AND_DROP
383 m_pDropTarget
= NULL
;
389 m_caretWidth
= 0; m_caretHeight
= 0;
390 m_caretEnabled
= FALSE
;
391 m_caretShown
= FALSE
;
402 m_defaultItem
= NULL
;
403 m_windowParent
= NULL
;
404 m_mouseInWindow
= FALSE
;
408 if (parent
) parent
->AddChild(this);
418 m_backgroundTransparent
= FALSE
;
420 m_lastXPos
= (float)-1.0;
421 m_lastYPos
= (float)-1.0;
428 m_windowId
= (int)NewControlId();
437 wxSystemSettings settings
;
439 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
) ; ;
440 m_foregroundColour
= *wxBLACK
;
441 m_defaultForegroundColour
= *wxBLACK
;
442 m_defaultBackgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
444 m_windowStyle
= style
;
447 if (style
& wxBORDER
)
448 msflags
|= WS_BORDER
;
449 if (style
& wxTHICK_FRAME
)
450 msflags
|= WS_THICKFRAME
;
452 msflags
|= WS_CHILD
| WS_VISIBLE
;
453 if (style
& wxCLIP_CHILDREN
)
454 msflags
|= WS_CLIPCHILDREN
;
457 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
459 // Even with extended styles, need to combine with WS_BORDER
460 // for them to look right.
461 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
462 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
463 msflags
|= WS_BORDER
;
465 m_mouseInWindow
= FALSE
;
467 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
468 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
473 void wxWindow::SetFocus(void)
475 HWND hWnd
= (HWND
) GetHWND();
480 void wxWindow::Enable(bool enable
)
482 m_winEnabled
= enable
;
483 HWND hWnd
= (HWND
) GetHWND();
485 ::EnableWindow(hWnd
, (BOOL
)enable
);
488 void wxWindow::CaptureMouse(void)
490 HWND hWnd
= (HWND
) GetHWND();
491 if (hWnd
&& !m_winCaptured
)
494 m_winCaptured
= TRUE
;
498 void wxWindow::ReleaseMouse(void)
503 m_winCaptured
= FALSE
;
507 // Push/pop event handler (i.e. allow a chain of event handlers
509 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
511 handler
->SetNextHandler(GetEventHandler());
512 SetEventHandler(handler
);
515 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
517 if ( GetEventHandler() )
519 wxEvtHandler
*handlerA
= GetEventHandler();
520 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
521 handlerA
->SetNextHandler(NULL
);
522 SetEventHandler(handlerB
);
535 #if USE_DRAG_AND_DROP
537 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
539 if ( m_pDropTarget
!= 0 ) {
540 m_pDropTarget
->Revoke(m_hWnd
);
541 delete m_pDropTarget
;
544 m_pDropTarget
= pDropTarget
;
545 if ( m_pDropTarget
!= 0 )
546 m_pDropTarget
->Register(m_hWnd
);
551 //old style file-manager drag&drop support
552 // I think we should retain the old-style
553 // DragAcceptFiles in parallel with SetDropTarget.
555 void wxWindow::DragAcceptFiles(bool accept
)
557 HWND hWnd
= (HWND
) GetHWND();
559 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
563 void wxWindow::GetSize(int *x
, int *y
) const
565 HWND hWnd
= (HWND
) GetHWND();
567 GetWindowRect(hWnd
, &rect
);
568 *x
= rect
.right
- rect
.left
;
569 *y
= rect
.bottom
- rect
.top
;
572 void wxWindow::GetPosition(int *x
, int *y
) const
574 HWND hWnd
= (HWND
) GetHWND();
577 hParentWnd
= (HWND
) GetParent()->GetHWND();
580 GetWindowRect(hWnd
, &rect
);
582 // Since we now have the absolute screen coords,
583 // if there's a parent we must subtract its top left corner
589 ::ScreenToClient(hParentWnd
, &point
);
592 // We may be faking the client origin.
593 // So a window that's really at (0, 30) may appear
594 // (to wxWin apps) to be at (0, 0).
597 wxPoint
pt(GetParent()->GetClientAreaOrigin());
605 void wxWindow::ScreenToClient(int *x
, int *y
) const
607 HWND hWnd
= (HWND
) GetHWND();
611 ::ScreenToClient(hWnd
, &pt
);
614 // We may be faking the client origin.
615 // So a window that's really at (0, 30) may appear
616 // (to wxWin apps) to be at (0, 0).
619 wxPoint pt1(GetParent()->GetClientAreaOrigin());
629 void wxWindow::ClientToScreen(int *x
, int *y
) const
631 HWND hWnd
= (HWND
) GetHWND();
637 // We may be faking the client origin.
638 // So a window that's really at (0, 30) may appear
639 // (to wxWin apps) to be at (0, 0).
642 wxPoint pt1(GetParent()->GetClientAreaOrigin());
648 ::ClientToScreen(hWnd
, &pt
);
654 void wxWindow::SetCursor(const wxCursor
& cursor
)
656 m_windowCursor
= cursor
;
657 if (m_windowCursor
.Ok())
659 HWND hWnd
= (HWND
) GetHWND();
661 // Change the cursor NOW if we're within the correct window
663 ::GetCursorPos(&point
);
666 ::GetWindowRect(hWnd
, &rect
);
668 if (::PtInRect(&rect
, point
) && !wxIsBusy())
669 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
672 // This will cause big reentrancy problems if wxFlushEvents is implemented.
674 // return old_cursor;
678 // Get size *available for subwindows* i.e. excluding menu bar etc.
679 void wxWindow::GetClientSize(int *x
, int *y
) const
681 HWND hWnd
= (HWND
) GetHWND();
683 GetClientRect(hWnd
, &rect
);
688 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
690 int currentX
, currentY
;
691 GetPosition(¤tX
, ¤tY
);
692 int actualWidth
= width
;
693 int actualHeight
= height
;
696 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
698 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
701 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
703 int currentW
,currentH
;
704 GetSize(¤tW
, ¤tH
);
706 actualWidth
= currentW
;
708 actualHeight
= currentH
;
710 HWND hWnd
= (HWND
) GetHWND();
712 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
715 void wxWindow::SetClientSize(int width
, int height
)
717 wxWindow
*parent
= GetParent();
718 HWND hWnd
= (HWND
) GetHWND();
719 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
722 GetClientRect(hWnd
, &rect
);
725 GetWindowRect(hWnd
, &rect2
);
727 // Find the difference between the entire window (title bar and all)
728 // and the client area; add this to the new client size to move the
730 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
731 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
733 // If there's a parent, must subtract the parent's top left corner
734 // since MoveWindow moves relative to the parent
737 point
.x
= rect2
.left
;
741 ::ScreenToClient(hParentWnd
, &point
);
744 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
746 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
747 event
.SetEventObject(this);
748 GetEventHandler()->ProcessEvent(event
);
751 // For implementation purposes - sometimes decorations make the client area
753 wxPoint
wxWindow::GetClientAreaOrigin() const
755 return wxPoint(0, 0);
758 // Makes an adjustment to the window position (for example, a frame that has
759 // a toolbar that it manages itself).
760 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
762 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
764 wxPoint
pt(GetParent()->GetClientAreaOrigin());
765 x
+= pt
.x
; y
+= pt
.y
;
769 bool wxWindow::Show(bool show
)
771 HWND hWnd
= (HWND
) GetHWND();
777 ShowWindow(hWnd
, (BOOL
)cshow
);
780 BringWindowToTop(hWnd
);
781 // Next line causes a crash on NT, apparently.
782 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
787 bool wxWindow::IsShown(void) const
789 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
792 int wxWindow::GetCharHeight(void) const
794 TEXTMETRIC lpTextMetric
;
795 HWND hWnd
= (HWND
) GetHWND();
796 HDC dc
= ::GetDC(hWnd
);
798 GetTextMetrics(dc
, &lpTextMetric
);
799 ::ReleaseDC(hWnd
, dc
);
801 return lpTextMetric
.tmHeight
;
804 int wxWindow::GetCharWidth(void) const
806 TEXTMETRIC lpTextMetric
;
807 HWND hWnd
= (HWND
) GetHWND();
808 HDC dc
= ::GetDC(hWnd
);
810 GetTextMetrics(dc
, &lpTextMetric
);
811 ::ReleaseDC(hWnd
, dc
);
813 return lpTextMetric
.tmAveCharWidth
;
816 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
817 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
819 wxFont
*fontToUse
= (wxFont
*)theFont
;
821 fontToUse
= (wxFont
*) & m_windowFont
;
823 HWND hWnd
= (HWND
) GetHWND();
824 HDC dc
= ::GetDC(hWnd
);
828 if (fontToUse
&& fontToUse
->Ok())
830 if ((fnt
=(HFONT
) fontToUse
->GetResourceHandle()))
831 was
= (HFONT
) SelectObject(dc
,fnt
) ;
836 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
837 GetTextMetrics(dc
, &tm
);
839 if (fontToUse
&& fnt
&& was
)
840 SelectObject(dc
,was
) ;
846 if (descent
) *descent
= tm
.tmDescent
;
847 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
850 // fontToUse->ReleaseResource();
853 void wxWindow::Refresh(bool eraseBack
, const wxRectangle
*rect
)
855 HWND hWnd
= (HWND
) GetHWND();
861 mswRect
.left
= rect
->x
;
862 mswRect
.top
= rect
->y
;
863 mswRect
.right
= rect
->x
+ rect
->width
;
864 mswRect
.bottom
= rect
->y
+ rect
->height
;
866 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
869 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
873 bool wxWindow::ProcessEvent(wxEvent
& event
)
875 // we save here the information about the last message because it might be
876 // overwritten if the event handler sends any messages to our window (case
877 // in point: wxNotebook::OnSize) - and then if we call Default() later
878 // (which is done quite often if the message is not processed) it will use
879 // incorrect values for m_lastXXX variables
880 WXUINT lastMsg
= m_lastMsg
;
881 WXWPARAM lastWParam
= m_lastWParam
;
882 WXLPARAM lastLParam
= m_lastLParam
;
884 // call the base version
885 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
889 m_lastWParam
= lastWParam
;
890 m_lastLParam
= lastLParam
;
895 // Hook for new window just as it's being created,
896 // when the window isn't yet associated with the handle
897 wxWindow
*wxWndHook
= NULL
;
900 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
902 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
904 if (!wnd
&& wxWndHook
)
906 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
909 wnd
->m_hWnd
= (WXHWND
) hWnd
;
912 wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd
, m_hWnd
, message
);
914 // Stop right here if we don't have a valid handle
915 // in our wxWnd object.
916 if (wnd
&& !wnd
->m_hWnd
) {
917 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
918 wnd
->m_hWnd
= (WXHWND
) hWnd
;
919 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
925 wnd
->m_lastMsg
= message
;
926 wnd
->m_lastWParam
= wParam
;
927 wnd
->m_lastLParam
= lParam
;
930 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
932 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
935 // Should probably have a test for 'genuine' NT
936 #if defined(__WIN32__)
937 #define DIMENSION_TYPE short
939 #define DIMENSION_TYPE int
942 // Main Windows 3 window proc
943 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
945 wxASSERT( m_lastMsg
== message
&&
946 m_lastWParam
== wParam
&&
947 m_lastLParam
== lParam
);
950 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
951 wxGetMessageName(message
), wParam
, lParam
);
954 HWND hWnd
= (HWND
)m_hWnd
;
961 WORD state
= LOWORD(wParam
);
962 WORD minimized
= HIWORD(wParam
);
963 HWND hwnd
= (HWND
)lParam
;
965 WORD state
= (WORD
)wParam
;
966 WORD minimized
= LOWORD(lParam
);
967 HWND hwnd
= (HWND
)HIWORD(lParam
);
969 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
975 HWND hwnd
= (HWND
)wParam
;
976 // return OnSetFocus(hwnd);
978 if (MSWOnSetFocus((WXHWND
) hwnd
))
980 else return MSWDefWindowProc(message
, wParam
, lParam
);
985 HWND hwnd
= (HWND
)lParam
;
986 // return OnKillFocus(hwnd);
987 if (MSWOnKillFocus((WXHWND
) hwnd
))
990 return MSWDefWindowProc(message
, wParam
, lParam
);
995 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
1001 MSWOnShow((wParam
!= 0), (int) lParam
);
1008 else return MSWDefWindowProc(message
, wParam
, lParam
);
1011 case WM_QUERYDRAGICON
:
1014 if ((hIcon
= (HICON
) MSWOnQueryDragIcon()))
1016 else return MSWDefWindowProc(message
, wParam
, lParam
);
1022 int width
= LOWORD(lParam
);
1023 int height
= HIWORD(lParam
);
1024 MSWOnSize(width
, height
, wParam
);
1028 case WM_WINDOWPOSCHANGING
:
1030 WINDOWPOS
*pos
= (WINDOWPOS
*)lParam
;
1031 MSWOnWindowPosChanging((void *)pos
);
1035 case WM_RBUTTONDOWN
:
1037 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1038 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1039 MSWOnRButtonDown(x
, y
, wParam
);
1044 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1045 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1046 MSWOnRButtonUp(x
, y
, wParam
);
1049 case WM_RBUTTONDBLCLK
:
1051 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1052 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1053 MSWOnRButtonDClick(x
, y
, wParam
);
1056 case WM_MBUTTONDOWN
:
1058 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1059 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1060 MSWOnMButtonDown(x
, y
, wParam
);
1065 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1066 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1067 MSWOnMButtonUp(x
, y
, wParam
);
1070 case WM_MBUTTONDBLCLK
:
1072 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1073 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1074 MSWOnMButtonDClick(x
, y
, wParam
);
1077 case WM_LBUTTONDOWN
:
1079 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1080 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1081 MSWOnLButtonDown(x
, y
, wParam
);
1086 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1087 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1088 MSWOnLButtonUp(x
, y
, wParam
);
1091 case WM_LBUTTONDBLCLK
:
1093 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1094 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1095 MSWOnLButtonDClick(x
, y
, wParam
);
1100 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1101 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1102 MSWOnMouseMove(x
, y
, wParam
);
1105 case MM_JOY1BUTTONDOWN
:
1107 int x
= LOWORD(lParam
);
1108 int y
= HIWORD(lParam
);
1109 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1112 case MM_JOY2BUTTONDOWN
:
1114 int x
= LOWORD(lParam
);
1115 int y
= HIWORD(lParam
);
1116 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1119 case MM_JOY1BUTTONUP
:
1121 int x
= LOWORD(lParam
);
1122 int y
= HIWORD(lParam
);
1123 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1126 case MM_JOY2BUTTONUP
:
1128 int x
= LOWORD(lParam
);
1129 int y
= HIWORD(lParam
);
1130 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1135 int x
= LOWORD(lParam
);
1136 int y
= HIWORD(lParam
);
1137 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1142 int x
= LOWORD(lParam
);
1143 int y
= HIWORD(lParam
);
1144 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1149 int z
= LOWORD(lParam
);
1150 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1155 int z
= LOWORD(lParam
);
1156 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1163 else return MSWDefWindowProc(message
, wParam
, lParam
);
1168 return MSWOnSysCommand(wParam
, lParam
);
1174 WORD id
= LOWORD(wParam
);
1175 HWND hwnd
= (HWND
)lParam
;
1176 WORD cmd
= HIWORD(wParam
);
1178 WORD id
= (WORD
)wParam
;
1179 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1180 WORD cmd
= HIWORD(lParam
);
1182 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1183 return MSWDefWindowProc(message
, wParam
, lParam
);
1186 #if defined(__WIN95__)
1189 if (!MSWOnNotify(wParam
, lParam
))
1190 return MSWDefWindowProc(message
, wParam
, lParam
);
1197 WORD flags
= HIWORD(wParam
);
1198 HMENU sysmenu
= (HMENU
)lParam
;
1200 WORD flags
= LOWORD(lParam
);
1201 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1203 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1206 case WM_INITMENUPOPUP
:
1208 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1213 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1216 case WM_MEASUREITEM
:
1218 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1223 // we consider these message "not interesting"
1224 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1227 // Avoid duplicate messages to OnChar
1228 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1229 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1230 (wParam
!= VK_TAB
) )
1232 MSWOnChar((WORD
)wParam
, lParam
);
1233 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1236 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1237 MSWOnChar((WORD
)wParam
, lParam
);
1242 case WM_CHAR
: // Always an ASCII character
1244 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1251 WORD code
= LOWORD(wParam
);
1252 WORD pos
= HIWORD(wParam
);
1253 HWND control
= (HWND
)lParam
;
1255 WORD code
= (WORD
)wParam
;
1256 WORD pos
= LOWORD(lParam
);
1257 HWND control
= (HWND
)HIWORD(lParam
);
1259 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1265 WORD code
= LOWORD(wParam
);
1266 WORD pos
= HIWORD(wParam
);
1267 HWND control
= (HWND
)lParam
;
1269 WORD code
= (WORD
)wParam
;
1270 WORD pos
= LOWORD(lParam
);
1271 HWND control
= (HWND
)HIWORD(lParam
);
1273 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1277 case WM_CTLCOLORBTN
:
1279 int nCtlColor
= CTLCOLOR_BTN
;
1280 HWND control
= (HWND
)lParam
;
1281 HDC pDC
= (HDC
)wParam
;
1282 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1283 message
, wParam
, lParam
);
1286 case WM_CTLCOLORDLG
:
1288 int nCtlColor
= CTLCOLOR_DLG
;
1289 HWND control
= (HWND
)lParam
;
1290 HDC pDC
= (HDC
)wParam
;
1291 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1292 message
, wParam
, lParam
);\
1295 case WM_CTLCOLORLISTBOX
:
1297 int nCtlColor
= CTLCOLOR_LISTBOX
;
1298 HWND control
= (HWND
)lParam
;
1299 HDC pDC
= (HDC
)wParam
;
1300 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1301 message
, wParam
, lParam
);
1304 case WM_CTLCOLORMSGBOX
:
1306 int nCtlColor
= CTLCOLOR_MSGBOX
;
1307 HWND control
= (HWND
)lParam
;
1308 HDC pDC
= (HDC
)wParam
;
1309 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1310 message
, wParam
, lParam
);
1313 case WM_CTLCOLORSCROLLBAR
:
1315 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1316 HWND control
= (HWND
)lParam
;
1317 HDC pDC
= (HDC
)wParam
;
1318 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1319 message
, wParam
, lParam
);
1322 case WM_CTLCOLORSTATIC
:
1324 int nCtlColor
= CTLCOLOR_STATIC
;
1325 HWND control
= (HWND
)lParam
;
1326 HDC pDC
= (HDC
)wParam
;
1327 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1328 message
, wParam
, lParam
);
1331 case WM_CTLCOLOREDIT
:
1333 int nCtlColor
= CTLCOLOR_EDIT
;
1334 HWND control
= (HWND
)lParam
;
1335 HDC pDC
= (HDC
)wParam
;
1336 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1337 message
, wParam
, lParam
);
1343 HWND control
= (HWND
)LOWORD(lParam
);
1344 int nCtlColor
= (int)HIWORD(lParam
);
1345 HDC pDC
= (HDC
)wParam
;
1346 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1347 message
, wParam
, lParam
);
1351 case WM_SYSCOLORCHANGE
:
1353 // Return value of 0 means, we processed it.
1354 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1357 return MSWDefWindowProc(message
, wParam
, lParam
);
1360 case WM_PALETTECHANGED
:
1362 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1365 case WM_QUERYNEWPALETTE
:
1367 return MSWOnQueryNewPalette();
1372 // Prevents flicker when dragging
1373 if (IsIconic(hWnd
)) return 1;
1375 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1376 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1380 case WM_MDIACTIVATE
:
1383 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1384 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1385 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1386 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1388 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1389 (HWND
)HIWORD(lParam
));
1394 MSWOnDropFiles(wParam
);
1399 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1402 case WM_QUERYENDSESSION
:
1404 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1405 return MSWOnClose();
1417 case WM_GETMINMAXINFO
:
1419 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1420 if (m_minSizeX
!= -1)
1421 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1422 if (m_minSizeY
!= -1)
1423 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1424 if (m_maxSizeX
!= -1)
1425 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1426 if (m_maxSizeY
!= -1)
1427 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1428 return MSWDefWindowProc(message
, wParam
, lParam
);
1433 return MSWGetDlgCode();
1436 return MSWDefWindowProc(message
, wParam
, lParam
);
1438 return 0; // Success: we processed this command.
1441 // Dialog window proc
1442 LONG APIENTRY _EXPORT
1443 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1448 wxList
*wxWinHandleList
= NULL
;
1449 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1451 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1454 return (wxWindow
*)node
->Data();
1457 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1459 // adding NULL hWnd is (first) surely a result of an error and
1460 // (secondly) breaks menu command processing
1461 wxCHECK_RET( hWnd
!= NULL
, "attempt to add a NULL hWnd to window list" );
1463 if ( !wxWinHandleList
->Find((long)hWnd
) )
1464 wxWinHandleList
->Append((long)hWnd
, win
);
1467 void wxRemoveHandleAssociation(wxWindow
*win
)
1469 wxWinHandleList
->DeleteObject(win
);
1472 // Default destroyer - override if you destroy it in some other way
1473 // (e.g. with MDI child windows)
1474 void wxWindow::MSWDestroyWindow(void)
1478 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1479 int x
, int y
, int width
, int height
,
1480 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1482 bool is_dialog
= (dialog_template
!= NULL
);
1483 int x1
= CW_USEDEFAULT
;
1485 int width1
= CW_USEDEFAULT
;
1488 // Find parent's size, if it exists, to set up a possible default
1489 // panel size the size of the parent window
1493 // Was GetWindowRect: JACS 5/5/95
1494 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1496 width1
= parent_rect
.right
- parent_rect
.left
;
1497 height1
= parent_rect
.bottom
- parent_rect
.top
;
1502 if (width
> -1) width1
= width
;
1503 if (height
> -1) height1
= height
;
1505 HWND hParent
= NULL
;
1507 hParent
= (HWND
) parent
->GetHWND();
1513 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1514 // other compilers???
1515 // VZ: it's always needed for Win16 and never for Win32
1517 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1518 (DLGPROC
)wxDlgProc
);
1520 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1522 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1527 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1528 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1529 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1534 if (style
& WS_CHILD
)
1539 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1544 hParent
, (HMENU
)controlId
, wxGetInstance(),
1548 wxLogError("Can't create window of class %s!\n"
1549 "Possible Windows 3.x compatibility problem?", wclass
);
1554 wxWinHandleList
->Append((long)m_hWnd
, this);
1557 wxDebugMsg("wxWindow::MSWCreate %d\n", m_hWnd
);
1561 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1565 bool wxWindow::MSWOnClose(void)
1568 wxDebugMsg("wxWindow::MSWOnClose %d\n", handle
);
1573 bool wxWindow::MSWOnDestroy(void)
1576 wxDebugMsg("wxWindow::MSWOnDestroy %d\n", handle
);
1578 // delete our drop target if we've got one
1579 #if USE_DRAG_AND_DROP
1580 if ( m_pDropTarget
!= NULL
) {
1581 m_pDropTarget
->Revoke(m_hWnd
);
1583 delete m_pDropTarget
;
1584 m_pDropTarget
= NULL
;
1591 // Deal with child commands from buttons etc.
1593 bool wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1595 #if defined(__WIN95__)
1596 // Find a child window to send the notification to, e.g. a toolbar.
1597 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1598 // handle of the toolbar; it's probably the handle of the tooltip
1599 // window (anyway, it's parent is also the toolbar's parent).
1600 // So, since we don't know which hWnd or wxWindow originated the
1601 // WM_NOTIFY, we'll need to go through all the children of this window
1602 // trying out MSWNotify.
1603 // This won't work now, though, because any number of controls
1604 // could respond to the same generic messages :-(
1606 /* This doesn't work for toolbars, but try for other controls first.
1608 NMHDR
*hdr
= (NMHDR
*)lParam
;
1609 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1610 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1613 return win
->MSWNotify(wParam
, lParam
);
1616 // Rely on MSWNotify to check whether the message
1617 // belongs to the window or not
1618 wxNode
*node
= GetChildren()->First();
1621 wxWindow
*child
= (wxWindow
*)node
->Data();
1622 if ( child
->MSWNotify(wParam
, lParam
) )
1624 node
= node
->Next();
1634 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1637 wxDebugMsg("wxWindow::MSWOnMenuHighlight %d\n", handle
);
1641 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1645 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
1648 wxDebugMsg("wxWindow::MSWOnActivate %d\n", handle
);
1651 wxActivateEvent
event(wxEVT_ACTIVATE
, ((state
== WA_ACTIVE
) || (state
== WA_CLICKACTIVE
)),
1653 event
.SetEventObject(this);
1654 GetEventHandler()->ProcessEvent(event
);
1658 bool wxWindow::MSWOnSetFocus(WXHWND
WXUNUSED(hwnd
))
1661 wxDebugMsg("wxWindow::MSWOnSetFocus %d\n", m_hWnd
);
1664 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1666 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1668 ::ShowCaret((HWND
) GetHWND());
1671 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1672 event
.SetEventObject(this);
1673 if (!GetEventHandler()->ProcessEvent(event
))
1678 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1681 wxDebugMsg("wxWindow::MSWOnKillFocus %d\n", m_hWnd
);
1689 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1690 event
.SetEventObject(this);
1691 if (!GetEventHandler()->ProcessEvent(event
))
1696 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1699 wxDebugMsg("wxWindow::MSWOnDropFiles %d\n", m_hWnd
);
1702 HDROP hFilesInfo
= (HDROP
) wParam
;
1704 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1706 // Get the total number of files dropped
1707 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1712 wxString
*files
= new wxString
[gwFilesDropped
];
1714 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1716 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1717 files
[wIndex
] = wxBuffer
;
1719 DragFinish (hFilesInfo
);
1721 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1722 event
.m_eventObject
= this;
1723 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1725 if (!GetEventHandler()->ProcessEvent(event
))
1731 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1734 if ( id
== 0 ) { // is it a menu item?
1735 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1736 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1737 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1739 // prepare to call OnDrawItem()
1741 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1742 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1743 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1744 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1745 return pMenuItem
->OnDrawItem(
1747 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1748 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1751 #endif // owner-drawn menus
1753 wxWindow
*item
= FindItem(id
);
1754 #if USE_DYNAMIC_CLASSES
1755 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1757 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1764 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1767 if ( id
== 0 ) { // is it a menu item?
1768 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1769 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1770 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1772 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1773 &pMeasureStruct
->itemHeight
);
1775 #endif // owner-drawn menus
1777 wxWindow
*item
= FindItem(id
);
1778 #if USE_DYNAMIC_CLASSES
1779 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1781 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1788 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1789 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1792 wxDebugMsg("wxWindow::MSWOnCtlColour %d\n", m_hWnd
);
1794 if (nCtlColor
== CTLCOLOR_DLG
)
1796 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1799 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1801 WXHBRUSH hBrush
= 0;
1804 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1806 // I think that even for dialogs, we may need to call DefWindowProc (?)
1807 // Or maybe just rely on the usual default behaviour.
1809 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1814 // Define for each class of dialog and control
1815 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1816 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1818 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1821 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1823 wxSysColourChangedEvent event
;
1824 event
.SetEventObject(this);
1826 // Check if app handles this.
1827 if (GetEventHandler()->ProcessEvent(event
))
1830 // We didn't process it
1834 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1836 wxPaletteChangedEvent
event(GetId());
1837 event
.SetEventObject(this);
1838 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1839 GetEventHandler()->ProcessEvent(event
);
1843 long wxWindow::MSWOnQueryNewPalette()
1845 wxQueryNewPaletteEvent
event(GetId());
1846 event
.SetEventObject(this);
1847 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1849 return (long) FALSE
;
1855 // Responds to colour changes: passes event on to children.
1856 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1858 wxNode
*node
= GetChildren()->First();
1861 // Only propagate to non-top-level windows
1862 wxWindow
*win
= (wxWindow
*)node
->Data();
1863 if ( win
->GetParent() )
1865 wxSysColourChangedEvent event2
;
1866 event
.m_eventObject
= win
;
1867 win
->GetEventHandler()->ProcessEvent(event2
);
1870 node
= node
->Next();
1874 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1877 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1879 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1882 long wxWindow::Default()
1884 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1889 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1890 wxGetMessageName(m_lastMsg
));
1893 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1896 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1898 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1899 // intercept dialog navigation keys
1900 MSG
*msg
= (MSG
*)pMsg
;
1901 bool bProcess
= TRUE
;
1902 if ( msg
->message
!= WM_KEYDOWN
)
1905 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1908 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1910 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1911 // (except for Ctrl-Tab combination which is always processed)
1913 if ( bProcess
&& !bCtrlDown
) {
1914 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1919 switch ( msg
->wParam
) {
1921 if ( lDlgCode
& DLGC_WANTTAB
)
1924 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1929 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1937 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1949 wxNavigationKeyEvent event
;
1950 event
.SetDirection(bForward
);
1951 event
.SetWindowChange(bCtrlDown
);
1952 event
.SetEventObject(this);
1954 if ( GetEventHandler()->ProcessEvent(event
) )
1958 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
1964 bool wxWindow::MSWTranslateMessage(WXMSG
* WXUNUSED(pMsg
))
1969 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
1972 wxDebugMsg("wxWindow::MSWOnMDIActivate %d\n", m_hWnd
);
1977 void wxWindow::MSWDetachWindowMenu(void)
1981 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
1983 for (i
= 0; i
< N
; i
++)
1986 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
1987 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
1989 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
1996 bool wxWindow::MSWOnPaint(void)
1999 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
2000 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
2002 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
2005 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
2007 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
2008 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
2011 wxPaintEvent
event(m_windowId
);
2012 event
.SetEventObject(this);
2013 if (!GetEventHandler()->ProcessEvent(event
))
2018 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2024 wxDebugMsg("wxWindow::MSWOnSize %d\n", m_hWnd
);
2031 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2032 event
.SetEventObject(this);
2033 if (!GetEventHandler()->ProcessEvent(event
))
2039 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2044 // Deal with child commands from buttons etc.
2045 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND
WXUNUSED(control
))
2048 wxDebugMsg("wxWindow::MSWOnCommand\n");
2050 if (wxCurrentPopupMenu
)
2052 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2053 wxCurrentPopupMenu
= NULL
;
2054 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2059 sprintf(buf
, "Looking for item %d...\n", id
);
2063 wxWindow
*item
= FindItem(id
);
2066 bool value
= item
->MSWCommand(cmd
, id
);
2069 wxDebugMsg("MSWCommand succeeded\n");
2071 wxDebugMsg("MSWCommand failed\n");
2078 wxDebugMsg("Could not find item!\n");
2080 wxDebugMsg("Item ids for this panel:\n");
2082 wxNode
*current
= GetChildren()->First();
2085 wxObject
*obj
= (wxObject
*)current
->Data() ;
2086 if (obj
->IsKindOf(CLASSINFO(wxControl
)))
2088 wxControl
*item
= (wxControl
*)current
->Data();
2089 sprintf(buf
, " %d\n", (int)item
->m_windowId
);
2092 current
= current
->Next();
2100 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2106 wxMaximizeEvent
event(m_windowId
);
2107 event
.SetEventObject(this);
2108 if (!GetEventHandler()->ProcessEvent(event
))
2116 wxIconizeEvent
event(m_windowId
);
2117 event
.SetEventObject(this);
2118 if (!GetEventHandler()->ProcessEvent(event
))
2130 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2132 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2134 event
.m_x
= x
; event
.m_y
= y
;
2135 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2136 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2137 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2138 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2139 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2140 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2141 event
.m_eventObject
= this;
2143 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVENT_TYPE_LEFT_DOWN
;
2145 if (!GetEventHandler()->ProcessEvent(event
))
2149 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2151 wxMouseEvent
event(wxEVT_LEFT_UP
);
2153 event
.m_x
= x
; event
.m_y
= y
;
2154 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2155 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2156 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2157 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2158 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2159 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2160 event
.m_eventObject
= this;
2162 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2164 if (!GetEventHandler()->ProcessEvent(event
))
2168 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2170 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2172 event
.m_x
= x
; event
.m_y
= y
;
2173 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2174 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2175 event
.m_leftDown
= ((flags
& MK_LBUTTON
!= 0));
2176 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2177 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2178 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2179 event
.m_eventObject
= this;
2181 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2183 if (!GetEventHandler()->ProcessEvent(event
))
2187 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2189 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2191 event
.m_x
= x
; event
.m_y
= y
;
2192 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2193 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2194 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2195 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2196 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2197 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2198 event
.m_eventObject
= this;
2200 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2202 if (!GetEventHandler()->ProcessEvent(event
))
2206 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2208 //wxDebugMsg("MButtonUp\n") ;
2209 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2211 event
.m_x
= x
; event
.m_y
= y
;
2212 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2213 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2214 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2215 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2216 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2217 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2218 event
.m_eventObject
= this;
2220 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2222 if (!GetEventHandler()->ProcessEvent(event
))
2226 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2228 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2230 event
.m_x
= x
; event
.m_y
= y
;
2231 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2232 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2233 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2234 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2235 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2236 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2237 event
.m_eventObject
= this;
2239 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2241 if (!GetEventHandler()->ProcessEvent(event
))
2245 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2247 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2249 event
.m_x
= x
; event
.m_y
= y
;
2250 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2251 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2252 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2253 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2254 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2255 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2256 event
.m_eventObject
= this;
2258 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2260 if (!GetEventHandler()->ProcessEvent(event
))
2264 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2266 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2268 event
.m_x
= x
; event
.m_y
= y
;
2269 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2270 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2271 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2272 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2273 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2274 event
.m_eventObject
= this;
2275 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2277 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2279 if (!GetEventHandler()->ProcessEvent(event
))
2283 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2285 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2287 event
.m_x
= x
; event
.m_y
= y
;
2288 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2289 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2290 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2291 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2292 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2293 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2294 event
.m_eventObject
= this;
2296 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2298 if (!GetEventHandler()->ProcessEvent(event
))
2302 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2304 // 'normal' move event...
2305 // Set cursor, but only if we're not in 'busy' mode
2307 // Trouble with this is that it sets the cursor for controls too :-(
2308 if (m_windowCursor
.Ok() && !wxIsBusy())
2309 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2311 if (!m_mouseInWindow
)
2313 // Generate an ENTER event
2314 m_mouseInWindow
= TRUE
;
2315 MSWOnMouseEnter(x
, y
, flags
);
2318 wxMouseEvent
event(wxEVT_MOTION
);
2320 event
.m_x
= x
; event
.m_y
= y
;
2321 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2322 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2323 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2324 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2325 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2326 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2327 event
.m_eventObject
= this;
2329 // Window gets a click down message followed by a mouse move
2330 // message even if position isn't changed! We want to discard
2331 // the trailing move event if x and y are the same.
2332 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2333 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2334 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2336 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2337 m_lastEvent
= wxEVT_MOTION
;
2341 m_lastEvent
= wxEVT_MOTION
;
2342 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2344 if (!GetEventHandler()->ProcessEvent(event
))
2348 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2350 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2352 event
.m_x
= x
; event
.m_y
= y
;
2353 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2354 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2355 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2356 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2357 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2358 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2359 event
.m_eventObject
= this;
2361 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2362 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2363 // No message - ensure we don't try to call the default behaviour accidentally.
2365 GetEventHandler()->ProcessEvent(event
);
2368 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2370 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2372 event
.m_x
= x
; event
.m_y
= y
;
2373 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2374 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2375 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2376 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2377 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2378 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2379 event
.m_eventObject
= this;
2381 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2382 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2383 // No message - ensure we don't try to call the default behaviour accidentally.
2385 GetEventHandler()->ProcessEvent(event
);
2388 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2391 bool tempControlDown
= FALSE
;
2394 // If 1 -> 26, translate to CTRL plus a letter.
2396 if ((id
> 0) && (id
< 27))
2417 tempControlDown
= TRUE
;
2423 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2424 // it's ASCII and will be processed here only when called from
2425 // WM_CHAR (i.e. when isASCII = TRUE)
2431 wxKeyEvent
event(wxEVT_CHAR
);
2432 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2433 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2434 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2435 event
.m_altDown
= TRUE
;
2437 event
.m_eventObject
= this;
2438 event
.m_keyCode
= id
;
2439 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2444 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2448 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2450 if (!GetEventHandler()->ProcessEvent(event
))
2455 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2459 if (flags
& JOY_BUTTON1CHG
)
2460 change
= wxJOY_BUTTON1
;
2461 if (flags
& JOY_BUTTON2CHG
)
2462 change
= wxJOY_BUTTON2
;
2463 if (flags
& JOY_BUTTON3CHG
)
2464 change
= wxJOY_BUTTON3
;
2465 if (flags
& JOY_BUTTON4CHG
)
2466 change
= wxJOY_BUTTON4
;
2468 if (flags
& JOY_BUTTON1
)
2469 buttons
|= wxJOY_BUTTON1
;
2470 if (flags
& JOY_BUTTON2
)
2471 buttons
|= wxJOY_BUTTON2
;
2472 if (flags
& JOY_BUTTON3
)
2473 buttons
|= wxJOY_BUTTON3
;
2474 if (flags
& JOY_BUTTON4
)
2475 buttons
|= wxJOY_BUTTON4
;
2477 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2478 event
.SetPosition(wxPoint(x
, y
));
2479 event
.SetEventObject(this);
2481 GetEventHandler()->ProcessEvent(event
);
2484 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2488 if (flags
& JOY_BUTTON1CHG
)
2489 change
= wxJOY_BUTTON1
;
2490 if (flags
& JOY_BUTTON2CHG
)
2491 change
= wxJOY_BUTTON2
;
2492 if (flags
& JOY_BUTTON3CHG
)
2493 change
= wxJOY_BUTTON3
;
2494 if (flags
& JOY_BUTTON4CHG
)
2495 change
= wxJOY_BUTTON4
;
2497 if (flags
& JOY_BUTTON1
)
2498 buttons
|= wxJOY_BUTTON1
;
2499 if (flags
& JOY_BUTTON2
)
2500 buttons
|= wxJOY_BUTTON2
;
2501 if (flags
& JOY_BUTTON3
)
2502 buttons
|= wxJOY_BUTTON3
;
2503 if (flags
& JOY_BUTTON4
)
2504 buttons
|= wxJOY_BUTTON4
;
2506 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2507 event
.SetPosition(wxPoint(x
, y
));
2508 event
.SetEventObject(this);
2510 GetEventHandler()->ProcessEvent(event
);
2513 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2516 if (flags
& JOY_BUTTON1
)
2517 buttons
|= wxJOY_BUTTON1
;
2518 if (flags
& JOY_BUTTON2
)
2519 buttons
|= wxJOY_BUTTON2
;
2520 if (flags
& JOY_BUTTON3
)
2521 buttons
|= wxJOY_BUTTON3
;
2522 if (flags
& JOY_BUTTON4
)
2523 buttons
|= wxJOY_BUTTON4
;
2525 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2526 event
.SetPosition(wxPoint(x
, y
));
2527 event
.SetEventObject(this);
2529 GetEventHandler()->ProcessEvent(event
);
2532 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2535 if (flags
& JOY_BUTTON1
)
2536 buttons
|= wxJOY_BUTTON1
;
2537 if (flags
& JOY_BUTTON2
)
2538 buttons
|= wxJOY_BUTTON2
;
2539 if (flags
& JOY_BUTTON3
)
2540 buttons
|= wxJOY_BUTTON3
;
2541 if (flags
& JOY_BUTTON4
)
2542 buttons
|= wxJOY_BUTTON4
;
2544 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2545 event
.SetZPosition(z
);
2546 event
.SetEventObject(this);
2548 GetEventHandler()->ProcessEvent(event
);
2551 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2555 wxWindow
*child
= wxFindWinFromHandle(control
);
2557 child
->MSWOnVScroll(wParam
, pos
, control
);
2561 wxScrollEvent event
;
2562 event
.SetPosition(pos
);
2563 event
.SetOrientation(wxVERTICAL
);
2564 event
.m_eventObject
= this;
2569 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2573 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2577 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2581 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2585 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2589 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2593 case SB_THUMBPOSITION
:
2594 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2602 if (!GetEventHandler()->ProcessEvent(event
))
2606 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2610 wxWindow
*child
= wxFindWinFromHandle(control
);
2612 child
->MSWOnHScroll(wParam
, pos
, control
);
2616 wxScrollEvent event
;
2617 event
.SetPosition(pos
);
2618 event
.SetOrientation(wxHORIZONTAL
);
2619 event
.m_eventObject
= this;
2624 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2628 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2632 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2636 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2640 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2644 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2648 case SB_THUMBPOSITION
:
2649 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2656 if (!GetEventHandler()->ProcessEvent(event
))
2660 void wxWindow::MSWOnShow(bool show
, int status
)
2662 wxShowEvent
event(GetId(), show
);
2663 event
.m_eventObject
= this;
2664 GetEventHandler()->ProcessEvent(event
);
2667 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2669 wxInitDialogEvent
event(GetId());
2670 event
.m_eventObject
= this;
2671 GetEventHandler()->ProcessEvent(event
);
2675 void wxWindow::InitDialog(void)
2677 wxInitDialogEvent
event(GetId());
2678 event
.SetEventObject( this );
2679 GetEventHandler()->ProcessEvent(event
);
2682 // Default init dialog behaviour is to transfer data to window
2683 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2685 TransferDataToWindow();
2688 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2691 HDC dc
= ::GetDC((HWND
) wnd
);
2697 wxDebugMsg("wxGetCharSize: Selecting HFONT %X\n", fnt
);
2699 // the_font->UseResource();
2700 // the_font->RealizeResource();
2701 if ((fnt
=(HFONT
) the_font
->GetResourceHandle()))
2702 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2704 GetTextMetrics(dc
, &tm
);
2705 if (the_font
&& fnt
&& was
)
2708 wxDebugMsg("wxGetCharSize: Selecting old HFONT %X\n", was
);
2710 SelectObject(dc
,was
) ;
2712 ReleaseDC((HWND
)wnd
, dc
);
2713 *x
= tm
.tmAveCharWidth
;
2714 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2717 // the_font->ReleaseResource();
2720 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2721 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2722 int wxCharCodeMSWToWX(int keySym
)
2727 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2728 case VK_BACK
: id
= WXK_BACK
; break;
2729 case VK_TAB
: id
= WXK_TAB
; break;
2730 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2731 case VK_RETURN
: id
= WXK_RETURN
; break;
2732 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2733 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2734 case VK_MENU
: id
= WXK_MENU
; break;
2735 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2736 case VK_SPACE
: id
= WXK_SPACE
; break;
2737 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2738 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2739 case VK_NEXT
: id
= WXK_NEXT
; break;
2740 case VK_END
: id
= WXK_END
; break;
2741 case VK_HOME
: id
= WXK_HOME
; break;
2742 case VK_LEFT
: id
= WXK_LEFT
; break;
2743 case VK_UP
: id
= WXK_UP
; break;
2744 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2745 case VK_DOWN
: id
= WXK_DOWN
; break;
2746 case VK_SELECT
: id
= WXK_SELECT
; break;
2747 case VK_PRINT
: id
= WXK_PRINT
; break;
2748 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2749 case VK_INSERT
: id
= WXK_INSERT
; break;
2750 case VK_DELETE
: id
= WXK_DELETE
; break;
2751 case VK_HELP
: id
= WXK_HELP
; break;
2752 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2753 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2754 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2755 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2756 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2757 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2758 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2759 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2760 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2761 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2762 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2763 case VK_ADD
: id
= WXK_ADD
; break;
2764 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2765 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2766 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2767 case VK_F1
: id
= WXK_F1
; break;
2768 case VK_F2
: id
= WXK_F2
; break;
2769 case VK_F3
: id
= WXK_F3
; break;
2770 case VK_F4
: id
= WXK_F4
; break;
2771 case VK_F5
: id
= WXK_F5
; break;
2772 case VK_F6
: id
= WXK_F6
; break;
2773 case VK_F7
: id
= WXK_F7
; break;
2774 case VK_F8
: id
= WXK_F8
; break;
2775 case VK_F9
: id
= WXK_F9
; break;
2776 case VK_F10
: id
= WXK_F10
; break;
2777 case VK_F11
: id
= WXK_F11
; break;
2778 case VK_F12
: id
= WXK_F12
; break;
2779 case VK_F13
: id
= WXK_F13
; break;
2780 case VK_F14
: id
= WXK_F14
; break;
2781 case VK_F15
: id
= WXK_F15
; break;
2782 case VK_F16
: id
= WXK_F16
; break;
2783 case VK_F17
: id
= WXK_F17
; break;
2784 case VK_F18
: id
= WXK_F18
; break;
2785 case VK_F19
: id
= WXK_F19
; break;
2786 case VK_F20
: id
= WXK_F20
; break;
2787 case VK_F21
: id
= WXK_F21
; break;
2788 case VK_F22
: id
= WXK_F22
; break;
2789 case VK_F23
: id
= WXK_F23
; break;
2790 case VK_F24
: id
= WXK_F24
; break;
2791 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2792 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2801 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2807 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2808 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2809 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2810 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2811 case WXK_MENU
: keySym
= VK_MENU
; break;
2812 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2813 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2814 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2815 case WXK_END
: keySym
= VK_END
; break;
2816 case WXK_HOME
: keySym
= VK_HOME
; break;
2817 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2818 case WXK_UP
: keySym
= VK_UP
; break;
2819 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2820 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2821 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2822 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2823 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2824 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2825 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2826 case WXK_HELP
: keySym
= VK_HELP
; break;
2827 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2828 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2829 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2830 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2831 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2832 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2833 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2834 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2835 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2836 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2837 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2838 case WXK_ADD
: keySym
= VK_ADD
; break;
2839 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2840 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2841 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2842 case WXK_F1
: keySym
= VK_F1
; break;
2843 case WXK_F2
: keySym
= VK_F2
; break;
2844 case WXK_F3
: keySym
= VK_F3
; break;
2845 case WXK_F4
: keySym
= VK_F4
; break;
2846 case WXK_F5
: keySym
= VK_F5
; break;
2847 case WXK_F6
: keySym
= VK_F6
; break;
2848 case WXK_F7
: keySym
= VK_F7
; break;
2849 case WXK_F8
: keySym
= VK_F8
; break;
2850 case WXK_F9
: keySym
= VK_F9
; break;
2851 case WXK_F10
: keySym
= VK_F10
; break;
2852 case WXK_F11
: keySym
= VK_F11
; break;
2853 case WXK_F12
: keySym
= VK_F12
; break;
2854 case WXK_F13
: keySym
= VK_F13
; break;
2855 case WXK_F14
: keySym
= VK_F14
; break;
2856 case WXK_F15
: keySym
= VK_F15
; break;
2857 case WXK_F16
: keySym
= VK_F16
; break;
2858 case WXK_F17
: keySym
= VK_F17
; break;
2859 case WXK_F18
: keySym
= VK_F18
; break;
2860 case WXK_F19
: keySym
= VK_F19
; break;
2861 case WXK_F20
: keySym
= VK_F20
; break;
2862 case WXK_F21
: keySym
= VK_F21
; break;
2863 case WXK_F22
: keySym
= VK_F22
; break;
2864 case WXK_F23
: keySym
= VK_F23
; break;
2865 case WXK_F24
: keySym
= VK_F24
; break;
2866 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2867 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2878 // Caret manipulation
2879 void wxWindow::CreateCaret(int w
, int h
)
2883 m_caretEnabled
= TRUE
;
2886 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2891 void wxWindow::ShowCaret(bool show
)
2896 ::ShowCaret((HWND
) GetHWND());
2898 ::HideCaret((HWND
) GetHWND());
2899 m_caretShown
= show
;
2903 void wxWindow::DestroyCaret(void)
2905 m_caretEnabled
= FALSE
;
2908 void wxWindow::SetCaretPos(int x
, int y
)
2910 ::SetCaretPos(x
, y
);
2913 void wxWindow::GetCaretPos(int *x
, int *y
) const
2916 ::GetCaretPos(&point
);
2921 wxWindow
*wxGetActiveWindow(void)
2923 HWND hWnd
= GetActiveWindow();
2926 return wxFindWinFromHandle((WXHWND
) hWnd
);
2931 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2932 // in active frames and dialogs, regardless of where the focus is.
2933 static HHOOK wxTheKeyboardHook
= 0;
2934 static FARPROC wxTheKeyboardHookProc
= 0;
2935 int APIENTRY _EXPORT
2936 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2938 void wxSetKeyboardHook(bool doIt
)
2942 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
2943 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
2945 GetCurrentThreadId());
2946 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2953 UnhookWindowsHookEx(wxTheKeyboardHook
);
2954 FreeProcInstance(wxTheKeyboardHookProc
);
2958 int APIENTRY _EXPORT
2959 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
2961 DWORD hiWord
= HIWORD(lParam
);
2962 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
2965 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
2967 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
2968 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2969 event
.m_altDown
= TRUE
;
2971 event
.m_eventObject
= NULL
;
2972 event
.m_keyCode
= id
;
2973 /* begin Albert's fix for control and shift key 26.5 */
2974 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2975 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2976 /* end Albert's fix for control and shift key 26.5 */
2977 event
.SetTimestamp(wxApp::sm_lastMessageTime
); /* MATTHEW: timeStamp */
2979 wxWindow
*win
= wxGetActiveWindow();
2982 if (win
->GetEventHandler()->ProcessEvent(event
))
2987 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
2992 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
2995 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3003 void wxWindow::Centre(int direction
)
3005 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3007 wxWindow
*father
= (wxWindow
*)GetParent();
3011 father
->GetClientSize(&panel_width
, &panel_height
);
3012 GetSize(&width
, &height
);
3013 GetPosition(&x
, &y
);
3018 if (direction
& wxHORIZONTAL
)
3019 new_x
= (int)((panel_width
- width
)/2);
3021 if (direction
& wxVERTICAL
)
3022 new_y
= (int)((panel_height
- height
)/2);
3024 SetSize(new_x
, new_y
, -1, -1);
3029 void wxWindow::OnPaint(void)
3031 PaintSelectionHandles();
3035 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3037 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3038 // pixel coordinates, relatives to the canvas -- So, we first need to
3039 // substract origin of the window, then convert to screen position
3041 int x
= x_pos
; int y
= y_pos
;
3043 GetWindowRect ((HWND
) GetHWND(), &rect
);
3048 SetCursorPos (x
, y
);
3051 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3055 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3063 wxEraseEvent
event(m_windowId
, &dc
);
3064 event
.m_eventObject
= this;
3065 if (!GetEventHandler()->ProcessEvent(event
))
3068 dc
.SelectOldObjects(pDC
);
3074 dc
.SelectOldObjects(pDC
);
3077 dc
.SetHDC((WXHDC
) NULL
);
3081 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3084 ::GetClientRect((HWND
) GetHWND(), &rect
);
3086 HBRUSH hBrush
= ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
3087 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3089 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3090 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3091 ::DeleteObject(hBrush
);
3092 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3094 // Less efficient version (and doesn't account for scrolling)
3096 GetClientSize(& w, & h);
3097 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3098 event.GetDC()->SetBrush(brush);
3099 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3101 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3105 #if WXWIN_COMPATIBILITY
3106 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3108 #if defined(__WIN95__)
3112 // Try to adjust the range to cope with page size > 1
3113 // - a Windows API quirk
3114 int pageSize
= GetScrollPage(orient
);
3115 if ( pageSize
> 1 && range
> 0)
3117 range1
+= (pageSize
- 1);
3123 if (orient
== wxHORIZONTAL
) {
3129 info
.cbSize
= sizeof(SCROLLINFO
);
3130 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3134 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3136 HWND hWnd
= (HWND
) GetHWND();
3138 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3141 if (orient
== wxHORIZONTAL
)
3146 HWND hWnd
= (HWND
) GetHWND();
3148 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3152 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3154 #if defined(__WIN95__)
3158 if (orient
== wxHORIZONTAL
) {
3160 m_xThumbSize
= page
;
3163 m_yThumbSize
= page
;
3166 info
.cbSize
= sizeof(SCROLLINFO
);
3169 info
.fMask
= SIF_PAGE
;
3171 HWND hWnd
= (HWND
) GetHWND();
3173 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3175 if (orient
== wxHORIZONTAL
)
3176 m_xThumbSize
= page
;
3178 m_yThumbSize
= page
;
3182 int wxWindow::OldGetScrollRange(int orient
) const
3185 if (orient
== wxHORIZONTAL
)
3190 #if __WATCOMC__ && defined(__WINDOWS_386__)
3191 short minPos
, maxPos
;
3195 HWND hWnd
= (HWND
) GetHWND();
3198 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3199 #if defined(__WIN95__)
3200 // Try to adjust the range to cope with page size > 1
3201 // - a Windows API quirk
3202 int pageSize
= GetScrollPage(orient
);
3205 maxPos
-= (pageSize
- 1);
3214 int wxWindow::GetScrollPage(int orient
) const
3216 if (orient
== wxHORIZONTAL
)
3217 return m_xThumbSize
;
3219 return m_yThumbSize
;
3223 int wxWindow::GetScrollPos(int orient
) const
3226 if (orient
== wxHORIZONTAL
)
3230 HWND hWnd
= (HWND
) GetHWND();
3233 return ::GetScrollPos(hWnd
, wOrient
);
3239 // This now returns the whole range, not just the number
3240 // of positions that we can scroll.
3241 int wxWindow::GetScrollRange(int orient
) const
3244 if (orient
== wxHORIZONTAL
)
3249 #if __WATCOMC__ && defined(__WINDOWS_386__)
3250 short minPos
, maxPos
;
3254 HWND hWnd
= (HWND
) GetHWND();
3257 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3258 #if defined(__WIN95__)
3259 // Try to adjust the range to cope with page size > 1
3260 // - a Windows API quirk
3261 int pageSize
= GetScrollPage(orient
);
3264 maxPos
-= (pageSize
- 1);
3266 // October 10th: new range concept.
3276 int wxWindow::GetScrollThumb(int orient
) const
3278 if (orient
== wxHORIZONTAL
)
3279 return m_xThumbSize
;
3281 return m_yThumbSize
;
3284 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3286 #if defined(__WIN95__)
3290 if (orient
== wxHORIZONTAL
) {
3296 info
.cbSize
= sizeof(SCROLLINFO
);
3300 info
.fMask
= SIF_POS
;
3302 HWND hWnd
= (HWND
) GetHWND();
3304 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3307 if (orient
== wxHORIZONTAL
)
3312 HWND hWnd
= (HWND
) GetHWND();
3314 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3318 // New function that will replace some of the above.
3319 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3320 int range
, bool refresh
)
3323 SetScrollPage(orient, thumbVisible, FALSE);
3325 int oldRange = range - thumbVisible ;
3326 SetScrollRange(orient, oldRange, FALSE);
3328 SetScrollPos(orient, pos, refresh);
3330 #if defined(__WIN95__)
3331 int oldRange
= range
- thumbVisible
;
3333 int range1
= oldRange
;
3335 // Try to adjust the range to cope with page size > 1
3336 // - a Windows API quirk
3337 int pageSize
= thumbVisible
;
3338 if ( pageSize
> 1 && range
> 0)
3340 range1
+= (pageSize
- 1);
3346 if (orient
== wxHORIZONTAL
) {
3352 info
.cbSize
= sizeof(SCROLLINFO
);
3353 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3357 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3359 HWND hWnd
= (HWND
) GetHWND();
3361 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3364 if (orient
== wxHORIZONTAL
)
3369 HWND hWnd
= (HWND
) GetHWND();
3372 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3373 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3376 if (orient
== wxHORIZONTAL
) {
3377 m_xThumbSize
= thumbVisible
;
3379 m_yThumbSize
= thumbVisible
;
3383 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRectangle
*rect
)
3388 rect2
.left
= rect
->x
;
3389 rect2
.top
= rect
->y
;
3390 rect2
.right
= rect
->x
+ rect
->width
;
3391 rect2
.bottom
= rect
->y
+ rect
->height
;
3395 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3397 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3400 void wxWindow::SetFont(const wxFont
& font
)
3402 m_windowFont
= font
;
3404 if (!m_windowFont
.Ok())
3407 HWND hWnd
= (HWND
) GetHWND();
3410 if (m_windowFont
.GetResourceHandle())
3411 SendMessage(hWnd
, WM_SETFONT
,
3412 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3416 void wxWindow::SubclassWin(WXHWND hWnd
)
3418 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3420 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3422 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3423 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3426 void wxWindow::UnsubclassWin(void)
3428 wxRemoveHandleAssociation(this);
3430 // Restore old Window proc
3431 if ((HWND
) GetHWND())
3433 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3434 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3436 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3442 // Make a Windows extended style from the given wxWindows window style
3443 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3445 WXDWORD exStyle
= 0;
3446 if ( style
& wxTRANSPARENT_WINDOW
)
3447 exStyle
|= WS_EX_TRANSPARENT
;
3449 if ( !eliminateBorders
)
3451 if ( style
& wxSUNKEN_BORDER
)
3452 exStyle
|= WS_EX_CLIENTEDGE
;
3453 if ( style
& wxDOUBLE_BORDER
)
3454 exStyle
|= WS_EX_DLGMODALFRAME
;
3455 #if defined(__WIN95__)
3456 if ( style
& wxRAISED_BORDER
)
3457 exStyle
|= WS_EX_WINDOWEDGE
;
3458 if ( style
& wxSTATIC_BORDER
)
3459 exStyle
|= WS_EX_STATICEDGE
;
3465 // Determines whether native 3D effects or CTL3D should be used,
3466 // applying a default border style if required, and returning an extended
3467 // style to pass to CreateWindowEx.
3468 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3470 // If matches certain criteria, then assume no 3D effects
3471 // unless specifically requested (dealt with in MakeExtendedStyle)
3472 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3475 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3478 // Determine whether we should be using 3D effects or not.
3479 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3481 // 1) App can specify global 3D effects
3482 *want3D
= wxTheApp
->GetAuto3D();
3484 // 2) If the parent is being drawn with user colours, or simple border specified,
3485 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3486 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3489 // 3) Control can override this global setting by defining
3490 // a border style, e.g. wxSUNKEN_BORDER
3491 if (m_windowStyle
& wxSUNKEN_BORDER
)
3494 // 4) If it's a special border, CTL3D can't cope so we want a native border
3495 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3496 (m_windowStyle
& wxSTATIC_BORDER
) )
3499 nativeBorder
= TRUE
;
3502 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3503 // effects from extended style
3506 nativeBorder
= FALSE
;
3509 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3511 // If we want 3D, but haven't specified a border here,
3512 // apply the default border style specified.
3513 // TODO what about non-Win95 WIN32? Does it have borders?
3514 #if defined(__WIN95__) && !CTL3D
3515 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3516 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3517 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3523 void wxWindow::OnChar(wxKeyEvent
& event
)
3525 if ( event
.KeyCode() == WXK_TAB
) {
3526 // propagate the TABs to the parent - it's up to it to decide what
3528 if ( GetParent() ) {
3529 if ( GetParent()->ProcessEvent(event
) )
3535 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3540 if ( !event
.ControlDown() )
3541 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3544 void wxWindow::OnPaint(wxPaintEvent
& event
)
3549 bool wxWindow::IsEnabled(void) const
3551 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3554 // Dialog support: override these and call
3555 // base class members to add functionality
3556 // that can't be done using validators.
3557 // NOTE: these functions assume that controls
3558 // are direct children of this window, not grandchildren
3559 // or other levels of descendant.
3561 // Transfer values to controls. If returns FALSE,
3562 // it's an application error (pops up a dialog)
3563 bool wxWindow::TransferDataToWindow(void)
3565 wxNode
*node
= GetChildren()->First();
3568 wxWindow
*child
= (wxWindow
*)node
->Data();
3569 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3570 !child
->GetValidator()->TransferToWindow() )
3572 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3576 node
= node
->Next();
3581 // Transfer values from controls. If returns FALSE,
3582 // validation failed: don't quit
3583 bool wxWindow::TransferDataFromWindow(void)
3585 wxNode
*node
= GetChildren()->First();
3588 wxWindow
*child
= (wxWindow
*)node
->Data();
3589 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3594 node
= node
->Next();
3599 bool wxWindow::Validate(void)
3601 wxNode
*node
= GetChildren()->First();
3604 wxWindow
*child
= (wxWindow
*)node
->Data();
3605 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3610 node
= node
->Next();
3615 // Get the window with the focus
3616 wxWindow
*wxWindow::FindFocus(void)
3618 HWND hWnd
= ::GetFocus();
3621 return wxFindWinFromHandle((WXHWND
) hWnd
);
3626 void wxWindow::AddChild(wxWindow
*child
)
3628 GetChildren()->Append(child
);
3629 child
->m_windowParent
= this;
3632 void wxWindow::RemoveChild(wxWindow
*child
)
3635 GetChildren()->DeleteObject(child
);
3636 child
->m_windowParent
= NULL
;
3639 void wxWindow::DestroyChildren(void)
3641 if (GetChildren()) {
3643 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
) {
3645 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3647 if ( GetChildren()->Member(child
) )
3654 void wxWindow::MakeModal(bool modal
)
3656 // Disable all other windows
3657 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3659 wxNode
*node
= wxTopLevelWindows
.First();
3662 wxWindow
*win
= (wxWindow
*)node
->Data();
3664 win
->Enable(!modal
);
3666 node
= node
->Next();
3671 // If nothing defined for this, try the parent.
3672 // E.g. we may be a button loaded from a resource, with no callback function
3674 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3676 if (GetEventHandler()->ProcessEvent(event
) )
3679 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3682 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3686 UnsetConstraints(m_constraints
);
3687 delete m_constraints
;
3692 // Make sure other windows know they're part of a 'meaningful relationship'
3693 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3694 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3695 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3696 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3697 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3698 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3699 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3700 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3701 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3702 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3703 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3704 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3705 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3706 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3707 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3708 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3712 // This removes any dangling pointers to this window
3713 // in other windows' constraintsInvolvedIn lists.
3714 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3718 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3719 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3720 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3721 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3722 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3723 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3724 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3725 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3726 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3727 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3728 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3729 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3730 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3731 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3732 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3733 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3737 // Back-pointer to other windows we're involved with, so if we delete
3738 // this window, we must delete any constraints we're involved with.
3739 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3741 if (!m_constraintsInvolvedIn
)
3742 m_constraintsInvolvedIn
= new wxList
;
3743 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3744 m_constraintsInvolvedIn
->Append(otherWin
);
3747 // REMOVE back-pointer to other windows we're involved with.
3748 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3750 if (m_constraintsInvolvedIn
)
3751 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3754 // Reset any constraints that mention this window
3755 void wxWindow::DeleteRelatedConstraints(void)
3757 if (m_constraintsInvolvedIn
)
3759 wxNode
*node
= m_constraintsInvolvedIn
->First();
3762 wxWindow
*win
= (wxWindow
*)node
->Data();
3763 wxNode
*next
= node
->Next();
3764 wxLayoutConstraints
*constr
= win
->GetConstraints();
3766 // Reset any constraints involving this window
3769 constr
->left
.ResetIfWin((wxWindow
*)this);
3770 constr
->top
.ResetIfWin((wxWindow
*)this);
3771 constr
->right
.ResetIfWin((wxWindow
*)this);
3772 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3773 constr
->width
.ResetIfWin((wxWindow
*)this);
3774 constr
->height
.ResetIfWin((wxWindow
*)this);
3775 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3776 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3781 delete m_constraintsInvolvedIn
;
3782 m_constraintsInvolvedIn
= NULL
;
3786 void wxWindow::SetSizer(wxSizer
*sizer
)
3788 m_windowSizer
= sizer
;
3790 sizer
->SetSizerParent((wxWindow
*)this);
3797 bool wxWindow::Layout(void)
3799 if (GetConstraints())
3802 GetClientSize(&w
, &h
);
3803 GetConstraints()->width
.SetValue(w
);
3804 GetConstraints()->height
.SetValue(h
);
3807 // If top level (one sizer), evaluate the sizer's constraints.
3811 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3812 GetSizer()->LayoutPhase1(&noChanges
);
3813 GetSizer()->LayoutPhase2(&noChanges
);
3814 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3819 // Otherwise, evaluate child constraints
3820 ResetConstraints(); // Mark all constraints as unevaluated
3821 DoPhase(1); // Just one phase need if no sizers involved
3823 SetConstraintSizes(); // Recursively set the real window sizes
3829 // Do a phase of evaluating constraints:
3830 // the default behaviour. wxSizers may do a similar
3831 // thing, but also impose their own 'constraints'
3832 // and order the evaluation differently.
3833 bool wxWindow::LayoutPhase1(int *noChanges
)
3835 wxLayoutConstraints
*constr
= GetConstraints();
3838 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3844 bool wxWindow::LayoutPhase2(int *noChanges
)
3854 // Do a phase of evaluating child constraints
3855 bool wxWindow::DoPhase(int phase
)
3857 int noIterations
= 0;
3858 int maxIterations
= 500;
3862 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3866 wxNode
*node
= GetChildren()->First();
3869 wxWindow
*child
= (wxWindow
*)node
->Data();
3870 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3872 wxLayoutConstraints
*constr
= child
->GetConstraints();
3875 if (succeeded
.Member(child
))
3880 int tempNoChanges
= 0;
3881 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3882 noChanges
+= tempNoChanges
;
3885 succeeded
.Append(child
);
3890 node
= node
->Next();
3897 void wxWindow::ResetConstraints(void)
3899 wxLayoutConstraints
*constr
= GetConstraints();
3902 constr
->left
.SetDone(FALSE
);
3903 constr
->top
.SetDone(FALSE
);
3904 constr
->right
.SetDone(FALSE
);
3905 constr
->bottom
.SetDone(FALSE
);
3906 constr
->width
.SetDone(FALSE
);
3907 constr
->height
.SetDone(FALSE
);
3908 constr
->centreX
.SetDone(FALSE
);
3909 constr
->centreY
.SetDone(FALSE
);
3911 wxNode
*node
= GetChildren()->First();
3914 wxWindow
*win
= (wxWindow
*)node
->Data();
3915 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3916 win
->ResetConstraints();
3917 node
= node
->Next();
3921 // Need to distinguish between setting the 'fake' size for
3922 // windows and sizers, and setting the real values.
3923 void wxWindow::SetConstraintSizes(bool recurse
)
3925 wxLayoutConstraints
*constr
= GetConstraints();
3926 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3927 constr
->width
.GetDone() && constr
->height
.GetDone())
3929 int x
= constr
->left
.GetValue();
3930 int y
= constr
->top
.GetValue();
3931 int w
= constr
->width
.GetValue();
3932 int h
= constr
->height
.GetValue();
3934 // If we don't want to resize this window, just move it...
3935 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3936 (constr
->height
.GetRelationship() != wxAsIs
))
3938 // Calls Layout() recursively. AAAGH. How can we stop that.
3939 // Simply take Layout() out of non-top level OnSizes.
3940 SizerSetSize(x
, y
, w
, h
);
3949 char *windowClass
= this->GetClassInfo()->GetClassName();
3952 if (GetName() == "")
3953 winName
= "unnamed";
3955 winName
= GetName();
3956 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
3957 if (!constr
->left
.GetDone())
3958 wxDebugMsg(" unsatisfied 'left' constraint.\n");
3959 if (!constr
->right
.GetDone())
3960 wxDebugMsg(" unsatisfied 'right' constraint.\n");
3961 if (!constr
->width
.GetDone())
3962 wxDebugMsg(" unsatisfied 'width' constraint.\n");
3963 if (!constr
->height
.GetDone())
3964 wxDebugMsg(" unsatisfied 'height' constraint.\n");
3965 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
3970 wxNode
*node
= GetChildren()->First();
3973 wxWindow
*win
= (wxWindow
*)node
->Data();
3974 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3975 win
->SetConstraintSizes();
3976 node
= node
->Next();
3981 // This assumes that all sizers are 'on' the same
3982 // window, i.e. the parent of this window.
3983 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
3985 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
3986 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
3990 m_sizerParent
->GetPosition(&xp
, &yp
);
3991 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
3996 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4000 TransformSizerToActual(&xx
, &yy
);
4001 SetSize(xx
, yy
, w
, h
);
4004 void wxWindow::SizerMove(int x
, int y
)
4008 TransformSizerToActual(&xx
, &yy
);
4012 // Only set the size/position of the constraint (if any)
4013 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4015 wxLayoutConstraints
*constr
= GetConstraints();
4020 constr
->left
.SetValue(x
);
4021 constr
->left
.SetDone(TRUE
);
4025 constr
->top
.SetValue(y
);
4026 constr
->top
.SetDone(TRUE
);
4030 constr
->width
.SetValue(w
);
4031 constr
->width
.SetDone(TRUE
);
4035 constr
->height
.SetValue(h
);
4036 constr
->height
.SetDone(TRUE
);
4041 void wxWindow::MoveConstraint(int x
, int y
)
4043 wxLayoutConstraints
*constr
= GetConstraints();
4048 constr
->left
.SetValue(x
);
4049 constr
->left
.SetDone(TRUE
);
4053 constr
->top
.SetValue(y
);
4054 constr
->top
.SetDone(TRUE
);
4059 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4061 wxLayoutConstraints
*constr
= GetConstraints();
4064 *w
= constr
->width
.GetValue();
4065 *h
= constr
->height
.GetValue();
4071 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4073 wxLayoutConstraints
*constr
= GetConstraints();
4076 *w
= constr
->width
.GetValue();
4077 *h
= constr
->height
.GetValue();
4080 GetClientSize(w
, h
);
4083 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4085 wxLayoutConstraints
*constr
= GetConstraints();
4088 *x
= constr
->left
.GetValue();
4089 *y
= constr
->top
.GetValue();
4095 bool wxWindow::Close(bool force
)
4097 // Let's generalise it to work the same for any window.
4099 if (!IsKindOf(CLASSINFO(wxDialog)) && !IsKindOf(CLASSINFO(wxFrame)))
4106 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4107 event
.SetEventObject(this);
4108 event
.SetForce(force
);
4110 return GetEventHandler()->ProcessEvent(event
);
4113 if ( !force && event.GetVeto() )
4118 if (!wxPendingDelete.Member(this))
4119 wxPendingDelete.Append(this);
4125 wxObject
* wxWindow::GetChild(int number
) const
4127 // Return a pointer to the Nth object in the Panel
4130 wxNode
*node
= GetChildren()->First();
4133 node
= node
->Next() ;
4136 wxObject
*obj
= (wxObject
*)node
->Data();
4143 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4145 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4146 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4149 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4151 wxListBox *lbox = (wxListBox *)initiatingItem;
4152 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4153 event.m_commandInt = -1;
4154 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4156 event.m_commandString = copystring(lbox->GetStringSelection());
4157 event.m_commandInt = lbox->GetSelection();
4158 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4160 event.m_eventObject = lbox;
4162 lbox->ProcessCommand(event);
4164 if (event.m_commandString)
4165 delete[] event.m_commandString;
4169 wxButton *but = GetDefaultItem();
4172 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4173 event.SetEventObject(but);
4174 but->Command(event);
4179 void wxWindow::Clear(void)
4181 wxClientDC
dc(this);
4182 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4183 dc
.SetBackground(brush
);
4187 // Fits the panel around the items
4188 void wxWindow::Fit(void)
4192 wxNode
*node
= GetChildren()->First();
4195 wxWindow
*win
= (wxWindow
*)node
->Data();
4197 win
->GetPosition(&wx
, &wy
);
4198 win
->GetSize(&ww
, &wh
);
4199 if ( wx
+ ww
> maxX
)
4201 if ( wy
+ wh
> maxY
)
4204 node
= node
->Next();
4206 SetClientSize(maxX
+ 5, maxY
+ 5);
4209 void wxWindow::SetValidator(const wxValidator
& validator
)
4211 if ( m_windowValidator
)
4212 delete m_windowValidator
;
4213 m_windowValidator
= validator
.Clone();
4215 if ( m_windowValidator
)
4216 m_windowValidator
->SetWindow(this) ;
4219 // Find a window by id or name
4220 wxWindow
*wxWindow::FindWindow(long id
)
4225 wxNode
*node
= GetChildren()->First();
4228 wxWindow
*child
= (wxWindow
*)node
->Data();
4229 wxWindow
*found
= child
->FindWindow(id
);
4232 node
= node
->Next();
4237 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4239 if ( GetName() == name
)
4242 wxNode
*node
= GetChildren()->First();
4245 wxWindow
*child
= (wxWindow
*)node
->Data();
4246 wxWindow
*found
= child
->FindWindow(name
);
4249 node
= node
->Next();
4255 // Default input behaviour for a scrolling canvas should be to scroll
4256 // according to the cursor keys pressed
4257 void wxWindow::OnChar(wxKeyEvent& event)
4269 GetScrollUnitsPerPage(&x_page, &y_page);
4271 GetVirtualSize(&v_width,&v_height);
4273 ViewStart(&start_x, &start_y);
4276 y_pages = (int)(v_height/vert_units) - y_page;
4284 switch (event.keyCode)
4291 if (start_y - y_page > 0)
4292 Scroll(start_x, start_y - y_page);
4302 if ((y_page > 0) && (start_y <= y_pages-y-1))
4304 if (y_pages + y < start_y + y_page)
4305 Scroll(start_x, y_pages + y);
4307 Scroll(start_x, start_y + y_page);
4314 if ((y_page > 0) && (start_y >= 1))
4315 Scroll(start_x, start_y - 1);
4321 if ((y_page > 0) && (start_y <= y_pages-y-1))
4324 Scroll(start_x, start_y + 1);
4330 if ((x_page > 0) && (start_x >= 1))
4331 Scroll(start_x - 1, start_y);
4337 Scroll(start_x + 1, start_y);
4348 Scroll(start_x, y_pages+y);
4356 // Setup background and foreground colours correctly
4357 void wxWindow::SetupColours(void)
4360 SetBackgroundColour(GetParent()->GetBackgroundColour());
4363 void wxWindow::OnIdle(wxIdleEvent
& event
)
4366 // Check if we need to send a LEAVE event
4367 if (m_mouseInWindow
)
4370 ::GetCursorPos(&pt
);
4371 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4373 // Generate a LEAVE event
4374 m_mouseInWindow
= FALSE
;
4375 MSWOnMouseLeave(pt
.x
, pt
.y
, 0);
4382 // Raise the window to the top of the Z order
4383 void wxWindow::Raise(void)
4385 ::BringWindowToTop((HWND
) GetHWND());
4388 // Lower the window to the bottom of the Z order
4389 void wxWindow::Lower(void)
4391 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4394 long wxWindow::MSWGetDlgCode()
4396 // default: just forward to def window proc (the msg has no parameters)
4397 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4400 bool wxWindow::AcceptsFocus() const
4402 return IsShown() && IsEnabled();
4405 // Update region access
4406 wxRegion
wxWindow::GetUpdateRegion() const
4408 return m_updateRegion
;
4411 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4413 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4416 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4418 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4421 bool wxWindow::IsExposed(const wxRect
& rect
) const
4423 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4427 const char *wxGetMessageName(int message
)
4429 switch ( message
) {
4430 case 0x0000: return "WM_NULL";
4431 case 0x0001: return "WM_CREATE";
4432 case 0x0002: return "WM_DESTROY";
4433 case 0x0003: return "WM_MOVE";
4434 case 0x0005: return "WM_SIZE";
4435 case 0x0006: return "WM_ACTIVATE";
4436 case 0x0007: return "WM_SETFOCUS";
4437 case 0x0008: return "WM_KILLFOCUS";
4438 case 0x000A: return "WM_ENABLE";
4439 case 0x000B: return "WM_SETREDRAW";
4440 case 0x000C: return "WM_SETTEXT";
4441 case 0x000D: return "WM_GETTEXT";
4442 case 0x000E: return "WM_GETTEXTLENGTH";
4443 case 0x000F: return "WM_PAINT";
4444 case 0x0010: return "WM_CLOSE";
4445 case 0x0011: return "WM_QUERYENDSESSION";
4446 case 0x0012: return "WM_QUIT";
4447 case 0x0013: return "WM_QUERYOPEN";
4448 case 0x0014: return "WM_ERASEBKGND";
4449 case 0x0015: return "WM_SYSCOLORCHANGE";
4450 case 0x0016: return "WM_ENDSESSION";
4451 case 0x0017: return "WM_SYSTEMERROR";
4452 case 0x0018: return "WM_SHOWWINDOW";
4453 case 0x0019: return "WM_CTLCOLOR";
4454 case 0x001A: return "WM_WININICHANGE";
4455 case 0x001B: return "WM_DEVMODECHANGE";
4456 case 0x001C: return "WM_ACTIVATEAPP";
4457 case 0x001D: return "WM_FONTCHANGE";
4458 case 0x001E: return "WM_TIMECHANGE";
4459 case 0x001F: return "WM_CANCELMODE";
4460 case 0x0020: return "WM_SETCURSOR";
4461 case 0x0021: return "WM_MOUSEACTIVATE";
4462 case 0x0022: return "WM_CHILDACTIVATE";
4463 case 0x0023: return "WM_QUEUESYNC";
4464 case 0x0024: return "WM_GETMINMAXINFO";
4465 case 0x0026: return "WM_PAINTICON";
4466 case 0x0027: return "WM_ICONERASEBKGND";
4467 case 0x0028: return "WM_NEXTDLGCTL";
4468 case 0x002A: return "WM_SPOOLERSTATUS";
4469 case 0x002B: return "WM_DRAWITEM";
4470 case 0x002C: return "WM_MEASUREITEM";
4471 case 0x002D: return "WM_DELETEITEM";
4472 case 0x002E: return "WM_VKEYTOITEM";
4473 case 0x002F: return "WM_CHARTOITEM";
4474 case 0x0030: return "WM_SETFONT";
4475 case 0x0031: return "WM_GETFONT";
4476 case 0x0037: return "WM_QUERYDRAGICON";
4477 case 0x0039: return "WM_COMPAREITEM";
4478 case 0x0041: return "WM_COMPACTING";
4479 case 0x0044: return "WM_COMMNOTIFY";
4480 case 0x0046: return "WM_WINDOWPOSCHANGING";
4481 case 0x0047: return "WM_WINDOWPOSCHANGED";
4482 case 0x0048: return "WM_POWER";
4485 case 0x004A: return "WM_COPYDATA";
4486 case 0x004B: return "WM_CANCELJOURNAL";
4487 case 0x004E: return "WM_NOTIFY";
4488 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4489 case 0x0051: return "WM_INPUTLANGCHANGE";
4490 case 0x0052: return "WM_TCARD";
4491 case 0x0053: return "WM_HELP";
4492 case 0x0054: return "WM_USERCHANGED";
4493 case 0x0055: return "WM_NOTIFYFORMAT";
4494 case 0x007B: return "WM_CONTEXTMENU";
4495 case 0x007C: return "WM_STYLECHANGING";
4496 case 0x007D: return "WM_STYLECHANGED";
4497 case 0x007E: return "WM_DISPLAYCHANGE";
4498 case 0x007F: return "WM_GETICON";
4499 case 0x0080: return "WM_SETICON";
4502 case 0x0081: return "WM_NCCREATE";
4503 case 0x0082: return "WM_NCDESTROY";
4504 case 0x0083: return "WM_NCCALCSIZE";
4505 case 0x0084: return "WM_NCHITTEST";
4506 case 0x0085: return "WM_NCPAINT";
4507 case 0x0086: return "WM_NCACTIVATE";
4508 case 0x0087: return "WM_GETDLGCODE";
4509 case 0x00A0: return "WM_NCMOUSEMOVE";
4510 case 0x00A1: return "WM_NCLBUTTONDOWN";
4511 case 0x00A2: return "WM_NCLBUTTONUP";
4512 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4513 case 0x00A4: return "WM_NCRBUTTONDOWN";
4514 case 0x00A5: return "WM_NCRBUTTONUP";
4515 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4516 case 0x00A7: return "WM_NCMBUTTONDOWN";
4517 case 0x00A8: return "WM_NCMBUTTONUP";
4518 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4519 case 0x0100: return "WM_KEYDOWN";
4520 case 0x0101: return "WM_KEYUP";
4521 case 0x0102: return "WM_CHAR";
4522 case 0x0103: return "WM_DEADCHAR";
4523 case 0x0104: return "WM_SYSKEYDOWN";
4524 case 0x0105: return "WM_SYSKEYUP";
4525 case 0x0106: return "WM_SYSCHAR";
4526 case 0x0107: return "WM_SYSDEADCHAR";
4527 case 0x0108: return "WM_KEYLAST";
4530 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4531 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4532 case 0x010F: return "WM_IME_COMPOSITION";
4535 case 0x0110: return "WM_INITDIALOG";
4536 case 0x0111: return "WM_COMMAND";
4537 case 0x0112: return "WM_SYSCOMMAND";
4538 case 0x0113: return "WM_TIMER";
4539 case 0x0114: return "WM_HSCROLL";
4540 case 0x0115: return "WM_VSCROLL";
4541 case 0x0116: return "WM_INITMENU";
4542 case 0x0117: return "WM_INITMENUPOPUP";
4543 case 0x011F: return "WM_MENUSELECT";
4544 case 0x0120: return "WM_MENUCHAR";
4545 case 0x0121: return "WM_ENTERIDLE";
4546 case 0x0200: return "WM_MOUSEMOVE";
4547 case 0x0201: return "WM_LBUTTONDOWN";
4548 case 0x0202: return "WM_LBUTTONUP";
4549 case 0x0203: return "WM_LBUTTONDBLCLK";
4550 case 0x0204: return "WM_RBUTTONDOWN";
4551 case 0x0205: return "WM_RBUTTONUP";
4552 case 0x0206: return "WM_RBUTTONDBLCLK";
4553 case 0x0207: return "WM_MBUTTONDOWN";
4554 case 0x0208: return "WM_MBUTTONUP";
4555 case 0x0209: return "WM_MBUTTONDBLCLK";
4556 case 0x0210: return "WM_PARENTNOTIFY";
4557 case 0x0211: return "WM_ENTERMENULOOP";
4558 case 0x0212: return "WM_EXITMENULOOP";
4561 case 0x0213: return "WM_NEXTMENU";
4562 case 0x0214: return "WM_SIZING";
4563 case 0x0215: return "WM_CAPTURECHANGED";
4564 case 0x0216: return "WM_MOVING";
4565 case 0x0218: return "WM_POWERBROADCAST";
4566 case 0x0219: return "WM_DEVICECHANGE";
4569 case 0x0220: return "WM_MDICREATE";
4570 case 0x0221: return "WM_MDIDESTROY";
4571 case 0x0222: return "WM_MDIACTIVATE";
4572 case 0x0223: return "WM_MDIRESTORE";
4573 case 0x0224: return "WM_MDINEXT";
4574 case 0x0225: return "WM_MDIMAXIMIZE";
4575 case 0x0226: return "WM_MDITILE";
4576 case 0x0227: return "WM_MDICASCADE";
4577 case 0x0228: return "WM_MDIICONARRANGE";
4578 case 0x0229: return "WM_MDIGETACTIVE";
4579 case 0x0230: return "WM_MDISETMENU";
4580 case 0x0233: return "WM_DROPFILES";
4583 case 0x0281: return "WM_IME_SETCONTEXT";
4584 case 0x0282: return "WM_IME_NOTIFY";
4585 case 0x0283: return "WM_IME_CONTROL";
4586 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4587 case 0x0285: return "WM_IME_SELECT";
4588 case 0x0286: return "WM_IME_CHAR";
4589 case 0x0290: return "WM_IME_KEYDOWN";
4590 case 0x0291: return "WM_IME_KEYUP";
4593 case 0x0300: return "WM_CUT";
4594 case 0x0301: return "WM_COPY";
4595 case 0x0302: return "WM_PASTE";
4596 case 0x0303: return "WM_CLEAR";
4597 case 0x0304: return "WM_UNDO";
4598 case 0x0305: return "WM_RENDERFORMAT";
4599 case 0x0306: return "WM_RENDERALLFORMATS";
4600 case 0x0307: return "WM_DESTROYCLIPBOARD";
4601 case 0x0308: return "WM_DRAWCLIPBOARD";
4602 case 0x0309: return "WM_PAINTCLIPBOARD";
4603 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4604 case 0x030B: return "WM_SIZECLIPBOARD";
4605 case 0x030C: return "WM_ASKCBFORMATNAME";
4606 case 0x030D: return "WM_CHANGECBCHAIN";
4607 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4608 case 0x030F: return "WM_QUERYNEWPALETTE";
4609 case 0x0310: return "WM_PALETTEISCHANGING";
4610 case 0x0311: return "WM_PALETTECHANGED";
4613 // common controls messages - although they're not strictly speaking
4614 // standard, it's nice to decode them nevertheless
4617 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4618 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4619 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4620 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4621 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4622 case 0x1000 + 5: return "LVM_GETITEMA";
4623 case 0x1000 + 75: return "LVM_GETITEMW";
4624 case 0x1000 + 6: return "LVM_SETITEMA";
4625 case 0x1000 + 76: return "LVM_SETITEMW";
4626 case 0x1000 + 7: return "LVM_INSERTITEMA";
4627 case 0x1000 + 77: return "LVM_INSERTITEMW";
4628 case 0x1000 + 8: return "LVM_DELETEITEM";
4629 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4630 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4631 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4632 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4633 case 0x1000 + 13: return "LVM_FINDITEMA";
4634 case 0x1000 + 83: return "LVM_FINDITEMW";
4635 case 0x1000 + 14: return "LVM_GETITEMRECT";
4636 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4637 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4638 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4639 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4640 case 0x1000 + 18: return "LVM_HITTEST";
4641 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4642 case 0x1000 + 20: return "LVM_SCROLL";
4643 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4644 case 0x1000 + 22: return "LVM_ARRANGE";
4645 case 0x1000 + 23: return "LVM_EDITLABELA";
4646 case 0x1000 + 118: return "LVM_EDITLABELW";
4647 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4648 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4649 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4650 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4651 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4652 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4653 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4654 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4655 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4656 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4657 case 0x1000 + 31: return "LVM_GETHEADER";
4658 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4659 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4660 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4661 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4662 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4663 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4664 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4665 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4666 case 0x1000 + 41: return "LVM_GETORIGIN";
4667 case 0x1000 + 42: return "LVM_UPDATE";
4668 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4669 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4670 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4671 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4672 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4673 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4674 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4675 case 0x1000 + 48: return "LVM_SORTITEMS";
4676 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4677 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4678 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4679 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4680 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4681 case 0x1000 + 53: return "LVM_SETICONSPACING";
4682 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4683 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4684 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4685 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4686 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4687 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4688 case 0x1000 + 60: return "LVM_SETHOTITEM";
4689 case 0x1000 + 61: return "LVM_GETHOTITEM";
4690 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4691 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4692 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4693 case 0x1000 + 65: return "LVM_SETWORKAREA";
4696 case 0x1100 + 0: return "TVM_INSERTITEMA";
4697 case 0x1100 + 50: return "TVM_INSERTITEMW";
4698 case 0x1100 + 1: return "TVM_DELETEITEM";
4699 case 0x1100 + 2: return "TVM_EXPAND";
4700 case 0x1100 + 4: return "TVM_GETITEMRECT";
4701 case 0x1100 + 5: return "TVM_GETCOUNT";
4702 case 0x1100 + 6: return "TVM_GETINDENT";
4703 case 0x1100 + 7: return "TVM_SETINDENT";
4704 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4705 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4706 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4707 case 0x1100 + 11: return "TVM_SELECTITEM";
4708 case 0x1100 + 12: return "TVM_GETITEMA";
4709 case 0x1100 + 62: return "TVM_GETITEMW";
4710 case 0x1100 + 13: return "TVM_SETITEMA";
4711 case 0x1100 + 63: return "TVM_SETITEMW";
4712 case 0x1100 + 14: return "TVM_EDITLABELA";
4713 case 0x1100 + 65: return "TVM_EDITLABELW";
4714 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4715 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4716 case 0x1100 + 17: return "TVM_HITTEST";
4717 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4718 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4719 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4720 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4721 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4722 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4723 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4724 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4725 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4728 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4729 case 0x1200 + 1: return "HDM_INSERTITEMA";
4730 case 0x1200 + 10: return "HDM_INSERTITEMW";
4731 case 0x1200 + 2: return "HDM_DELETEITEM";
4732 case 0x1200 + 3: return "HDM_GETITEMA";
4733 case 0x1200 + 11: return "HDM_GETITEMW";
4734 case 0x1200 + 4: return "HDM_SETITEMA";
4735 case 0x1200 + 12: return "HDM_SETITEMW";
4736 case 0x1200 + 5: return "HDM_LAYOUT";
4737 case 0x1200 + 6: return "HDM_HITTEST";
4738 case 0x1200 + 7: return "HDM_GETITEMRECT";
4739 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4740 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4741 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4742 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4743 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4744 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4745 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4748 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4749 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4750 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4751 case 0x1300 + 5: return "TCM_GETITEMA";
4752 case 0x1300 + 60: return "TCM_GETITEMW";
4753 case 0x1300 + 6: return "TCM_SETITEMA";
4754 case 0x1300 + 61: return "TCM_SETITEMW";
4755 case 0x1300 + 7: return "TCM_INSERTITEMA";
4756 case 0x1300 + 62: return "TCM_INSERTITEMW";
4757 case 0x1300 + 8: return "TCM_DELETEITEM";
4758 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4759 case 0x1300 + 10: return "TCM_GETITEMRECT";
4760 case 0x1300 + 11: return "TCM_GETCURSEL";
4761 case 0x1300 + 12: return "TCM_SETCURSEL";
4762 case 0x1300 + 13: return "TCM_HITTEST";
4763 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4764 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4765 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4766 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4767 case 0x1300 + 43: return "TCM_SETPADDING";
4768 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4769 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4770 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4771 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4772 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4773 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4774 case 0x1300 + 50: return "TCM_DESELECTALL";
4777 case WM_USER
+1: return "TB_ENABLEBUTTON";
4778 case WM_USER
+2: return "TB_CHECKBUTTON";
4779 case WM_USER
+3: return "TB_PRESSBUTTON";
4780 case WM_USER
+4: return "TB_HIDEBUTTON";
4781 case WM_USER
+5: return "TB_INDETERMINATE";
4782 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4783 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4784 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4785 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4786 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4787 case WM_USER
+17: return "TB_SETSTATE";
4788 case WM_USER
+18: return "TB_GETSTATE";
4789 case WM_USER
+19: return "TB_ADDBITMAP";
4790 case WM_USER
+20: return "TB_ADDBUTTONS";
4791 case WM_USER
+21: return "TB_INSERTBUTTON";
4792 case WM_USER
+22: return "TB_DELETEBUTTON";
4793 case WM_USER
+23: return "TB_GETBUTTON";
4794 case WM_USER
+24: return "TB_BUTTONCOUNT";
4795 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4796 case WM_USER
+26: return "TB_SAVERESTOREA";
4797 case WM_USER
+76: return "TB_SAVERESTOREW";
4798 case WM_USER
+27: return "TB_CUSTOMIZE";
4799 case WM_USER
+28: return "TB_ADDSTRINGA";
4800 case WM_USER
+77: return "TB_ADDSTRINGW";
4801 case WM_USER
+29: return "TB_GETITEMRECT";
4802 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4803 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4804 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4805 case WM_USER
+33: return "TB_AUTOSIZE";
4806 case WM_USER
+35: return "TB_GETTOOLTIPS";
4807 case WM_USER
+36: return "TB_SETTOOLTIPS";
4808 case WM_USER
+37: return "TB_SETPARENT";
4809 case WM_USER
+39: return "TB_SETROWS";
4810 case WM_USER
+40: return "TB_GETROWS";
4811 case WM_USER
+42: return "TB_SETCMDID";
4812 case WM_USER
+43: return "TB_CHANGEBITMAP";
4813 case WM_USER
+44: return "TB_GETBITMAP";
4814 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4815 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4816 case WM_USER
+46: return "TB_REPLACEBITMAP";
4817 case WM_USER
+47: return "TB_SETINDENT";
4818 case WM_USER
+48: return "TB_SETIMAGELIST";
4819 case WM_USER
+49: return "TB_GETIMAGELIST";
4820 case WM_USER
+50: return "TB_LOADIMAGES";
4821 case WM_USER
+51: return "TB_GETRECT";
4822 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4823 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4824 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4825 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4826 case WM_USER
+56: return "TB_SETSTYLE";
4827 case WM_USER
+57: return "TB_GETSTYLE";
4828 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4829 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4830 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4831 case WM_USER
+61: return "TB_GETTEXTROWS";
4832 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4837 static char s_szBuf
[128];
4838 sprintf(s_szBuf
, "<unknown message = %d>", message
);