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 » Display chevron for invisible buttons Collapse All
Subject Author Date
Thomas Maurer Aug 16, 2006 - 3:48 AM

Hello

I have a toolbar derived from CExtToolControlBar in my mainframe. This toolbar is fixed = it is not allowed to be floated or docked anywhere else but has to stay where it is. This works fine.

My problem is that when the window gets smaller some buttons on the right of the toolbar might become invisible. In this case a chevron button should be displayed with ">>" to display the invisible controls. This seems to be a pretty standard scenario but it doesn’t work somehow.

Problems:

- There is no Chevron button in my toolbar. I have not done anything with OnCreateBarRightBtn and when I debug I see that OnCreateBarRightBtn is actually creating the button. Maybe I have done something else to prevent displaying the button which I am not aware of (anymore). I have "overriden" OnConstructPopupMenuCB and OnPreparePopupMenu. But these handlers do not even get called upon displaying the window.

- I only want the ">>" without any customization and displaying/hiding toolbars stuff. Just the invisible controls.

- I only want the button if there are invisible controls (but maybe this comes for free with a solution for the above problem).

Thanks in advance

Thomas

Borremans Pierre Nov 7, 2009 - 12:28 AM

When I reduce de the size of my application the chevron is visible and button in the toolbar is hidden but when I click on the chevron the context menu is empty.

Technical Support Nov 8, 2009 - 10:42 AM

We cannot confirm this. We inserted the CMyBar class into the SDIDOCVIEW sample project. Here is what we see:

http://www.prof-uis.com/download/forums/tmp/TestToolBarChevronAutoHiding1.png
http://www.prof-uis.com/download/forums/tmp/TestToolBarChevronAutoHiding2.png

Technical Support Aug 16, 2006 - 10:19 AM

The content expand button (aka chevron button) is added automatically if you use the CExtToolControlBar::LoadToolBar() method for loading toolbar buttons. If you add buttons to your toobar using the CExtToolControlBar::SetButtons() method and want to add the chevron button, you need to use the CExtToolControlBar::InitContentExpandButton() method. To make the chevron button auto hideable, create a CExtToolControlBar-derived class and override the CExtToolControlBar::OnCreateBarRightBtn() virtual method that should return the instance of your CExtBarContentExpandButton-derived class. The latter implements the toolbar’s chevron button. In your version of this button, implement the CExtBarButton::IsVisible() virtual method so it returns the flag computed with the ( ( CExtBarContentExpandButton::GetButtons().GetSize() > 0 ) ? true : false ) code.

Thomas Maurer Aug 16, 2006 - 11:23 AM

Many thanks for your answer. Now I know why the chevron button wasn’t displayed: It is because my toolbar was not dockable = it had no grippers either and therefore it was considered floating (I saw that in the debugger) and so there was no chevron button. I do not want my toolbars to be dockable or floatable = they should remain just where they are.

When I made the toolbar dockable with the following code the toolbar became floatable again and it showed the gripper.

// all this I did not have before
m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP);
CExtControlBar::FrameEnableDocking(this);
DockControlBar(&m_wndToolBar);
RecalcLayout();

So with above code I have the chevron button but also the gripper I don’t want.

Questions:

- can I somehow turn on the chevron button for non dockable toolbars = those I did not declare to be dockable?
- or do I have to prevent the toolbar from becoming floating (I think I know how this works)? but then I would want the gripper to disappear somehow.

If you think you don’t know what I mean I could provide screen shots.

Thanks in advance

Thomas

Technical Support Aug 17, 2006 - 8:21 AM

You can prevent a toolbar from being floating by using your own CExtToolControlBar-derived class in which the CExtControlBar::FloatControlBar() virtual method is overridden: it should do nothing (i.e., leave it empty). The flags specified in the default parameters of the CExtControlBar::Create() method include CBRS_GRIPPER. So, if you remove this style, you will also remove the gripper. And you can find an example of using non re-dockable toolbars with chevron button in the ProfUIS_Controls sample.

Thomas Maurer Aug 18, 2006 - 6:53 AM

About PROBLEM 2 from my other reply: When the toolbar is docked I have prevented it from being floating but I can still move it around when the toolbar is smaller than the window or when there are two toolbars I can switch positions. How can I make a docked toolbar to stay exactly where it is?

Thanks in advance

Thomas

Thomas Maurer Aug 18, 2006 - 3:30 AM

Thank you for your most valuable tips. I think I got most things under control. However, there are a few problems I am fighting with.

PROBLEM 1:

I noticed that with your solution of creating the rightButton myself I get this button even if I do not dock my toolbar. But because the toolbar is considered floating the position of the rightButton is most left. You can see this in the following screenshot:

http://www.ierax.ch/download/screenbetter.jpg

Actually if there is an easy way to make the rightButton appear right without having to make the toolbars dockable would be my favourite solution.


PROBLEM 2:

If I DO make the toolbar dockable and dock it to the top I get the problem that the tab of the mdi child is above the toolbar. See screenshot:

http://www.ierax.ch/download/screenproblem.jpg

I guess this can be fixed more easily than problem 1. I could live with that too. The only thing that is a little disturbing that I get the NWSE-Cursor when I try move the toolbar. The toolbar can’t be moved anymore but the cursor should not change its shape. But this is something minor I could live with.

Many thanks

Thomas

Thomas Maurer Aug 24, 2006 - 1:43 AM

Hello

I just wanted to ask shyly if you could help me with the problems in the previous post. I have not received a reply so far.

Thank you very much in advance

Thomas

Technical Support Aug 24, 2006 - 5:22 AM

We are really sorry. The reply was made in time but it was not posted.

The fist problem occurs because the content expand button was initialized before other buttons in the same toolbar. Please check the toolbar’s initialization code. The second problem occurs because the tab window was created before the toolbar window. If you change the creation order, this will move the tab window to its desired location. It seems the tab window should be the last created window in the main frame. If you want to disable any drag-and-drop of the toolbar, create a CExtToolControlBar-derived class and override the following virtual method:

    virtual void _DraggingStart(
        const CPoint & point,
        const CPoint & pointOffset = CPoint( 0, 0 ),
        CSize sizeWaitMouseMove = CSize( 1, 1 )
        );
The method should have an empty body.

Thomas Maurer Aug 24, 2006 - 8:56 AM

Thanks very much for your reply. Unfortunately the problem remains:

PROBLEM 1 (the one with the "non-dockable toolbar)

http://www.ierax.ch/download/screenbetter.jpg

The button is created as the last button but I think the problem lies in void CExtToolControlBar::_RecalcPositionsImpl()

...
if( bFloating || m_bPaletteMode )
{
m_pRightBtn->Show( false );
m_pRightBtn->SetRect(CRect( ptLimitTL, sizeTBBRight ));
if( nReviewCount == 0 )
return;
} // if( bFloating || m_bPaletteMode )
...

bFloating is always true in this scenario and so despite the right button being the last in the list SetRect is always called for position (0;0)


PROBLEM 2 (when toolbars are docked)

http://www.ierax.ch/download/screenproblem.jpg

The toolbar is created BEFORE the document = before I open any MDI child the toolbar is already there.

I create the child with the following call:

this->pDocumentFrame = (CChildFrame*)pFrame->CreateNewChild(RUNTIME_CLASS(CChildFrame), IDR_MAINFRAME, pFrame->m_hMDIMenu,pFrame->m_hMDIAccel);


Thank you in advance

Thomas

Technical Support Aug 24, 2006 - 9:39 AM

We can guess all the problem related source code is in the main frame window. Could you let us take a look at the main frame’s source code?

Thomas Maurer Aug 25, 2006 - 4:21 AM

Hello

Thank you for your effort. I have sent you the requested code (and some more) in an e-mail to the support e-mail address.

Thanks in advance

Thomas

Technical Support Aug 25, 2006 - 7:34 AM

We think the location of the right content expand button in the array of the toolbar buttons is correct and it is the last button. The problem with this button is linked to its position and visibility synchronization. This problem can be solved by overriding the CExtToolControlBar::_RecalcPositionsImpl() internal virtual method like as follows:

virtual void CYourVeToolBar::_RecalcPositionsImpl()
{
    ASSERT_VALID( this );
    // STEP 1: detect whether the right button is visible 
    //here (whether all the buttons are displayed)
    CExtToolControlBar::_RecalcPositionsImpl()
    // STEP 2: detect whether all the buttons are displayed now 
    //and return if the right button’s visibility is not changed
    CExtToolControlBar::_RecalcPositionsImpl()
}

Thomas Maurer Aug 25, 2006 - 10:21 AM

Thank you for your answer. I successfully introduced above method.

I assume that I have to implement something myself for STEP 1 and STEP 2.

Question about STEP 1: What do I have to do if it is visible and what do I have to do if it is not visible?

Question about STEP 2: Do I have to detect whether all buttons are displayed including the right button or without the right button?

Sorry for asking these simple questions but I am afraid I do not understand why I have to implement it like this and so I will just do what you tell me ;-)

Thanks

Thomas

Thomas Maurer Aug 25, 2006 - 10:24 AM

Something came to my mind: Were your comments about STEP 1 and STEP 2 only comments of the following calls = I do not have to implement something myself and it should just work without any changes? In this case the result is negative. The function gets called but the button stays on the left side.

Thomas

Technical Support Aug 28, 2006 - 10:51 AM

Here is the source code for the toolbar window like you need:

    class CMyBar : public CExtToolControlBar
    {
    public:
        class CMyContentExpandButton : public CExtBarContentExpandButton
        {
        public:
            CMyContentExpandButton( CExtToolControlBar * pBar = NULL )
                : CExtBarContentExpandButton( pBar )
            {
            }
            virtual bool IsVisible() const
            {
                bool bVisible = ( GetButtons().GetSize() > 0 ) ? true : false;
                return bVisible;
            }
        };
        virtual CExtBarContentExpandButton * OnCreateBarRightBtn()
        {
            return new CMyContentExpandButton( this );
        }
        virtual void _RecalcPositionsImpl()
        {
            CExtToolControlBar::_RecalcPositionsImpl();
            if( m_pDockBar != NULL )
                return;
            CExtBarContentExpandButton * pRightTBB = GetRightButton();
            if( pRightTBB == NULL )
                return;
            if( ! pRightTBB->IsVisible() )
                return;
            bool bHorz = ((GetBarStyle()&(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM))!=0) ? true : false;
            CRect rcRightTBB = *pRightTBB, rcClient;
            GetClientRect( &rcClient );
            rcRightTBB.OffsetRect(
                bHorz ? ( rcClient.right - rcRightTBB.right ) : 0,
                bHorz ? 0 : ( rcClient.bottom - rcRightTBB.bottom )
                );
            pRightTBB->SetRect( rcRightTBB );
            INT nIndex, nCount = GetButtonsCount();
            for( nIndex = 0; nIndex < nCount; nIndex ++ )
            {
                CExtBarButton * pTBB = GetButton( nIndex );
                if( ! pTBB->IsVisible() )
                    continue;
                if( pTBB == pRightTBB )
                    continue;
                CRect rcTBB = *pTBB;
                if( bHorz )
                {
                    if( rcTBB.right < rcRightTBB.left )
                        continue;
                }
                else
                {
                    if( rcTBB.bottom < rcRightTBB.top )
                        continue;
                }
                pTBB->Show( false );
                pRightTBB->GetButtons().InsertAt( 0, pTBB );
            }
        }
    };


Thomas Maurer Aug 31, 2006 - 2:08 AM

Hello

It works! Thank you very much. It shows three things to me:

1. Support from Prof-UIS is great and very helpful!
2. The library is very flexible!
3. It is not always possible to achieve something without help of support

Thomas

Borremans Pierre Nov 6, 2009 - 6:56 AM

I use your example "CMybar" in my application but when I click on the chevron there is no contextmenu with button. What can I do to resolve this problem ?

Technical Support Nov 6, 2009 - 10:13 AM

The chevron context menu is enabled for this improved toolbar only of there is at least one toolbar button is hidden in it.