Community
Showing results for 
Search instead for 
Do you mean 
Reply

Add a menu and submenus to Tool tab up top

Copper Contributor
Posts: 12
Country: USA

Add a menu and submenus to Tool tab up top

Is there a way to add a menu selection and then a submenu with several sub-selections to the Act Tools tab at the top?  Right now, I am using Jim Durkin's excellent example to add four selections directly under Tools, but its getting cluttered.

Copper Contributor
Posts: 12
Country: USA

Re: Add a menu and submenus to Tool tab up top

[ Edited ]

OK, this is what I used.  Thank you to Jim Durkin and "ramjet" from these boards.

 

    Private Sub HostApplicationAfterLogon(ByVal Sender As Object, ByVal e As System.EventArgs)

        Dim count As Integer = HostApplication.Explorer.CommandBarCollection("Connected Menus").ControlCollection.Count
        For i As Integer = 0 To count
            If HostApplication.Explorer.CommandBarCollection("Connected Menus").ControlCollection(i).Text = "&Tools" Then
                Dim NewMenu As CommandBarButton = New CommandBarButton("Call Trunk", _
    "Call Trunk Actions", _
    Nothing, _
    "act-ui://com.act/application/menu/tools/calltrunk", _
    My.Resources.ctTrunkIco, _
    CommandBarControl.ItemDisplayStyle.ImageAndText, _
    True)
                HostApplication.Explorer.CommandBarCollection("Connected Menus").ControlCollection(i).AddSubItem(NewMenu)

                Dim button1 As CommandBarButton = New CommandBarButton("Make a Call", _
    "Make a Call Using Call Trunk", _
    New EventHandler(AddressOf MakeCallMenuClick), _
    "act-ui://com.act/application/menu/tools/calltrunk/makecall", _
    My.Resources.ctTrunkIco, _
    CommandBarControl.ItemDisplayStyle.TextOnly, _
    False)
                NewMenu.AddSubItem(button1)

                Dim button2 As CommandBarButton = New CommandBarButton("View History", _
    "View History of Call Trunk Recordings", _
    New EventHandler(AddressOf ViewHistoryMenuClick), _
    "act-ui://com.act/application/menu/tools/calltrunk/viewhistory", _
    My.Resources.ctTrunkIco, _
    CommandBarControl.ItemDisplayStyle.TextOnly, _
    False)
                NewMenu.AddSubItem(button2)

                Dim button3 As CommandBarButton = New CommandBarButton("Account Settings", _
    "Account Settings For Call Trunk", _
    New EventHandler(AddressOf UserSettingsMenuClick), _
    "act-ui://com.act/application/menu/tools/calltrunk/settings", _
    My.Resources.ctTrunkIco, _
    CommandBarControl.ItemDisplayStyle.TextOnly, _
    False)
                NewMenu.AddSubItem(button3)

                Dim button4 As CommandBarButton = New CommandBarButton("Uninstall", _
    "Uninstall the Call Trunk AddIn", _
    New EventHandler(AddressOf UninstallAddin), _
    "act-ui://com.act/application/menu/tools/calltrunk/uninstall", _
    My.Resources.ctTrunkIco, _
    CommandBarControl.ItemDisplayStyle.TextOnly, _
    False)
                NewMenu.AddSubItem(button4)

            End If
        Next

    End Sub

    Private Sub HostApplicationBeforeLogoff(ByVal Sender As Object, ByVal e As System.EventArgs)

        Me.RemoveMenuItem("act-ui://com.act/application/menu/tools/calltrunk/makecall", Me.HostApplication)
        Me.RemoveMenuItem("act-ui://com.act/application/menu/tools/calltrunk/viewhistory", Me.HostApplication)
        Me.RemoveMenuItem("act-ui://com.act/application/menu/tools/calltrunk/settings", Me.HostApplication)
        Me.RemoveMenuItem("act-ui://com.act/application/menu/tools/calltrunk/uninstall", Me.HostApplication)
        Me.RemoveMenuItem("act-ui://com.act/application/menu/tools/calltrunk", Me.HostApplication)

    End Sub

    'RemoveMenuItem
    Private Sub RemoveMenuItem(ByVal urn As String, ByVal ACTAPP As Act.UI.ActApplication)
        Try
            If ACTAPP.Explorer.CommandBarCollection("Connected Menus") Is Nothing Then
                Return
            End If

            ACTAPP.RevokeCommand(urn)
            Dim RemoveMenu As Act.UI.Core.CommandBarControl
            RemoveMenu = ACTAPP.Explorer.CommandBarCollection("Connected Menus").ControlCollection(urn)
            If Not RemoveMenu Is Nothing Then
                ACTAPP.Explorer.CommandBarCollection("Connected Menus").ControlCollection(GetParentControlURN(urn)).RemoveSubItem(RemoveMenu)
            End If

        Catch ex As Exception
            Throw New Exception("ACTAPPFunctions:RemoveMenuItem", ex)
        End Try

    End Sub

    'GetParentControlURN
    Private Function GetParentControlURN(ByVal urn As String) As String
        Try
            Return urn.Substring(0, urn.LastIndexOf("/"))
        Catch ex As Exception
            Throw New Exception("ACTAPPFunctions:GetParentControlURN", ex)
        End Try
    End Function