Fundamentals of the Picture Control Drag Method on the C++ MFC

Asked 2 years ago, Updated 2 years ago, 103 views

Picture control After receiving the m_pic in CRect form, click the mouse in the coordinates, update the coordinates of the m_pic during Mouse Move, and draw it again using RedrawWindow(); but it doesn't move and only moves the coordinates where it can't be seen Is there any way to move Picture Control? I'd appreciate it if you could give me an answer.

mfc c++

2022-09-22 19:36

1 Answers

Try implementing it in the mouse click event as below

void OnLButtonDown(UINT nFlags, CPoint point)
{
    CRect rc;
    m_Pic.GetClientRect(&rc);
    rc.MoveToXY(point);
    m_Pic.MoveWindow(rc);
}

To move when dragging, change bDragFlag to true in LButtonDown Event MouseMoveIn the event, when the bDragFlag value is true, you can change the position of the m_Pic to the code above, and implement bDragFlag to set the bDragFlag to false in LButtonUp


2022-09-22 19:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.