⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rollbmpview.cpp

📁 本压缩软件为《Visual C++6.0基础教程》(黑魔方系列)一书的源代码
💻 CPP
字号:
// RollBmpView.cpp : implementation of the CRollBmpView class
//

#include "stdafx.h"
#include "RollBmp.h"

#include "RollBmpDoc.h"
#include "RollBmpView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRollBmpView

IMPLEMENT_DYNCREATE(CRollBmpView, CView)

BEGIN_MESSAGE_MAP(CRollBmpView, CView)
	//{{AFX_MSG_MAP(CRollBmpView)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRollBmpView construction/destruction

CRollBmpView::CRollBmpView()
{
	// TODO: add construction code here

}

CRollBmpView::~CRollBmpView()
{
}

BOOL CRollBmpView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CRollBmpView drawing

void CRollBmpView::OnDraw(CDC* pDC)
{
	CRollBmpDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CRollBmpView diagnostics

#ifdef _DEBUG
void CRollBmpView::AssertValid() const
{
	CView::AssertValid();
}

void CRollBmpView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CRollBmpDoc* CRollBmpView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRollBmpDoc)));
	return (CRollBmpDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRollBmpView message handlers

void CRollBmpView::OnPaint() 
{
	RECT rect;
	CPaintDC dc(this);      //建立响应WM_PAINT消息的DC
  	CDC *md = new CDC;       //建立一暂存DC md
	CBitmap *bg=new CBitmap;  //建立CBitmap位图对象
 	CBitmap *bitmap = new CBitmap;  //建立CBitmap位图对象
 	GetClientRect(&rect);   //取得操作窗口大小
 	md->CreateCompatibleDC(&dc); //将md转换成与dc兼容的DC
    //加载位图
	bg->m_hObject = (HBITMAP)::LoadImage(NULL,"back1.bmp",
	IMAGE_BITMAP,rect.right,rect.bottom,LR_LOADFROMFILE); 
	md->SelectObject(bg);  //选择位图对象到md中
	dc.BitBlt(0,0,rect.right,rect.bottom,md,0,0,SRCCOPY);
	bitmap->m_hObject = (HBITMAP)::LoadImage(NULL,"ship.bmp",
		IMAGE_BITMAP,198,74,LR_LOADFROMFILE); //加载源位图图案
	md->SelectObject(bitmap);     //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -