MFC ToolBar工具栏修改指定Button的Icon,添加文字的方法

一.修改指定Button的ICon:

	int TotalImage =m_wndColorToolBar.GetToolBarCtrl().AddBitmap(1, IDB_SELECTCHECKBOX/*BMP Resource*/);
	m_wndColorToolBar.SetButtonInfo(5/*Button Index In Tool Bar*/, IDB_CHECKBTNTOOLBAR/*One Button In Tool Bar*/, TBBS_CHECKBOX , TotalImage);

二.给Button添加文字:

#define TBSTYLE_EX_MIXEDBUTTONS   0x00000008
#define BTNS_SHOWTEXT 0x0040

m_wndColorToolBar.ModifyStyle(0, BTNS_SHOWTEXT | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_LIST);

//set text of button in tool bar.
m_wndColorToolBar.SetButtonText(5, _T("Text"));
WORD cx = LOWORD(m_wndColorToolBar.GetToolBarCtrl().GetButtonSize());
WORD cy = HIWORD(m_wndColorToolBar.GetToolBarCtrl().GetButtonSize());
m_wndColorToolBar.GetToolBarCtrl().SetButtonSize(CSize(cx, cy));






你可能感兴趣的:(MFC ToolBar工具栏修改指定Button的Icon,添加文字的方法)