- HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle
- ::GetUpdateRgn((HWND) GetHWND(), hRegion, FALSE);
-
- m_updateRegion = wxRegion((WXHRGN) hRegion);
-#else
- RECT updateRect;
- ::GetUpdateRect((HWND) GetHWND(), & updateRect, FALSE);
-
- m_updateRegion = wxRegion(updateRect.left, updateRect.top,
- updateRect.right - updateRect.left, updateRect.bottom - updateRect.top);
-#endif
-
- wxPaintEvent event(m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
- return TRUE;
-}
-
-void wxWindow::MSWOnSize(int w, int h, WXUINT WXUNUSED(flag))
-{
- if (m_inOnSize)
- return;
-
- if (!m_hWnd)
- return;
-
- m_inOnSize = TRUE;
-
- wxSizeEvent event(wxSize(w, h), m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-
- m_inOnSize = FALSE;
-}
-
-void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos))
-{
- Default();
-}
-
-// Deal with child commands from buttons etc.
-bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
-{
- if (wxCurrentPopupMenu)
- {
- wxMenu *popupMenu = wxCurrentPopupMenu;
- wxCurrentPopupMenu = NULL;
- bool succ = popupMenu->MSWCommand(cmd, id);
- return succ;
- }
-
- wxWindow *item = FindItem(id);
- if (item)
- {
- bool value = item->MSWCommand(cmd, id);
- return value;
- }
- else
- {
- wxWindow *win = wxFindWinFromHandle(control);
- if (win)
- return win->MSWCommand(cmd, id);
- }
- return FALSE;
-}
-
-long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam)
-{
- switch (wParam & 0xFFFFFFF0)
- {
- case SC_MAXIMIZE:
- {
- wxMaximizeEvent event(m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- return Default();
- else
- return 0;
- break;
- }
- case SC_MINIMIZE:
- {
- wxIconizeEvent event(m_windowId);
- event.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(event))
- return Default();
- else
- return 0;
- break;
- }
- default:
- return Default();
- }
- return 0;
-}
-
-void wxWindow::MSWOnLButtonDown(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_LEFT_DOWN);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DOWN;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnLButtonUp(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_LEFT_UP);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_UP;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnLButtonDClick(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_LEFT_DCLICK);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DCLICK;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnMButtonDown(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_MIDDLE_DOWN);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DOWN;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnMButtonUp(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_MIDDLE_UP);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_UP;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnMButtonDClick(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_MIDDLE_DCLICK);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DCLICK;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnRButtonDown(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_RIGHT_DOWN);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DOWN;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnRButtonUp(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_RIGHT_UP);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.m_eventObject = this;
- event.SetTimestamp(wxApp::sm_lastMessageTime);
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_UP;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnRButtonDClick(int x, int y, WXUINT flags)
-{
- wxMouseEvent event(wxEVT_RIGHT_DCLICK);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DCLICK;
-
- if (!GetEventHandler()->ProcessEvent(event))
- Default();
-}
-
-void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags)
-{
- // 'normal' move event...
-
- if (!m_mouseInWindow)
- {
- // Generate an ENTER event
- m_mouseInWindow = TRUE;
- MSWOnMouseEnter(x, y, flags);
- }
-
- wxMouseEvent event(wxEVT_MOTION);
-
- event.m_x = x; event.m_y = y;
- event.m_shiftDown = ((flags & MK_SHIFT) != 0);
- event.m_controlDown = ((flags & MK_CONTROL) != 0);
- event.m_leftDown = ((flags & MK_LBUTTON) != 0);
- event.m_middleDown = ((flags & MK_MBUTTON) != 0);
- event.m_rightDown = ((flags & MK_RBUTTON) != 0);
- event.SetTimestamp(wxApp::sm_lastMessageTime);
- event.m_eventObject = this;
-
- // Window gets a click down message followed by a mouse move
- // message even if position isn't changed! We want to discard
- // the trailing move event if x and y are the same.
- if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN ||
- m_lastEvent == wxEVT_MIDDLE_DOWN) &&
- (m_lastXPos == event.m_x && m_lastYPos == event.m_y))
- {
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;
- m_lastEvent = wxEVT_MOTION;
- return;
- }
-
- m_lastEvent = wxEVT_MOTION;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y;