Hide Table of Contents
AddMenuItem2 Method (IFrame)

Adds a menu item and bitmap or a separator to an existing pull-down menu.

.NET Syntax

Visual Basic (Declaration) 
Function AddMenuItem2( _
   ByVal Menu As String, _
   ByVal Item As String, _
   ByVal Position As Integer, _
   ByVal CallbackFcnAndModule As String, _
   ByVal BitmapFileName As String _
) As Boolean
Visual Basic (Usage) 
Dim instance As IFrame
Dim Menu As String
Dim Item As String
Dim Position As Integer
Dim CallbackFcnAndModule As String
Dim BitmapFileName As String
Dim value As Boolean
 
value = instance.AddMenuItem2(Menu, Item, Position, CallbackFcnAndModule, BitmapFileName)
C# 
bool AddMenuItem2( 
   string Menu,
   string Item,
   int Position,
   string CallbackFcnAndModule,
   string BitmapFileName
)
C++/CLI 
bool AddMenuItem2( 
&   String^ Menu,
&   String^ Item,
&   int Position,
&   String^ CallbackFcnAndModule,
&   String^ BitmapFileName
) 

Parameters

Menu
Name of the menu to which to add item
Item
Name of item (including accelerator key "&"); if Item is NULL or empty, then this method adds a separator
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 end of the list
CallbackFcnAndModule
Function called when user clicks the menu item (see Remarks)
BitmapFileName
Path and filename of the bitmap for the menu item

Return Value

True if menu item is added, false if not

Remarks

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:

"dllname@function@updatefunction,hintstring"

where:

dllname

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.

function

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

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

updatefunction

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 update function 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 specify your updatefunction.

hintstring

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

"Userdll@AddBox@checkForUserSelects,Add a box"

 

See Also

Availability

SolidWorks 2005 FCS, Revision Number 13.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:   AddMenuItem2 Method (IFrame)
*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.