Public
Sub GetAddInInfo(ByRef poInfo As EdmLib.EdmAddInInfo, ByVal poVault As
EdmLib.IEdmVault5, ByVal poCmdMgr As EdmLib.IEdmCmdMgr5) Implements
EdmLib.IEdmAddIn5.GetAddInInfo
'Specify the add-in information
poInfo.mbsAddInName = "Menu command sample"
poInfo.mbsCompany = "SOLIDWORKS Corporation"
poInfo.mbsDescription = "Adds menu
command items"
poInfo.mlAddInVersion = 1
poInfo.mlRequiredVersionMajor = 5
poInfo.mlRequiredVersionMinor = 2
'Add
menu command items (the command-ID numbers 1000 and 1001 are
'arbitrary; PDM does not use them;
instead, PDM only passes them to the
'implementation of OnCmd
to know which command was selected)
poCmdMgr.AddCmd(1000, "First command",
EdmMenuFlags.EdmMenu_Nothing, "This is the first command",
"First command", 0, 99)
poCmdMgr.AddCmd(1001, "Second command",
EdmMenuFlags.EdmMenu_MustHaveSelection, "This is the second
command", "Second command", 1, 99)
End Sub
The flag
EdmMenuFlags.EdmMenu_MustHaveSelection
means that
the second command is only available if the user has selected one or more
files or folders.
Public Sub OnCmd(ByRef poCmd As EdmLib.EdmCmd,
ByRef ppoData As System.Array) Implements EdmLib.IEdmAddIn5.OnCmd
'Check the command ID to
see which command was selected
'(This only affects the
caption of the message box below)
Dim CommandName As String
If poCmd.mlCmdID = 1000 Then
CommandName = "The first command."
Else
CommandName = "The second command."
End If
'Retrieve the bounds of the
array containing the selected files and folders
Dim index As Long
Dim last As Long
index = LBound(ppoData)
last = UBound(ppoData)
Dim StrID As String
'Create a message showing the
names and IDs of all selected files and folders
Dim message As String
message = "You have selected the
following files and folders: " + vbLf
While index <= last
If ppoData(index).mlObjectID1 = 0 Then
message = message + "Folder: (ID="
StrID
= ppoData(index).mlObjectID2
message
= message + StrID + ") "
Else
message = message + "File: (ID="
StrID
= ppoData(index).mlObjectID1
message
= message + StrID + ") "
End If
message = message + ppoData(index).mbsStrData1 + vbLf
index = index + 1
End While
'Display the message
Dim v As EdmVault5
v = poCmd.mpoVault
v.MsgBox(poCmd.mlParentWnd, message, EdmMBoxType.EdmMbt_OKOnly,
CommandName)
End Sub