mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[MSPAINT] Implement mouse middle button dragging (#5804)
- Handle WM_MBUTTONDOWN and WM_MBUTTONUP messages. - Implement dragging by mouse middle button. - Add IDC_HANDDRAG cursor resource. CORE-19094
This commit is contained in:
parent
40d444919e
commit
97e53c6963
5 changed files with 33 additions and 4 deletions
|
@ -278,7 +278,7 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar)
|
|||
{
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
si.nPos = (SHORT)HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
si.nPos -= 5;
|
||||
|
@ -293,9 +293,9 @@ VOID CCanvasWindow::OnHVScroll(WPARAM wParam, INT fnBar)
|
|||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
si.nPos = max(min(si.nPos, si.nMax), si.nMin);
|
||||
SetScrollInfo(fnBar, &si);
|
||||
updateScrollRange();
|
||||
Invalidate(FALSE); // FIXME: Flicker
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
|
@ -315,7 +315,15 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
|||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
|
||||
m_nMouseDownMsg = nMsg;
|
||||
BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN);
|
||||
BOOL bLeftButton = (nMsg == WM_LBUTTONDOWN);
|
||||
|
||||
if (nMsg == WM_MBUTTONDOWN)
|
||||
{
|
||||
m_ptOrig = pt;
|
||||
SetCapture();
|
||||
::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
HITTEST hitSelection = SelectionHitTest(pt);
|
||||
if (hitSelection != HIT_NONE)
|
||||
|
@ -407,6 +415,17 @@ LRESULT CCanvasWindow::OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
|||
LRESULT CCanvasWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
|
||||
if (m_nMouseDownMsg == WM_MBUTTONDOWN)
|
||||
{
|
||||
INT x = GetScrollPos(SB_HORZ) - (pt.x - m_ptOrig.x);
|
||||
INT y = GetScrollPos(SB_VERT) - (pt.y - m_ptOrig.y);
|
||||
SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
|
||||
SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
|
||||
m_ptOrig = pt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CanvasToImage(pt);
|
||||
|
||||
if (toolsModel.GetActiveTool() == TOOL_ZOOM)
|
||||
|
@ -675,6 +694,12 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (m_nMouseDownMsg == WM_MBUTTONDOWN)
|
||||
{
|
||||
::SetCursor(::LoadCursor(g_hinstExe, MAKEINTRESOURCE(IDC_HANDDRAG)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
POINT pt;
|
||||
::GetCursorPos(&pt);
|
||||
ScreenToClient(&pt);
|
||||
|
|
|
@ -22,11 +22,13 @@ public:
|
|||
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnButtonDown)
|
||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnButtonDown)
|
||||
MESSAGE_HANDLER(WM_MBUTTONDOWN, OnButtonDown)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnButtonDblClk)
|
||||
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnButtonDblClk)
|
||||
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
|
||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnButtonUp)
|
||||
MESSAGE_HANDLER(WM_RBUTTONUP, OnButtonUp)
|
||||
MESSAGE_HANDLER(WM_MBUTTONUP, OnButtonUp)
|
||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
|
||||
MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode)
|
||||
|
|
BIN
base/applications/mspaint/icons/handdrag.cur
Normal file
BIN
base/applications/mspaint/icons/handdrag.cur
Normal file
Binary file not shown.
After Width: | Height: | Size: 326 B |
|
@ -22,6 +22,7 @@
|
|||
#define IDC_ZOOM 532
|
||||
#define IDC_PEN 533
|
||||
#define IDC_AIRBRUSH 534
|
||||
#define IDC_HANDDRAG 535
|
||||
|
||||
#define IDI_HORZSTRETCH 535
|
||||
#define IDI_VERTSTRETCH 536
|
||||
|
|
|
@ -33,6 +33,7 @@ IDC_COLOR ICON "icons/color_cur.ico"
|
|||
IDC_ZOOM ICON "icons/zoom_cur.ico"
|
||||
IDC_PEN ICON "icons/pen_cur.ico"
|
||||
IDC_AIRBRUSH ICON "icons/airbrush_cur.ico"
|
||||
IDC_HANDDRAG CURSOR "icons/handdrag.cur"
|
||||
|
||||
IDI_HORZSTRETCH ICON "icons/horzstretch.ico"
|
||||
IDI_VERTSTRETCH ICON "icons/vertstretch.ico"
|
||||
|
|
Loading…
Reference in a new issue