绘图-根据Mouse状态画图

来源:互联网 发布:raphael min.js 编辑:程序博客网 时间:2024/06/06 17:39

m_isUp 保存是否抬起鼠标
m_startPoint 保存鼠标起点位置

void CDlg_DCTest1::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 CClientDC dc(this);
 m_isUp = false;
 m_startPoint = point;
 //dc.MoveTo(point);
 CDialog::OnLButtonDown(nFlags, point);
}

void CDlg_DCTest1::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 m_isUp = true;
 CDialog::OnLButtonUp(nFlags, point);
}

void CDlg_DCTest1::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 if (!m_isUp)
 {
  CClientDC dc(this);
  dc.MoveTo(m_startPoint);
  //dc.MoveTo(80, 80); //如果固定起点,会画出扇形
  dc.LineTo(point);
  m_startPoint = point;
 }
 CDialog::OnMouseMove(nFlags, point);
}

 
原创粉丝点击