如题所述
鼠标放开能获取到当前坐标,促发鼠标放开事件。
可以在这两个事件响应函数中进行绘图。追问
具体函数
追答
void CDrawLinesDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptLastPoint = point;
CDialog::OnLButtonDown(nFlags, point);
}
void CDrawLinesDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptSecondPoint = point;
CClientDC dc(this);
if(m_nDrawType == 0) //画线
{
dc.MoveTo(m_ptLastPoint);
dc.LineTo(point);
}
else if(m_nDrawType == 1)
{
dc.Rectangle(m_ptLastPoint.x,m_ptLastPoint.y,point.x,point.y);
}
else
{
dc.Ellipse(m_ptLastPoint.x,m_ptLastPoint.y,point.x,point.y);
}
CDialog::OnLButtonUp(nFlags, point);
}
void CDrawLinesDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if((nFlags & MK_LBUTTON)==MK_LBUTTON)
{
//真正的实时绘画应该在这里做。
//记得每次擦除上一次绘画的内容,画上这一次绘画的内容。
}
CDialog::OnMouseMove(nFlags, point);
}