Hide Table of Contents
AddMenuItem4 Method (ISldWorks)

Adds a menu item and bitmap to the SolidWorks interface.

.NET Syntax

Visual Basic (Declaration) 
Function AddMenuItem4( _
   ByVal DocumentType As Integer, _
   ByVal Cookie As Integer, _
   ByVal MenuItem As String, _
   ByVal Position As Integer, _
   ByVal MenuCallback As String, _
   ByVal MenuEnableMethod As String, _
   ByVal HintString As String, _
   ByVal BitmapFilePath As String _
) As Integer
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim DocumentType As Integer
Dim Cookie As Integer
Dim MenuItem As String
Dim Position As Integer
Dim MenuCallback As String
Dim MenuEnableMethod As String
Dim HintString As String
Dim BitmapFilePath As String
Dim value As Integer
 
value = instance.AddMenuItem4(DocumentType, Cookie, MenuItem, Position, MenuCallback, MenuEnableMethod, HintString, BitmapFilePath)
C# 
int AddMenuItem4( 
   int DocumentType,
   int Cookie,
   string MenuItem,
   int Position,
   string MenuCallback,
   string MenuEnableMethod,
   string HintString,
   string BitmapFilePath
)
C++/CLI 
int AddMenuItem4( 
&   int DocumentType,
&   int Cookie,
&   String^ MenuItem,
&   int Position,
&   String^ MenuCallback,
&   String^ MenuEnableMethod,
&   String^ HintString,
&   String^ BitmapFilePath
) 

Parameters

DocumentType

Document type to which the menu item is to be added as defined by swDocumentTypes_e

Cookie
Cookie specified as defined in ISwAddin::ConnectToSW
MenuItem

Menu string ("menuItem@subMenuString@menuString"); SolidWorks creates menus and submenus only if they do not already exist

NOTE: Use the & symbol to include an accelerator key, e.g, "MyItem@&File" adds MyItem to the File menu with an accelerator key. To display the accelerator key, press the Alt key in SolidWorks. The accelerator key is underlined.

Position

Position at which to add the new menu item

The first item is at position 0; if Position is 1, the new menu item is added to the bottom of the list; this argument specifies the position of the menu item in relation to its immediate parent menu

MenuCallback

Function to call when this menu item is selected (see Remarks)

MenuEnableMethod

Optional function that controls the state of the menu item.

If specified, SolidWorks:

  • Calls this function before displaying the menu

  • Display of the menu item is controlled by the return value of MenuEnableMethod

If MenuEnableMethod returns...

Then SolidWorks...

0

Deselects and disables the menu item

1

Deselects and enables the menu item; this is the default menu state if no update function is specified

2

Selects and disables the menu item

3

Selects and enables the menu item

(See Remarks)

HintString

Text to show in the SolidWorks status bar when the user moves their mouse over this menu item; if you specify a HintString, it must be preceded by a comma

BitmapFilePath

Path and filename of bitmap

Return Value

SolidWorks runtime command ID or -1 if the method fails

Remarks

See Add-in Callback and Enable Methods to learn how to specify MenuCallback and MenuEnableMethod.

For information about using this method with the ISwAddin object, see Using ISwAddin to Create a SolidWorks Add-in.

The bitmap must be 16w x 16h x 256 colors. Transparency is RGB (192, 192, 192).

You can add a new menu to any one of the four SolidWorks frames (main, part, assembly, or drawing). To do this, call this method with the appropriate argument in the DocumentType parameter. For example, if you want your menu to be available when a part document is active, then call this method and pass swDocPART as the first argument. After you have added your menu to the part frame, you do not need to do it again during the current SolidWorks session. Once a part document is activated by the user, SolidWorks automatically displays your menu option.

To add a menu separator:

  • leave the text for the menu item blank, so that the menu string for the MenuItem argument starts with the at-sign symbol ( @):

    "@menuString"

    "@subMenuString@menuString"

  • specify an existing method for the MenuCallback argument. This method is never called, so its implementation can be empty.

  • specify empty strings for the MenuEnableMethod, HintString, and bitmapFilePath arguments.

Read about Add-in Shortcut Menus.

 

See Also

Availability

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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   AddMenuItem4 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) 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.