Hide Table of Contents
AddMenuPopupItem2 Method (IFrame)

Adds a menu item or separator to a shortcut menu (i.e., a right-click pop-up menu).

.NET Syntax

Visual Basic (Declaration) 
Function AddMenuPopupItem2( _
   ByVal DocType As Integer, _
   ByVal SelectType As Integer, _
   ByVal Item As String, _
   ByVal CallbackFcnAndModule As String, _
   ByVal CustomNames As String, _
   ByVal Unused As Integer, _
   ByVal BitmapFileName As String _
) As Boolean
Visual Basic (Usage) 
Dim instance As IFrame
Dim DocType As Integer
Dim SelectType As Integer
Dim Item As String
Dim CallbackFcnAndModule As String
Dim CustomNames As String
Dim Unused As Integer
Dim BitmapFileName As String
Dim value As Boolean
value = instance.AddMenuPopupItem2(DocType, SelectType, Item, CallbackFcnAndModule, CustomNames, Unused, BitmapFileName)
bool AddMenuPopupItem2( 
   int DocType,
   int SelectType,
   string Item,
   string CallbackFcnAndModule,
   string CustomNames,
   int Unused,
   string BitmapFileName
bool AddMenuPopupItem2( 
&   int DocType,
&   int SelectType,
&   String^ Item,
&   String^ CallbackFcnAndModule,
&   String^ CustomNames,
&   int Unused,
&   String^ BitmapFileName



Document type to which to add the shortcut menu item

Selection type to which to add the shortcut menu item
Description that appears on the shortcut menu item
Functions called when user clicks the shortcut menu item (see Remarks)
Names of custom feature types (see Remarks)

Reserved for future use, set to 0

Path and filename of bitmap for the shortcut menu item

Return Value

True if shortcut menu item is added, false if not


To add a separator, set the Item argument to NULL or an empty string.

If you want to create a pull-down menu, use IFrame::AddMenu.

This method only works for the C++ application implemented as a DLL, not as an EXE. Any function exposed as a callback from a menu item must be declared as an EXPORT or included in your .def file.

You can add a new menu to any one of the four SolidWorks frames (Main frame, part frame, assembly frame, or drawing frame). To do this, you must get the IFrame object when the desired frame is active. For example, if you want your menu to be available when a part document is active, then call ISldWorks::Frame when a part is first loaded or created, and use that IFrame object to call this method. Once you add your menu to the part frame, you do not need to do it again during the current SolidWorks session.

The CallbackFcnAndModule argument specifies which function to call when this menu item is selected by the user. The syntax is as follows:




Name of your library as specified in the project .def file. The actual DLL filename and the definition in the .def file must be the same.


Name of the function that gets called when the user clicks the button. This function must also be declared as an EXPORT in your .def file.

See Add-in Callback and Enable Methods to learn how to implement your callback function.


Optional argument that controls the state of the button. If specified, then SolidWorks calls this function before the button is displayed. Define your updatefunction to return an integer and declare it as an EXPORT or included in your .def file. The display of the button is controlled by the return value of the function as follows:

  • return 0 - Menu item is unchecked and disabled.
  • return 1 - Menu item is unchecked and enabled. This is the default menu state if no updatefunction is specified.
  • return 2 - Menu item is checked and disabled.
  • return 3 - Menu item is checked and enabled.

See Add-in Callback and Enable Methods to learn how to implement your updatefunction.


Optional argument that contains a text hint displayed in the SolidWorks status bar when the user moves the mouse over this menu option. If hintstring is specified, then it must be preceded by a comma. For example:

Userdll@AddBox@checkForUserSelects,Add a box

CustomNames is semi-colon separated list of the names of the custom feature types. This argument is applicable only if SelectType is a custom feature type (like swSelATTRIBUTES); in the case of swSelATTRIBUTES, set this field to the name of the attribute definition.


See Also


SolidWorks 2009 FCS, Revision Number 17.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

Subject:   Feedback on Help Topics
Page:   AddMenuPopupItem2 Method (IFrame)
*   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:


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

Web Help Content Version: API Help (English only) 2012 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.