void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//MessageBox("view clicked");
m_ptOrigin = point;
m_bDraw = TRUE;
CView::OnLButtonDown(nFlags, point);
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
第一种:使用API函数
/* HDC hdc;
hdc = ::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);
*/
第二种:使用CDC类实现
/*CDC *pDC = GetDC();
pDC->MoveTo(m_ptOrigin);
pDC->LineTo(point);
ReleaseDC(pDC); */
第三种:使用CClientDC
/*CClientDC dc(this);
//CClientDC dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);*/
第四种:使用CWindow