19,466
社区成员
发帖
与我相关
我的任务
分享
CPoint m_PrePoint; //鼠标的先前位置
bool m_bLButtonDown;//鼠标左键是否被按下
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_bLButtonDown = true;
CDC *pDC = GetDC();
pDC->MoveTo(point);
m_PrePoint = point;
ReleaseDC(pDC);
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_bLButtonDown = false;
CView::OnLButtonUp(nFlags, point);
}
void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pDC = GetDC();
if(m_bLButtonDown)
{
pDC->MoveTo(m_PrePoint);
pDC->LineTo(point);
}
m_PrePoint = point;
ReleaseDC(pDC);
CView::OnMouseMove(nFlags, point);
}