LRESULT RootWindow::OnMouseMove(WPARAM key, int x, int y) { BOOL fShouldHaveBorder = PointInsideRect(x, y, m_pictPosX, m_pictPosY, m_pictPixelDx, m_pictPixelDy); if (fShouldHaveBorder == m_fPictHasBorder) return 0; m_fPictHasBorder = fShouldHaveBorder; InvalidateRect(m_hwnd, NULL, FALSE); UpdateWindow(m_hwnd); return 0; }
/** Processes a window-message. Return false to stop the message from going to children */ bool D2DDialog::OnWindowMessage(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam, const D2D1_RECT_F& clientRectAbs) { switch(msg) { case WM_LBUTTONDOWN: { POINT p = D2DView::GetCursorPosition(); if(PointInsideRect(p, D2D1::RectF(clientRectAbs.left, clientRectAbs.top, clientRectAbs.right, clientRectAbs.top + DIALOG_HEADER_SIZE))) { DraggingWindow = true; WindowDragOffset = D2D1::Point2F(p.x - clientRectAbs.left, p.y - clientRectAbs.top); return false; } } break; case WM_MOUSEMOVE: if(DraggingWindow) { POINT p = D2DView::GetCursorPosition(); SetPosition(D2D1::Point2F(p.x - WindowDragOffset.x, p.y - WindowDragOffset.y)); return false; } break; case WM_LBUTTONUP: if(DraggingWindow) { DraggingWindow = false; return false; } break; } return D2DSubView::OnWindowMessage(hWnd, msg, wParam, lParam, clientRectAbs); }
/** Processes a window-message. Return false to stop the message from going to children */ bool SV_GMeshInfoView::OnWindowMessage(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam, const D2D1_RECT_F& clientRectAbs) { switch(msg) { case WM_MOUSEMOVE: if(IsDraggingView) { POINT p = D2DView::GetCursorPosition(); float yaw, pitch, distance; GetObjectOrientation(yaw, pitch, distance); yaw += (LastDragPosition.x - p.x) * MESH_ROT_SPEED; pitch -= (LastDragPosition.y - p.y) * MESH_ROT_SPEED; SetObjectOrientation(yaw, pitch, distance); UpdateView(); LastDragPosition = p; return false; } break; case WM_LBUTTONDOWN: { POINT p = D2DView::GetCursorPosition(); D2D1_RECT_F panelrect = D2D1::RectF(Panel->GetPosition().x + clientRectAbs.left, Panel->GetPosition().y + clientRectAbs.top, Panel->GetSize().width + clientRectAbs.left, Panel->GetSize().height + clientRectAbs.top); if(PointInsideRect(D2D1::Point2F((float)p.x, (float)p.y), panelrect)) { IsDraggingView = true; LastDragPosition = p; return false; } } break; case WM_LBUTTONUP: if(IsDraggingView) { IsDraggingView = false; return false; } break; case WM_MOUSEWHEEL: { POINT p = D2DView::GetCursorPosition(); D2D1_RECT_F panelrect = D2D1::RectF(Panel->GetPosition().x + clientRectAbs.left, Panel->GetPosition().y + clientRectAbs.top, Panel->GetSize().width + clientRectAbs.left, Panel->GetSize().height + clientRectAbs.top); if(PointInsideRect(D2D1::Point2F((float)p.x, (float)p.y), panelrect)) { FOV += GET_WHEEL_DELTA_WPARAM(wParam) * ZOOM_SPEED; UpdateView(); } } break; } return D2DSubView::OnWindowMessage(hWnd, msg, wParam, lParam, clientRectAbs); }