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

📄 bitmappaveview.cpp

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

#include "stdafx.h"
#include "BitmapPave.h"

#include "BitmapPaveDoc.h"
#include "BitmapPaveView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBitmapPaveView

IMPLEMENT_DYNCREATE(CBitmapPaveView, CView)

BEGIN_MESSAGE_MAP(CBitmapPaveView, CView)
	//{{AFX_MSG_MAP(CBitmapPaveView)
	ON_COMMAND(IDM_CONTROL_NOPAVE, OnControlNopave)
	ON_COMMAND(IDM_CONTROL_PAVE, OnControlPave)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CBitmapPaveView construction/destruction

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

}

CBitmapPaveView::~CBitmapPaveView()
{
}

BOOL CBitmapPaveView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	pingpu = false;
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CBitmapPaveView drawing

void CBitmapPaveView::OnDraw(CDC* pDC)
{
	CBitmapPaveDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CBitmap bitmap;
	CDC dcMemory;
	bitmap.LoadBitmap ( IDB_BITMAPPAVE);//装载ID为IDB_BITMAPPAVE的位图资源
	dcMemory.CreateCompatibleDC ( pDC);//开辟特殊内存
	CBitmap *pOldBitmap = dcMemory.SelectObject ( &bitmap);//选入设备环境
	if( pingpu == false)
	pDC->BitBlt ( 0, 0,174, 197, &dcMemory , 0, 0, SRCCOPY);
	if ( pingpu == true)
		for ( int i=0; i<22;i++)
			for (int j=0; j<16; j++)
			{
				 pDC->BitBlt ( 174*i, 197*j, 174,197, &dcMemory , 0, 0, SRCCOPY);
			}
	dcMemory.SelectObject ( pOldBitmap);//选入设备环境,以便删除
}

/////////////////////////////////////////////////////////////////////////////
// CBitmapPaveView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CBitmapPaveView message handlers

void CBitmapPaveView::OnControlNopave() 
{
	// TODO: Add your command handler code here
	pingpu = false;//对控制变量作修改
	Invalidate();
	
}

void CBitmapPaveView::OnControlPave() 
{
	// TODO: Add your command handler code here
	pingpu = true;//对控制变量作修改
	Invalidate();
}

⌨️ 快捷键说明

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