📄 ch9demo6view.cpp
字号:
// Ch9Demo6View.cpp : implementation of the CCh9Demo6View class
//
#include "stdafx.h"
#include "Ch9Demo6.h"
#include "Ch9Demo6Doc.h"
#include "Ch9Demo6View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View
IMPLEMENT_DYNCREATE(CCh9Demo6View, CView)
BEGIN_MESSAGE_MAP(CCh9Demo6View, CView)
//{{AFX_MSG_MAP(CCh9Demo6View)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
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()
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View construction/destruction
CCh9Demo6View::CCh9Demo6View()
{
// TODO: add construction code here
}
CCh9Demo6View::~CCh9Demo6View()
{
}
BOOL CCh9Demo6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View drawing
void CCh9Demo6View::OnDraw(CDC* pDC)
{
CCh9Demo6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CBitmap bitmap; //创建CBitmap对象
CDC dcMemory;
bitmap.LoadBitmap(IDB_BITMAP1); //加载位图资源
dcMemory.CreateCompatibleDC(pDC); //创建内存设备环境
dcMemory.SelectObject(& bitmap); //将位图选入内存设备环境中
pDC->BitBlt(0,0,250,234,&dcMemory,0,0,SRCCOPY); //将内存设备环境复制到当前设备环境中
pDC->TextOut(40,240,"原始位图图像");
pDC->StretchBlt(255,0,250,234,&dcMemory,62,58,125,117,SRCCOPY); //局部放大一倍显示位图
pDC->TextOut(290,240,"局部放大一倍");
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View printing
BOOL CCh9Demo6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCh9Demo6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCh9Demo6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View diagnostics
#ifdef _DEBUG
void CCh9Demo6View::AssertValid() const
{
CView::AssertValid();
}
void CCh9Demo6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCh9Demo6Doc* CCh9Demo6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCh9Demo6Doc)));
return (CCh9Demo6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo6View message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -