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);//从任务栏中去掉.