如何为BCGControlBar中的toolbar控件里的Button添加自己的图标? OutLookBar中的shortcut 1。如果是普通的单文档工程,添加一个toolbar变量后后再添加两个按钮,怎样将随意选择的32*32(或者比它小)图标加入到按钮上面去?2。如何为OutLookBar中的shortcut button添加敲击事件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #define ID_SHORTCUT_1 101;#define ID_SHORTCUT_2 102;#define ID_SHORTCUT_3 103;#define ID_SHORTCUT_4 104;BEGAIN_MESSAGE_MAP ON_COMMAND_RANGE(ID_SHORTCUT_1,ID_SHORTCUT_4,OnShortcut)void CYourDlg::OnShortcut(UNIT uiCmdID){// uiCmdID 是点击的按钮的ID(添加时的ID)} 给段代码你自己分析下: m_wndToolBar.SetLook2000(); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1,1,1,1),0xffff)|| !m_wndToolBar.LoadBitmap(IDB_TOOLBAR_NEW1)) { TRACE0("Failed to create toolbar\n"); return; // fail to create } vector<ToolBarBtn> tbbArray; GetToolButtons(tbbArray,0xffff); int nCount = tbbArray.size(); CBCGPToolBar::SetShowTooltips(TRUE); CToolTipCtrl* pToolTip = NULL; CBCGPToolbarButton button; for(int nIndex = 0;nIndex<nCount;nIndex++) { button.m_strText = tbbArray[nIndex].tsBtnText.c_str(); m_wndToolBar.InsertButton(button); m_wndToolBar.SetButtonInfo(nIndex,tbbArray[nIndex].nBtnID,tbbArray[nIndex].nStyle,tbbArray[nIndex].nImage); m_wndToolBar.SetToolBarBtnText(nIndex,tbbArray[nIndex].tsBtnText.c_str(),tbbArray[nIndex].bShowText,TRUE); } m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 谢谢 . 不错 ,弄好后存在问题:按钮的ID和对应菜单项ID都是用一个ID,为什么在菜单里添加敲击事件后,相应的ToolBar按钮却不会执行Menu上的事件? 在点击后给CStatic控件加上边框 怎样从文本文件中读取数据 赋给一个结构体 winpcap 捕获RTP数据包 远程线程执行体中值的更改问题 修改图片DP之后,要放大到多少象素,打印出来的才和原来的大小一样 如何清空CListBox的内容 如何能够设置CVIEW视图下的默认3D边框的颜色啊 小弟请教下m_kWnd是什么意思 请教关于类中静态结构成员初始化的问题 如何用VC编程序给其他应用程序的对话框发送消息 vc+ado+oracle提示错误:当前记录集不支持更新。这可能是提供程序的限制.... 读数据库字段时出错
#define ID_SHORTCUT_2 102;
#define ID_SHORTCUT_3 103;
#define ID_SHORTCUT_4 104;
BEGAIN_MESSAGE_MAP
ON_COMMAND_RANGE(ID_SHORTCUT_1,ID_SHORTCUT_4,OnShortcut)void CYourDlg::OnShortcut(UNIT uiCmdID)
{
// uiCmdID 是点击的按钮的ID(添加时的ID)
}
m_wndToolBar.SetLook2000();
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
CRect(1,1,1,1),0xffff)||
!m_wndToolBar.LoadBitmap(IDB_TOOLBAR_NEW1))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
} vector<ToolBarBtn> tbbArray;
GetToolButtons(tbbArray,0xffff);
int nCount = tbbArray.size();
CBCGPToolBar::SetShowTooltips(TRUE);
CToolTipCtrl* pToolTip = NULL;
CBCGPToolbarButton button;
for(int nIndex = 0;nIndex<nCount;nIndex++)
{
button.m_strText = tbbArray[nIndex].tsBtnText.c_str();
m_wndToolBar.InsertButton(button);
m_wndToolBar.SetButtonInfo(nIndex,tbbArray[nIndex].nBtnID,tbbArray[nIndex].nStyle,tbbArray[nIndex].nImage);
m_wndToolBar.SetToolBarBtnText(nIndex,tbbArray[nIndex].tsBtnText.c_str(),tbbArray[nIndex].bShowText,TRUE);
}
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
按钮的ID和对应菜单项ID都是用一个ID,为什么在菜单里添加敲击事件后,相应的ToolBar按钮却不会执行Menu上的事件?