Hide Table of Contents
AddItemToThirdPartyPopupMenu2 Method (ISldWorks)

Adds menu items to a pop-up (shortcut) menu in a SOLIDWORKS add-in.

.NET Syntax

Visual Basic (Declaration) 
Function AddItemToThirdPartyPopupMenu2( _
   ByVal RegisterId As System.Integer, _
   ByVal DocType As System.Integer, _
   ByVal Item As System.String, _
   ByVal Identifier As System.Integer, _
   ByVal CallbackFunction As System.String, _
   ByVal EnableFunction As System.String, _
   ByVal CustomName As System.String, _
   ByVal HintString As System.String, _
   ByVal BitmapFileName As System.String, _
   ByVal MenuItemTypeOption As System.Integer _
) As System.Boolean
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim RegisterId As System.Integer
Dim DocType As System.Integer
Dim Item As System.String
Dim Identifier As System.Integer
Dim CallbackFunction As System.String
Dim EnableFunction As System.String
Dim CustomName As System.String
Dim HintString As System.String
Dim BitmapFileName As System.String
Dim MenuItemTypeOption As System.Integer
Dim value As System.Boolean
 
value = instance.AddItemToThirdPartyPopupMenu2(RegisterId, DocType, Item, Identifier, CallbackFunction, EnableFunction, CustomName, HintString, BitmapFileName, MenuItemTypeOption)
C# 
System.bool AddItemToThirdPartyPopupMenu2( 
   System.int RegisterId,
   System.int DocType,
   System.string Item,
   System.int Identifier,
   System.string CallbackFunction,
   System.string EnableFunction,
   System.string CustomName,
   System.string HintString,
   System.string BitmapFileName,
   System.int MenuItemTypeOption
)
C++/CLI 
System.bool AddItemToThirdPartyPopupMenu2( 
&   System.int RegisterId,
&   System.int DocType,
&   System.String^ Item,
&   System.int Identifier,
&   System.String^ CallbackFunction,
&   System.String^ EnableFunction,
&   System.String^ CustomName,
&   System.String^ HintString,
&   System.String^ BitmapFileName,
&   System.int MenuItemTypeOption
) 

Parameters

RegisterId
ID of shortcut menu from ISldWorks::RegisterThirdPartyPopupMenu
DocType
Document type where to display shortcut menu, as defined in swDocumentTypes_e
Item

Unique display name of shortcut menu item (see Remarks); specify an empty string if adding an icon to the menu bar

Identifier
ID of the add-in; value of the Cookie argument passed by ISwAddin::ConnectToSW
CallbackFunction

Function called when user clicks the shortcut menu item; specify an empty string if MenuItemTypeOption is:

(see Remarks)

EnableFunction

Optional function that controls the state of the shortcut menu item

If specified, SOLIDWORKS:

  1. calls this function before displaying the menu
  2. displays the menu item according to the return value of this function

If EnableFunction returns...

Then SOLIDWORKS...

0

Deselects and disables the menu item

1

Deselects and enables the menu item; this is the default menu state if EnableFunction is not specified

2

Selects and disables the menu item

3

Selects and enables the menu item

Specify an empty string if MenuItemTypeOption is:

(see Remarks)

CustomName
Empty string
HintString
Text to display in the SOLIDWORKS status bar when users move the mouse over this shortcut menu item
BitmapFileName

Path and filename of bitmap for icons (menu bar or menu item)

Specify an empty string if MenuItemTypeOption is:

MenuItemTypeOption
Type of menu item as defined in swMenuItemType_e

Return Value

True if the shortcut menu item is added, false if not

Example

VB.NET
'To create and register a shortcut menu:
   registerID = SwApp.RegisterThirdPartyPopupMenu()
   
'To add an actionable menu item to a shortcut menu:
   resultCode = SwApp.AddItemToThirdPartyPopupMenu2(
   registerID, 
   CInt(swDocumentTypes_e.swDocPART), 
   "Test1", 
   addinID, 
   "TestCallback", 
   "EnableTest", 
   "", 
   "Test1", 
   cmdGroup.SmallMainIcon, 
   CInt(swMenuItemType_e.swMenuItemType_Default))
   
'To add a separator bar to a shortcut menu 
   resultCode = SwApp.AddItemToThirdPartyPopupMenu2(
   registerID, 
   CInt(swDocumentTypes_e.swDocPART), 
   "Separator1",
   addinID 
   "", 
   "", 
   "", 
   "", 
   "",
   CInt(swMenuItemType_e.swMenuItemType_Separator))
   
'To add a section title or break to a shortcut menu:
   resultCode = SwApp.AddItemToThirdPartyPopupMenu2(
   registerID, 
   CInt(swDocumentTypes_e.swDocPART), 
   "Menu Break", 
   addinID, 
   "", 
   "", 
   "", 
   "", 
   "", 
   CInt(swMenuItemType_e.swMenuItemType_Break))

'To add an icon to the menu bar above a shortcut menu:
   resultCode = SwApp.AddItemToThirdPartyPopupMenu2(
   registerID, 
   CInt(swDocumentTypes_e.swDocPART), 
   "", 
   addinID, 
   "TestCallback", 
   "EnableTest", 
   "", 
   "NoOp", 
   cmdGroup.SmallMainIcon, 
   CInt(swMenuItemType_e.swMenuItemType_Default))

Example

Remarks

See Add-in Callback and Enable Methods to learn how to specify CallbackFunction and EnableFunction.

Read about Add-in Shortcut Menus.

 

See Also

Availability

SOLIDWORKS 2011 FCS, Revision Number 19.0


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   AddItemToThirdPartyPopupMenu2 Method (ISldWorks)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.