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 General Discussion » Floating CExtToolControlBar: can't control float size Collapse All
Subject Author Date
Dave Kymlicka Mar 2, 2005 - 10:50 AM

When trying to float a CExtToolControlBar, I am unable to control its size: it appears as another full-screen frame with the desired toolbar on top.

It can drag-n-dock into Mainframe OK, but when when dragged out of Mainframe to float, it reverts back to undesired full-screen size.

Here’s what I’m doing:

CExtToolControlBar* pToolBar;

pToolBar->SetInitDesiredSizeFloating( CSize(150, 30) );
CRect screenRect;
MAIN_FRAME->GetWindowRect(&screenRect);
CPoint point;
point.x = screenRect.left + 100;
point.y = screenRect.top + 100;

pToolBar->FloatControlBar(point);

Can you point out what I’m doing wrong?

Also, what happens if toolbar needs to be wider that what you’ve specified in SetInitDesiredSizeFloating()?

Thanks.

Technical Support Mar 3, 2005 - 2:23 AM

Please tell us what you mean by "full-screen size" of the toolbar? The toolbar tries to calculate its size as much closer as possible to the desired size. In fact, there is no reason to specify the desired size of a floating toolbar. You can control its size by specifying wrap flags for its buttons. Each button with the wrap flag turned on will be the last button in its row. To mark the button as the last in its row, invoke:

    m_wndToolbar.GetButton( nButtonIndex ) ->
        SetWrap( CExtBarButton::__EVT_FLOAT );
Please note that the button index is zero based and a separator is also a kind of toolbar button.

Dave Kymlicka Mar 3, 2005 - 6:13 PM

By "Full-screen" size I truly mean the size of my monitor’s screen.
The frame constructed to hold the toolbar is full screen, with only one parital row of toolbar buttons at the top. Remainder of screen is filled with whatever the background is at the time of creation.
By "partial row" I mean that I can only see about 24 buttons (almost 40 buttons in this toolbar), and the bitmap is abrubtly cut off. Buttons are not wrapping.

I’ve tried floating toolbars in your samples... works perfect of course.
Using CalcDynamicLayout() helps quite a bit, and afterwards, the toolbar will resize correctly once moved with mouse: all buttons wrap as expected.

I would love to hear any suggestions/suspicions.

Technical Support Mar 4, 2005 - 8:29 AM

We may guess you want your toolbars to support the multiple row/column layout when they are docked and there is not enough room to fit all buttons into a single row (as it is done for the menu bar). Yes, it is supported by the CExtToolControlBar class. This feature is used when the Customize dialog is open. Please create a CExtToolControlBar-derived class and override the OnQueryMultiRowLayout() virtual method like as follows:

bool CYourCustomToolControlBar::
    OnQueryMultiRowLayout() const
{
    ASSERT_VALID( this );
    if(  m_bPresubclassDialogMode )
        return false;
    if( m_pDockBar != NULL )
    {
        if( IsFloating() )
            return false;
    } // if( m_pDockBar != NULL )
    return true;
}
If you prefer toolbars which always occupy the full row/column as it is implemeted in the menu bar, then you need to override the following virtual method:
bool CYourCustomToolControlBar::
    _GetFullRowMode() const
{
    ASSERT_VALID( this );
    return true;
}

Dave Kymlicka Mar 2, 2005 - 11:12 AM

This seems to help: the frame is MUCH smaller and the frame height has almost snapped to the correct height of toolbar buttons (about 20 pixels too tall). I only get one row of buttons, even if width is too small to accomodate them all.

int nHeight = 22; // doesn’t seem to matter what I set this to, tried with: 0/22/30/100
pToolBar->SetInitDesiredSizeFloating( CSize(150, 30) );
CSize newSize = pToolBar->_CalcSize(FALSE);
int mode = LM_HORZ | LM_COMMIT;
pToolBar->CalcDynamicLayout(newSize.cx, mode);

... remainder same as before...


Once I resize with mouse, it seems to resize the frame correctly, and all buttons behave as expected: if the width is too small, more rows get added as necessary.
However, I can only expand frame width so much, there seems to be a max width constraint, and it isn’t my specified value from SetInitDesiredSizeFloating().

Almost!

Technical Support Mar 2, 2005 - 1:16 PM

Thank you for sharing results with us! But again, a floating toolbar is typically measured by a number of button rows and a number of buttons in each row. We will try to find out why the toolbar has a few pixels more in this case.