欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

【MFC系列-第25、26天】绘图软件

发布时间:2023/12/2 编程问答 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 【MFC系列-第25、26天】绘图软件 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

25.1 绘图软件的绘制原理

纯虚函数:抽象函数,强制在派生类中进行实现;
虚函数:有函数体,可在基类也可在派生类中实现。
基类CLayer

class CLayer {//抽象类 public:CLayer();~CLayer();virtual void OnDraw(CDC* pDC) = 0;virtual void OnLButtonDown(UINT nFlags, CPoint point)=0; //纯虚函数,在派生类中具体实现//virtual void OnLButtonUp(UINT nFlags, CPoint point);//virtual void OnMouseMove(UINT nFlags, CPoint point); };

派生类Cline

class CLine : public CLayer {CPoint m_start, m_end;void OnDraw(CDC* pDC);void OnLButtonDown(UINT nFlags, CPoint point); public:CLine();~CLine(); }; void CLine::OnDraw(CDC * pDC) {pDC->MoveTo(m_start);pDC->LineTo(m_end); } void CLine::OnLButtonDown(UINT nFlags, CPoint point) {m_start = point; } CLine::CLine():m_start(0,0),m_end(0,0) { } CLine::~CLine() { }

派生类CRecta

class CRecta :public CLayer {CRect m_rect;void OnLButtonDown(UINT nFlags, CPoint point);void OnDraw(CDC* pDC); public:CRecta();~CRecta(); };void CRecta::OnLButtonDown(UINT nFlags, CPoint point) {m_rect.TopLeft() = point; } void CRecta::OnDraw(CDC * pDC) {pDC->Rectangle(m_rect); } CRecta::CRecta():m_rect(0,0,0,0) { } CRecta::~CRecta() { }

派生类CEllipse

class CEllipse :public CLayer {CRect m_rect;void OnDraw(CDC* pDC);void OnLButtonDown(UINT nFlags, CPoint point); public:CEllipse();~CEllipse(); };void CEllipse::OnDraw(CDC * pDC) {pDC->Ellipse(m_rect); }void CEllipse::OnLButtonDown(UINT nFlags, CPoint point) {m_rect.TopLeft() = point; }CEllipse::CEllipse():m_rect(0,0,0,0) { }CEllipse::~CEllipse() { }

25.2 绘图软件的绘制过程

25.3 图层选中状态控制

26.1 图层拖动过程控制

26.2 绘图软件的文字录入控制

26.3 绘图软件的文字选取控制

26.4 绘图软件的文字颜色控制

从任务栏去掉窗口

ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);//从任务栏中去掉.

总结

以上是生活随笔为你收集整理的【MFC系列-第25、26天】绘图软件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。