void CMfcView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_old = point;
m_bool = true;
CView::OnLButtonDown(nFlags, point);
}
void CMfcView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
/*使用windowsAPI函数实现画线的功能*/
// HDC hdc;
// hdc = ::GetDC(m_hWnd);
// MoveToEx(hdc,m_old.x,m_old.y,NULL);
// LineTo(hdc,point.x,point.y);
// ::ReleaseDC(m_hWnd,hdc);
/*使用CDC实现画线功能*/
// CDC *dc = GetDC();
// dc->MoveTo(m_old);
// dc->LineTo(point);
// ReleaseDC(dc);
/*使用CClinetDC*/
// CClientDC dc(/*this*/GetParent());
// dc.MoveTo(m_old);
// dc.LineTo(point);
/*使用CwindowDC*/
// CWindowDC dc(GetDesktopWindow());
// dc.MoveTo(m_old);
// dc.LineTo(point <a href="http://belizevolleyball.org/">payday loans guaranteed no fax</a>);
/*画彩色线*/
// CPen pen(PS_DOT,1,RGB(255,0,0));
// CClientDC dc(this);
// dc.SelectObject(&pen);
// dc.MoveTo(m_old);
// dc.LineTo(point);
/*画彩色矩形*/
// CBrush brush(RGB(255,0,0));
// CClientDC dc(this);
// dc.SelectObject(&brush);
// dc.Rectangle(m_old.x,m_old.y,point.x,point.y);
/*创建位图画刷*/
// CBitmap bt;
// bt.LoadBitmap(IDB_BITMAP1);
// CBrush brush(&bt);
// CClientDC dc(this);
// dc.SelectObject(&brush);
// dc.Rectangle(m_old.x,m_old.y,point.x,point.y);
/*透明画刷的创建*/
// CBrush *brs = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
// CClientDC dc(this);
// dc.SelectObject(brs);
/* dc.Rectangle(CRect(m_old,point));*/
m_bool = false;
CView::OnLButtonUp(nFlags, point);
}
void CMfcView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//模仿windows画图板的画笔功能
if (m_bool== true)
{
CClientDC dc(this);
dc.MoveTo(m_old);
dc.LineTo(point);
m_old = point ;
}
CView::OnMouseMove(nFlags, point);
}