MFC下编写的简易画图系统
来源:互联网 发布:英雄美工钢笔183 编辑:程序博客网 时间:2024/04/27 18:41
主要声明及函数实现:
class CDrawDoc : public CDocument{public:CList<CPoint,CPoint&> linelist;CList<CPoint,CPoint&> rectlist;int lineCount;int rectCount;........}
class CDrawView : public CView{private:bool m_bFlag;CPoint m_headp;CPoint m_endp;CPoint *line;CPoint *rect;int lineCount;int rectCount;......}
CDrawView::CDrawView(){ // TODO: add construction code here m_bFlag = true; line = new CPoint[30]; rect = new CPoint[30]; lineCount = 0; rectCount = 0;}
void CDrawView::OnDraw(CDC* pDC){ CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data hereif(lineCount>=30){CPoint *Line = line;line = new CPoint[lineCount+30];for(int i=0;i<lineCount;i++)line[i] = Line[i];delete Line;}if(rectCount>=30)//数组动态实现{CPoint *Rect = rect;rect = new CPoint[rectCount+30];for(int i=0;i<rectCount;i++)rect[i] = Rect[i];delete Rect;} if(m_bFlag) {line[lineCount++]=m_headp; //将点计入数组中line[lineCount++]=m_endp; pDoc->linelist.AddTail(m_headp);//将点加入到链表中 pDoc->linelist.AddTail(m_endp); pDoc->lineCount++; } else {rect[rectCount++]=m_headp;rect[rectCount++]=m_endp; pDoc->rectlist.AddTail(m_headp); pDoc->rectlist.AddTail(m_endp); pDoc->rectCount++; }//for(int i=0;i<lineCount/2;i++)//{//pDC->MoveTo(line[i*2]);//pDC->LineTo(line[i*2+1]);// }// // for(int j=0;j<rectCount/2;j++)// {// CRect rect(line[j*2],line[j*2+1]);// pDC->Rectangle(rect);// }// for(int j=0; j<lineCount; j++)// {// //循环打印图形,起到重绘的效果// pDC->MoveTo(m_headp);// pDC->LineTo(m_endp);// }// for(int k=0; k<lineCount; k++)// {// CRect rect(m_headp,m_endp);// pDC->Rectangle(rect);// } POSITION posLine; POSITION posRect; posLine=pDoc->linelist.GetHeadPosition(); posRect=pDoc->rectlist.GetHeadPosition(); while(posLine!=NULL) { m_headp=pDoc->linelist.GetNext(posLine); m_endp=pDoc->linelist.GetNext(posLine); pDC->MoveTo(m_headp); pDC->LineTo(m_endp); } while (posRect!=NULL) { m_headp=pDoc->rectlist.GetNext(posRect); m_endp=pDoc->rectlist.GetNext(posRect); pDC->Rectangle(&CRect(m_headp,m_endp)); }}
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point){ // TODO: Add your message handler code here and/or call default m_headp = point; CView::OnLButtonDown(nFlags, point);}void CDrawView::OnLButtonUp(UINT nFlags, CPoint point){ // TODO: Add your message handler code here and/or call default m_endp = point; Invalidate(); CView::OnLButtonUp(nFlags, point);}void CDrawView::OnAppLine(){ // TODO: Add your command handler code here m_bFlag = true;//修改属性画直线}void CDrawView::OnAppRect(){ // TODO: Add your command handler code here m_bFlag = false;//修改属性画矩形}
void CDrawDoc::Serialize(CArchive& ar){if (ar.IsStoring()){// TODO: add storing code here}else{// TODO: add loading code here}linelist.Serialize(ar);//打开保存串行化实现rectlist.Serialize(ar);}
0 0
- MFC下编写的简易画图系统
- vc编写简易画图程序
- mfc下内存缓冲画图的实践
- MFC环境下的vtkChartXY画图指南
- mfc下画图
- MFC下画图
- MFC编写简易计算器应用程序
- MFC画图的基本知识
- Linux系统下简易进度条的实现
- php使用websocket编写的简易客服系统源码分析
- MFC的Dialog下编写OPENGL !
- 转载]MFC下编写的Split函数 :
- MFC下编写的Split函数
- Linux下编写简易进度条
- MFC下写简易计算器
- 简易计算器的编写
- 用STL做的简易英汉词典(VS2005下编写)
- QT5下简易扫雷游戏的编写(过程详细)
- C++类中成员变量的初始化总结
- C++ 虚函数表解析
- ListView 滑动变黑
- 视图创建HTML标签,控制器的几种操作结果
- HTML5 CSS3 诱人的实例 :canvas 模拟实现电子彩票刮刮乐
- MFC下编写的简易画图系统
- EffectiveC++第四章类和函数:设计与声明学习笔记
- Debug .NET Framework Source
- MongoDB学习笔记
- 报表创建和设计控件Stimulsoft Reports.Web for MVC
- svn trunk tag branches
- struts DispatchAction
- XMPP 相关知识整理
- Spring MVC 框架搭建及详解