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

📄 bitmapbtndlg.cpp

📁 evc做的用图片做按钮的小程序
💻 CPP
字号:
// bitmapbtnDlg.cpp : implementation file
//

#include "stdafx.h"
#include "bitmapbtn.h"
#include "bitmapbtnDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBitmapbtnDlg dialog

CBitmapbtnDlg::CBitmapbtnDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBitmapbtnDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBitmapbtnDlg)
		// 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 CBitmapbtnDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBitmapbtnDlg)
	DDX_Control(pDX, IDC_BUTTON1, m_bitmapbtn);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBitmapbtnDlg, CDialog)
	//{{AFX_MSG_MAP(CBitmapbtnDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBitmapbtnDlg message handlers

BOOL CBitmapbtnDlg::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
	m_bitmapbtn.SetIcon(IDI_ICON5,IDI_ICON2);
	m_bitmapbtn.MoveWindow(50,40,32,32);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CBitmapbtnDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	AfxMessageBox(L"您单击了图片按钮");
}

HBRUSH CBitmapbtnDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	COLORREF  clo=RGB(250,0,0);
/*
	if(pWnd->GetDlgCtrlID()==IDC_BUTTON1)
	{
		pDC->SetBkColor(clo);
		pDC->SetBkMode(TRANSPARENT);
		hbr=CreateSolidBrush(clo);
	}*/
	if(nCtlColor   ==   CTLCOLOR_BTN)   
	{                                                   
	 pDC->SetBkColor(clo);
	 // TODO: Return a different brush if the default is not desired
	 return hbr;
	}

	
	return   CDialog::OnCtlColor(pDC,   pWnd,   nCtlColor);   
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -