MFC opened an image, how to use the mouse to drag the image?
CodePudding user response:
Response to a WM_MOUSEMOVE message, if the left key press, according to the drawing as the cursor position weight
CodePudding user response:
Graphics into the CStatic is:
Void CMyStatic: : onm ouseMove (UINT nFlags, CPoint point)
{
//TODO: Add your message handler code here and/or call the default
The static CPoint ptLast;
//
If (MK_LBUTTON==nFlags)
{
CRect rc;
GetWindowRect (& amp; Rc);
The ScreenToClient (& amp; Rc);
MapWindowPoints (GetParent (), & amp; Rc);
MoveWindow (rc) left + point. X-ray ptLast. (x), rc. The top + point. Y - ptLast. (y), rc. The Width (), rc, Height ());
}
The else
{
PtLast=point;
CStatic: onm ouseMove (nFlags, point);
}
Invalidate ().
}
CodePudding user response: