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

📄 1_7view.cpp

📁 VC++6游戏编程入门及源码,新手必备~
💻 CPP
字号:
// 1_7View.cpp : implementation of the CMy1_7View class
//

#include "stdafx.h"
#include "1_7.h"

#include "1_7Doc.h"
#include "1_7View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View

IMPLEMENT_DYNCREATE(CMy1_7View, CView)

BEGIN_MESSAGE_MAP(CMy1_7View, CView)
	//{{AFX_MSG_MAP(CMy1_7View)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View construction/destruction

CMy1_7View::CMy1_7View()
{
	// TODO: add construction code here
	bitmap.LoadBitmap(IDB_BITMAP1);
}

CMy1_7View::~CMy1_7View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View drawing

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


	int x,y,width,height,i;
	//设置反面显示位图的起点和大小
	//可以在别的地方设置,赋值
	x=350;
	y=30;
	width=240;
	height=200;

    BITMAP     m_bm;
	CDC Dc;
	if(Dc.CreateCompatibleDC(pDC)==FALSE)
		AfxMessageBox("Can't create DC");
	// 选入位图
    Dc.SelectObject(bitmap);
	GetObject(bitmap, sizeof(BITMAP), (LPSTR)&m_bm);
   //显示位图宽高
   POINT      ptSize;
   // 取得位图的宽度
   ptSize.x = m_bm.bmWidth;     
    // 取得位图的该度
   ptSize.y = m_bm.bmHeight;  
   //显示正面位图
   pDC->StretchBlt(10,30,240,200,&Dc,0,0,ptSize.x,ptSize.y,SRCCOPY);
	
    //显示反面位图
	//以下参数的说明:
		//x+(i*width/ptSize.x)表示每个循环的起点位置,其中width/ptSize.x表示每次移动的大小
		//y为显示的top
		//height为显示位图的高度
		//ptSize.x-i为每次SRCCOPY的起点x
 	//在不同位置显示位图	
   for( i=0;i<ptSize.x;i++)
		pDC->StretchBlt(x+(i*width/ptSize.x),y,width/ptSize.x,height,&Dc,ptSize.x-i,0,1,ptSize.y,SRCCOPY);
	


}

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View printing

BOOL CMy1_7View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMy1_7View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMy1_7View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy1_7View message handlers




 

 

⌨️ 快捷键说明

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