1。如果是普通的单文档工程,添加一个toolbar变量后后再添加两个按钮,怎样将随意选择的32*32(或者比它小)图标加入到按钮上面去?
2。如何为OutLookBar中的shortcut button添加敲击事件?

解决方案 »

  1.   

    #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)
    }
      

  2.   

    给段代码你自己分析下:
              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);
      

  3.   

    谢谢 . 不错 ,弄好后存在问题:
    按钮的ID和对应菜单项ID都是用一个ID,为什么在菜单里添加敲击事件后,相应的ToolBar按钮却不会执行Menu上的事件?