Skip to content

Hidden Property

Description

The Hidden property indicates when a ShortcutBarItem is hidden.

Property Type

Read-only property

Syntax (Visual Basic)

Public Property Hidden() As Boolean

Remarks

An item is hidden when the width of the Shortcut Bar is too small to display all of the shortcut buttons. The hidden buttons will appear in a:

Hidden Buttons

Example

Overriding the Default Expand Button Popup (Visual Basic)

This sample illustrates how to override the default popup menu that is displayed when the expand button is pressed. This allows you to add your own controls to the popup menu.

Const ID_TASKITEM_HIDECONTENTS = 1  
Const ID_TASKITEM_ADDORREMOVE = 2  
Const ID_TASKITEM_SEARCH = 3  
Const ID_TASKITEM_NEWFOLDER = 4  
Const ID_TASKITEM_PUBLISH = 5  
Const ID_TASKITEM_SHARE = 6  
Const ID_TASKITEM_MYCOMPUTER = 7  
Const ID_TASKITEM_MYDOCUMENTS = 8  

Const ID_SHORTCUT_SHOW_MORE = 300  
Const ID_SHORTCUT_SHOW_FEWER = 301  

Private Sub wndShortcutBar_ExpandButtonDown(CancelMenu As Boolean)  
    ' Cancels the default menu that is displayed when the expand button is pressed.  
    ' The default button only displays the "Show More Buttons" and "Show Fewer Buttons" commands.  
    CancelMenu = True  

    Dim Popup As CommandBar  
    Dim Control As CommandBarControl  
    Dim i As Long  
    Dim Item As ShortcutBarItem  

    ' Creates a popup command bar  
    Set Popup = CommandBars.Add("Popup", xtpBarPopup)  

    ' Adds buttons to the popup command bar  
    With Popup  
        ' Adds the "Show More Buttons" button  
        Set Control = AddButton(.Controls, xtpControlButton, ID_SHORTCUT_SHOW_MORE, "Show &More Buttons")  
        ' Enable this button if all buttons are not expanded  
        Control.Enabled = (wndShortcutBar.ExpandedLinesCount <> 9)  

        ' Adds the "Show Fewer Buttons" button  
        Set Control = AddButton(.Controls, xtpControlButton, ID_SHORTCUT_SHOW_FEWER, "Show &Fewer Buttons")  
        ' Enable this button if there are 1 or more buttons expanded  
        Control.Enabled = (wndShortcutBar.ExpandedLinesCount <> 1)  

        ' Starts a new group  
        Dim BeginGroup As Boolean  
        BeginGroup = True  

        ' Adds all hidden shortcut bar buttons to the popup menu  
        For Each Item In wndShortcutBar  
            ' If shortcut bar item is hidden, then add it to the popup menu  
            If (Item.Hidden) Then  
                AddButton .Controls, xtpControlButton, Item.Id, Item.Caption, BeginGroup  
                BeginGroup = False  
            End If  
        Next  
    End With  

    ' Stores the ID of the selected control from the expand button popup menu.  
    Dim nCommand As Long  

    ' Displays the expand button popup.  
    ' Passing TPM_RETURNCMD into ShowPopup will cause the ID of the control to be returned  
    ' when a control in the popup is clicked. When using the TPM_RETURNCMD parameter, the  
    ' CommandBars_Execute event does not fire because the ID of the control is returned instead.  
    nCommand = Popup.ShowPopup(TPM_RETURNCMD)  

    ' Popup is closed and the user did not select anything, they might have clicked on something  
    ' other than the popup menu  
    If (nCommand = 0) Then Exit Sub  

    ' A control was selected from the popup menu. Determines which control was selected.  
    Select Case (nCommand)  
        Case ID_SHORTCUT_SHOW_MORE: 
            wndShortcutBar.ExpandedLinesCount = wndShortcutBar.ExpandedLinesCount + 1  
        Case ID_SHORTCUT_SHOW_FEWER: 
            wndShortcutBar.ExpandedLinesCount = wndShortcutBar.ExpandedLinesCount - 1  
        Case Else:  
            ' Selects the selected shortcut bar item.  
            wndShortcutBar.Selected = wndShortcutBar.FindItem(nCommand)  
    End Select  
End Sub

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.