BOOL CToolsDlg::OnInitDialog()
{
    CToolBar m_wndToolBar;
    m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP |   CBRS_TOOLTIPS |CBRS_FLYBY | CBRS_BORDER_BOTTOM);
    m_wndToolBar.LoadToolBar(IDR_TOOLBAR1);}为什么加不上啊??
是CDialog程序!!!!

解决方案 »

  1.   

    把CToolBar m_wndToolBar放在对话框的类定义中,试试。
      

  2.   

    http://www.codeguru.com/dialog/toolbars.shtml
      

  3.   

    http://www.vckbase.com/vckbase/vckbase11
    对话框目录中的《在Dialog中使用Menu和Toolbar》
      

  4.   

    还是不成啊!!!!
    首先在:OnInitDialog中加上:
    if (!m_wndToolBar.Create( this ) ||
    !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1) )
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    } m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
    CBRS_TOOLTIPS | CBRS_FLYBY  );怎么还是不显示!!!!!!!!!!!!!????????????????????????!!!!!!!!!!!!!!!!!!
      

  5.   

    解决了!!谢谢
    但还是有点不明白啊!·!m_wndToolBar.CreateEx( this,TBSTYLE_FLAT ,  WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS,CRect(0,0,0,0));
    m_wndToolBar.LoadToolBar(IDR_TOOLBAR1);
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0);这里RepositionBars()是什么意思??
    AFX_IDW_CONTROLBAR_FIRST有是什么?在msdn里都没找到啊!谢谢
      

  6.   

    1.这里RepositionBars()是什么意思??
    --------Called to reposition and resize control bars in the client area of a window. 
      

  7.   

    ResCalled to reposition and resize control bars in the client area of a window. The nIDFirst and nIDLast parameters define a range of control-bar IDs to be repositioned in the client area. The nIDLeftOver parameter specifies the ID of the child window (normally the view) which is repositioned and resized to fill the rest of the client area not filled by control bars.
      

  8.   

    See the useful sampel below, FYI :http://www.codeproject.com/docking/display_dialog_tooltips.asp
      

  9.   

    创建工具条的代码
    m_pImageList = new CImageList;
    SetupImages(m_pImageList);TBBUTTON tb;m_ToolBar = new CToolBarCtrl;
    m_ToolBar->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|TBSTYLE_FLAT,
    CRect(0,0,0,0), this, 0);m_ToolBar->SetImageList(m_pImageList);
    tb.iBitmap = 0;
    tb.iString = NULL;
    tb.fsState = TBSTATE_ENABLED;
    tb.fsStyle = TBSTYLE_BUTTON;
    tb.idCommand = ID_HELP_ABOUT;m_ToolBar->AddButtons(1, &tb);
    tb.iBitmap = 1;
    tb.idCommand = ID_BOLD;
    m_ToolBar->AddButtons(1, &tb);
    tb.iBitmap = 2;
    tb.idCommand = ID_DRAWING;
    m_ToolBar->AddButtons(1, &tb);TBBUTTON tb1;
    tb1.fsStyle = TBSTYLE_SEP;
    m_ToolBar->AddButtons(1, &tb1);tb.iBitmap = 3;
    tb.idCommand = ID_STRIKEOUT;
    tb.iString = NULL;
    m_ToolBar->AddButtons(1, &tb);
      

  10.   

    RepositionBars()是客户区重新计算
    AFX_IDW_CONTROLBAR_FIRST 代表的数字为  0
    AFX_IDW_CONTROLBAR_LAST  代表数字为    0xffff
    你可以试试
    RepositionBars(0,0xffff,NULL)也可以的
    另外,在对话框中创建工具栏时应该用CreateEx()