?? ddbitmap.cpp
字號:
// Filename: DDBitmap.cpp
#include "stdafx.h"
#include "DDBitmap.h"
// Constructors & Destructors
CDDBitmap::CDDBitmap()
{
// Place any one-time construction code here.
}
CDDBitmap::~CDDBitmap()
{
// Place any destruction code here (i.e. clean-up).
}
// Operations
BOOL CDDBitmap::DrawOnDC (CDC* pDC, int x, int y)
{
// Note: this function should really call
// the StretchOnDC() function so as to minimize
// code duplication. However, implementing this
// second method demonstrates the BitBlt()
// function of the CDC class.
// make sure the CDC pointer is usable
ASSERT_VALID(pDC);
// get bitmap info
BITMAP bm;
GetObject(sizeof(bm), &bm);
// create bitmap memory context
CDC dcBM;
dcBM.CreateCompatibleDC(pDC);
// select the bitmap into the DC
CBitmap* pOldBM = dcBM.SelectObject(this);
// block transfer the bitmap onto the screen
BOOL Result = pDC->BitBlt(x, y, bm.bmWidth,
bm.bmHeight, &dcBM, 0, 0, SRCCOPY);
// return the DC to its original state
dcBM.SelectObject(pOldBM);
return Result;
}
BOOL CDDBitmap::StretchOnDC (CDC* pDC,
int x, int y, int newWidth, int newHeight)
{
// make sure the CDC pointer is usable
ASSERT_VALID(pDC);
// get bitmap info
BITMAP bm;
GetObject(sizeof(bm), &bm);
// create bitmap memory context
CDC dcBM;
dcBM.CreateCompatibleDC(pDC);
// select the bitmap into the DC
CBitmap* pOldBM = dcBM.SelectObject(this);
// stretch the bitmap onto the screen
BOOL Result = pDC->StretchBlt(x, y,
newWidth, newHeight, &dcBM, 0, 0,
bm.bmWidth, bm.bmHeight, SRCCOPY);
// return the DC to its original state
dcBM.SelectObject(pOldBM);
return Result;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -