STL的心得(4)--运用(MFC)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

用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);

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航