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

📄 statictestdlg.cpp

📁 WinCE开发技巧与实例的配套源码
💻 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 + -