void SetButtonInfo(
   int nIndex,
   UINT nID,
   UINT nStyle,
   int iImage 
);Parameters --------------------------------------------------------------------------------[in] nIndex 
The zero-based index of the button whose properties are set. [in] nID 
The command ID of the button. [in] nStyle 
The style of the button. See ToolBar Control Styles for the list of available toolbar button styles. [in] iImage 
The zero-based image index of the button (that is, the index in the collection of toolbar images). 

解决方案 »

  1.   

    第一个Index是针对你的Toolbar按钮的顺序第四个Index是针对你加载的图片(CImageList)的顺序吧。这个应该要加载图片的例子
      

  2.   

    参数说明:这里面主要的参数是第一个参数 int nIndex,它指示了工具栏显示按钮的下标,也就是要操作的位置。对这个位置的按钮怎样进行操作呢,首先,通过第二个参数(菜单命令ID,或控件ID)来关联一个对这个位置的按钮进行操作的函数(命令响应和控件消息响应,及刷新响应),然后通过第4个参数来指示这个按钮上应该显示的位图的下标,也就是在loadtoolbar的时候,指定的位图资源ID所代表的位图中的第xx(xx==iImage)个按钮的位图图标
    如果按钮的显示有问题,可以检查函数第二个参数所关联的命令ID,这个ID是否关联了正确的消息响应函数感兴趣,就查了一下与楼主分享。
      

  3.   

    [in] nIndex  The zero-based index of the button whose properties are set. //第一参数什么意思呢 实在不懂
      

  4.   

    DockPane调用之后,才可改变工具栏大小// 
    下面图片显示不出来在按钮上?
    一定要用静态的CMFCToolBar::SetUserImages(&m_UserImages);CMFCToolBar       m_wndToolBar; 
    CMFCToolBarImages m_UserImages; 
    CImageList        m_wndImage;m_wndImage.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);             
    m_wndImage.Add(AfxGetApp()->LoadIcon(IDI_ICON2));             
    m_wndImage.Add(AfxGetApp()->LoadIcon(IDI_ICON3));             m_UserImages.CreateFromImageList(m_wndImage);            
    m_UserImages.SetImageSize(CSize(32,32), TRUE);             
    UINT nArray[2] = { ID_MENU1, ID_MENU1};               
    m_wndToolBar.SetButtons(nArray, 2);             
    m_wndToolBar.SetSizes(CSize(32,32),CSize(32,32));             m_wndToolBar.SetUserImages(&m_UserImages);             
    m_wndToolBar.SetButtonInfo(0,ID_MENU1,TBBS_CHECKBOX,0);