CBitmapButton* pmyButton = new CBitmapButton();// Create the bitmap button (must include the BS_OWNERDRAW style). pmyButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(10,10,100,100), pParentWnd, 1);// Load the bitmaps for this button. pmyButton->LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);
http://topic.csdn.net/t/20031211/13/2552565.html
或者http://www.vckbase.com/document/viewdoc/?id=1690
min.LoadBitmaps(IDB_BITMAP47,IDB_BITMAP48,IDB_BITMAP49,IDB_BITMAP47);
min.SubclassDlgItem(IDC_BUTTON1,this);
min.SizeToContent();按钮属性owner draw改为true
CBitmapButton* pmyButton = new CBitmapButton();// Create the bitmap button (must include the BS_OWNERDRAW style).
pmyButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
CRect(10,10,100,100), pParentWnd, 1);// Load the bitmaps for this button.
pmyButton->LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);
不过原理是一样的
http://blog.csdn.net/xianglitian/archive/2007/08/06/1728242.aspx
最简单的方法是用BITMAP
按钮上显示图片或图标在按钮属性中选中Bitmap或Icon:
先定义CButton m_ico成员变量,然后再初始化中加入
HBITMAP hBitmap1=::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_1));
m_ico.SetBitmap(hBitmap1);
//其中IDB_1为要在按钮上显示的图像
若为图标,则在初始化中:
HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICONBUTTON);
m_ico.SetIcon(hIcon);
//IDI_ICONBUTTON为在按钮上显示的图标 以上代码添加在CXXXXDlg::OnInitDialog()里面
引自