?? statictestdlg.cpp
字號:
// StaticTestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "StaticTest.h"
#include "StaticTestDlg.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaticTestDlg dialog
CStaticTestDlg::CStaticTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStaticTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStaticTestDlg)
// 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 CStaticTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStaticTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStaticTestDlg, CDialog)
//{{AFX_MSG_MAP(CStaticTestDlg)
ON_BN_CLICKED(IDC_STATICTEST, OnStatictest)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaticTestDlg message handlers
BOOL CStaticTestDlg::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
return TRUE; // return TRUE unless you set the focus to a control
}
void CStaticTestDlg::OnStatictest()
{
MessageBox(L"You clicked a static control");
}
void CStaticTestDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcPlaceHolder;
GetDlgItem(IDC_STATICTEST)->GetWindowRect(&rcPlaceHolder);
ScreenToClient(&rcPlaceHolder);
CBitmap bmp;
if (bmp.LoadBitmap(IDB_BITMAP1))
{
// 獲得位圖
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);
// 建立CDC對象
CDC dcMemory;
dcMemory.CreateCompatibleDC(&dc);
// 將位圖選入CDC對象中.
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
// 找到繪圖區中點.
CRect rect;
GetClientRect(&rect);
int nX = rcPlaceHolder.left;//rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
int nY = rcPlaceHolder.top;//rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
// 將位圖從CDC中復制到屏幕上.
dc.BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
增大字號
Ctrl + =
減小字號
Ctrl + -