private:
CPoint m_ptOrigin;
CPtestView::CPtestView()
{
// TODO: add construction code here
m_ptOrigin=0;
}
void CPtestView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// MessageBox("view clicked");
m_ptOrigin=point;
CView::OnLButtonDown(nFlags, point);
}
void CPtestView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//画线1
/*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);
*/
//画线2
/*
CDC *pDc=GetDC();
pDc->MoveTo(m_ptOrigin);
pDc->LineTo(point);
ReleaseDC(pDc);
*/
//画线3
/*
CClientDC dc(this);//dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
*/
/*
//画线4
//CWindowDC dc(this);//本View的指针地址
//CWindowDC dc(GetParent());//父框架的指针地址
CWindowDC dc(GetDesktopWindow());//GetDesktopWindow();桌面得指针地址
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
*/
//画线5
/*
CPen pen(PS_SOLID,10,RGB(255,0,0));
CClientDC dc(this);
CPen *pOldPen=dc.SelectObject(&pen);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
dc.SelectObject(pOldPen);
*/
CView::OnLButtonUp(nFlags, point);
}