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 » Docking "percentages" for CExtToolControlBar Collapse All
Subject Author Date
Dave Kymlicka Mar 14, 2005 - 9:44 PM

Apologies if this was posted twice, didn’t appear to make it through the first time.

Currently, our app permits user-configurable layouts (docking, sizes, visibility) of ControlBars from XML file, at any time (not just at startup). I have successfully managed to convert (from another MFC lib) most tasks, but still have the following issues:

1. Cannot dock 3 (or more) control bars such that they __equally__ divide-up the space along an edge. Following your sample code, here’s how I dock 3 CExtControlBar along the bottom:

pBarA->DockControlBar(AFX_IDW_DOCKBAR_BOTTOM, 1, MAIN_FRAME, true);
pBarA->DockControlBar(pBarB, true, false, MAIN_FRAME, true);
pBarB->DockControlBar(pBarC, true, false, MAIN_FRAME, true);

The results: BarA gets 50% space, BarB gets 25%, and BarC gets 25%.

|********************************|
|.......... BarA ......... |. Bar B .|. Bar C .|
|********************************|

Is there some way to get them to equally share the available space?

|********************************|
|.... Bar A ....|.... Bar B ....|.... Bar C ....|
|********************************|

I’ve looked at CExtControlBars::DockControlBarLTRB(): comes close, but it doesn’t dock the bars along the same edge (aka docking circle/ring?): seems to "stack" them instead.

2. Or even tougher: instead of equally sharing the space, how about being able to specify "sharing ratios"?
Eg: BarA gets 20%, BarB gets 60%, BarC gets 20%

|********************************|
|.. BarA ..|........ Bar B ........|.. Bar C ..|
|********************************|


3. Or, the best would be an implementation of CExtControlBar::ProfileBarStateSerialize(IXMLDOMDocument *pXMLDoc)... but I don’t think that’s happening anytime soon, right? Had to try ;-)

Technical Support Mar 15, 2005 - 7:19 AM

To get resizable control bars docked with the frame edge so that they share the common background in certain proportions, just use the CExtControlBar::DockControlBarLTRB() method. For instance, you need to dock three control bars into one row and the first two of them should occupy 33 percent of the row length, and the third -- 34% (33+33+34=100%). Start with the third control bar and dock it by using the DockControlBarInnerOuter() method, which will make it occupy 100% of the row. Then, dock the second relative to third control bar with the DockControlBarLTRB() method and specify 66% as its share. Now the third bar occupies 34% of the row and the second -- 66%. Finally, dock the first control bar by using DockControlBarLTRB() and specify 50% of the space occupied by the second control. After that, three control bars are docked as it is depicted below:


Dave Kymlicka Mar 15, 2005 - 2:09 PM

I tested your instructions in sample project ’MDI_InnerOuterBars’, but didn’t get the results you describe. Can you point out what I did wrong?

// m_wndResizableBar0.DockControlBar( AFX_IDW_DOCKBAR_LEFT, 1 );
// m_wndResizableBar0.DockControlBar( &m_wndResizableBar1, true );
// m_wndResizableBar2.DockControlBar( AFX_IDW_DOCKBAR_RIGHT, 1

CExtControlBar* pBarA = &m_wndResizableBar0;
CExtControlBar* pBarB = &m_wndResizableBar1;
CExtControlBar* pBarC = &m_wndResizableBar2;

pBarA->DockControlBarInnerOuter(
AFX_IDW_DOCKBAR_BOTTOM,
true,
    this,
    true );

pBarB->DockControlBarLTRB(
66,
pBarA,
AFX_IDW_DOCKBAR_BOTTOM,
true );

pBarC->DockControlBarLTRB(
50,
pBarB,
AFX_IDW_DOCKBAR_BOTTOM,
true );

This code produced the following results:

|********************************|
|... Bar A ...........................................|
|********************************|
|... Bar B ...........................................|
|********************************|
|... Bar C ...........................................|
|********************************|


Dave Kymlicka Mar 15, 2005 - 2:50 PM

Realized I didn’t quite follow your instructions precisely: was docking bars in the wrong oder (A, B, C). Here’s my code to dock in the order you specified (C, B, A):

pBarC->DockControlBarInnerOuter(AFX_IDW_DOCKBAR_BOTTOM, true, this, true );
pBarB->DockControlBarLTRB(66, pBarC, AFX_IDW_DOCKBAR_BOTTOM, true );
pBarA->DockControlBarLTRB(50, pBarB, AFX_IDW_DOCKBAR_BOTTOM, true );

Still produced same results as before: they get "Stacked" on top of each other, instead of sharing the row.
|********************************|
|... Bar C ...........................................|
|********************************|
|... Bar B ...........................................|
|********************************|
|... Bar A ...........................................|
|********************************|

Technical Support Mar 16, 2005 - 8:46 AM

Yes, you followed the instructions but not exactly. Please try this:

// dock C to an entirely new row at bottom
    pBarC->DockControlBarInnerOuter(
        AFX_IDW_DOCKBAR_BOTTOM,
        true,
        this,
        true
        );
    // make B sharing 66% of C’s area
    // at left
    pBarB->DockControlBarLTRB(
        66,
        pBarC,
        AFX_IDW_DOCKBAR_LEFT,
        true
        ); 
    // make A sharing 50% of B’s area
    // at left that is equal to
    // 33% space of entire row
    pBarA->DockControlBarLTRB(
        50,
        pBarB,
        AFX_IDW_DOCKBAR_LEFT,
        true
        );

Dave Kymlicka Mar 16, 2005 - 9:39 AM

Yes, that works much better, gives me exactly what I was looking for, thank you!
That also explains why we have to pass in the DockBarID, didn’t make sense to me until now.

Is it always necessary to go from right to left?

I tried going from left to right, and it seems to produce the same results:
pBarA->DockControlBarInnerOuter(AFX_IDW_DOCKBAR_BOTTOM, true, this, true );
pBarB->DockControlBarLTRB(66, pBarA, AFX_IDW_DOCKBAR_RIGHT, true );
pBarC->DockControlBarLTRB(50, pBarB, AFX_IDW_DOCKBAR_RIGHT, true );

Is this equally as good, or will this cause some problems?

Technical Support Mar 16, 2005 - 10:19 AM

You can use either left-to-right or right-to-left docking order without any problems. The third parameter of the CExtControlBar::DockControlBarLTRB() method specifies whcih part of the already docked resizable control bar is to be occupied by the current (not yet docked) control bar. You may also play with three or more control bars by specifying different percents to see how it all works.