BEGIN_MESSAGE_MAP(CmfcView, CView)
    ON_WM_LBUTTONDOWN()
    ON_WM_LBUTTONUP()
    ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()

CPoint   m_startpt;
void CmfcView::OnLButtonDown(UINT nFlags, CPoint point)
{
    m_startpt = point;
    SetCapture();
    CView::OnLButtonDown(nFlags, point);
}

void CmfcView::OnLButtonUp(UINT nFlags, CPoint point)
{
    if (GetCapture() == this) {
        ReleaseCapture();
    }
    CView::OnLButtonUp(nFlags, point);
}

void CmfcView::OnMouseMove(UINT nFlags, CPoint point)
{
    if (nFlags && MK_LBUTTON) {
        //画直线
        CClientDC dc(this);
        dc.MoveTo(m_startpt.x, m_startpt.y);
        dc.LineTo(point.x, point.y);
    }
    CView::OnMouseMove(nFlags, point);
}