?? animatedrawdlg.cpp
字號:
// AnimateDrawDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AnimateDraw.h"
#include "AnimateDrawDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAnimateDrawDlg dialog
CAnimateDrawDlg::CAnimateDrawDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAnimateDrawDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAnimateDrawDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAnimateDrawDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAnimateDrawDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAnimateDrawDlg, CDialog)
//{{AFX_MSG_MAP(CAnimateDrawDlg)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAnimateDrawDlg message handlers
BOOL CAnimateDrawDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CAnimateDrawDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
//得到窗口繪圖環境
// CClientDC dc(this);
//定義離屏繪圖環境
CDC offDC;
//定義離屏位圖
CBitmap offBitmap;
//創建離屏環境
offDC.CreateCompatibleDC(&dc);
offBitmap.CreateCompatibleBitmap(&dc,240,320);
offDC.SelectObject(&offBitmap);
//定義位圖繪制環境
CDC bmpDC;
CBitmap aniBmp;
//加載位圖
aniBmp.LoadBitmap(IDB_BMP_ANIMATE);
bmpDC.CreateCompatibleDC(&offDC);
bmpDC.SelectObject(aniBmp);
//循環顯示位圖,形成動畫效果
for(int nCnt=0; nCnt<4; nCnt++)
{
//設置離屏環境為純白色
offDC.PatBlt(0, 0, 240, 320, WHITENESS);
//繪制位圖到離屏繪圖環境中
TransparentImage(offDC.m_hDC,nCnt*4,0,46,57,bmpDC.m_hDC,nCnt*46,0,46,57, RGB(255,0,255));
//將離屏繪圖環境繪制到實際窗口繪圖環境
dc.BitBlt(0,0,240,320,&offDC,0,0,SRCCOPY);
Sleep(100);
}
//刪除位圖GDI對象
aniBmp.DeleteObject();
//刪除位圖繪制環境
bmpDC.DeleteDC();
//刪除離屏位圖GDI對象
offBitmap.DeleteObject();
//刪除離屏繪圖環境
offDC.DeleteDC();
Invalidate();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -