The following exercise adds new menu items to the tree nodes that were added in the previous exercise. You must complete this exercise before the examples later in this section will work.
Add the following code to the IOlapAddIn_ProvideMenuItems method:
Private Sub IOlapAddIn_ProvideMenuItems( _
CurrentNode As DSSAddInsManager.OlapTreeNode, _
MenuItems As DSSAddInsManager.OlapMenuItems)
On Error GoTo IOlapAddIn_ProvideMenuItems_Err
Dim iFlags As OlapMenuFlags
'The OLAP Add-In Manager calls this method each time a tree node is
'accessed. Since multiple add-in programs are allowed,
'verify that this is the correct tree node to respond to.
If CurrentNode.OwnerAddInName <> ThisAddInName Then Exit Sub
Select Case CurrentNode.Caption
Case "Sample Forms"
MenuItems.Add mnuStandard, "&Form", _
mnuactAddNewForm, , mnuflagNew
MenuItems.Add mnuStandard, "&Refresh", _
mnuactRefreshList, , mnuflagNew
Case Else
MenuItems.Add mnuStandard, "&Show", _
mnuactShowSampleForm, , mnuflagPopup
MenuItems.Add mnuStandard, "&Top", mnuactShowTop, _
mnuactShowSampleForm, mnuflagSubmenu
MenuItems.Add mnuStandard, "&Center", _
mnuactShowCenter, mnuactShowSampleForm, _
mnuflagSubmenu
MenuItems.Add mnuStandard, "&Bottom", _
mnuactShowBottom, mnuactShowSampleForm, _
mnuflagSubmenu
MenuItems.Add mnuSeparator
MenuItems.Add mnuStandard, "&Rename"
MenuItems.Add mnuStandard, "&Delete", _
mnuactDeleteSampleForm, , mnuflagDeleteKey
End Select
Exit Sub
IOlapAddIn_ProvideMenuItems_Err:
Debug.Print Err.Number, Err.Description, Err.Source
Debug.Assert False
MsgBox "Provide Menu Items Failed"
Err.Clear
Exit Sub
End Sub
Run the application.
With the Microsoft® Visual Basic® project executing, start the OLAP Manager, and then browse the tree view. Right-click one of the new tree nodes, and then examine the added menu items.