15,980
社区成员
发帖
与我相关
我的任务
分享
BOOL bDown = FALSE;
CPoint m_ptStart;
CPoint m_ptEnd;
void CXXView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
bDown = TRUE;
m_ptStart = point;
CView::OnLButtonDown(nFlags, point);
}
void CXXView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
bDown = FALSE;
CView::OnLButtonUp(nFlags, point);
}
void CXXView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(bDown)
{
m_ptEnd = point;
InvalidateRect(NULL);
}
CView::OnMouseMove(nFlags, point);
}
void CXXView::OnDraw(CDC* pDC)
{
CAXDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->MoveTo(m_ptStart);
pDC->LineTo(m_ptEnd);
}