?? 1_7view.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;
//設(shè)置反面顯示位圖的起點(diǎn)和大小
//可以在別的地方設(shè)置,賦值
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);
//顯示反面位圖
//以下參數(shù)的說明:
//x+(i*width/ptSize.x)表示每個循環(huán)的起點(diǎn)位置,其中width/ptSize.x表示每次移動的大小
//y為顯示的top
//height為顯示位圖的高度
//ptSize.x-i為每次SRCCOPY的起點(diǎn)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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -