1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include "wx/dcclient.h"
32 #include "wx/layout.h"
33 #include "wx/dialog.h"
35 #include "wx/listbox.h"
36 #include "wx/button.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
42 #include "wx/ownerdrw.h"
45 #if wxUSE_DRAG_AND_DROP
46 #include "wx/msw/ole/droptgt.h"
49 #include "wx/menuitem.h"
51 #include "wx/msw/private.h"
66 #include <wx/msw/gnuwin32/extra.h>
87 const char *wxGetMessageName(int message
);
90 #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
92 wxMenu
*wxCurrentPopupMenu
= NULL
;
93 extern wxList WXDLLEXPORT wxPendingDelete
;
95 void wxRemoveHandleAssociation(wxWindow
*win
);
96 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
97 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
);
99 #if !USE_SHARED_LIBRARY
100 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxEvtHandler
)
103 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
104 EVT_CHAR(wxWindow::OnChar
)
105 EVT_KEY_DOWN(wxWindow::OnKeyDown
)
106 EVT_KEY_UP(wxWindow::OnKeyUp
)
107 EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground
)
108 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
109 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
110 EVT_IDLE(wxWindow::OnIdle
)
113 // Find an item given the MS Windows id
114 wxWindow
*wxWindow::FindItem(int id
) const
116 // if (!GetChildren())
118 wxNode
*current
= GetChildren().First();
121 wxWindow
*childWin
= (wxWindow
*)current
->Data();
123 wxWindow
*wnd
= childWin
->FindItem(id
) ;
127 if (childWin
->IsKindOf(CLASSINFO(wxControl
)))
129 wxControl
*item
= (wxControl
*)childWin
;
130 if (item
->GetId() == id
)
134 // In case it's a 'virtual' control (e.g. radiobox)
135 if (item
->GetSubcontrols().Member((wxObject
*)id
))
139 current
= current
->Next();
144 // Find an item given the MS Windows handle
145 wxWindow
*wxWindow::FindItemByHWND(WXHWND hWnd
, bool controlOnly
) const
147 // if (!GetChildren())
149 wxNode
*current
= GetChildren().First();
152 wxObject
*obj
= (wxObject
*)current
->Data() ;
153 // Do a recursive search.
154 wxWindow
*parent
= (wxWindow
*)obj
;
155 wxWindow
*wnd
= parent
->FindItemByHWND(hWnd
) ;
159 if ((!controlOnly
) || obj
->IsKindOf(CLASSINFO(wxControl
)))
161 wxWindow
*item
= (wxWindow
*)current
->Data();
162 if ((HWND
)(item
->GetHWND()) == (HWND
) hWnd
)
166 if ( item
->ContainsHWND(hWnd
) )
170 current
= current
->Next();
175 // Default command handler
176 bool wxWindow::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
181 bool wxWindow::MSWNotify(WXWPARAM
WXUNUSED(wParam
),
182 WXLPARAM
WXUNUSED(lParam
),
183 WXLPARAM
* WXUNUSED(result
))
188 void wxWindow::PreDelete(WXHDC
WXUNUSED(dc
))
192 WXHWND
wxWindow::GetHWND(void) const
194 return (WXHWND
) m_hWnd
;
197 void wxWindow::SetHWND(WXHWND hWnd
)
202 // ----------------------------------------------------------------------------
203 // constructors and such
204 // ----------------------------------------------------------------------------
206 void wxWindow::Init()
212 m_windowParent
= NULL
;
213 m_windowEventHandler
= this;
214 m_windowCursor
= *wxSTANDARD_CURSOR
;
215 m_children
= new wxList
;
216 m_doubleClickAllowed
= 0 ;
217 m_winCaptured
= FALSE
;
218 m_constraints
= NULL
;
219 m_constraintsInvolvedIn
= NULL
;
220 m_windowSizer
= NULL
;
221 m_sizerParent
= NULL
;
222 m_autoLayout
= FALSE
;
223 m_windowValidator
= NULL
;
228 m_caretWidth
= m_caretHeight
= 0;
230 m_caretShown
= FALSE
;
237 m_isBeingDeleted
= FALSE
;
243 m_mouseInWindow
= FALSE
;
245 m_windowParent
= NULL
;
246 m_defaultItem
= NULL
;
248 wxSystemSettings settings
;
250 m_backgroundColour
= settings
.GetSystemColour(wxSYS_COLOUR_3DFACE
) ;
251 m_foregroundColour
= *wxBLACK
;
261 m_backgroundTransparent
= FALSE
;
263 m_lastXPos
= (float)-1.0;
264 m_lastYPos
= (float)-1.0;
268 #if wxUSE_DRAG_AND_DROP
269 m_pDropTarget
= NULL
;
279 wxWindow::~wxWindow()
281 m_isBeingDeleted
= TRUE
;
283 // JACS - if behaviour is odd, restore this
284 // to the start of ~wxWindow. Vadim has changed
285 // it to nearer the end. Unsure of side-effects
286 // e.g. when deleting associated global data.
287 // Restore old Window proc, if required
290 // Have to delete constraints/sizer FIRST otherwise
291 // sizers may try to look at deleted windows as they
292 // delete themselves.
293 #if wxUSE_CONSTRAINTS
294 DeleteRelatedConstraints();
297 // This removes any dangling pointers to this window
298 // in other windows' constraintsInvolvedIn lists.
299 UnsetConstraints(m_constraints
);
300 delete m_constraints
;
301 m_constraints
= NULL
;
305 delete m_windowSizer
;
306 m_windowSizer
= NULL
;
308 // If this is a child of a sizer, remove self from parent
310 m_sizerParent
->RemoveChild((wxWindow
*)this);
314 MSWDetachWindowMenu();
317 m_windowParent
->RemoveChild(this);
322 ::DestroyWindow((HWND
)m_hWnd
);
324 wxRemoveHandleAssociation(this);
329 GlobalFree((HGLOBAL
) m_globalHandle
);
337 // Just in case the window has been Closed, but
338 // we're then deleting immediately: don't leave
339 // dangling pointers.
340 wxPendingDelete
.DeleteObject(this);
342 // Just in case we've loaded a top-level window via
343 // wxWindow::LoadNativeDialog but we weren't a dialog
345 wxTopLevelWindows
.DeleteObject(this);
347 if ( m_windowValidator
)
348 delete m_windowValidator
;
350 // Restore old Window proc, if required
351 // and remove hWnd <-> wxWindow association
355 // Destroy the window (delayed, if a managed window)
356 bool wxWindow::Destroy()
362 extern char wxCanvasClassName
[];
364 // real construction (Init() must have been called before!)
365 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
369 const wxString
& name
)
371 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
373 parent
->AddChild(this);
378 m_windowId
= (int)NewControlId();
387 // To be consistent with wxGTK
393 wxSystemSettings settings
;
395 m_windowStyle
= style
;
398 if (style
& wxBORDER
)
399 msflags
|= WS_BORDER
;
400 if (style
& wxTHICK_FRAME
)
401 msflags
|= WS_THICKFRAME
;
403 msflags
|= WS_CHILD
| WS_VISIBLE
;
404 if (style
& wxCLIP_CHILDREN
)
405 msflags
|= WS_CLIPCHILDREN
;
408 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
410 // Even with extended styles, need to combine with WS_BORDER
411 // for them to look right.
412 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
413 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
414 msflags
|= WS_BORDER
;
416 MSWCreate(m_windowId
, parent
, wxCanvasClassName
, this, NULL
,
417 x
, y
, width
, height
, msflags
, NULL
, exStyle
);
422 void wxWindow::SetFocus()
424 HWND hWnd
= (HWND
) GetHWND();
429 void wxWindow::Enable(bool enable
)
431 m_winEnabled
= enable
;
432 HWND hWnd
= (HWND
) GetHWND();
434 ::EnableWindow(hWnd
, (BOOL
)enable
);
437 void wxWindow::CaptureMouse()
439 HWND hWnd
= (HWND
) GetHWND();
440 if (hWnd
&& !m_winCaptured
)
443 m_winCaptured
= TRUE
;
447 void wxWindow::ReleaseMouse()
452 m_winCaptured
= FALSE
;
456 void wxWindow::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
458 m_acceleratorTable
= accel
;
462 // Push/pop event handler (i.e. allow a chain of event handlers
464 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
466 handler
->SetNextHandler(GetEventHandler());
467 SetEventHandler(handler
);
470 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
472 if ( GetEventHandler() )
474 wxEvtHandler
*handlerA
= GetEventHandler();
475 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
476 handlerA
->SetNextHandler(NULL
);
477 SetEventHandler(handlerB
);
490 #if wxUSE_DRAG_AND_DROP
492 void wxWindow::SetDropTarget(wxDropTarget
*pDropTarget
)
494 if ( m_pDropTarget
!= 0 ) {
495 m_pDropTarget
->Revoke(m_hWnd
);
496 delete m_pDropTarget
;
499 m_pDropTarget
= pDropTarget
;
500 if ( m_pDropTarget
!= 0 )
501 m_pDropTarget
->Register(m_hWnd
);
506 //old style file-manager drag&drop support
507 // I think we should retain the old-style
508 // DragAcceptFiles in parallel with SetDropTarget.
510 void wxWindow::DragAcceptFiles(bool accept
)
512 HWND hWnd
= (HWND
) GetHWND();
514 ::DragAcceptFiles(hWnd
, (BOOL
)accept
);
518 void wxWindow::GetSize(int *x
, int *y
) const
520 HWND hWnd
= (HWND
) GetHWND();
522 GetWindowRect(hWnd
, &rect
);
523 *x
= rect
.right
- rect
.left
;
524 *y
= rect
.bottom
- rect
.top
;
527 void wxWindow::GetPosition(int *x
, int *y
) const
529 HWND hWnd
= (HWND
) GetHWND();
532 hParentWnd
= (HWND
) GetParent()->GetHWND();
535 GetWindowRect(hWnd
, &rect
);
537 // Since we now have the absolute screen coords,
538 // if there's a parent we must subtract its top left corner
544 ::ScreenToClient(hParentWnd
, &point
);
547 // We may be faking the client origin.
548 // So a window that's really at (0, 30) may appear
549 // (to wxWin apps) to be at (0, 0).
552 wxPoint
pt(GetParent()->GetClientAreaOrigin());
560 void wxWindow::ScreenToClient(int *x
, int *y
) const
562 HWND hWnd
= (HWND
) GetHWND();
567 ::ScreenToClient(hWnd
, &pt
);
573 void wxWindow::ClientToScreen(int *x
, int *y
) const
575 HWND hWnd
= (HWND
) GetHWND();
580 ::ClientToScreen(hWnd
, &pt
);
586 void wxWindow::SetCursor(const wxCursor
& cursor
)
588 m_windowCursor
= cursor
;
589 if (m_windowCursor
.Ok())
591 HWND hWnd
= (HWND
) GetHWND();
593 // Change the cursor NOW if we're within the correct window
595 ::GetCursorPos(&point
);
598 ::GetWindowRect(hWnd
, &rect
);
600 if (::PtInRect(&rect
, point
) && !wxIsBusy())
601 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
604 // This will cause big reentrancy problems if wxFlushEvents is implemented.
606 // return old_cursor;
610 // Get size *available for subwindows* i.e. excluding menu bar etc.
611 void wxWindow::GetClientSize(int *x
, int *y
) const
613 HWND hWnd
= (HWND
) GetHWND();
615 GetClientRect(hWnd
, &rect
);
620 void wxWindow::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
622 int currentX
, currentY
;
623 GetPosition(¤tX
, ¤tY
);
624 int currentW
,currentH
;
625 GetSize(¤tW
, ¤tH
);
627 if (x
== currentX
&& y
== currentY
&& width
== currentW
&& height
== currentH
)
630 int actualWidth
= width
;
631 int actualHeight
= height
;
634 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
636 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
639 AdjustForParentClientOrigin(actualX
, actualY
, sizeFlags
);
642 actualWidth
= currentW
;
644 actualHeight
= currentH
;
646 HWND hWnd
= (HWND
) GetHWND();
648 MoveWindow(hWnd
, actualX
, actualY
, actualWidth
, actualHeight
, (BOOL
)TRUE
);
651 void wxWindow::SetClientSize(int width
, int height
)
653 wxWindow
*parent
= GetParent();
654 HWND hWnd
= (HWND
) GetHWND();
655 HWND hParentWnd
= (HWND
) (HWND
) parent
->GetHWND();
658 GetClientRect(hWnd
, &rect
);
661 GetWindowRect(hWnd
, &rect2
);
663 // Find the difference between the entire window (title bar and all)
664 // and the client area; add this to the new client size to move the
666 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
667 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
669 // If there's a parent, must subtract the parent's top left corner
670 // since MoveWindow moves relative to the parent
673 point
.x
= rect2
.left
;
677 ::ScreenToClient(hParentWnd
, &point
);
680 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
682 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
683 event
.SetEventObject(this);
684 GetEventHandler()->ProcessEvent(event
);
687 // For implementation purposes - sometimes decorations make the client area
689 wxPoint
wxWindow::GetClientAreaOrigin() const
691 return wxPoint(0, 0);
694 // Makes an adjustment to the window position (for example, a frame that has
695 // a toolbar that it manages itself).
696 void wxWindow::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
698 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
700 wxPoint
pt(GetParent()->GetClientAreaOrigin());
701 x
+= pt
.x
; y
+= pt
.y
;
705 bool wxWindow::Show(bool show
)
707 HWND hWnd
= (HWND
) GetHWND();
713 ShowWindow(hWnd
, (BOOL
)cshow
);
716 BringWindowToTop(hWnd
);
717 // Next line causes a crash on NT, apparently.
718 // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency?
723 bool wxWindow::IsShown(void) const
725 return (::IsWindowVisible((HWND
) GetHWND()) != 0);
728 int wxWindow::GetCharHeight(void) const
730 TEXTMETRIC lpTextMetric
;
731 HWND hWnd
= (HWND
) GetHWND();
732 HDC dc
= ::GetDC(hWnd
);
734 GetTextMetrics(dc
, &lpTextMetric
);
735 ::ReleaseDC(hWnd
, dc
);
737 return lpTextMetric
.tmHeight
;
740 int wxWindow::GetCharWidth(void) const
742 TEXTMETRIC lpTextMetric
;
743 HWND hWnd
= (HWND
) GetHWND();
744 HDC dc
= ::GetDC(hWnd
);
746 GetTextMetrics(dc
, &lpTextMetric
);
747 ::ReleaseDC(hWnd
, dc
);
749 return lpTextMetric
.tmAveCharWidth
;
752 void wxWindow::GetTextExtent(const wxString
& string
, int *x
, int *y
,
753 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool) const
755 wxFont
*fontToUse
= (wxFont
*)theFont
;
757 fontToUse
= (wxFont
*) & m_windowFont
;
759 HWND hWnd
= (HWND
) GetHWND();
760 HDC dc
= ::GetDC(hWnd
);
764 if (fontToUse
&& fontToUse
->Ok())
766 fnt
= (HFONT
)fontToUse
->GetResourceHandle();
768 was
= (HFONT
) SelectObject(dc
,fnt
) ;
773 GetTextExtentPoint(dc
, (const char *)string
, (int)string
.Length(), &sizeRect
);
774 GetTextMetrics(dc
, &tm
);
776 if (fontToUse
&& fnt
&& was
)
777 SelectObject(dc
,was
) ;
783 if (descent
) *descent
= tm
.tmDescent
;
784 if (externalLeading
) *externalLeading
= tm
.tmExternalLeading
;
787 // fontToUse->ReleaseResource();
790 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
792 HWND hWnd
= (HWND
) GetHWND();
798 mswRect
.left
= rect
->x
;
799 mswRect
.top
= rect
->y
;
800 mswRect
.right
= rect
->x
+ rect
->width
;
801 mswRect
.bottom
= rect
->y
+ rect
->height
;
803 ::InvalidateRect(hWnd
, &mswRect
, eraseBack
);
806 ::InvalidateRect(hWnd
, NULL
, eraseBack
);
810 bool wxWindow::ProcessEvent(wxEvent
& event
)
812 // we save here the information about the last message because it might be
813 // overwritten if the event handler sends any messages to our window (case
814 // in point: wxNotebook::OnSize) - and then if we call Default() later
815 // (which is done quite often if the message is not processed) it will use
816 // incorrect values for m_lastXXX variables
817 WXUINT lastMsg
= m_lastMsg
;
818 WXWPARAM lastWParam
= m_lastWParam
;
819 WXLPARAM lastLParam
= m_lastLParam
;
821 // call the base version
822 bool bProcessed
= wxEvtHandler::ProcessEvent(event
);
826 m_lastWParam
= lastWParam
;
827 m_lastLParam
= lastLParam
;
832 // Hook for new window just as it's being created,
833 // when the window isn't yet associated with the handle
834 wxWindow
*wxWndHook
= NULL
;
837 LRESULT APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
839 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
841 if (!wnd
&& wxWndHook
)
843 wxAssociateWinWithHandle(hWnd
, wxWndHook
);
846 wnd
->m_hWnd
= (WXHWND
) hWnd
;
849 // Stop right here if we don't have a valid handle
850 // in our wxWnd object.
851 if (wnd
&& !wnd
->m_hWnd
) {
852 // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
853 wnd
->m_hWnd
= (WXHWND
) hWnd
;
854 long res
= wnd
->MSWDefWindowProc(message
, wParam
, lParam
);
860 wnd
->m_lastMsg
= message
;
861 wnd
->m_lastWParam
= wParam
;
862 wnd
->m_lastLParam
= lParam
;
865 return wnd
->MSWWindowProc(message
, wParam
, lParam
);
867 return DefWindowProc( hWnd
, message
, wParam
, lParam
);
870 // Should probably have a test for 'genuine' NT
871 #if defined(__WIN32__)
872 #define DIMENSION_TYPE short
874 #define DIMENSION_TYPE int
877 // Main Windows 3 window proc
878 long wxWindow::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
880 wxASSERT( m_lastMsg
== message
&&
881 m_lastWParam
== wParam
&& m_lastLParam
== lParam
);
884 wxLogTrace(wxTraceMessages
, "Processing %s(%lx, %lx)",
885 wxGetMessageName(message
), wParam
, lParam
);
886 #endif // __WXDEBUG__
888 HWND hWnd
= (HWND
)m_hWnd
;
895 WORD state
= LOWORD(wParam
);
896 WORD minimized
= HIWORD(wParam
);
897 HWND hwnd
= (HWND
)lParam
;
899 WORD state
= (WORD
)wParam
;
900 WORD minimized
= LOWORD(lParam
);
901 HWND hwnd
= (HWND
)HIWORD(lParam
);
903 MSWOnActivate(state
, (minimized
!= 0), (WXHWND
) hwnd
);
909 HWND hwnd
= (HWND
)wParam
;
910 // return OnSetFocus(hwnd);
912 if (MSWOnSetFocus((WXHWND
) hwnd
))
914 else return MSWDefWindowProc(message
, wParam
, lParam
);
919 HWND hwnd
= (HWND
)lParam
;
920 // return OnKillFocus(hwnd);
921 if (MSWOnKillFocus((WXHWND
) hwnd
))
924 return MSWDefWindowProc(message
, wParam
, lParam
);
929 MSWOnCreate((WXLPCREATESTRUCT
) (LPCREATESTRUCT
)lParam
);
935 MSWOnShow((wParam
!= 0), (int) lParam
);
942 else return MSWDefWindowProc(message
, wParam
, lParam
);
945 case WM_QUERYDRAGICON
:
947 HICON hIcon
= (HICON
)MSWOnQueryDragIcon();
951 return MSWDefWindowProc(message
, wParam
, lParam
);
957 int width
= LOWORD(lParam
);
958 int height
= HIWORD(lParam
);
959 MSWOnSize(width
, height
, wParam
);
965 wxMoveEvent
event(wxPoint(LOWORD(lParam
), HIWORD(lParam
)),
967 event
.SetEventObject(this);
968 if ( !GetEventHandler()->ProcessEvent(event
) )
973 case WM_WINDOWPOSCHANGING
:
975 MSWOnWindowPosChanging((void *)lParam
);
981 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
982 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
983 MSWOnRButtonDown(x
, y
, wParam
);
988 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
989 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
990 MSWOnRButtonUp(x
, y
, wParam
);
993 case WM_RBUTTONDBLCLK
:
995 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
996 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
997 MSWOnRButtonDClick(x
, y
, wParam
);
1000 case WM_MBUTTONDOWN
:
1002 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1003 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1004 MSWOnMButtonDown(x
, y
, wParam
);
1009 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1010 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1011 MSWOnMButtonUp(x
, y
, wParam
);
1014 case WM_MBUTTONDBLCLK
:
1016 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1017 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1018 MSWOnMButtonDClick(x
, y
, wParam
);
1021 case WM_LBUTTONDOWN
:
1023 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1024 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1025 MSWOnLButtonDown(x
, y
, wParam
);
1030 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1031 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1032 MSWOnLButtonUp(x
, y
, wParam
);
1035 case WM_LBUTTONDBLCLK
:
1037 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1038 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1039 MSWOnLButtonDClick(x
, y
, wParam
);
1044 int x
= (DIMENSION_TYPE
) LOWORD(lParam
);
1045 int y
= (DIMENSION_TYPE
) HIWORD(lParam
);
1046 MSWOnMouseMove(x
, y
, wParam
);
1049 case MM_JOY1BUTTONDOWN
:
1051 int x
= LOWORD(lParam
);
1052 int y
= HIWORD(lParam
);
1053 MSWOnJoyDown(wxJOYSTICK1
, x
, y
, wParam
);
1056 case MM_JOY2BUTTONDOWN
:
1058 int x
= LOWORD(lParam
);
1059 int y
= HIWORD(lParam
);
1060 MSWOnJoyDown(wxJOYSTICK2
, x
, y
, wParam
);
1063 case MM_JOY1BUTTONUP
:
1065 int x
= LOWORD(lParam
);
1066 int y
= HIWORD(lParam
);
1067 MSWOnJoyUp(wxJOYSTICK1
, x
, y
, wParam
);
1070 case MM_JOY2BUTTONUP
:
1072 int x
= LOWORD(lParam
);
1073 int y
= HIWORD(lParam
);
1074 MSWOnJoyUp(wxJOYSTICK2
, x
, y
, wParam
);
1079 int x
= LOWORD(lParam
);
1080 int y
= HIWORD(lParam
);
1081 MSWOnJoyMove(wxJOYSTICK1
, x
, y
, wParam
);
1086 int x
= LOWORD(lParam
);
1087 int y
= HIWORD(lParam
);
1088 MSWOnJoyMove(wxJOYSTICK2
, x
, y
, wParam
);
1093 int z
= LOWORD(lParam
);
1094 MSWOnJoyZMove(wxJOYSTICK1
, z
, wParam
);
1099 int z
= LOWORD(lParam
);
1100 MSWOnJoyZMove(wxJOYSTICK2
, z
, wParam
);
1107 else return MSWDefWindowProc(message
, wParam
, lParam
);
1112 return MSWOnSysCommand(wParam
, lParam
);
1118 WORD id
= LOWORD(wParam
);
1119 HWND hwnd
= (HWND
)lParam
;
1120 WORD cmd
= HIWORD(wParam
);
1122 WORD id
= (WORD
)wParam
;
1123 HWND hwnd
= (HWND
)LOWORD(lParam
) ;
1124 WORD cmd
= HIWORD(lParam
);
1126 if (!MSWOnCommand(id
, cmd
, (WXHWND
) hwnd
))
1127 return MSWDefWindowProc(message
, wParam
, lParam
);
1130 #if defined(__WIN95__)
1133 // for some messages (TVN_ITEMEXPANDING for example), the return
1134 // value of WM_NOTIFY handler is important, so don't just return 0
1135 // if we processed the message
1136 return MSWOnNotify(wParam
, lParam
);
1142 WORD flags
= HIWORD(wParam
);
1143 HMENU sysmenu
= (HMENU
)lParam
;
1145 WORD flags
= LOWORD(lParam
);
1146 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1148 MSWOnMenuHighlight((WORD
)wParam
, flags
, (WXHMENU
) sysmenu
);
1151 case WM_INITMENUPOPUP
:
1153 MSWOnInitMenuPopup((WXHMENU
) (HMENU
)wParam
, (int)LOWORD(lParam
), (HIWORD(lParam
) != 0));
1158 return MSWOnDrawItem((int)wParam
, (WXDRAWITEMSTRUCT
*)lParam
);
1161 case WM_MEASUREITEM
:
1163 return MSWOnMeasureItem((int)wParam
, (WXMEASUREITEMSTRUCT
*)lParam
);
1169 MSWOnKeyDown((WORD
) wParam
, lParam
);
1171 // we consider these message "not interesting"
1172 if ( wParam
== VK_SHIFT
|| wParam
== VK_CONTROL
)
1175 // Avoid duplicate messages to OnChar
1176 if ( (wParam
!= VK_ESCAPE
) && (wParam
!= VK_SPACE
) &&
1177 (wParam
!= VK_RETURN
) && (wParam
!= VK_BACK
) &&
1178 (wParam
!= VK_TAB
) )
1180 MSWOnChar((WORD
)wParam
, lParam
);
1181 if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1184 else if ( ::GetKeyState(VK_CONTROL
) & 0x100 )
1185 MSWOnChar((WORD
)wParam
, lParam
);
1194 MSWOnKeyUp((WORD
) wParam
, lParam
);
1197 case WM_CHAR
: // Always an ASCII character
1199 MSWOnChar((WORD
)wParam
, lParam
, TRUE
);
1206 WORD code
= LOWORD(wParam
);
1207 WORD pos
= HIWORD(wParam
);
1208 HWND control
= (HWND
)lParam
;
1210 WORD code
= (WORD
)wParam
;
1211 WORD pos
= LOWORD(lParam
);
1212 HWND control
= (HWND
)HIWORD(lParam
);
1214 MSWOnHScroll(code
, pos
, (WXHWND
) control
);
1220 WORD code
= LOWORD(wParam
);
1221 WORD pos
= HIWORD(wParam
);
1222 HWND control
= (HWND
)lParam
;
1224 WORD code
= (WORD
)wParam
;
1225 WORD pos
= LOWORD(lParam
);
1226 HWND control
= (HWND
)HIWORD(lParam
);
1228 MSWOnVScroll(code
, pos
, (WXHWND
) control
);
1232 case WM_CTLCOLORBTN
:
1234 int nCtlColor
= CTLCOLOR_BTN
;
1235 HWND control
= (HWND
)lParam
;
1236 HDC pDC
= (HDC
)wParam
;
1237 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1238 message
, wParam
, lParam
);
1241 case WM_CTLCOLORDLG
:
1243 int nCtlColor
= CTLCOLOR_DLG
;
1244 HWND control
= (HWND
)lParam
;
1245 HDC pDC
= (HDC
)wParam
;
1246 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1247 message
, wParam
, lParam
);\
1250 case WM_CTLCOLORLISTBOX
:
1252 int nCtlColor
= CTLCOLOR_LISTBOX
;
1253 HWND control
= (HWND
)lParam
;
1254 HDC pDC
= (HDC
)wParam
;
1255 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1256 message
, wParam
, lParam
);
1259 case WM_CTLCOLORMSGBOX
:
1261 int nCtlColor
= CTLCOLOR_MSGBOX
;
1262 HWND control
= (HWND
)lParam
;
1263 HDC pDC
= (HDC
)wParam
;
1264 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1265 message
, wParam
, lParam
);
1268 case WM_CTLCOLORSCROLLBAR
:
1270 int nCtlColor
= CTLCOLOR_SCROLLBAR
;
1271 HWND control
= (HWND
)lParam
;
1272 HDC pDC
= (HDC
)wParam
;
1273 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1274 message
, wParam
, lParam
);
1277 case WM_CTLCOLORSTATIC
:
1279 int nCtlColor
= CTLCOLOR_STATIC
;
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_CTLCOLOREDIT
:
1288 int nCtlColor
= CTLCOLOR_EDIT
;
1289 HWND control
= (HWND
)lParam
;
1290 HDC pDC
= (HDC
)wParam
;
1291 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1292 message
, wParam
, lParam
);
1298 HWND control
= (HWND
)LOWORD(lParam
);
1299 int nCtlColor
= (int)HIWORD(lParam
);
1300 HDC pDC
= (HDC
)wParam
;
1301 return (DWORD
)MSWOnCtlColor((WXHDC
) pDC
, (WXHWND
) control
, nCtlColor
,
1302 message
, wParam
, lParam
);
1306 case WM_SYSCOLORCHANGE
:
1308 // Return value of 0 means, we processed it.
1309 if (MSWOnColorChange((WXHWND
) hWnd
, message
, wParam
, lParam
) == 0)
1312 return MSWDefWindowProc(message
, wParam
, lParam
);
1315 case WM_PALETTECHANGED
:
1317 return MSWOnPaletteChanged((WXHWND
) (HWND
) wParam
);
1320 case WM_QUERYNEWPALETTE
:
1322 return MSWOnQueryNewPalette();
1327 // Prevents flicker when dragging
1328 if (IsIconic(hWnd
)) return 1;
1330 if (!MSWOnEraseBkgnd((WXHDC
) (HDC
)wParam
))
1331 return 0; // Default(); MSWDefWindowProc(message, wParam, lParam );
1335 case WM_MDIACTIVATE
:
1338 HWND hWndActivate
= GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam
,lParam
);
1339 HWND hWndDeactivate
= GET_WM_MDIACTIVATE_HWNDDEACT(wParam
,lParam
);
1340 BOOL activate
= GET_WM_MDIACTIVATE_FACTIVATE(hWnd
,wParam
,lParam
);
1341 return MSWOnMDIActivate((long) activate
, (WXHWND
) hWndActivate
, (WXHWND
) hWndDeactivate
);
1343 return MSWOnMDIActivate((BOOL
)wParam
, (HWND
)LOWORD(lParam
),
1344 (HWND
)HIWORD(lParam
));
1349 MSWOnDropFiles(wParam
);
1354 return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam);
1357 case WM_QUERYENDSESSION
:
1359 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1360 // return MSWOnClose();
1362 return MSWOnQueryEndSession(lParam
);
1367 // Same as WM_CLOSE, but inverted results. Thx Microsoft :-)
1368 MSWOnEndSession((wParam
!= 0), lParam
);
1381 case WM_GETMINMAXINFO
:
1383 MINMAXINFO
*info
= (MINMAXINFO
*)lParam
;
1384 if (m_minSizeX
!= -1)
1385 info
->ptMinTrackSize
.x
= (int)m_minSizeX
;
1386 if (m_minSizeY
!= -1)
1387 info
->ptMinTrackSize
.y
= (int)m_minSizeY
;
1388 if (m_maxSizeX
!= -1)
1389 info
->ptMaxTrackSize
.x
= (int)m_maxSizeX
;
1390 if (m_maxSizeY
!= -1)
1391 info
->ptMaxTrackSize
.y
= (int)m_maxSizeY
;
1392 return MSWDefWindowProc(message
, wParam
, lParam
);
1397 return MSWGetDlgCode();
1400 return MSWDefWindowProc(message
, wParam
, lParam
);
1402 return 0; // Success: we processed this command.
1405 // Dialog window proc
1406 LONG APIENTRY _EXPORT
1407 wxDlgProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1412 wxList
*wxWinHandleList
= NULL
;
1413 wxWindow
*wxFindWinFromHandle(WXHWND hWnd
)
1415 wxNode
*node
= wxWinHandleList
->Find((long)hWnd
);
1418 return (wxWindow
*)node
->Data();
1421 void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
)
1423 // adding NULL hWnd is (first) surely a result of an error and
1424 // (secondly) breaks menu command processing
1425 wxCHECK_RET( hWnd
!= (HWND
) NULL
, "attempt to add a NULL hWnd to window list" );
1427 if ( !wxWinHandleList
->Find((long)hWnd
) )
1428 wxWinHandleList
->Append((long)hWnd
, win
);
1431 void wxRemoveHandleAssociation(wxWindow
*win
)
1433 wxWinHandleList
->DeleteObject(win
);
1436 // Default destroyer - override if you destroy it in some other way
1437 // (e.g. with MDI child windows)
1438 void wxWindow::MSWDestroyWindow()
1442 void wxWindow::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
1443 int x
, int y
, int width
, int height
,
1444 WXDWORD style
, const char *dialog_template
, WXDWORD extendedStyle
)
1446 bool is_dialog
= (dialog_template
!= NULL
);
1447 int x1
= CW_USEDEFAULT
;
1449 int width1
= CW_USEDEFAULT
;
1452 // Find parent's size, if it exists, to set up a possible default
1453 // panel size the size of the parent window
1457 // Was GetWindowRect: JACS 5/5/95
1458 ::GetClientRect((HWND
) parent
->GetHWND(), &parent_rect
);
1460 width1
= parent_rect
.right
- parent_rect
.left
;
1461 height1
= parent_rect
.bottom
- parent_rect
.top
;
1466 if (width
> -1) width1
= width
;
1467 if (height
> -1) height1
= height
;
1469 HWND hParent
= NULL
;
1471 hParent
= (HWND
) parent
->GetHWND();
1477 // MakeProcInstance doesn't seem to be needed in C7. Is it needed for
1478 // other compilers???
1479 // VZ: it's always needed for Win16 and never for Win32
1481 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1482 (DLGPROC
)wxDlgProc
);
1484 // N.B.: if we _don't_ use this form,
1485 // then with VC++ 1.5, it crashes horribly.
1487 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1488 (DLGPROC
)wxDlgProc
);
1490 // Crashes when we use this.
1491 DLGPROC dlgproc
= (DLGPROC
)MakeProcInstance((DLGPROC
)wxWndProc
, wxGetInstance());
1493 m_hWnd
= (WXHWND
) ::CreateDialog(wxGetInstance(), dialog_template
, hParent
,
1499 MessageBox(NULL
, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.",
1500 "wxWindows Error", MB_ICONEXCLAMATION
| MB_OK
);
1501 else MoveWindow((HWND
) m_hWnd
, x1
, y1
, width1
, height1
, FALSE
);
1506 if (style
& WS_CHILD
)
1511 m_hWnd
= (WXHWND
)CreateWindowEx(extendedStyle
, wclass
,
1516 hParent
, (HMENU
)controlId
, wxGetInstance(),
1520 wxLogError("Can't create window of class %s!\n"
1521 "Possible Windows 3.x compatibility problem?", wclass
);
1526 wxWinHandleList
->Append((long)m_hWnd
, this);
1529 void wxWindow::MSWOnCreate(WXLPCREATESTRUCT
WXUNUSED(cs
))
1533 bool wxWindow::MSWOnClose()
1538 // Some compilers don't define this
1539 #ifndef ENDSESSION_LOGOFF
1540 #define ENDSESSION_LOGOFF 0x80000000
1543 // Return TRUE to end session, FALSE to veto end session.
1544 bool wxWindow::MSWOnQueryEndSession(long logOff
)
1546 wxCloseEvent
event(wxEVT_QUERY_END_SESSION
, -1);
1547 event
.SetEventObject(wxTheApp
);
1548 event
.SetCanVeto(TRUE
);
1549 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1550 if ((this == wxTheApp
->GetTopWindow()) && // Only send once
1551 wxTheApp
->ProcessEvent(event
) && event
.GetVeto())
1553 return FALSE
; // Veto!
1557 return TRUE
; // Don't veto
1561 bool wxWindow::MSWOnEndSession(bool endSession
, long logOff
)
1563 wxCloseEvent
event(wxEVT_END_SESSION
, -1);
1564 event
.SetEventObject(wxTheApp
);
1565 event
.SetCanVeto(FALSE
);
1566 event
.SetLoggingOff( (logOff
== ENDSESSION_LOGOFF
) );
1567 if (endSession
&& // No need to send if the session isn't ending
1568 (this == wxTheApp
->GetTopWindow()) && // Only send once
1569 wxTheApp
->ProcessEvent(event
))
1575 bool wxWindow::MSWOnDestroy()
1577 // delete our drop target if we've got one
1578 #if wxUSE_DRAG_AND_DROP
1579 if ( m_pDropTarget
!= NULL
) {
1580 m_pDropTarget
->Revoke(m_hWnd
);
1582 delete m_pDropTarget
;
1583 m_pDropTarget
= NULL
;
1590 // Deal with child commands from buttons etc.
1592 long wxWindow::MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
)
1594 #if defined(__WIN95__)
1595 // Find a child window to send the notification to, e.g. a toolbar.
1596 // There's a problem here. NMHDR::hwndFrom doesn't give us the
1597 // handle of the toolbar; it's probably the handle of the tooltip
1598 // window (anyway, it's parent is also the toolbar's parent).
1599 // So, since we don't know which hWnd or wxWindow originated the
1600 // WM_NOTIFY, we'll need to go through all the children of this window
1601 // trying out MSWNotify.
1602 // This won't work now, though, because any number of controls
1603 // could respond to the same generic messages :-(
1605 /* This doesn't work for toolbars, but try for other controls first.
1607 NMHDR
*hdr
= (NMHDR
*)lParam
;
1608 HWND hWnd
= (HWND
)hdr
->hwndFrom
;
1609 wxWindow
*win
= wxFindWinFromHandle((WXHWND
) hWnd
);
1611 WXLPARAM result
= 0;
1615 if ( win
->MSWNotify(wParam
, lParam
, &result
) )
1620 // Rely on MSWNotify to check whether the message
1621 // belongs to the window or not
1622 wxNode
*node
= GetChildren().First();
1625 wxWindow
*child
= (wxWindow
*)node
->Data();
1626 if ( child
->MSWNotify(wParam
, lParam
, &result
) )
1628 node
= node
->Next();
1631 // finally try this window too (catches toolbar case)
1632 if ( MSWNotify(wParam
, lParam
, &result
) )
1641 void wxWindow::MSWOnMenuHighlight(WXWORD
WXUNUSED(item
), WXWORD
WXUNUSED(flags
), WXHMENU
WXUNUSED(sysmenu
))
1645 void wxWindow::MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
)
1649 bool wxWindow::MSWOnActivate(int state
, bool WXUNUSED(minimized
), WXHWND
WXUNUSED(activate
))
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 if (m_caretEnabled
&& (m_caretWidth
> 0) && (m_caretHeight
> 0))
1663 ::CreateCaret((HWND
) GetHWND(), NULL
, m_caretWidth
, m_caretHeight
);
1665 ::ShowCaret((HWND
) GetHWND());
1668 wxFocusEvent
event(wxEVT_SET_FOCUS
, m_windowId
);
1669 event
.SetEventObject(this);
1670 if (!GetEventHandler()->ProcessEvent(event
))
1675 bool wxWindow::MSWOnKillFocus(WXHWND
WXUNUSED(hwnd
))
1683 wxFocusEvent
event(wxEVT_KILL_FOCUS
, m_windowId
);
1684 event
.SetEventObject(this);
1685 if (!GetEventHandler()->ProcessEvent(event
))
1690 void wxWindow::MSWOnDropFiles(WXWPARAM wParam
)
1693 HDROP hFilesInfo
= (HDROP
) wParam
;
1695 DragQueryPoint(hFilesInfo
, (LPPOINT
) &dropPoint
);
1697 // Get the total number of files dropped
1698 WORD gwFilesDropped
= (WORD
)DragQueryFile ((HDROP
)hFilesInfo
,
1703 wxString
*files
= new wxString
[gwFilesDropped
];
1705 for (wIndex
=0; wIndex
< (int)gwFilesDropped
; wIndex
++)
1707 DragQueryFile (hFilesInfo
, wIndex
, (LPSTR
) wxBuffer
, 1000);
1708 files
[wIndex
] = wxBuffer
;
1710 DragFinish (hFilesInfo
);
1712 wxDropFilesEvent
event(wxEVT_DROP_FILES
, gwFilesDropped
, files
);
1713 event
.m_eventObject
= this;
1714 event
.m_pos
.x
= dropPoint
.x
; event
.m_pos
.x
= dropPoint
.y
;
1716 if (!GetEventHandler()->ProcessEvent(event
))
1722 bool wxWindow::MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*itemStruct
)
1724 #if wxUSE_OWNER_DRAWN
1725 if ( id
== 0 ) { // is it a menu item?
1726 DRAWITEMSTRUCT
*pDrawStruct
= (DRAWITEMSTRUCT
*)itemStruct
;
1727 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pDrawStruct
->itemData
);
1728 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1730 // prepare to call OnDrawItem()
1732 dc
.SetHDC((WXHDC
)pDrawStruct
->hDC
, FALSE
);
1733 wxRect
rect(pDrawStruct
->rcItem
.left
, pDrawStruct
->rcItem
.top
,
1734 pDrawStruct
->rcItem
.right
- pDrawStruct
->rcItem
.left
,
1735 pDrawStruct
->rcItem
.bottom
- pDrawStruct
->rcItem
.top
);
1736 return pMenuItem
->OnDrawItem(
1738 (wxOwnerDrawn::wxODAction
)pDrawStruct
->itemAction
,
1739 (wxOwnerDrawn::wxODStatus
)pDrawStruct
->itemState
1742 #endif // owner-drawn menus
1744 wxWindow
*item
= FindItem(id
);
1745 #if wxUSE_DYNAMIC_CLASSES
1746 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1748 return ((wxControl
*)item
)->MSWOnDraw(itemStruct
);
1755 bool wxWindow::MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*itemStruct
)
1757 #if wxUSE_OWNER_DRAWN
1758 if ( id
== 0 ) { // is it a menu item?
1759 MEASUREITEMSTRUCT
*pMeasureStruct
= (MEASUREITEMSTRUCT
*)itemStruct
;
1760 wxMenuItem
*pMenuItem
= (wxMenuItem
*)(pMeasureStruct
->itemData
);
1761 wxCHECK( pMenuItem
->IsKindOf(CLASSINFO(wxMenuItem
)), FALSE
);
1763 return pMenuItem
->OnMeasureItem(&pMeasureStruct
->itemWidth
,
1764 &pMeasureStruct
->itemHeight
);
1766 #endif // owner-drawn menus
1768 wxWindow
*item
= FindItem(id
);
1769 #if wxUSE_DYNAMIC_CLASSES
1770 if (item
&& item
->IsKindOf(CLASSINFO(wxControl
)))
1772 return ((wxControl
*)item
)->MSWOnMeasure(itemStruct
);
1779 WXHBRUSH
wxWindow::MSWOnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1780 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1782 if (nCtlColor
== CTLCOLOR_DLG
)
1784 return OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1787 wxControl
*item
= (wxControl
*)FindItemByHWND(pWnd
, TRUE
);
1789 WXHBRUSH hBrush
= 0;
1792 hBrush
= item
->OnCtlColor(pDC
, pWnd
, nCtlColor
, message
, wParam
, lParam
);
1794 // I think that even for dialogs, we may need to call DefWindowProc (?)
1795 // Or maybe just rely on the usual default behaviour.
1797 hBrush
= (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1802 // Define for each class of dialog and control
1803 WXHBRUSH
wxWindow::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
1804 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1806 return (WXHBRUSH
) MSWDefWindowProc(message
, wParam
, lParam
);
1809 bool wxWindow::MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1811 wxSysColourChangedEvent event
;
1812 event
.SetEventObject(this);
1814 // Check if app handles this.
1815 if (GetEventHandler()->ProcessEvent(event
))
1818 // We didn't process it
1822 long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange
)
1824 wxPaletteChangedEvent
event(GetId());
1825 event
.SetEventObject(this);
1826 event
.SetChangedWindow(wxFindWinFromHandle(hWndPalChange
));
1827 GetEventHandler()->ProcessEvent(event
);
1831 long wxWindow::MSWOnQueryNewPalette()
1833 wxQueryNewPaletteEvent
event(GetId());
1834 event
.SetEventObject(this);
1835 if (!GetEventHandler()->ProcessEvent(event
) || !event
.GetPaletteRealized())
1837 return (long) FALSE
;
1843 // Responds to colour changes: passes event on to children.
1844 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1846 wxNode
*node
= GetChildren().First();
1849 // Only propagate to non-top-level windows
1850 wxWindow
*win
= (wxWindow
*)node
->Data();
1851 if ( win
->GetParent() )
1853 wxSysColourChangedEvent event2
;
1854 event
.m_eventObject
= win
;
1855 win
->GetEventHandler()->ProcessEvent(event2
);
1858 node
= node
->Next();
1862 long wxWindow::MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
1865 return ::CallWindowProc(CASTWNDPROC m_oldWndProc
, (HWND
) GetHWND(), (UINT
) nMsg
, (WPARAM
) wParam
, (LPARAM
) lParam
);
1867 return ::DefWindowProc((HWND
) GetHWND(), nMsg
, wParam
, lParam
);
1870 long wxWindow::Default()
1872 // Ignore 'fake' events (perhaps generated as a result of a separate real event)
1877 wxLogTrace(wxTraceMessages
, "Forwarding %s to DefWindowProc.",
1878 wxGetMessageName(m_lastMsg
));
1879 #endif // __WXDEBUG__
1881 return this->MSWDefWindowProc(m_lastMsg
, m_lastWParam
, m_lastLParam
);
1884 bool wxWindow::MSWProcessMessage(WXMSG
* pMsg
)
1886 if ( m_hWnd
!= 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL
) ) {
1887 // intercept dialog navigation keys
1888 MSG
*msg
= (MSG
*)pMsg
;
1889 bool bProcess
= TRUE
;
1890 if ( msg
->message
!= WM_KEYDOWN
)
1893 if ( (HIWORD(msg
->lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
1896 bool bCtrlDown
= (::GetKeyState(VK_CONTROL
) & 0x100) != 0;
1898 // WM_GETDLGCODE: if the control wants it for itself, don't process it
1899 // (except for Ctrl-Tab combination which is always processed)
1901 if ( bProcess
&& !bCtrlDown
) {
1902 lDlgCode
= ::SendMessage(msg
->hwnd
, WM_GETDLGCODE
, 0, 0);
1905 bool bForward
= TRUE
;
1907 switch ( msg
->wParam
) {
1909 if ( lDlgCode
& DLGC_WANTTAB
) // FALSE for Ctrl-Tab
1912 bForward
= !(::GetKeyState(VK_SHIFT
) & 0x100);
1917 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1925 if ( (lDlgCode
& DLGC_WANTARROWS
) || bCtrlDown
)
1935 wxNavigationKeyEvent event
;
1936 event
.SetDirection(bForward
);
1937 event
.SetWindowChange(bCtrlDown
);
1938 event
.SetEventObject(this);
1940 if ( GetEventHandler()->ProcessEvent(event
) )
1944 return ::IsDialogMessage((HWND
)GetHWND(), msg
) != 0;
1950 bool wxWindow::MSWTranslateMessage(WXMSG
* pMsg
)
1952 if (m_acceleratorTable
.Ok() &&
1953 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
1959 long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag
), WXHWND
WXUNUSED(activate
), WXHWND
WXUNUSED(deactivate
))
1964 void wxWindow::MSWDetachWindowMenu()
1968 int N
= GetMenuItemCount((HMENU
) m_hMenu
);
1970 for (i
= 0; i
< N
; i
++)
1973 int chars
= GetMenuString((HMENU
) m_hMenu
, i
, buf
, 100, MF_BYPOSITION
);
1974 if ((chars
> 0) && (strcmp(buf
, "&Window") == 0))
1976 RemoveMenu((HMENU
) m_hMenu
, i
, MF_BYPOSITION
);
1983 bool wxWindow::MSWOnPaint()
1986 HRGN hRegion
= ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
1987 ::GetUpdateRgn((HWND
) GetHWND(), hRegion
, FALSE
);
1989 m_updateRegion
= wxRegion((WXHRGN
) hRegion
);
1992 ::GetUpdateRect((HWND
) GetHWND(), & updateRect
, FALSE
);
1994 m_updateRegion
= wxRegion(updateRect
.left
, updateRect
.top
,
1995 updateRect
.right
- updateRect
.left
, updateRect
.bottom
- updateRect
.top
);
1998 wxPaintEvent
event(m_windowId
);
1999 event
.SetEventObject(this);
2000 if (!GetEventHandler()->ProcessEvent(event
))
2005 void wxWindow::MSWOnSize(int w
, int h
, WXUINT
WXUNUSED(flag
))
2015 wxSizeEvent
event(wxSize(w
, h
), m_windowId
);
2016 event
.SetEventObject(this);
2017 if (!GetEventHandler()->ProcessEvent(event
))
2023 void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos
))
2028 // Deal with child commands from buttons etc.
2029 bool wxWindow::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
2031 if (wxCurrentPopupMenu
)
2033 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
2034 wxCurrentPopupMenu
= NULL
;
2035 bool succ
= popupMenu
->MSWCommand(cmd
, id
);
2039 wxWindow
*item
= FindItem(id
);
2042 bool value
= item
->MSWCommand(cmd
, id
);
2047 wxWindow
*win
= wxFindWinFromHandle(control
);
2049 return win
->MSWCommand(cmd
, id
);
2054 long wxWindow::MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
)
2060 wxMaximizeEvent
event(m_windowId
);
2061 event
.SetEventObject(this);
2062 if (!GetEventHandler()->ProcessEvent(event
))
2070 wxIconizeEvent
event(m_windowId
);
2071 event
.SetEventObject(this);
2072 if (!GetEventHandler()->ProcessEvent(event
))
2084 void wxWindow::MSWOnLButtonDown(int x
, int y
, WXUINT flags
)
2086 wxMouseEvent
event(wxEVT_LEFT_DOWN
);
2088 event
.m_x
= x
; event
.m_y
= y
;
2089 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2090 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2091 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2092 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2093 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2094 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2095 event
.m_eventObject
= this;
2097 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DOWN
;
2099 if (!GetEventHandler()->ProcessEvent(event
))
2103 void wxWindow::MSWOnLButtonUp(int x
, int y
, WXUINT flags
)
2105 wxMouseEvent
event(wxEVT_LEFT_UP
);
2107 event
.m_x
= x
; event
.m_y
= y
;
2108 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2109 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2110 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2111 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2112 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2113 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2114 event
.m_eventObject
= this;
2116 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_UP
;
2118 if (!GetEventHandler()->ProcessEvent(event
))
2122 void wxWindow::MSWOnLButtonDClick(int x
, int y
, WXUINT flags
)
2124 wxMouseEvent
event(wxEVT_LEFT_DCLICK
);
2126 event
.m_x
= x
; event
.m_y
= y
;
2127 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2128 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2129 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2130 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2131 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2132 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2133 event
.m_eventObject
= this;
2135 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_LEFT_DCLICK
;
2137 if (!GetEventHandler()->ProcessEvent(event
))
2141 void wxWindow::MSWOnMButtonDown(int x
, int y
, WXUINT flags
)
2143 wxMouseEvent
event(wxEVT_MIDDLE_DOWN
);
2145 event
.m_x
= x
; event
.m_y
= y
;
2146 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2147 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2148 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2149 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2150 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2151 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2152 event
.m_eventObject
= this;
2154 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DOWN
;
2156 if (!GetEventHandler()->ProcessEvent(event
))
2160 void wxWindow::MSWOnMButtonUp(int x
, int y
, WXUINT flags
)
2162 //wxDebugMsg("MButtonUp\n") ;
2163 wxMouseEvent
event(wxEVT_MIDDLE_UP
);
2165 event
.m_x
= x
; event
.m_y
= y
;
2166 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2167 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2168 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2169 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2170 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2171 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2172 event
.m_eventObject
= this;
2174 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_UP
;
2176 if (!GetEventHandler()->ProcessEvent(event
))
2180 void wxWindow::MSWOnMButtonDClick(int x
, int y
, WXUINT flags
)
2182 wxMouseEvent
event(wxEVT_MIDDLE_DCLICK
);
2184 event
.m_x
= x
; event
.m_y
= y
;
2185 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2186 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2187 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2188 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2189 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2190 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2191 event
.m_eventObject
= this;
2193 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_MIDDLE_DCLICK
;
2195 if (!GetEventHandler()->ProcessEvent(event
))
2199 void wxWindow::MSWOnRButtonDown(int x
, int y
, WXUINT flags
)
2201 wxMouseEvent
event(wxEVT_RIGHT_DOWN
);
2203 event
.m_x
= x
; event
.m_y
= y
;
2204 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2205 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2206 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2207 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2208 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2209 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2210 event
.m_eventObject
= this;
2212 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DOWN
;
2214 if (!GetEventHandler()->ProcessEvent(event
))
2218 void wxWindow::MSWOnRButtonUp(int x
, int y
, WXUINT flags
)
2220 wxMouseEvent
event(wxEVT_RIGHT_UP
);
2222 event
.m_x
= x
; event
.m_y
= y
;
2223 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2224 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2225 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2226 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2227 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2228 event
.m_eventObject
= this;
2229 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2231 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_UP
;
2233 if (!GetEventHandler()->ProcessEvent(event
))
2237 void wxWindow::MSWOnRButtonDClick(int x
, int y
, WXUINT flags
)
2239 wxMouseEvent
event(wxEVT_RIGHT_DCLICK
);
2241 event
.m_x
= x
; event
.m_y
= y
;
2242 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2243 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2244 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2245 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2246 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2247 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2248 event
.m_eventObject
= this;
2250 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
; m_lastEvent
= wxEVT_RIGHT_DCLICK
;
2252 if (!GetEventHandler()->ProcessEvent(event
))
2256 void wxWindow::MSWOnMouseMove(int x
, int y
, WXUINT flags
)
2258 // 'normal' move event...
2259 // Set cursor, but only if we're not in 'busy' mode
2261 // Trouble with this is that it sets the cursor for controls too :-(
2262 if (m_windowCursor
.Ok() && !wxIsBusy())
2263 ::SetCursor((HCURSOR
) m_windowCursor
.GetHCURSOR());
2265 if (!m_mouseInWindow
)
2267 // Generate an ENTER event
2268 m_mouseInWindow
= TRUE
;
2269 MSWOnMouseEnter(x
, y
, flags
);
2272 wxMouseEvent
event(wxEVT_MOTION
);
2274 event
.m_x
= x
; event
.m_y
= y
;
2275 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2276 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2277 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2278 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2279 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2280 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2281 event
.m_eventObject
= this;
2283 // Window gets a click down message followed by a mouse move
2284 // message even if position isn't changed! We want to discard
2285 // the trailing move event if x and y are the same.
2286 if ((m_lastEvent
== wxEVT_RIGHT_DOWN
|| m_lastEvent
== wxEVT_LEFT_DOWN
||
2287 m_lastEvent
== wxEVT_MIDDLE_DOWN
) &&
2288 (m_lastXPos
== event
.m_x
&& m_lastYPos
== event
.m_y
))
2290 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2291 m_lastEvent
= wxEVT_MOTION
;
2295 m_lastEvent
= wxEVT_MOTION
;
2296 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2298 if (!GetEventHandler()->ProcessEvent(event
))
2302 void wxWindow::MSWOnMouseEnter(int x
, int y
, WXUINT flags
)
2304 wxMouseEvent
event(wxEVT_ENTER_WINDOW
);
2306 event
.m_x
= x
; event
.m_y
= y
;
2307 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2308 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2309 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2310 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2311 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2312 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2313 event
.m_eventObject
= this;
2315 m_lastEvent
= wxEVT_ENTER_WINDOW
;
2316 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2317 // No message - ensure we don't try to call the default behaviour accidentally.
2319 GetEventHandler()->ProcessEvent(event
);
2322 void wxWindow::MSWOnMouseLeave(int x
, int y
, WXUINT flags
)
2324 wxMouseEvent
event(wxEVT_LEAVE_WINDOW
);
2326 event
.m_x
= x
; event
.m_y
= y
;
2327 event
.m_shiftDown
= ((flags
& MK_SHIFT
) != 0);
2328 event
.m_controlDown
= ((flags
& MK_CONTROL
) != 0);
2329 event
.m_leftDown
= ((flags
& MK_LBUTTON
) != 0);
2330 event
.m_middleDown
= ((flags
& MK_MBUTTON
) != 0);
2331 event
.m_rightDown
= ((flags
& MK_RBUTTON
) != 0);
2332 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2333 event
.m_eventObject
= this;
2335 m_lastEvent
= wxEVT_LEAVE_WINDOW
;
2336 m_lastXPos
= event
.m_x
; m_lastYPos
= event
.m_y
;
2337 // No message - ensure we don't try to call the default behaviour accidentally.
2339 GetEventHandler()->ProcessEvent(event
);
2342 void wxWindow::MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2345 bool tempControlDown
= FALSE
;
2348 // If 1 -> 26, translate to CTRL plus a letter.
2350 if ((id
> 0) && (id
< 27))
2371 tempControlDown
= TRUE
;
2377 else if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2378 // it's ASCII and will be processed here only when called from
2379 // WM_CHAR (i.e. when isASCII = TRUE)
2385 wxKeyEvent
event(wxEVT_CHAR
);
2386 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2387 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2388 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2389 event
.m_altDown
= TRUE
;
2391 event
.m_eventObject
= this;
2392 event
.m_keyCode
= id
;
2393 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2398 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2402 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2404 if (!GetEventHandler()->ProcessEvent(event
))
2409 void wxWindow::MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2413 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2419 wxKeyEvent
event(wxEVT_KEY_DOWN
);
2420 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2421 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2422 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2423 event
.m_altDown
= TRUE
;
2425 event
.m_eventObject
= this;
2426 event
.m_keyCode
= id
;
2427 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2432 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2436 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2438 if (!GetEventHandler()->ProcessEvent(event
))
2443 void wxWindow::MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
)
2447 if ((id
= wxCharCodeMSWToWX(wParam
)) == 0) {
2453 wxKeyEvent
event(wxEVT_KEY_UP
);
2454 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2455 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
2456 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2457 event
.m_altDown
= TRUE
;
2459 event
.m_eventObject
= this;
2460 event
.m_keyCode
= id
;
2461 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
2466 GetWindowRect((HWND
) GetHWND(),&rect
) ;
2470 event
.m_x
= pt
.x
; event
.m_y
= pt
.y
;
2472 if (!GetEventHandler()->ProcessEvent(event
))
2477 void wxWindow::MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
)
2481 if (flags
& JOY_BUTTON1CHG
)
2482 change
= wxJOY_BUTTON1
;
2483 if (flags
& JOY_BUTTON2CHG
)
2484 change
= wxJOY_BUTTON2
;
2485 if (flags
& JOY_BUTTON3CHG
)
2486 change
= wxJOY_BUTTON3
;
2487 if (flags
& JOY_BUTTON4CHG
)
2488 change
= wxJOY_BUTTON4
;
2490 if (flags
& JOY_BUTTON1
)
2491 buttons
|= wxJOY_BUTTON1
;
2492 if (flags
& JOY_BUTTON2
)
2493 buttons
|= wxJOY_BUTTON2
;
2494 if (flags
& JOY_BUTTON3
)
2495 buttons
|= wxJOY_BUTTON3
;
2496 if (flags
& JOY_BUTTON4
)
2497 buttons
|= wxJOY_BUTTON4
;
2499 wxJoystickEvent
event(wxEVT_JOY_BUTTON_DOWN
, buttons
, joystick
, change
);
2500 event
.SetPosition(wxPoint(x
, y
));
2501 event
.SetEventObject(this);
2503 GetEventHandler()->ProcessEvent(event
);
2506 void wxWindow::MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
)
2510 if (flags
& JOY_BUTTON1CHG
)
2511 change
= wxJOY_BUTTON1
;
2512 if (flags
& JOY_BUTTON2CHG
)
2513 change
= wxJOY_BUTTON2
;
2514 if (flags
& JOY_BUTTON3CHG
)
2515 change
= wxJOY_BUTTON3
;
2516 if (flags
& JOY_BUTTON4CHG
)
2517 change
= wxJOY_BUTTON4
;
2519 if (flags
& JOY_BUTTON1
)
2520 buttons
|= wxJOY_BUTTON1
;
2521 if (flags
& JOY_BUTTON2
)
2522 buttons
|= wxJOY_BUTTON2
;
2523 if (flags
& JOY_BUTTON3
)
2524 buttons
|= wxJOY_BUTTON3
;
2525 if (flags
& JOY_BUTTON4
)
2526 buttons
|= wxJOY_BUTTON4
;
2528 wxJoystickEvent
event(wxEVT_JOY_BUTTON_UP
, buttons
, joystick
, change
);
2529 event
.SetPosition(wxPoint(x
, y
));
2530 event
.SetEventObject(this);
2532 GetEventHandler()->ProcessEvent(event
);
2535 void wxWindow::MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
)
2538 if (flags
& JOY_BUTTON1
)
2539 buttons
|= wxJOY_BUTTON1
;
2540 if (flags
& JOY_BUTTON2
)
2541 buttons
|= wxJOY_BUTTON2
;
2542 if (flags
& JOY_BUTTON3
)
2543 buttons
|= wxJOY_BUTTON3
;
2544 if (flags
& JOY_BUTTON4
)
2545 buttons
|= wxJOY_BUTTON4
;
2547 wxJoystickEvent
event(wxEVT_JOY_MOVE
, buttons
, joystick
, 0);
2548 event
.SetPosition(wxPoint(x
, y
));
2549 event
.SetEventObject(this);
2551 GetEventHandler()->ProcessEvent(event
);
2554 void wxWindow::MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
)
2557 if (flags
& JOY_BUTTON1
)
2558 buttons
|= wxJOY_BUTTON1
;
2559 if (flags
& JOY_BUTTON2
)
2560 buttons
|= wxJOY_BUTTON2
;
2561 if (flags
& JOY_BUTTON3
)
2562 buttons
|= wxJOY_BUTTON3
;
2563 if (flags
& JOY_BUTTON4
)
2564 buttons
|= wxJOY_BUTTON4
;
2566 wxJoystickEvent
event(wxEVT_JOY_ZMOVE
, buttons
, joystick
, 0);
2567 event
.SetZPosition(z
);
2568 event
.SetEventObject(this);
2570 GetEventHandler()->ProcessEvent(event
);
2573 void wxWindow::MSWOnVScroll(WXWORD wParam
, WXWORD pos
, WXHWND control
)
2577 wxWindow
*child
= wxFindWinFromHandle(control
);
2579 child
->MSWOnVScroll(wParam
, pos
, control
);
2583 wxScrollEvent event
;
2584 event
.SetPosition(pos
);
2585 event
.SetOrientation(wxVERTICAL
);
2586 event
.m_eventObject
= this;
2591 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2595 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2599 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2603 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2607 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2611 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2615 case SB_THUMBPOSITION
:
2616 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2624 if (!GetEventHandler()->ProcessEvent(event
))
2628 void wxWindow::MSWOnHScroll( WXWORD wParam
, WXWORD pos
, WXHWND control
)
2632 wxWindow
*child
= wxFindWinFromHandle(control
);
2634 child
->MSWOnHScroll(wParam
, pos
, control
);
2640 wxScrollEvent event
;
2641 event
.SetPosition(pos
);
2642 event
.SetOrientation(wxHORIZONTAL
);
2643 event
.m_eventObject
= this;
2648 event
.m_eventType
= wxEVT_SCROLL_TOP
;
2652 event
.m_eventType
= wxEVT_SCROLL_BOTTOM
;
2656 event
.m_eventType
= wxEVT_SCROLL_LINEUP
;
2660 event
.m_eventType
= wxEVT_SCROLL_LINEDOWN
;
2664 event
.m_eventType
= wxEVT_SCROLL_PAGEUP
;
2668 event
.m_eventType
= wxEVT_SCROLL_PAGEDOWN
;
2672 case SB_THUMBPOSITION
:
2673 event
.m_eventType
= wxEVT_SCROLL_THUMBTRACK
;
2680 if ( GetEventHandler()->ProcessEvent(event
) )
2684 // call the default WM_HSCROLL handler: it's non trivial in some common
2685 // controls (up-down control for example)
2689 void wxWindow::MSWOnShow(bool show
, int status
)
2691 wxShowEvent
event(GetId(), show
);
2692 event
.m_eventObject
= this;
2693 GetEventHandler()->ProcessEvent(event
);
2696 bool wxWindow::MSWOnInitDialog(WXHWND
WXUNUSED(hWndFocus
))
2698 wxInitDialogEvent
event(GetId());
2699 event
.m_eventObject
= this;
2700 GetEventHandler()->ProcessEvent(event
);
2704 void wxWindow::InitDialog()
2706 wxInitDialogEvent
event(GetId());
2707 event
.SetEventObject( this );
2708 GetEventHandler()->ProcessEvent(event
);
2711 // Default init dialog behaviour is to transfer data to window
2712 void wxWindow::OnInitDialog(wxInitDialogEvent
& event
)
2714 TransferDataToWindow();
2717 void wxGetCharSize(WXHWND wnd
, int *x
, int *y
,wxFont
*the_font
)
2720 HDC dc
= ::GetDC((HWND
) wnd
);
2725 // the_font->UseResource();
2726 // the_font->RealizeResource();
2727 fnt
= (HFONT
)the_font
->GetResourceHandle();
2729 was
= (HFONT
) SelectObject(dc
,fnt
) ;
2731 GetTextMetrics(dc
, &tm
);
2732 if (the_font
&& fnt
&& was
)
2734 SelectObject(dc
,was
) ;
2736 ReleaseDC((HWND
)wnd
, dc
);
2737 *x
= tm
.tmAveCharWidth
;
2738 *y
= tm
.tmHeight
+ tm
.tmExternalLeading
;
2741 // the_font->ReleaseResource();
2744 // Returns 0 if was a normal ASCII value, not a special key. This indicates that
2745 // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
2746 int wxCharCodeMSWToWX(int keySym
)
2751 case VK_CANCEL
: id
= WXK_CANCEL
; break;
2752 case VK_BACK
: id
= WXK_BACK
; break;
2753 case VK_TAB
: id
= WXK_TAB
; break;
2754 case VK_CLEAR
: id
= WXK_CLEAR
; break;
2755 case VK_RETURN
: id
= WXK_RETURN
; break;
2756 case VK_SHIFT
: id
= WXK_SHIFT
; break;
2757 case VK_CONTROL
: id
= WXK_CONTROL
; break;
2758 case VK_MENU
: id
= WXK_MENU
; break;
2759 case VK_PAUSE
: id
= WXK_PAUSE
; break;
2760 case VK_SPACE
: id
= WXK_SPACE
; break;
2761 case VK_ESCAPE
: id
= WXK_ESCAPE
; break;
2762 case VK_PRIOR
: id
= WXK_PRIOR
; break;
2763 case VK_NEXT
: id
= WXK_NEXT
; break;
2764 case VK_END
: id
= WXK_END
; break;
2765 case VK_HOME
: id
= WXK_HOME
; break;
2766 case VK_LEFT
: id
= WXK_LEFT
; break;
2767 case VK_UP
: id
= WXK_UP
; break;
2768 case VK_RIGHT
: id
= WXK_RIGHT
; break;
2769 case VK_DOWN
: id
= WXK_DOWN
; break;
2770 case VK_SELECT
: id
= WXK_SELECT
; break;
2771 case VK_PRINT
: id
= WXK_PRINT
; break;
2772 case VK_EXECUTE
: id
= WXK_EXECUTE
; break;
2773 case VK_INSERT
: id
= WXK_INSERT
; break;
2774 case VK_DELETE
: id
= WXK_DELETE
; break;
2775 case VK_HELP
: id
= WXK_HELP
; break;
2776 case VK_NUMPAD0
: id
= WXK_NUMPAD0
; break;
2777 case VK_NUMPAD1
: id
= WXK_NUMPAD1
; break;
2778 case VK_NUMPAD2
: id
= WXK_NUMPAD2
; break;
2779 case VK_NUMPAD3
: id
= WXK_NUMPAD3
; break;
2780 case VK_NUMPAD4
: id
= WXK_NUMPAD4
; break;
2781 case VK_NUMPAD5
: id
= WXK_NUMPAD5
; break;
2782 case VK_NUMPAD6
: id
= WXK_NUMPAD6
; break;
2783 case VK_NUMPAD7
: id
= WXK_NUMPAD7
; break;
2784 case VK_NUMPAD8
: id
= WXK_NUMPAD8
; break;
2785 case VK_NUMPAD9
: id
= WXK_NUMPAD9
; break;
2786 case VK_MULTIPLY
: id
= WXK_MULTIPLY
; break;
2787 case VK_ADD
: id
= WXK_ADD
; break;
2788 case VK_SUBTRACT
: id
= WXK_SUBTRACT
; break;
2789 case VK_DECIMAL
: id
= WXK_DECIMAL
; break;
2790 case VK_DIVIDE
: id
= WXK_DIVIDE
; break;
2791 case VK_F1
: id
= WXK_F1
; break;
2792 case VK_F2
: id
= WXK_F2
; break;
2793 case VK_F3
: id
= WXK_F3
; break;
2794 case VK_F4
: id
= WXK_F4
; break;
2795 case VK_F5
: id
= WXK_F5
; break;
2796 case VK_F6
: id
= WXK_F6
; break;
2797 case VK_F7
: id
= WXK_F7
; break;
2798 case VK_F8
: id
= WXK_F8
; break;
2799 case VK_F9
: id
= WXK_F9
; break;
2800 case VK_F10
: id
= WXK_F10
; break;
2801 case VK_F11
: id
= WXK_F11
; break;
2802 case VK_F12
: id
= WXK_F12
; break;
2803 case VK_F13
: id
= WXK_F13
; break;
2804 case VK_F14
: id
= WXK_F14
; break;
2805 case VK_F15
: id
= WXK_F15
; break;
2806 case VK_F16
: id
= WXK_F16
; break;
2807 case VK_F17
: id
= WXK_F17
; break;
2808 case VK_F18
: id
= WXK_F18
; break;
2809 case VK_F19
: id
= WXK_F19
; break;
2810 case VK_F20
: id
= WXK_F20
; break;
2811 case VK_F21
: id
= WXK_F21
; break;
2812 case VK_F22
: id
= WXK_F22
; break;
2813 case VK_F23
: id
= WXK_F23
; break;
2814 case VK_F24
: id
= WXK_F24
; break;
2815 case VK_NUMLOCK
: id
= WXK_NUMLOCK
; break;
2816 case VK_SCROLL
: id
= WXK_SCROLL
; break;
2825 int wxCharCodeWXToMSW(int id
, bool *isVirtual
)
2831 case WXK_CANCEL
: keySym
= VK_CANCEL
; break;
2832 case WXK_CLEAR
: keySym
= VK_CLEAR
; break;
2833 case WXK_SHIFT
: keySym
= VK_SHIFT
; break;
2834 case WXK_CONTROL
: keySym
= VK_CONTROL
; break;
2835 case WXK_MENU
: keySym
= VK_MENU
; break;
2836 case WXK_PAUSE
: keySym
= VK_PAUSE
; break;
2837 case WXK_PRIOR
: keySym
= VK_PRIOR
; break;
2838 case WXK_NEXT
: keySym
= VK_NEXT
; break;
2839 case WXK_END
: keySym
= VK_END
; break;
2840 case WXK_HOME
: keySym
= VK_HOME
; break;
2841 case WXK_LEFT
: keySym
= VK_LEFT
; break;
2842 case WXK_UP
: keySym
= VK_UP
; break;
2843 case WXK_RIGHT
: keySym
= VK_RIGHT
; break;
2844 case WXK_DOWN
: keySym
= VK_DOWN
; break;
2845 case WXK_SELECT
: keySym
= VK_SELECT
; break;
2846 case WXK_PRINT
: keySym
= VK_PRINT
; break;
2847 case WXK_EXECUTE
: keySym
= VK_EXECUTE
; break;
2848 case WXK_INSERT
: keySym
= VK_INSERT
; break;
2849 case WXK_DELETE
: keySym
= VK_DELETE
; break;
2850 case WXK_HELP
: keySym
= VK_HELP
; break;
2851 case WXK_NUMPAD0
: keySym
= VK_NUMPAD0
; break;
2852 case WXK_NUMPAD1
: keySym
= VK_NUMPAD1
; break;
2853 case WXK_NUMPAD2
: keySym
= VK_NUMPAD2
; break;
2854 case WXK_NUMPAD3
: keySym
= VK_NUMPAD3
; break;
2855 case WXK_NUMPAD4
: keySym
= VK_NUMPAD4
; break;
2856 case WXK_NUMPAD5
: keySym
= VK_NUMPAD5
; break;
2857 case WXK_NUMPAD6
: keySym
= VK_NUMPAD6
; break;
2858 case WXK_NUMPAD7
: keySym
= VK_NUMPAD7
; break;
2859 case WXK_NUMPAD8
: keySym
= VK_NUMPAD8
; break;
2860 case WXK_NUMPAD9
: keySym
= VK_NUMPAD9
; break;
2861 case WXK_MULTIPLY
: keySym
= VK_MULTIPLY
; break;
2862 case WXK_ADD
: keySym
= VK_ADD
; break;
2863 case WXK_SUBTRACT
: keySym
= VK_SUBTRACT
; break;
2864 case WXK_DECIMAL
: keySym
= VK_DECIMAL
; break;
2865 case WXK_DIVIDE
: keySym
= VK_DIVIDE
; break;
2866 case WXK_F1
: keySym
= VK_F1
; break;
2867 case WXK_F2
: keySym
= VK_F2
; break;
2868 case WXK_F3
: keySym
= VK_F3
; break;
2869 case WXK_F4
: keySym
= VK_F4
; break;
2870 case WXK_F5
: keySym
= VK_F5
; break;
2871 case WXK_F6
: keySym
= VK_F6
; break;
2872 case WXK_F7
: keySym
= VK_F7
; break;
2873 case WXK_F8
: keySym
= VK_F8
; break;
2874 case WXK_F9
: keySym
= VK_F9
; break;
2875 case WXK_F10
: keySym
= VK_F10
; break;
2876 case WXK_F11
: keySym
= VK_F11
; break;
2877 case WXK_F12
: keySym
= VK_F12
; break;
2878 case WXK_F13
: keySym
= VK_F13
; break;
2879 case WXK_F14
: keySym
= VK_F14
; break;
2880 case WXK_F15
: keySym
= VK_F15
; break;
2881 case WXK_F16
: keySym
= VK_F16
; break;
2882 case WXK_F17
: keySym
= VK_F17
; break;
2883 case WXK_F18
: keySym
= VK_F18
; break;
2884 case WXK_F19
: keySym
= VK_F19
; break;
2885 case WXK_F20
: keySym
= VK_F20
; break;
2886 case WXK_F21
: keySym
= VK_F21
; break;
2887 case WXK_F22
: keySym
= VK_F22
; break;
2888 case WXK_F23
: keySym
= VK_F23
; break;
2889 case WXK_F24
: keySym
= VK_F24
; break;
2890 case WXK_NUMLOCK
: keySym
= VK_NUMLOCK
; break;
2891 case WXK_SCROLL
: keySym
= VK_SCROLL
; break;
2902 // Caret manipulation
2903 void wxWindow::CreateCaret(int w
, int h
)
2907 m_caretEnabled
= TRUE
;
2910 void wxWindow::CreateCaret(const wxBitmap
*WXUNUSED(bitmap
))
2915 void wxWindow::ShowCaret(bool show
)
2920 ::ShowCaret((HWND
) GetHWND());
2922 ::HideCaret((HWND
) GetHWND());
2923 m_caretShown
= show
;
2927 void wxWindow::DestroyCaret()
2929 m_caretEnabled
= FALSE
;
2932 void wxWindow::SetCaretPos(int x
, int y
)
2934 ::SetCaretPos(x
, y
);
2937 void wxWindow::GetCaretPos(int *x
, int *y
) const
2940 ::GetCaretPos(&point
);
2945 wxWindow
*wxGetActiveWindow()
2947 HWND hWnd
= GetActiveWindow();
2950 return wxFindWinFromHandle((WXHWND
) hWnd
);
2955 // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
2956 // in active frames and dialogs, regardless of where the focus is.
2957 static HHOOK wxTheKeyboardHook
= 0;
2958 static FARPROC wxTheKeyboardHookProc
= 0;
2959 int APIENTRY _EXPORT
2960 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
);
2962 void wxSetKeyboardHook(bool doIt
)
2966 wxTheKeyboardHookProc
= MakeProcInstance((FARPROC
) wxKeyboardHook
, wxGetInstance());
2967 wxTheKeyboardHook
= SetWindowsHookEx(WH_KEYBOARD
, (HOOKPROC
) wxTheKeyboardHookProc
, wxGetInstance(),
2968 #if defined(__WIN32__) && !defined(__TWIN32__)
2969 GetCurrentThreadId());
2970 // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
2977 UnhookWindowsHookEx(wxTheKeyboardHook
);
2978 FreeProcInstance(wxTheKeyboardHookProc
);
2982 int APIENTRY _EXPORT
2983 wxKeyboardHook(int nCode
, WORD wParam
, DWORD lParam
)
2985 DWORD hiWord
= HIWORD(lParam
);
2986 if (nCode
!= HC_NOREMOVE
&& ((hiWord
& KF_UP
) == 0))
2989 if ((id
= wxCharCodeMSWToWX(wParam
)) != 0)
2991 wxKeyEvent
event(wxEVT_CHAR_HOOK
);
2992 if ((HIWORD(lParam
) & KF_ALTDOWN
) == KF_ALTDOWN
)
2993 event
.m_altDown
= TRUE
;
2995 event
.m_eventObject
= NULL
;
2996 event
.m_keyCode
= id
;
2997 /* begin Albert's fix for control and shift key 26.5 */
2998 event
.m_shiftDown
= (::GetKeyState(VK_SHIFT
)&0x100?TRUE
:FALSE
);
2999 event
.m_controlDown
= (::GetKeyState(VK_CONTROL
)&0x100?TRUE
:FALSE
);
3000 /* end Albert's fix for control and shift key 26.5 */
3001 event
.SetTimestamp(wxApp::sm_lastMessageTime
);
3003 wxWindow
*win
= wxGetActiveWindow();
3006 if (win
->GetEventHandler()->ProcessEvent(event
))
3011 if ( wxTheApp
&& wxTheApp
->ProcessEvent(event
) )
3016 return (int)CallNextHookEx(wxTheKeyboardHook
, nCode
, wParam
, lParam
);
3019 void wxWindow::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
))
3027 void wxWindow::Centre(int direction
)
3029 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
3031 wxWindow
*father
= (wxWindow
*)GetParent();
3035 father
->GetClientSize(&panel_width
, &panel_height
);
3036 GetSize(&width
, &height
);
3037 GetPosition(&x
, &y
);
3042 if (direction
& wxHORIZONTAL
)
3043 new_x
= (int)((panel_width
- width
)/2);
3045 if (direction
& wxVERTICAL
)
3046 new_y
= (int)((panel_height
- height
)/2);
3048 SetSize(new_x
, new_y
, -1, -1);
3053 void wxWindow::OnPaint()
3055 PaintSelectionHandles();
3059 void wxWindow::WarpPointer (int x_pos
, int y_pos
)
3061 // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
3062 // pixel coordinates, relatives to the canvas -- So, we first need to
3063 // substract origin of the window, then convert to screen position
3065 int x
= x_pos
; int y
= y_pos
;
3067 GetWindowRect ((HWND
) GetHWND(), &rect
);
3072 SetCursorPos (x
, y
);
3075 void wxWindow::MSWDeviceToLogical (float *x
, float *y
) const
3079 bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC
)
3087 wxEraseEvent
event(m_windowId
, &dc
);
3088 event
.m_eventObject
= this;
3089 if (!GetEventHandler()->ProcessEvent(event
))
3092 dc
.SelectOldObjects(pDC
);
3098 dc
.SelectOldObjects(pDC
);
3101 dc
.SetHDC((WXHDC
) NULL
);
3105 void wxWindow::OnEraseBackground(wxEraseEvent
& event
)
3111 ::GetClientRect((HWND
) GetHWND(), &rect
);
3113 COLORREF ref
= PALETTERGB(m_backgroundColour
.Red(), m_backgroundColour
.Green(), m_backgroundColour
.Blue()) ;
3114 HBRUSH hBrush
= ::CreateSolidBrush(ref
);
3115 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
3117 // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
3118 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
3119 ::DeleteObject(hBrush
);
3120 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
3122 // Less efficient version (and doesn't account for scrolling)
3124 GetClientSize(& w, & h);
3125 wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID);
3126 event.GetDC()->SetBrush(brush);
3127 event.GetDC()->SetPen(wxTRANSPARENT_PEN);
3129 event.GetDC()->DrawRectangle(0, 0, w+1, h+1);
3133 #if WXWIN_COMPATIBILITY
3134 void wxWindow::SetScrollRange(int orient
, int range
, bool refresh
)
3136 #if defined(__WIN95__)
3140 // Try to adjust the range to cope with page size > 1
3141 // - a Windows API quirk
3142 int pageSize
= GetScrollPage(orient
);
3143 if ( pageSize
> 1 && range
> 0)
3145 range1
+= (pageSize
- 1);
3151 if (orient
== wxHORIZONTAL
) {
3157 info
.cbSize
= sizeof(SCROLLINFO
);
3158 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3162 info
.fMask
= SIF_RANGE
| SIF_PAGE
;
3164 HWND hWnd
= (HWND
) GetHWND();
3166 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3169 if (orient
== wxHORIZONTAL
)
3174 HWND hWnd
= (HWND
) GetHWND();
3176 ::SetScrollRange(hWnd
, wOrient
, 0, range
, refresh
);
3180 void wxWindow::SetScrollPage(int orient
, int page
, bool refresh
)
3182 #if defined(__WIN95__)
3186 if (orient
== wxHORIZONTAL
) {
3188 m_xThumbSize
= page
;
3191 m_yThumbSize
= page
;
3194 info
.cbSize
= sizeof(SCROLLINFO
);
3197 info
.fMask
= SIF_PAGE
;
3199 HWND hWnd
= (HWND
) GetHWND();
3201 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3203 if (orient
== wxHORIZONTAL
)
3204 m_xThumbSize
= page
;
3206 m_yThumbSize
= page
;
3210 int wxWindow::OldGetScrollRange(int orient
) const
3213 if (orient
== wxHORIZONTAL
)
3218 #if __WATCOMC__ && defined(__WINDOWS_386__)
3219 short minPos
, maxPos
;
3223 HWND hWnd
= (HWND
) GetHWND();
3226 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3227 #if defined(__WIN95__)
3228 // Try to adjust the range to cope with page size > 1
3229 // - a Windows API quirk
3230 int pageSize
= GetScrollPage(orient
);
3233 maxPos
-= (pageSize
- 1);
3242 int wxWindow::GetScrollPage(int orient
) const
3244 if (orient
== wxHORIZONTAL
)
3245 return m_xThumbSize
;
3247 return m_yThumbSize
;
3251 int wxWindow::GetScrollPos(int orient
) const
3254 if (orient
== wxHORIZONTAL
)
3258 HWND hWnd
= (HWND
) GetHWND();
3261 return ::GetScrollPos(hWnd
, wOrient
);
3267 // This now returns the whole range, not just the number
3268 // of positions that we can scroll.
3269 int wxWindow::GetScrollRange(int orient
) const
3272 if (orient
== wxHORIZONTAL
)
3277 #if __WATCOMC__ && defined(__WINDOWS_386__)
3278 short minPos
, maxPos
;
3282 HWND hWnd
= (HWND
) GetHWND();
3285 ::GetScrollRange(hWnd
, wOrient
, &minPos
, &maxPos
);
3286 #if defined(__WIN95__)
3287 // Try to adjust the range to cope with page size > 1
3288 // - a Windows API quirk
3289 int pageSize
= GetScrollThumb(orient
);
3292 maxPos
-= (pageSize
- 1);
3294 // October 10th: new range concept.
3304 int wxWindow::GetScrollThumb(int orient
) const
3306 if (orient
== wxHORIZONTAL
)
3307 return m_xThumbSize
;
3309 return m_yThumbSize
;
3312 void wxWindow::SetScrollPos(int orient
, int pos
, bool refresh
)
3314 #if defined(__WIN95__)
3318 if (orient
== wxHORIZONTAL
) {
3324 info
.cbSize
= sizeof(SCROLLINFO
);
3328 info
.fMask
= SIF_POS
;
3330 HWND hWnd
= (HWND
) GetHWND();
3332 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3335 if (orient
== wxHORIZONTAL
)
3340 HWND hWnd
= (HWND
) GetHWND();
3342 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3346 // New function that will replace some of the above.
3347 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
3348 int range
, bool refresh
)
3351 SetScrollPage(orient, thumbVisible, FALSE);
3353 int oldRange = range - thumbVisible ;
3354 SetScrollRange(orient, oldRange, FALSE);
3356 SetScrollPos(orient, pos, refresh);
3358 #if defined(__WIN95__)
3359 int oldRange
= range
- thumbVisible
;
3361 int range1
= oldRange
;
3363 // Try to adjust the range to cope with page size > 1
3364 // - a Windows API quirk
3365 int pageSize
= thumbVisible
;
3366 if ( pageSize
> 1 && range
> 0)
3368 range1
+= (pageSize
- 1);
3374 if (orient
== wxHORIZONTAL
) {
3380 info
.cbSize
= sizeof(SCROLLINFO
);
3381 info
.nPage
= pageSize
; // Have to set this, or scrollbar goes awry
3385 info
.fMask
= SIF_RANGE
| SIF_PAGE
| SIF_POS
;
3387 HWND hWnd
= (HWND
) GetHWND();
3389 ::SetScrollInfo(hWnd
, dir
, &info
, refresh
);
3392 if (orient
== wxHORIZONTAL
)
3397 HWND hWnd
= (HWND
) GetHWND();
3400 ::SetScrollRange(hWnd
, wOrient
, 0, range
, FALSE
);
3401 ::SetScrollPos(hWnd
, wOrient
, pos
, refresh
);
3404 if (orient
== wxHORIZONTAL
) {
3405 m_xThumbSize
= thumbVisible
;
3407 m_yThumbSize
= thumbVisible
;
3411 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
3416 rect2
.left
= rect
->x
;
3417 rect2
.top
= rect
->y
;
3418 rect2
.right
= rect
->x
+ rect
->width
;
3419 rect2
.bottom
= rect
->y
+ rect
->height
;
3423 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, &rect2
, NULL
);
3425 ::ScrollWindow((HWND
) GetHWND(), dx
, dy
, NULL
, NULL
);
3428 void wxWindow::SetFont(const wxFont
& font
)
3430 m_windowFont
= font
;
3432 if (!m_windowFont
.Ok())
3435 HWND hWnd
= (HWND
) GetHWND();
3438 if (m_windowFont
.GetResourceHandle())
3439 SendMessage(hWnd
, WM_SETFONT
,
3440 (WPARAM
)m_windowFont
.GetResourceHandle(),TRUE
);
3444 void wxWindow::SubclassWin(WXHWND hWnd
)
3446 wxASSERT_MSG( !m_oldWndProc
, "subclassing window twice?" );
3448 wxAssociateWinWithHandle((HWND
)hWnd
, this);
3450 m_oldWndProc
= (WXFARPROC
) GetWindowLong((HWND
) hWnd
, GWL_WNDPROC
);
3451 SetWindowLong((HWND
) hWnd
, GWL_WNDPROC
, (LONG
) wxWndProc
);
3454 void wxWindow::UnsubclassWin()
3456 wxRemoveHandleAssociation(this);
3458 // Restore old Window proc
3459 if ((HWND
) GetHWND())
3461 FARPROC farProc
= (FARPROC
) GetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
);
3462 if ((m_oldWndProc
!= 0) && (farProc
!= (FARPROC
) m_oldWndProc
))
3464 SetWindowLong((HWND
) GetHWND(), GWL_WNDPROC
, (LONG
) m_oldWndProc
);
3470 // Make a Windows extended style from the given wxWindows window style
3471 WXDWORD
wxWindow::MakeExtendedStyle(long style
, bool eliminateBorders
)
3473 WXDWORD exStyle
= 0;
3474 if ( style
& wxTRANSPARENT_WINDOW
)
3475 exStyle
|= WS_EX_TRANSPARENT
;
3477 if ( !eliminateBorders
)
3479 if ( style
& wxSUNKEN_BORDER
)
3480 exStyle
|= WS_EX_CLIENTEDGE
;
3481 if ( style
& wxDOUBLE_BORDER
)
3482 exStyle
|= WS_EX_DLGMODALFRAME
;
3483 #if defined(__WIN95__)
3484 if ( style
& wxRAISED_BORDER
)
3485 exStyle
|= WS_EX_WINDOWEDGE
;
3486 if ( style
& wxSTATIC_BORDER
)
3487 exStyle
|= WS_EX_STATICEDGE
;
3493 // Determines whether native 3D effects or CTL3D should be used,
3494 // applying a default border style if required, and returning an extended
3495 // style to pass to CreateWindowEx.
3496 WXDWORD
wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
)
3498 // If matches certain criteria, then assume no 3D effects
3499 // unless specifically requested (dealt with in MakeExtendedStyle)
3500 if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl
)) || (m_windowStyle
& wxNO_BORDER
) )
3503 return MakeExtendedStyle(m_windowStyle
, FALSE
);
3506 // Determine whether we should be using 3D effects or not.
3507 bool nativeBorder
= FALSE
; // by default, we don't want a Win95 effect
3509 // 1) App can specify global 3D effects
3510 *want3D
= wxTheApp
->GetAuto3D();
3512 // 2) If the parent is being drawn with user colours, or simple border specified,
3513 // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D
3514 if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS
) || (m_windowStyle
& wxSIMPLE_BORDER
))
3517 // 3) Control can override this global setting by defining
3518 // a border style, e.g. wxSUNKEN_BORDER
3519 if (m_windowStyle
& wxSUNKEN_BORDER
)
3522 // 4) If it's a special border, CTL3D can't cope so we want a native border
3523 if ( (m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3524 (m_windowStyle
& wxSTATIC_BORDER
) )
3527 nativeBorder
= TRUE
;
3530 // 5) If this isn't a Win95 app, and we are using CTL3D, remove border
3531 // effects from extended style
3534 nativeBorder
= FALSE
;
3537 DWORD exStyle
= MakeExtendedStyle(m_windowStyle
, !nativeBorder
);
3539 // If we want 3D, but haven't specified a border here,
3540 // apply the default border style specified.
3541 // TODO what about non-Win95 WIN32? Does it have borders?
3542 #if defined(__WIN95__) && !CTL3D
3543 if (defaultBorderStyle
&& (*want3D
) && ! ((m_windowStyle
& wxDOUBLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
3544 (m_windowStyle
& wxSTATIC_BORDER
) || (m_windowStyle
& wxSIMPLE_BORDER
) ))
3545 exStyle
|= defaultBorderStyle
; // WS_EX_CLIENTEDGE ;
3551 void wxWindow::OnChar(wxKeyEvent
& event
)
3553 /* I'm commenting this out because otherwise, we lose tabs in e.g. a text window (see MDI sample)
3555 if ( event.KeyCode() == WXK_TAB ) {
3556 // propagate the TABs to the parent - it's up to it to decide what
3558 if ( GetParent() ) {
3559 if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
3566 int id
= wxCharCodeWXToMSW((int)event
.KeyCode(), &isVirtual
);
3571 if ( !event
.ControlDown() )
3572 (void) MSWDefWindowProc(m_lastMsg
, (WPARAM
) id
, m_lastLParam
);
3575 void wxWindow::OnKeyDown(wxKeyEvent
& event
)
3580 void wxWindow::OnKeyUp(wxKeyEvent
& event
)
3585 void wxWindow::OnPaint(wxPaintEvent
& event
)
3590 bool wxWindow::IsEnabled(void) const
3592 return (::IsWindowEnabled((HWND
) GetHWND()) != 0);
3595 // Dialog support: override these and call
3596 // base class members to add functionality
3597 // that can't be done using validators.
3598 // NOTE: these functions assume that controls
3599 // are direct children of this window, not grandchildren
3600 // or other levels of descendant.
3602 // Transfer values to controls. If returns FALSE,
3603 // it's an application error (pops up a dialog)
3604 bool wxWindow::TransferDataToWindow()
3606 wxNode
*node
= GetChildren().First();
3609 wxWindow
*child
= (wxWindow
*)node
->Data();
3610 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */
3611 !child
->GetValidator()->TransferToWindow() )
3613 wxMessageBox("Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
3617 node
= node
->Next();
3622 // Transfer values from controls. If returns FALSE,
3623 // validation failed: don't quit
3624 bool wxWindow::TransferDataFromWindow()
3626 wxNode
*node
= GetChildren().First();
3629 wxWindow
*child
= (wxWindow
*)node
->Data();
3630 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
3635 node
= node
->Next();
3640 bool wxWindow::Validate()
3642 wxNode
*node
= GetChildren().First();
3645 wxWindow
*child
= (wxWindow
*)node
->Data();
3646 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this) )
3651 node
= node
->Next();
3656 // Get the window with the focus
3657 wxWindow
*wxWindow::FindFocus()
3659 HWND hWnd
= ::GetFocus();
3662 return wxFindWinFromHandle((WXHWND
) hWnd
);
3667 void wxWindow::AddChild(wxWindow
*child
)
3669 GetChildren().Append(child
);
3670 child
->m_windowParent
= this;
3673 void wxWindow::RemoveChild(wxWindow
*child
)
3675 // if (GetChildren())
3676 GetChildren().DeleteObject(child
);
3677 child
->m_windowParent
= NULL
;
3680 void wxWindow::DestroyChildren()
3683 while ((node
= GetChildren().First()) != (wxNode
*)NULL
) {
3685 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
) {
3687 if ( GetChildren().Member(child
) )
3693 void wxWindow::MakeModal(bool modal
)
3695 // Disable all other windows
3696 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
3698 wxNode
*node
= wxTopLevelWindows
.First();
3701 wxWindow
*win
= (wxWindow
*)node
->Data();
3703 win
->Enable(!modal
);
3705 node
= node
->Next();
3710 // If nothing defined for this, try the parent.
3711 // E.g. we may be a button loaded from a resource, with no callback function
3713 void wxWindow::OnCommand(wxWindow
& win
, wxCommandEvent
& event
)
3715 if (GetEventHandler()->ProcessEvent(event
) )
3718 m_windowParent
->GetEventHandler()->OnCommand(win
, event
);
3721 void wxWindow::SetConstraints(wxLayoutConstraints
*c
)
3725 UnsetConstraints(m_constraints
);
3726 delete m_constraints
;
3731 // Make sure other windows know they're part of a 'meaningful relationship'
3732 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3733 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3734 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3735 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3736 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3737 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3738 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3739 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3740 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3741 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3742 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3743 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3744 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3745 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3746 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3747 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3751 // This removes any dangling pointers to this window
3752 // in other windows' constraintsInvolvedIn lists.
3753 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3757 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3758 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3759 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3760 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3761 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3762 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3763 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3764 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3765 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3766 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3767 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3768 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3769 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3770 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3771 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3772 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3776 // Back-pointer to other windows we're involved with, so if we delete
3777 // this window, we must delete any constraints we're involved with.
3778 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3780 if (!m_constraintsInvolvedIn
)
3781 m_constraintsInvolvedIn
= new wxList
;
3782 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3783 m_constraintsInvolvedIn
->Append(otherWin
);
3786 // REMOVE back-pointer to other windows we're involved with.
3787 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3789 if (m_constraintsInvolvedIn
)
3790 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3793 // Reset any constraints that mention this window
3794 void wxWindow::DeleteRelatedConstraints()
3796 if (m_constraintsInvolvedIn
)
3798 wxNode
*node
= m_constraintsInvolvedIn
->First();
3801 wxWindow
*win
= (wxWindow
*)node
->Data();
3802 wxNode
*next
= node
->Next();
3803 wxLayoutConstraints
*constr
= win
->GetConstraints();
3805 // Reset any constraints involving this window
3808 constr
->left
.ResetIfWin((wxWindow
*)this);
3809 constr
->top
.ResetIfWin((wxWindow
*)this);
3810 constr
->right
.ResetIfWin((wxWindow
*)this);
3811 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3812 constr
->width
.ResetIfWin((wxWindow
*)this);
3813 constr
->height
.ResetIfWin((wxWindow
*)this);
3814 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3815 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3820 delete m_constraintsInvolvedIn
;
3821 m_constraintsInvolvedIn
= NULL
;
3825 void wxWindow::SetSizer(wxSizer
*sizer
)
3827 m_windowSizer
= sizer
;
3829 sizer
->SetSizerParent((wxWindow
*)this);
3836 bool wxWindow::Layout()
3838 if (GetConstraints())
3841 GetClientSize(&w
, &h
);
3842 GetConstraints()->width
.SetValue(w
);
3843 GetConstraints()->height
.SetValue(h
);
3846 // If top level (one sizer), evaluate the sizer's constraints.
3850 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3851 GetSizer()->LayoutPhase1(&noChanges
);
3852 GetSizer()->LayoutPhase2(&noChanges
);
3853 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3858 // Otherwise, evaluate child constraints
3859 ResetConstraints(); // Mark all constraints as unevaluated
3860 DoPhase(1); // Just one phase need if no sizers involved
3862 SetConstraintSizes(); // Recursively set the real window sizes
3868 // Do a phase of evaluating constraints:
3869 // the default behaviour. wxSizers may do a similar
3870 // thing, but also impose their own 'constraints'
3871 // and order the evaluation differently.
3872 bool wxWindow::LayoutPhase1(int *noChanges
)
3874 wxLayoutConstraints
*constr
= GetConstraints();
3877 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3883 bool wxWindow::LayoutPhase2(int *noChanges
)
3893 // Do a phase of evaluating child constraints
3894 bool wxWindow::DoPhase(int phase
)
3896 int noIterations
= 0;
3897 int maxIterations
= 500;
3901 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3905 wxNode
*node
= GetChildren().First();
3908 wxWindow
*child
= (wxWindow
*)node
->Data();
3909 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3911 wxLayoutConstraints
*constr
= child
->GetConstraints();
3914 if (succeeded
.Member(child
))
3919 int tempNoChanges
= 0;
3920 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3921 noChanges
+= tempNoChanges
;
3924 succeeded
.Append(child
);
3929 node
= node
->Next();
3936 void wxWindow::ResetConstraints()
3938 wxLayoutConstraints
*constr
= GetConstraints();
3941 constr
->left
.SetDone(FALSE
);
3942 constr
->top
.SetDone(FALSE
);
3943 constr
->right
.SetDone(FALSE
);
3944 constr
->bottom
.SetDone(FALSE
);
3945 constr
->width
.SetDone(FALSE
);
3946 constr
->height
.SetDone(FALSE
);
3947 constr
->centreX
.SetDone(FALSE
);
3948 constr
->centreY
.SetDone(FALSE
);
3950 wxNode
*node
= GetChildren().First();
3953 wxWindow
*win
= (wxWindow
*)node
->Data();
3954 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3955 win
->ResetConstraints();
3956 node
= node
->Next();
3960 // Need to distinguish between setting the 'fake' size for
3961 // windows and sizers, and setting the real values.
3962 void wxWindow::SetConstraintSizes(bool recurse
)
3964 wxLayoutConstraints
*constr
= GetConstraints();
3965 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3966 constr
->width
.GetDone() && constr
->height
.GetDone())
3968 int x
= constr
->left
.GetValue();
3969 int y
= constr
->top
.GetValue();
3970 int w
= constr
->width
.GetValue();
3971 int h
= constr
->height
.GetValue();
3973 // If we don't want to resize this window, just move it...
3974 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3975 (constr
->height
.GetRelationship() != wxAsIs
))
3977 // Calls Layout() recursively. AAAGH. How can we stop that.
3978 // Simply take Layout() out of non-top level OnSizes.
3979 SizerSetSize(x
, y
, w
, h
);
3988 char *windowClass
= this->GetClassInfo()->GetClassName();
3991 if (GetName() == "")
3992 winName
= "unnamed";
3994 winName
= GetName();
3995 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
3996 if (!constr
->left
.GetDone())
3997 wxDebugMsg(" unsatisfied 'left' constraint.\n");
3998 if (!constr
->right
.GetDone())
3999 wxDebugMsg(" unsatisfied 'right' constraint.\n");
4000 if (!constr
->width
.GetDone())
4001 wxDebugMsg(" unsatisfied 'width' constraint.\n");
4002 if (!constr
->height
.GetDone())
4003 wxDebugMsg(" unsatisfied 'height' constraint.\n");
4004 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
4009 wxNode
*node
= GetChildren().First();
4012 wxWindow
*win
= (wxWindow
*)node
->Data();
4013 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
4014 win
->SetConstraintSizes();
4015 node
= node
->Next();
4020 // This assumes that all sizers are 'on' the same
4021 // window, i.e. the parent of this window.
4022 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
4024 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
4025 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
4029 m_sizerParent
->GetPosition(&xp
, &yp
);
4030 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
4035 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
4039 TransformSizerToActual(&xx
, &yy
);
4040 SetSize(xx
, yy
, w
, h
);
4043 void wxWindow::SizerMove(int x
, int y
)
4047 TransformSizerToActual(&xx
, &yy
);
4051 // Only set the size/position of the constraint (if any)
4052 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
4054 wxLayoutConstraints
*constr
= GetConstraints();
4059 constr
->left
.SetValue(x
);
4060 constr
->left
.SetDone(TRUE
);
4064 constr
->top
.SetValue(y
);
4065 constr
->top
.SetDone(TRUE
);
4069 constr
->width
.SetValue(w
);
4070 constr
->width
.SetDone(TRUE
);
4074 constr
->height
.SetValue(h
);
4075 constr
->height
.SetDone(TRUE
);
4080 void wxWindow::MoveConstraint(int x
, int y
)
4082 wxLayoutConstraints
*constr
= GetConstraints();
4087 constr
->left
.SetValue(x
);
4088 constr
->left
.SetDone(TRUE
);
4092 constr
->top
.SetValue(y
);
4093 constr
->top
.SetDone(TRUE
);
4098 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
4100 wxLayoutConstraints
*constr
= GetConstraints();
4103 *w
= constr
->width
.GetValue();
4104 *h
= constr
->height
.GetValue();
4110 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
4112 wxLayoutConstraints
*constr
= GetConstraints();
4115 *w
= constr
->width
.GetValue();
4116 *h
= constr
->height
.GetValue();
4119 GetClientSize(w
, h
);
4122 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
4124 wxLayoutConstraints
*constr
= GetConstraints();
4127 *x
= constr
->left
.GetValue();
4128 *y
= constr
->top
.GetValue();
4134 bool wxWindow::Close(bool force
)
4136 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
4137 event
.SetEventObject(this);
4138 event
.SetForce(force
);
4139 event
.SetCanVeto(!force
);
4141 return (GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto());
4144 wxObject
* wxWindow::GetChild(int number
) const
4146 // Return a pointer to the Nth object in the Panel
4147 // if (!GetChildren())
4149 wxNode
*node
= GetChildren().First();
4152 node
= node
->Next() ;
4155 wxObject
*obj
= (wxObject
*)node
->Data();
4162 void wxWindow::OnDefaultAction(wxControl
*initiatingItem
)
4164 /* This is obsolete now; if we wish to intercept listbox double-clicks,
4165 * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
4168 if (initiatingItem->IsKindOf(CLASSINFO(wxListBox)))
4170 wxListBox *lbox = (wxListBox *)initiatingItem;
4171 wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK);
4172 event.m_commandInt = -1;
4173 if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0)
4175 event.m_commandString = copystring(lbox->GetStringSelection());
4176 event.m_commandInt = lbox->GetSelection();
4177 event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt);
4179 event.m_eventObject = lbox;
4181 lbox->ProcessCommand(event);
4183 if (event.m_commandString)
4184 delete[] event.m_commandString;
4188 wxButton *but = GetDefaultItem();
4191 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
4192 event.SetEventObject(but);
4193 but->Command(event);
4198 void wxWindow::Clear()
4200 wxClientDC
dc(this);
4201 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
4202 dc
.SetBackground(brush
);
4206 // Fits the panel around the items
4207 void wxWindow::Fit()
4211 wxNode
*node
= GetChildren().First();
4214 wxWindow
*win
= (wxWindow
*)node
->Data();
4216 win
->GetPosition(&wx
, &wy
);
4217 win
->GetSize(&ww
, &wh
);
4218 if ( wx
+ ww
> maxX
)
4220 if ( wy
+ wh
> maxY
)
4223 node
= node
->Next();
4225 SetClientSize(maxX
+ 5, maxY
+ 5);
4228 void wxWindow::SetValidator(const wxValidator
& validator
)
4230 if ( m_windowValidator
)
4231 delete m_windowValidator
;
4232 m_windowValidator
= validator
.Clone();
4234 if ( m_windowValidator
)
4235 m_windowValidator
->SetWindow(this) ;
4238 // Find a window by id or name
4239 wxWindow
*wxWindow::FindWindow(long id
)
4244 wxNode
*node
= GetChildren().First();
4247 wxWindow
*child
= (wxWindow
*)node
->Data();
4248 wxWindow
*found
= child
->FindWindow(id
);
4251 node
= node
->Next();
4256 wxWindow
*wxWindow::FindWindow(const wxString
& name
)
4258 if ( GetName() == name
)
4261 wxNode
*node
= GetChildren().First();
4264 wxWindow
*child
= (wxWindow
*)node
->Data();
4265 wxWindow
*found
= child
->FindWindow(name
);
4268 node
= node
->Next();
4274 // Default input behaviour for a scrolling canvas should be to scroll
4275 // according to the cursor keys pressed
4276 void wxWindow::OnChar(wxKeyEvent& event)
4288 GetScrollUnitsPerPage(&x_page, &y_page);
4290 GetVirtualSize(&v_width,&v_height);
4292 ViewStart(&start_x, &start_y);
4295 y_pages = (int)(v_height/vert_units) - y_page;
4303 switch (event.keyCode)
4310 if (start_y - y_page > 0)
4311 Scroll(start_x, start_y - y_page);
4321 if ((y_page > 0) && (start_y <= y_pages-y-1))
4323 if (y_pages + y < start_y + y_page)
4324 Scroll(start_x, y_pages + y);
4326 Scroll(start_x, start_y + y_page);
4333 if ((y_page > 0) && (start_y >= 1))
4334 Scroll(start_x, start_y - 1);
4340 if ((y_page > 0) && (start_y <= y_pages-y-1))
4343 Scroll(start_x, start_y + 1);
4349 if ((x_page > 0) && (start_x >= 1))
4350 Scroll(start_x - 1, start_y);
4356 Scroll(start_x + 1, start_y);
4367 Scroll(start_x, y_pages+y);
4375 // Setup background and foreground colours correctly
4376 void wxWindow::SetupColours()
4379 SetBackgroundColour(GetParent()->GetBackgroundColour());
4382 void wxWindow::OnIdle(wxIdleEvent
& event
)
4384 // Check if we need to send a LEAVE event
4385 if (m_mouseInWindow
)
4388 ::GetCursorPos(&pt
);
4389 if (::WindowFromPoint(pt
) != (HWND
) GetHWND())
4391 // Generate a LEAVE event
4392 m_mouseInWindow
= FALSE
;
4395 if (::GetKeyState(VK_SHIFT
) != 0)
4397 if (::GetKeyState(VK_CONTROL
) != 0)
4398 state
|= MK_CONTROL
;
4400 // Unfortunately the mouse button and keyboard state may have changed
4401 // by the time the OnIdle function is called, so 'state' may be
4404 MSWOnMouseLeave(pt
.x
, pt
.y
, state
);
4410 // Raise the window to the top of the Z order
4411 void wxWindow::Raise()
4413 ::BringWindowToTop((HWND
) GetHWND());
4416 // Lower the window to the bottom of the Z order
4417 void wxWindow::Lower()
4419 ::SetWindowPos((HWND
) GetHWND(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
);
4422 long wxWindow::MSWGetDlgCode()
4424 // default: just forward to def window proc (the msg has no parameters)
4425 return MSWDefWindowProc(WM_GETDLGCODE
, 0, 0);
4428 bool wxWindow::AcceptsFocus() const
4430 return IsShown() && IsEnabled();
4433 // Update region access
4434 wxRegion
wxWindow::GetUpdateRegion() const
4436 return m_updateRegion
;
4439 bool wxWindow::IsExposed(int x
, int y
, int w
, int h
) const
4441 return (m_updateRegion
.Contains(x
, y
, w
, h
) != wxOutRegion
);
4444 bool wxWindow::IsExposed(const wxPoint
& pt
) const
4446 return (m_updateRegion
.Contains(pt
) != wxOutRegion
);
4449 bool wxWindow::IsExposed(const wxRect
& rect
) const
4451 return (m_updateRegion
.Contains(rect
) != wxOutRegion
);
4454 // Set this window to be the child of 'parent'.
4455 bool wxWindow::Reparent(wxWindow
*parent
)
4457 if (parent
== GetParent())
4460 // Unlink this window from the existing parent.
4463 GetParent()->RemoveChild(this);
4466 wxTopLevelWindows
.DeleteObject(this);
4468 HWND hWndParent
= 0;
4469 HWND hWndChild
= (HWND
) GetHWND();
4470 if (parent
!= (wxWindow
*) NULL
)
4472 parent
->AddChild(this);
4473 hWndParent
= (HWND
) parent
->GetHWND();
4476 wxTopLevelWindows
.Append(this);
4478 ::SetParent(hWndChild
, hWndParent
);
4484 const char *wxGetMessageName(int message
)
4486 switch ( message
) {
4487 case 0x0000: return "WM_NULL";
4488 case 0x0001: return "WM_CREATE";
4489 case 0x0002: return "WM_DESTROY";
4490 case 0x0003: return "WM_MOVE";
4491 case 0x0005: return "WM_SIZE";
4492 case 0x0006: return "WM_ACTIVATE";
4493 case 0x0007: return "WM_SETFOCUS";
4494 case 0x0008: return "WM_KILLFOCUS";
4495 case 0x000A: return "WM_ENABLE";
4496 case 0x000B: return "WM_SETREDRAW";
4497 case 0x000C: return "WM_SETTEXT";
4498 case 0x000D: return "WM_GETTEXT";
4499 case 0x000E: return "WM_GETTEXTLENGTH";
4500 case 0x000F: return "WM_PAINT";
4501 case 0x0010: return "WM_CLOSE";
4502 case 0x0011: return "WM_QUERYENDSESSION";
4503 case 0x0012: return "WM_QUIT";
4504 case 0x0013: return "WM_QUERYOPEN";
4505 case 0x0014: return "WM_ERASEBKGND";
4506 case 0x0015: return "WM_SYSCOLORCHANGE";
4507 case 0x0016: return "WM_ENDSESSION";
4508 case 0x0017: return "WM_SYSTEMERROR";
4509 case 0x0018: return "WM_SHOWWINDOW";
4510 case 0x0019: return "WM_CTLCOLOR";
4511 case 0x001A: return "WM_WININICHANGE";
4512 case 0x001B: return "WM_DEVMODECHANGE";
4513 case 0x001C: return "WM_ACTIVATEAPP";
4514 case 0x001D: return "WM_FONTCHANGE";
4515 case 0x001E: return "WM_TIMECHANGE";
4516 case 0x001F: return "WM_CANCELMODE";
4517 case 0x0020: return "WM_SETCURSOR";
4518 case 0x0021: return "WM_MOUSEACTIVATE";
4519 case 0x0022: return "WM_CHILDACTIVATE";
4520 case 0x0023: return "WM_QUEUESYNC";
4521 case 0x0024: return "WM_GETMINMAXINFO";
4522 case 0x0026: return "WM_PAINTICON";
4523 case 0x0027: return "WM_ICONERASEBKGND";
4524 case 0x0028: return "WM_NEXTDLGCTL";
4525 case 0x002A: return "WM_SPOOLERSTATUS";
4526 case 0x002B: return "WM_DRAWITEM";
4527 case 0x002C: return "WM_MEASUREITEM";
4528 case 0x002D: return "WM_DELETEITEM";
4529 case 0x002E: return "WM_VKEYTOITEM";
4530 case 0x002F: return "WM_CHARTOITEM";
4531 case 0x0030: return "WM_SETFONT";
4532 case 0x0031: return "WM_GETFONT";
4533 case 0x0037: return "WM_QUERYDRAGICON";
4534 case 0x0039: return "WM_COMPAREITEM";
4535 case 0x0041: return "WM_COMPACTING";
4536 case 0x0044: return "WM_COMMNOTIFY";
4537 case 0x0046: return "WM_WINDOWPOSCHANGING";
4538 case 0x0047: return "WM_WINDOWPOSCHANGED";
4539 case 0x0048: return "WM_POWER";
4542 case 0x004A: return "WM_COPYDATA";
4543 case 0x004B: return "WM_CANCELJOURNAL";
4544 case 0x004E: return "WM_NOTIFY";
4545 case 0x0050: return "WM_INPUTLANGCHANGEREQUEST";
4546 case 0x0051: return "WM_INPUTLANGCHANGE";
4547 case 0x0052: return "WM_TCARD";
4548 case 0x0053: return "WM_HELP";
4549 case 0x0054: return "WM_USERCHANGED";
4550 case 0x0055: return "WM_NOTIFYFORMAT";
4551 case 0x007B: return "WM_CONTEXTMENU";
4552 case 0x007C: return "WM_STYLECHANGING";
4553 case 0x007D: return "WM_STYLECHANGED";
4554 case 0x007E: return "WM_DISPLAYCHANGE";
4555 case 0x007F: return "WM_GETICON";
4556 case 0x0080: return "WM_SETICON";
4559 case 0x0081: return "WM_NCCREATE";
4560 case 0x0082: return "WM_NCDESTROY";
4561 case 0x0083: return "WM_NCCALCSIZE";
4562 case 0x0084: return "WM_NCHITTEST";
4563 case 0x0085: return "WM_NCPAINT";
4564 case 0x0086: return "WM_NCACTIVATE";
4565 case 0x0087: return "WM_GETDLGCODE";
4566 case 0x00A0: return "WM_NCMOUSEMOVE";
4567 case 0x00A1: return "WM_NCLBUTTONDOWN";
4568 case 0x00A2: return "WM_NCLBUTTONUP";
4569 case 0x00A3: return "WM_NCLBUTTONDBLCLK";
4570 case 0x00A4: return "WM_NCRBUTTONDOWN";
4571 case 0x00A5: return "WM_NCRBUTTONUP";
4572 case 0x00A6: return "WM_NCRBUTTONDBLCLK";
4573 case 0x00A7: return "WM_NCMBUTTONDOWN";
4574 case 0x00A8: return "WM_NCMBUTTONUP";
4575 case 0x00A9: return "WM_NCMBUTTONDBLCLK";
4576 case 0x0100: return "WM_KEYDOWN";
4577 case 0x0101: return "WM_KEYUP";
4578 case 0x0102: return "WM_CHAR";
4579 case 0x0103: return "WM_DEADCHAR";
4580 case 0x0104: return "WM_SYSKEYDOWN";
4581 case 0x0105: return "WM_SYSKEYUP";
4582 case 0x0106: return "WM_SYSCHAR";
4583 case 0x0107: return "WM_SYSDEADCHAR";
4584 case 0x0108: return "WM_KEYLAST";
4587 case 0x010D: return "WM_IME_STARTCOMPOSITION";
4588 case 0x010E: return "WM_IME_ENDCOMPOSITION";
4589 case 0x010F: return "WM_IME_COMPOSITION";
4592 case 0x0110: return "WM_INITDIALOG";
4593 case 0x0111: return "WM_COMMAND";
4594 case 0x0112: return "WM_SYSCOMMAND";
4595 case 0x0113: return "WM_TIMER";
4596 case 0x0114: return "WM_HSCROLL";
4597 case 0x0115: return "WM_VSCROLL";
4598 case 0x0116: return "WM_INITMENU";
4599 case 0x0117: return "WM_INITMENUPOPUP";
4600 case 0x011F: return "WM_MENUSELECT";
4601 case 0x0120: return "WM_MENUCHAR";
4602 case 0x0121: return "WM_ENTERIDLE";
4603 case 0x0200: return "WM_MOUSEMOVE";
4604 case 0x0201: return "WM_LBUTTONDOWN";
4605 case 0x0202: return "WM_LBUTTONUP";
4606 case 0x0203: return "WM_LBUTTONDBLCLK";
4607 case 0x0204: return "WM_RBUTTONDOWN";
4608 case 0x0205: return "WM_RBUTTONUP";
4609 case 0x0206: return "WM_RBUTTONDBLCLK";
4610 case 0x0207: return "WM_MBUTTONDOWN";
4611 case 0x0208: return "WM_MBUTTONUP";
4612 case 0x0209: return "WM_MBUTTONDBLCLK";
4613 case 0x0210: return "WM_PARENTNOTIFY";
4614 case 0x0211: return "WM_ENTERMENULOOP";
4615 case 0x0212: return "WM_EXITMENULOOP";
4618 case 0x0213: return "WM_NEXTMENU";
4619 case 0x0214: return "WM_SIZING";
4620 case 0x0215: return "WM_CAPTURECHANGED";
4621 case 0x0216: return "WM_MOVING";
4622 case 0x0218: return "WM_POWERBROADCAST";
4623 case 0x0219: return "WM_DEVICECHANGE";
4626 case 0x0220: return "WM_MDICREATE";
4627 case 0x0221: return "WM_MDIDESTROY";
4628 case 0x0222: return "WM_MDIACTIVATE";
4629 case 0x0223: return "WM_MDIRESTORE";
4630 case 0x0224: return "WM_MDINEXT";
4631 case 0x0225: return "WM_MDIMAXIMIZE";
4632 case 0x0226: return "WM_MDITILE";
4633 case 0x0227: return "WM_MDICASCADE";
4634 case 0x0228: return "WM_MDIICONARRANGE";
4635 case 0x0229: return "WM_MDIGETACTIVE";
4636 case 0x0230: return "WM_MDISETMENU";
4637 case 0x0233: return "WM_DROPFILES";
4640 case 0x0281: return "WM_IME_SETCONTEXT";
4641 case 0x0282: return "WM_IME_NOTIFY";
4642 case 0x0283: return "WM_IME_CONTROL";
4643 case 0x0284: return "WM_IME_COMPOSITIONFULL";
4644 case 0x0285: return "WM_IME_SELECT";
4645 case 0x0286: return "WM_IME_CHAR";
4646 case 0x0290: return "WM_IME_KEYDOWN";
4647 case 0x0291: return "WM_IME_KEYUP";
4650 case 0x0300: return "WM_CUT";
4651 case 0x0301: return "WM_COPY";
4652 case 0x0302: return "WM_PASTE";
4653 case 0x0303: return "WM_CLEAR";
4654 case 0x0304: return "WM_UNDO";
4655 case 0x0305: return "WM_RENDERFORMAT";
4656 case 0x0306: return "WM_RENDERALLFORMATS";
4657 case 0x0307: return "WM_DESTROYCLIPBOARD";
4658 case 0x0308: return "WM_DRAWCLIPBOARD";
4659 case 0x0309: return "WM_PAINTCLIPBOARD";
4660 case 0x030A: return "WM_VSCROLLCLIPBOARD";
4661 case 0x030B: return "WM_SIZECLIPBOARD";
4662 case 0x030C: return "WM_ASKCBFORMATNAME";
4663 case 0x030D: return "WM_CHANGECBCHAIN";
4664 case 0x030E: return "WM_HSCROLLCLIPBOARD";
4665 case 0x030F: return "WM_QUERYNEWPALETTE";
4666 case 0x0310: return "WM_PALETTEISCHANGING";
4667 case 0x0311: return "WM_PALETTECHANGED";
4670 // common controls messages - although they're not strictly speaking
4671 // standard, it's nice to decode them nevertheless
4674 case 0x1000 + 0: return "LVM_GETBKCOLOR";
4675 case 0x1000 + 1: return "LVM_SETBKCOLOR";
4676 case 0x1000 + 2: return "LVM_GETIMAGELIST";
4677 case 0x1000 + 3: return "LVM_SETIMAGELIST";
4678 case 0x1000 + 4: return "LVM_GETITEMCOUNT";
4679 case 0x1000 + 5: return "LVM_GETITEMA";
4680 case 0x1000 + 75: return "LVM_GETITEMW";
4681 case 0x1000 + 6: return "LVM_SETITEMA";
4682 case 0x1000 + 76: return "LVM_SETITEMW";
4683 case 0x1000 + 7: return "LVM_INSERTITEMA";
4684 case 0x1000 + 77: return "LVM_INSERTITEMW";
4685 case 0x1000 + 8: return "LVM_DELETEITEM";
4686 case 0x1000 + 9: return "LVM_DELETEALLITEMS";
4687 case 0x1000 + 10: return "LVM_GETCALLBACKMASK";
4688 case 0x1000 + 11: return "LVM_SETCALLBACKMASK";
4689 case 0x1000 + 12: return "LVM_GETNEXTITEM";
4690 case 0x1000 + 13: return "LVM_FINDITEMA";
4691 case 0x1000 + 83: return "LVM_FINDITEMW";
4692 case 0x1000 + 14: return "LVM_GETITEMRECT";
4693 case 0x1000 + 15: return "LVM_SETITEMPOSITION";
4694 case 0x1000 + 16: return "LVM_GETITEMPOSITION";
4695 case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA";
4696 case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW";
4697 case 0x1000 + 18: return "LVM_HITTEST";
4698 case 0x1000 + 19: return "LVM_ENSUREVISIBLE";
4699 case 0x1000 + 20: return "LVM_SCROLL";
4700 case 0x1000 + 21: return "LVM_REDRAWITEMS";
4701 case 0x1000 + 22: return "LVM_ARRANGE";
4702 case 0x1000 + 23: return "LVM_EDITLABELA";
4703 case 0x1000 + 118: return "LVM_EDITLABELW";
4704 case 0x1000 + 24: return "LVM_GETEDITCONTROL";
4705 case 0x1000 + 25: return "LVM_GETCOLUMNA";
4706 case 0x1000 + 95: return "LVM_GETCOLUMNW";
4707 case 0x1000 + 26: return "LVM_SETCOLUMNA";
4708 case 0x1000 + 96: return "LVM_SETCOLUMNW";
4709 case 0x1000 + 27: return "LVM_INSERTCOLUMNA";
4710 case 0x1000 + 97: return "LVM_INSERTCOLUMNW";
4711 case 0x1000 + 28: return "LVM_DELETECOLUMN";
4712 case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH";
4713 case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH";
4714 case 0x1000 + 31: return "LVM_GETHEADER";
4715 case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE";
4716 case 0x1000 + 34: return "LVM_GETVIEWRECT";
4717 case 0x1000 + 35: return "LVM_GETTEXTCOLOR";
4718 case 0x1000 + 36: return "LVM_SETTEXTCOLOR";
4719 case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR";
4720 case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR";
4721 case 0x1000 + 39: return "LVM_GETTOPINDEX";
4722 case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE";
4723 case 0x1000 + 41: return "LVM_GETORIGIN";
4724 case 0x1000 + 42: return "LVM_UPDATE";
4725 case 0x1000 + 43: return "LVM_SETITEMSTATE";
4726 case 0x1000 + 44: return "LVM_GETITEMSTATE";
4727 case 0x1000 + 45: return "LVM_GETITEMTEXTA";
4728 case 0x1000 + 115: return "LVM_GETITEMTEXTW";
4729 case 0x1000 + 46: return "LVM_SETITEMTEXTA";
4730 case 0x1000 + 116: return "LVM_SETITEMTEXTW";
4731 case 0x1000 + 47: return "LVM_SETITEMCOUNT";
4732 case 0x1000 + 48: return "LVM_SORTITEMS";
4733 case 0x1000 + 49: return "LVM_SETITEMPOSITION32";
4734 case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT";
4735 case 0x1000 + 51: return "LVM_GETITEMSPACING";
4736 case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA";
4737 case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW";
4738 case 0x1000 + 53: return "LVM_SETICONSPACING";
4739 case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE";
4740 case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE";
4741 case 0x1000 + 56: return "LVM_GETSUBITEMRECT";
4742 case 0x1000 + 57: return "LVM_SUBITEMHITTEST";
4743 case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY";
4744 case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY";
4745 case 0x1000 + 60: return "LVM_SETHOTITEM";
4746 case 0x1000 + 61: return "LVM_GETHOTITEM";
4747 case 0x1000 + 62: return "LVM_SETHOTCURSOR";
4748 case 0x1000 + 63: return "LVM_GETHOTCURSOR";
4749 case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT";
4750 case 0x1000 + 65: return "LVM_SETWORKAREA";
4753 case 0x1100 + 0: return "TVM_INSERTITEMA";
4754 case 0x1100 + 50: return "TVM_INSERTITEMW";
4755 case 0x1100 + 1: return "TVM_DELETEITEM";
4756 case 0x1100 + 2: return "TVM_EXPAND";
4757 case 0x1100 + 4: return "TVM_GETITEMRECT";
4758 case 0x1100 + 5: return "TVM_GETCOUNT";
4759 case 0x1100 + 6: return "TVM_GETINDENT";
4760 case 0x1100 + 7: return "TVM_SETINDENT";
4761 case 0x1100 + 8: return "TVM_GETIMAGELIST";
4762 case 0x1100 + 9: return "TVM_SETIMAGELIST";
4763 case 0x1100 + 10: return "TVM_GETNEXTITEM";
4764 case 0x1100 + 11: return "TVM_SELECTITEM";
4765 case 0x1100 + 12: return "TVM_GETITEMA";
4766 case 0x1100 + 62: return "TVM_GETITEMW";
4767 case 0x1100 + 13: return "TVM_SETITEMA";
4768 case 0x1100 + 63: return "TVM_SETITEMW";
4769 case 0x1100 + 14: return "TVM_EDITLABELA";
4770 case 0x1100 + 65: return "TVM_EDITLABELW";
4771 case 0x1100 + 15: return "TVM_GETEDITCONTROL";
4772 case 0x1100 + 16: return "TVM_GETVISIBLECOUNT";
4773 case 0x1100 + 17: return "TVM_HITTEST";
4774 case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE";
4775 case 0x1100 + 19: return "TVM_SORTCHILDREN";
4776 case 0x1100 + 20: return "TVM_ENSUREVISIBLE";
4777 case 0x1100 + 21: return "TVM_SORTCHILDRENCB";
4778 case 0x1100 + 22: return "TVM_ENDEDITLABELNOW";
4779 case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA";
4780 case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW";
4781 case 0x1100 + 24: return "TVM_SETTOOLTIPS";
4782 case 0x1100 + 25: return "TVM_GETTOOLTIPS";
4785 case 0x1200 + 0: return "HDM_GETITEMCOUNT";
4786 case 0x1200 + 1: return "HDM_INSERTITEMA";
4787 case 0x1200 + 10: return "HDM_INSERTITEMW";
4788 case 0x1200 + 2: return "HDM_DELETEITEM";
4789 case 0x1200 + 3: return "HDM_GETITEMA";
4790 case 0x1200 + 11: return "HDM_GETITEMW";
4791 case 0x1200 + 4: return "HDM_SETITEMA";
4792 case 0x1200 + 12: return "HDM_SETITEMW";
4793 case 0x1200 + 5: return "HDM_LAYOUT";
4794 case 0x1200 + 6: return "HDM_HITTEST";
4795 case 0x1200 + 7: return "HDM_GETITEMRECT";
4796 case 0x1200 + 8: return "HDM_SETIMAGELIST";
4797 case 0x1200 + 9: return "HDM_GETIMAGELIST";
4798 case 0x1200 + 15: return "HDM_ORDERTOINDEX";
4799 case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE";
4800 case 0x1200 + 17: return "HDM_GETORDERARRAY";
4801 case 0x1200 + 18: return "HDM_SETORDERARRAY";
4802 case 0x1200 + 19: return "HDM_SETHOTDIVIDER";
4805 case 0x1300 + 2: return "TCM_GETIMAGELIST";
4806 case 0x1300 + 3: return "TCM_SETIMAGELIST";
4807 case 0x1300 + 4: return "TCM_GETITEMCOUNT";
4808 case 0x1300 + 5: return "TCM_GETITEMA";
4809 case 0x1300 + 60: return "TCM_GETITEMW";
4810 case 0x1300 + 6: return "TCM_SETITEMA";
4811 case 0x1300 + 61: return "TCM_SETITEMW";
4812 case 0x1300 + 7: return "TCM_INSERTITEMA";
4813 case 0x1300 + 62: return "TCM_INSERTITEMW";
4814 case 0x1300 + 8: return "TCM_DELETEITEM";
4815 case 0x1300 + 9: return "TCM_DELETEALLITEMS";
4816 case 0x1300 + 10: return "TCM_GETITEMRECT";
4817 case 0x1300 + 11: return "TCM_GETCURSEL";
4818 case 0x1300 + 12: return "TCM_SETCURSEL";
4819 case 0x1300 + 13: return "TCM_HITTEST";
4820 case 0x1300 + 14: return "TCM_SETITEMEXTRA";
4821 case 0x1300 + 40: return "TCM_ADJUSTRECT";
4822 case 0x1300 + 41: return "TCM_SETITEMSIZE";
4823 case 0x1300 + 42: return "TCM_REMOVEIMAGE";
4824 case 0x1300 + 43: return "TCM_SETPADDING";
4825 case 0x1300 + 44: return "TCM_GETROWCOUNT";
4826 case 0x1300 + 45: return "TCM_GETTOOLTIPS";
4827 case 0x1300 + 46: return "TCM_SETTOOLTIPS";
4828 case 0x1300 + 47: return "TCM_GETCURFOCUS";
4829 case 0x1300 + 48: return "TCM_SETCURFOCUS";
4830 case 0x1300 + 49: return "TCM_SETMINTABWIDTH";
4831 case 0x1300 + 50: return "TCM_DESELECTALL";
4834 case WM_USER
+1: return "TB_ENABLEBUTTON";
4835 case WM_USER
+2: return "TB_CHECKBUTTON";
4836 case WM_USER
+3: return "TB_PRESSBUTTON";
4837 case WM_USER
+4: return "TB_HIDEBUTTON";
4838 case WM_USER
+5: return "TB_INDETERMINATE";
4839 case WM_USER
+9: return "TB_ISBUTTONENABLED";
4840 case WM_USER
+10: return "TB_ISBUTTONCHECKED";
4841 case WM_USER
+11: return "TB_ISBUTTONPRESSED";
4842 case WM_USER
+12: return "TB_ISBUTTONHIDDEN";
4843 case WM_USER
+13: return "TB_ISBUTTONINDETERMINATE";
4844 case WM_USER
+17: return "TB_SETSTATE";
4845 case WM_USER
+18: return "TB_GETSTATE";
4846 case WM_USER
+19: return "TB_ADDBITMAP";
4847 case WM_USER
+20: return "TB_ADDBUTTONS";
4848 case WM_USER
+21: return "TB_INSERTBUTTON";
4849 case WM_USER
+22: return "TB_DELETEBUTTON";
4850 case WM_USER
+23: return "TB_GETBUTTON";
4851 case WM_USER
+24: return "TB_BUTTONCOUNT";
4852 case WM_USER
+25: return "TB_COMMANDTOINDEX";
4853 case WM_USER
+26: return "TB_SAVERESTOREA";
4854 case WM_USER
+76: return "TB_SAVERESTOREW";
4855 case WM_USER
+27: return "TB_CUSTOMIZE";
4856 case WM_USER
+28: return "TB_ADDSTRINGA";
4857 case WM_USER
+77: return "TB_ADDSTRINGW";
4858 case WM_USER
+29: return "TB_GETITEMRECT";
4859 case WM_USER
+30: return "TB_BUTTONSTRUCTSIZE";
4860 case WM_USER
+31: return "TB_SETBUTTONSIZE";
4861 case WM_USER
+32: return "TB_SETBITMAPSIZE";
4862 case WM_USER
+33: return "TB_AUTOSIZE";
4863 case WM_USER
+35: return "TB_GETTOOLTIPS";
4864 case WM_USER
+36: return "TB_SETTOOLTIPS";
4865 case WM_USER
+37: return "TB_SETPARENT";
4866 case WM_USER
+39: return "TB_SETROWS";
4867 case WM_USER
+40: return "TB_GETROWS";
4868 case WM_USER
+42: return "TB_SETCMDID";
4869 case WM_USER
+43: return "TB_CHANGEBITMAP";
4870 case WM_USER
+44: return "TB_GETBITMAP";
4871 case WM_USER
+45: return "TB_GETBUTTONTEXTA";
4872 case WM_USER
+75: return "TB_GETBUTTONTEXTW";
4873 case WM_USER
+46: return "TB_REPLACEBITMAP";
4874 case WM_USER
+47: return "TB_SETINDENT";
4875 case WM_USER
+48: return "TB_SETIMAGELIST";
4876 case WM_USER
+49: return "TB_GETIMAGELIST";
4877 case WM_USER
+50: return "TB_LOADIMAGES";
4878 case WM_USER
+51: return "TB_GETRECT";
4879 case WM_USER
+52: return "TB_SETHOTIMAGELIST";
4880 case WM_USER
+53: return "TB_GETHOTIMAGELIST";
4881 case WM_USER
+54: return "TB_SETDISABLEDIMAGELIST";
4882 case WM_USER
+55: return "TB_GETDISABLEDIMAGELIST";
4883 case WM_USER
+56: return "TB_SETSTYLE";
4884 case WM_USER
+57: return "TB_GETSTYLE";
4885 case WM_USER
+58: return "TB_GETBUTTONSIZE";
4886 case WM_USER
+59: return "TB_SETBUTTONWIDTH";
4887 case WM_USER
+60: return "TB_SETMAXTEXTROWS";
4888 case WM_USER
+61: return "TB_GETTEXTROWS";
4889 case WM_USER
+41: return "TB_GETBITMAPFLAGS";
4894 static char s_szBuf
[128];
4895 sprintf(s_szBuf
, "<unknown message = %d>", message
);
4899 #endif //__WXDEBUG__