请注意两个关键字 一 "悬浮"不是"停靠" ,二"竖直".

解决方案 »

  1.   

    用对话框做一个工具条,用MoveWindow设置其停靠的位置,同时用SetParent设置其父窗口为view
      

  2.   

    把DockControlBar替换成FloatControlBar可以让它浮动
      

  3.   

    用CFrameWnd::FloatControlBarCFrameWnd* FloatControlBar( CControlBar * pBar, CPoint point, DWORD dwStyle = CBRS_ALIGN_TOP );
      

  4.   

    都是没有实践过的吧。
    我试过了,用FloatControlBar只能改变浮动位置,但是不能改变工具条的按钮图标的排列方向。
    用DockControlBar只能使工具条停靠在左侧。但一浮动,工具条的按钮图标的排列方向还是会复原。
    也许用DialogBar来自己管理工具条是条路。不过我也希望看到默认工具条能够支持这个方式。
    对CToolBarCtrl也不熟,不清楚其中的一些函数都能够达到什么目的。
      

  5.   

    http://www.99inf.net/SoftwareDev/VC/13317.htm
    这篇文章没有仔细看。不知道是不是解决这个问题的,或者可以借鉴。
      

  6.   

    找遍baidu没找到一篇中文文章有解决方案的.上google in english找到一个外国的代码实现了谢谢大家.下班给分.代码是codeproject上的.如下/* Lets float one of our toolbars but make sure that is 
    has the desired row count. if the count is too small to 
    be set, then return the row count used.Parameters: 
    pToolbar -  Pointer to the MFC tool bar 
                object to be manipulatednRows -     Requested number of rowsbLarger -   Tells whether to use more rows or fewer rows 
                if the toolbar  cannot be resized to the 
                requested number of rows.
    (for details see CToolBarCtrl::SetRows in the MSDN 
    documentation)  pClient -   Pointer to a CPoint object for the position int 
                client coordinates for the toolbar to appear 
                floated. If this Parameter is NULL,  the default 
                upper left corner of "this" window will be used
                
    Returns:    The value of the function CToolBarCtrl->GetRows
                after the resizing has occured. A simple experiment 
                shows,but this is NOT the real number of rows 
                displayed :( 
    */
    int CMainFrame::FloatToolbarSetRows(
                CToolBar *pToolbar, int nRows, BOOL bLarger,    
                CPoint *pClientPos)
    {
        // default upper left corner
        // of the floating toolbar
        // is upper left corner of main wnd
        CPoint newPos(0,0); // if other pos specified, use it
            if (pClientPos)
                newPos = *pClientPos;    // functions use screen coords
        ClientToScreen(&newPos);
        // first, make sure our toolbar is floating
        if (!pToolbar->IsFloating())
            FloatControlBar(pToolbar, CPoint(0,0));
        // now set the desired row count
        // may result in more rows than specified
        // see the MSDN docs: CToolBarCtrl::SetRows
        //
        // this function also calculates the new
        // toolbar window size
        // unfortunately this function only arranges
        // the toolbar buttons, but will not update
        // the size of the tool bar window ...
        CRect rcNew;
        pToolbar->GetToolBarCtrl().SetRows(nRows, 
            bLarger, &rcNew);
        // we need to reset the horizontal extend
        // of the toolbar before it "knows" its 
        // width. It will not diplay this width 
        // before the window is touched by us (or
        //  by the mouse)
        pToolbar->CalcDynamicLayout(rcNew.Width(), 
            LM_HORZ | LM_COMMIT);    // now move the window to the desired position
        FloatControlBar(pToolbar, newPos,
            CBRS_ALIGN_TOP | CBRS_SIZE_DYNAMIC);    return pToolbar->GetToolBarCtrl().GetRows();
    }
      

  7.   

    果然用到了CToolBarCtrl的SetRows了。我机器上没有MSDN。一时没有查出这个函数的用法。原来第三个参数是返回值,我当传入值在用了。
      

  8.   

    我同意FloatControlBar可以让它浮动,但没说它能让图标竖排本来就是想CDialogBar,这样实现起来方便
      

  9.   

    几年前我做过,我是这样做的,工具栏中的BUTTON可以设置各种风格,其中TBBS_WRAPPED风格就是让此按钮另起一行。我的代码如下:
    在创建工具箱后:
    //浮动工具箱的位置
    CRect rect;
    GetWindowRect(&rect);
    CPoint pt(rect.Width()/60,rect.Height()/6);
            // 设置工具箱按钮排列
             int nBtnCols = 2;// 列数
    int nCount = m_ToolBox.GetToolBarCtrl().GetButtonCount();
    for (int i = 0; i < nCount; i++)
    {
    UINT nStyle = m_ToolBox.GetButtonStyle(i);
    BOOL bWrap = (((i+1) % nBtnCols) == 0);
    if (bWrap)
    nStyle |= TBBS_WRAPPED;
    else
    nStyle &= ~TBBS_WRAPPED;
    m_ToolBox.SetButtonStyle(i, nStyle);
    }
    m_ToolBox.Invalidate();
    RecalcLayout();
    // Create the Palette.  We are using hardcoded numbers for ease here
    // normally the location would be read in from an ini file.
    FloatControlBar(&m_ToolBox, pt);
    ShowControlBar(&m_ToolBox, TRUE, FALSE);
      

  10.   

    哦?GetToolBarCtrl还是转成ToolBarCtrl做的吧?