*********ins-ert***********编译出错请去掉“-”
1. 用下面的类CBmpButton
2. 例化一个CBmpButton并将 控件映射 到想要显示为BMP的按钮上
3. 注意: 要显示BMP的按钮的style属性应选为: owner draw , bitmap
4. 在按钮所在的类里的 3处 添加:
在*.H文件中:
#include "BmpButton.h" //-- 包含头文件
//---------------------------
//-- 添加1
//---------------------------
// Dialog Data
//{ {AFX_DATA(CBitmapButtonDlg)
enum { IDD = IDD_BITMAPBUTTON_DIALOG };
CBmpButton m_BmpButton; //-- added here
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
//---------------------------
//-- 添加1
//---------------------------
// Dialog Data
//{ {AFX_DATA(CBitmapButtonDlg)
enum { IDD = IDD_BITMAPBUTTON_DIALOG };
CBmpButton m_BmpButton; //-- added here
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
//---------------------------
//-- 添加2
//---------------------------
void CBitmapButtonDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{ {AFX_DATA_MAP(CBitmapButtonDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDOK, m_BmpButton);//-- added here
//}}AFX_DATA_MAP
}
//---------------------------
//-- 添加3
//---------------------------
BOOL CBitmapButtonDlg::OnInitDialog()
{
......系统初始化代码
m_BmpButton.SetData( TRUE, IDB_OK );
return TRUE;
}
//---------------------------------------------------------------------------------
//-- 给予CBUTTON的CBmpButton类如下
//-- BmpButton.h
//---------------------------------------------------------------------------------
#if !defined(AFX_BMPBUTTON_H__31EF914C_A839_441A_8FB8_846E71DB1F99__INCLUDED_)
#define AFX_BMPBUTTON_H__31EF914C_A839_441A_8FB8_846E71DB1F99__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BmpButton.h : header file
//
/
// CBmpButton window
class CBmpButton : public CButton
{
// Construction
public:
CBmpButton();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{ {AFX_VIRTUAL(CBmpButton)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL SetData( BOOL ImageOnLeft, UINT IDUp, UINT IDDown=0, UINT IDFocus=0, UINT IDDisabled=0);
void DrawTransparent(CDC* pDC, int x, int y, CBitmap* hbmImage, BOOL LowerLeft=TRUE, COLORREF crColor=0);
void Emboss( CBitmap& Dest, CBitmap& bmSource );
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// Bitmaps for image display
CBitmap m_Up, m_Down, m_Focus, m_Disabled;
// Bitmap height and width information
int m_ImageWidth, m_ImageHeight;
// Flag for image on left or right
BOOL m_ImageOnLeft;
virtual ~CBmpButton();
// Generated message map funct
1. 用下面的类CBmpButton
2. 例化一个CBmpButton并将 控件映射 到想要显示为BMP的按钮上
3. 注意: 要显示BMP的按钮的style属性应选为: owner draw , bitmap
4. 在按钮所在的类里的 3处 添加:
在*.H文件中:
#include "BmpButton.h" //-- 包含头文件
//---------------------------
//-- 添加1
//---------------------------
// Dialog Data
//{ {AFX_DATA(CBitmapButtonDlg)
enum { IDD = IDD_BITMAPBUTTON_DIALOG };
CBmpButton m_BmpButton; //-- added here
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
//---------------------------
//-- 添加1
//---------------------------
// Dialog Data
//{ {AFX_DATA(CBitmapButtonDlg)
enum { IDD = IDD_BITMAPBUTTON_DIALOG };
CBmpButton m_BmpButton; //-- added here
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
//---------------------------
//-- 添加2
//---------------------------
void CBitmapButtonDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{ {AFX_DATA_MAP(CBitmapButtonDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDOK, m_BmpButton);//-- added here
//}}AFX_DATA_MAP
}
//---------------------------
//-- 添加3
//---------------------------
BOOL CBitmapButtonDlg::OnInitDialog()
{
......系统初始化代码
m_BmpButton.SetData( TRUE, IDB_OK );
return TRUE;
}
//---------------------------------------------------------------------------------
//-- 给予CBUTTON的CBmpButton类如下
//-- BmpButton.h
//---------------------------------------------------------------------------------
#if !defined(AFX_BMPBUTTON_H__31EF914C_A839_441A_8FB8_846E71DB1F99__INCLUDED_)
#define AFX_BMPBUTTON_H__31EF914C_A839_441A_8FB8_846E71DB1F99__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BmpButton.h : header file
//
/
// CBmpButton window
class CBmpButton : public CButton
{
// Construction
public:
CBmpButton();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{ {AFX_VIRTUAL(CBmpButton)
//}}AFX_VIRTUAL
// Implementation
public:
BOOL SetData( BOOL ImageOnLeft, UINT IDUp, UINT IDDown=0, UINT IDFocus=0, UINT IDDisabled=0);
void DrawTransparent(CDC* pDC, int x, int y, CBitmap* hbmImage, BOOL LowerLeft=TRUE, COLORREF crColor=0);
void Emboss( CBitmap& Dest, CBitmap& bmSource );
void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// Bitmaps for image display
CBitmap m_Up, m_Down, m_Focus, m_Disabled;
// Bitmap height and width information
int m_ImageWidth, m_ImageHeight;
// Flag for image on left or right
BOOL m_ImageOnLeft;
virtual ~CBmpButton();
// Generated message map funct