用MFC写一个简单的画图程序(恐怕这个应该是大家更加注意的)
在这里只贴出部分代码:
下面源代码,可以直接运行(VC6 MFC)(关于其整个工程文件可以到www.confach.533.net去Download),如果你找不到,可以直接按上面的联系方式与我Mail,我会尽快给你发过去,大家一起学习)
void CSTLMFCTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCapture();
if(mPointVector.size()!=0)
{
CClientDC dc(this);
CSTLMFCTestDoc* pDoc=this->GetDocument();
CPen lNewPen(PS_SOLID,pDoc->m_iPenWidth,pDoc->mColor);
CPen* pOldPen=dc.SelectObject(&lNewPen);
dc.MoveTo((CPoint)mPointVector[mPointVector.size()-1]);
dc.LineTo(point);
dc.SelectObject(pOldPen);
pDoc->SetModifiedFlag(TRUE);
}
mPointVector.push_back(point);
CView::OnLButtonDown(nFlags, point);
}
void CSTLMFCTestView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(GetCapture()==this)
ReleaseCapture();
CView::OnLButtonUp(nFlags, point);
}
void CSTLMFCTestView::OnMouseMove(UINT nFlags, CPoint point)
{
// // TODO: Add your message handler code here and/or call default
if((nFlags&MK_LBUTTON)!=MK_LBUTTON)
{
return;
}
if(mPointVector.size()!=0)
{
CClientDC dc(this);
CSTLMFCTestDoc* pDoc=this->GetDocument();
CPen lNewPen(PS_SOLID,pDoc->m_iPenWidth,pDoc->mColor);
CPen* pOldPen=dc.SelectObject(&lNewPen);
dc.MoveTo((CPoint)mPointVector[mPointVector.size()-1]);
dc.LineTo(point);
dc.SelectObject(pOldPen);
pDoc->SetModifiedFlag(TRUE);
}
mPointVector.push_back(point);
CView::OnMouseMove(nFlags, point);
}