gdiview.cpp
来自「MFC编程实例」· C++ 代码 · 共 84 行
CPP
84 行
#include "stdafx.h"
#include "GDI.h"
#include "GDIDoc.h"
#include "GDIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CGDIView, CView)
BEGIN_MESSAGE_MAP(CGDIView, CView)
//{{AFX_MSG_MAP(CGDIView)
//}}AFX_MSG_MAP
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
CGDIView::CGDIView()
{
}
CGDIView::~CGDIView()
{
}
BOOL CGDIView::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
void CGDIView::OnDraw(CDC *pDC)
{
CBrush brush;
CRect rect;
int i;
CGDIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
GetClientRect(rect);
rect.bottom+=255;
rect.bottom/=256;
for(i=0; i<256; i++)
{
brush.CreateSolidBrush(RGB(0, 0, i));
pDC->FillRect(rect, &brush);
brush.DeleteObject();
rect.OffsetRect(0, rect.Height());
}
}
BOOL CGDIView::OnPreparePrinting(CPrintInfo* pInfo)
{
return DoPreparePrinting(pInfo);
}
void CGDIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
void CGDIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
#ifdef _DEBUG
void CGDIView::AssertValid() const
{
CView::AssertValid();
}
void CGDIView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CGDIDoc* CGDIView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGDIDoc)));
return (CGDIDoc*)m_pDocument;
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?