工具栏加载按钮位图,
VERIFY(AddBitmap(m_nButtonCount,IDB_TOOLBAR) != -1);  //添加位图
....
//加载工具条
m_StandardBar.Create(WS_BORDER|WS_VISIBLE|WS_CHILD|TBSTYLE_WRAPABLE
|CCS_TOP|CCS_ADJUSTABLE,CRect(0,0,0,0),this,IDB_TOOLBAR)
这样加载256色位图是可以的,但是如果是24为的bmp图片就运行不了,请问各位有什么办法加载24位的图标

解决方案 »

  1.   

    http://www.vckbase.com/document/viewdoc/?id=516
    看看行不行
      

  2.   

    ToolBar也可以在Dialog中使用的,你把那个链接的例子稍微改下就可以的,注意在对话框中使用CToolbarCtrl而不是CToolbar
      

  3.   

    Toolbar有两种设置图标的方式,如果它是通过CreateToolbar,你就只能通过AddBitmap的方法加图标,若你通过CreateWindowEx()创建,则你可通过设置一个ImageList来给Toolbar加图标,这个方法可以实现32Bit的真彩图标
      

  4.   


    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    } CImageList imageList;
    CBitmap bitmap; // Create and set the normal toolbar image list.
    bitmap.LoadBitmap(IDB_TOOLBAR_COLD);
    imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
    imageList.Add(&bitmap, RGB(255,0,255));
    m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
    imageList.Detach();
    bitmap.Detach(); // Create and set the hot toolbar image list.
    bitmap.LoadBitmap(IDB_TOOLBAR_HOT);
    imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
    imageList.Add(&bitmap, RGB(255,0,255));
    m_wndToolBar.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
    imageList.Detach();
    bitmap.Detach(); // TODO: Delete these three lines if you don't want the toolbar to
    //  be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);所需用到的工具TBCreator,用于生成两个BMP图片。
    把两个图片加入到RESOURCE。