Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Wrapping Toolbars... Collapse All
Subject Author Date
Chris Fudge Feb 8, 2006 - 3:39 PM

Is there a parameter I need to specify when creating multiple Toolbars to get a newly added one to be positioned below the existing toolbars if the edge of the window is reached?

Im creating my toolbars from an array :

        if(    !m_ToolBarArray[m_nToolbarCount].Create(
                NULL, // _T("Main Toolbar"),
                this,
                AFX_IDW_TOOLBAR,
                WS_CHILD | WS_VISIBLE |
                CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC| CBRS_TOOLTIPS| CBRS_HIDE_INPLACE))
        {
            TRACE0("Failed to create toolbar\n");
            return -1; // fail to create
        }

However when they reach the edge of the screen they do not automatically wrap to the next row.

I have deliberately disabled the "Add/Remove buttons" and "show/hide panels" toolbar popup as I want all buttons to be visible at all times.

Thanks.

Technical Support Feb 9, 2006 - 10:07 AM

Let us assume we have two toolbars m_wndToolBar1 and m_wndToolBar2. The following code docks m_wndToolBar2 after m_wndToolBar1:

    pMainFrame->DockControlBar( &m_wndToolBar1 );
    pMainFrame->RecalcLayout();
    CRect wrAlreadyDockedBar;
    pMainFrame->m_wndToolBar1.GetWindowRect( &wrAlreadyDockedBar );
    wrAlreadyDockedBar.OffsetRect( 1, 0 );
    pMainFrame->DockControlBar( &pMainFrame->m_wndToolBar2, AFX_IDW_DOCKBAR_TOP, &wrAlreadyDockedBar );
    pMainFrame->RecalcLayout();
At this point the second toolbar is completely redocked (to its new position). We can analyze whether its right side is intersected with the right side of the main frame window:
    pMainFrame->m_wndToolBar2.GetWindowRect( &wrAlreadyDockedBar );
    CRect rcMainFrame;
    pMainFrame->GetClientRect( &rcMainFrame );
    pMainFrame->ClientToScreen( &rcMainFrame );
    bool bInstresected = ( wrAlreadyDockedBar.right > rcMainFrame.right ) ? true : false;
If the right side of the second toolbar intersects with the right side of the main frame window, then you can re-dock it to the next row.

Chris Fudge Feb 9, 2006 - 10:27 AM

Thank you,

How do I re-dock to the next row ? I have tried

wrAlreadyDockedBar.OffsetRect( 0, 1 );

and using that rectangle but it didnt seem to work.

Technical Support Feb 9, 2006 - 1:04 PM

The wrAlreadyDockedBar.OffsetRect( 0, 1 ) code makes switching to the next row, but we need to specify the rectangle which is at the left side of the main frame window and shifted to the next row at the same time. According to the source code in our previous sample:

wrAlreadyDockedBar.OffsetRect(
   wrAlreadyDockedBar.left - rcMainFrame.left,
   1
);