BOOL w=FALSE;
void CLineView::OnLButtonDown(UINT nFlags, CPoint point)
{
CView::OnLButtonDown(nFlags, point);
if(w)
{
m_ptFrist.x=point.x;
m_ptFrist.y=point.y;
}
else
{
m_ptSecend.x=point.x;
m_ptSecend.y=point.y;
}
w=!w;
}void CLineView::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(m_ptFrist);
dc.LineTo(m_ptSecend);
}
我原来的想法是点下鼠标左键时,随着鼠标的移动会在屏幕上不停的绘制直线,当再次点下左键的时候停止。但是调试时我发现,我点下左键后屏幕没有任何的反应,再在屏幕上另外一点点下后,再点左上角的新建(我建立的是一个单文档),就在我点的这两点间绘制了一条直线,怎么会事的啊~~??
void CLineView::OnLButtonDown(UINT nFlags, CPoint point)
{
CView::OnLButtonDown(nFlags, point);
if(w)
{
m_ptFrist.x=point.x;
m_ptFrist.y=point.y;
}
else
{
m_ptSecend.x=point.x;
m_ptSecend.y=point.y;
}
w=!w;
}void CLineView::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(m_ptFrist);
dc.LineTo(m_ptSecend);
}
我原来的想法是点下鼠标左键时,随着鼠标的移动会在屏幕上不停的绘制直线,当再次点下左键的时候停止。但是调试时我发现,我点下左键后屏幕没有任何的反应,再在屏幕上另外一点点下后,再点左上角的新建(我建立的是一个单文档),就在我点的这两点间绘制了一条直线,怎么会事的啊~~??
根据移动的当前点和原来鼠标左键的点画线
CView::OnLButtonDown(nFlags, point);
if(w)
{
m_ptFrist.x=point.x;
m_ptFrist.y=point.y;
}
else
{
m_ptSecend.x=point.x;
m_ptSecend.y=point.y;
Invalidate( TRUE )
}
w=!w;
void CLineView::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(m_ptFrist);
dc.LineTo(m_ptSecend);
}
void CLineView::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(m_ptFrist);
dc.LineTo(m_ptSecend);
}如果想要原来的线段,就得把原来的线段重新画一遍,要不就只有刚画的这条了.
最好是用个数组.