【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-ex41View.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// ex41View.cpp : Cex41View 类的实现
//
#include "stdafx.h"
#include "ex41.h"
#include "ex41Doc.h"
#include "ex41View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cex41View
IMPLEMENT_DYNCREATE(Cex41View, CView)
BEGIN_MESSAGE_MAP(Cex41View, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_WM_PAINT()
END_MESSAGE_MAP()
// Cex41View 构造/销毁
Cex41View::Cex41View()
{
// TODO: 在此处添加构造代码
}
Cex41View::~Cex41View()
{
}
BOOL Cex41View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// Cex41View 绘制
void Cex41View::OnDraw(CDC* pDC)
{
CBrush red(RGB(255,0,0));
pDC->SelectObject(&red);
pDC->Rectangle(m_rcInvalidate);
pDC->SetBkMode(TRANSPARENT);
pDC->DrawText("已经刷新的无效矩形区!",m_rcInvalidate,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
pDC->SelectStockObject(WHITE_BRUSH);
}
// Cex41View 打印
BOOL Cex41View::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void Cex41View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印前添加额外的初始化
}
void Cex41View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印后添加清除过程
}
// Cex41View 诊断
#ifdef _DEBUG
void Cex41View::AssertValid() const
{
CView::AssertValid();
}
void Cex41View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
Cex41Doc* Cex41View::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cex41Doc)));
return (Cex41Doc*)m_pDocument;
}
#endif //_DEBUG
// Cex41View 消息处理
程序 void Cex41View::OnPaint()
{
CPaintDC dc(this); //构造dc
dc.GetClipBox(m_rcInvalidate); //获取无效矩型区放在m_rcInvalidate
////////////////////////////
Invalidate(); //将整个视窗口无效
PAINTSTRUCT ps;
BeginPaint(&ps); //将整个视窗口刷新
EndPaint(&ps); //宣布整个视窗口有效
///////////////////////////
OnDraw(&dc); //画无效矩型区
} //析构dc