msdn第一张盘,sample\vc98\mfc\general\ctrlbars\ctrlbars.dsw,这个例程不仅有多排按钮的工具条,而且它的工具条的按钮列数可以动态改变.多看些msdn例程是很有帮助的.

解决方案 »

  1.   

    void g_DockControlBarOn(CFrameWnd*pFrame,CControlBar* pBarToDock,CControlBar* pBarOn,CSize sizeOffset)
    {
    CRect rect;
    DWORD dw;
    UINT n; // get MFC to adjust the dimensions of all docked ToolBars
    // so that GetWindowRect will be accurate
    pFrame->RecalcLayout();
    pBarOn->GetWindowRect(&rect);
    rect.OffsetRect(sizeOffset);
    dw=pBarOn->GetBarStyle();
    n = 0;
    n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
    n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
    n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
    n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n; // When we take the default parameters on rect, DockControlBar will dock
    // each Toolbar on a seperate line.  By calculating a rectangle, we in effect
    // are simulating a Toolbar being dragged to that location and docked.
    pFrame->DockControlBar(pBarToDock,n,&rect);}