Hide Table of Contents
AddItemToThirdPartyPopupMenu Method (ISldWorks)

Adds menu items to a pop-up (shortcut) menu in a C++ SolidWorks add-in.

.NET Syntax

Visual Basic (Declaration) 
Function AddItemToThirdPartyPopupMenu( _
   ByVal RegisterId As System.Integer, _
   ByVal DocType As System.Integer, _
   ByVal Item As System.String, _
   ByVal CallbackFcnAndModule 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 CallbackFcnAndModule 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.AddItemToThirdPartyPopupMenu(RegisterId, DocType, Item, CallbackFcnAndModule, CustomName, HintString, BitmapFileName, MenuItemTypeOption)
C# 
System.bool AddItemToThirdPartyPopupMenu( 
   System.int RegisterId,
   System.int DocType,
   System.string Item,
   System.string CallbackFcnAndModule,
   System.string CustomName,
   System.string HintString,
   System.string BitmapFileName,
   System.int MenuItemTypeOption
)
C++/CLI 
System.bool AddItemToThirdPartyPopupMenu( 
&   System.int RegisterId,
&   System.int DocType,
&   System.String^ Item,
&   System.String^ CallbackFcnAndModule,
&   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
Name of shortcut menu item (see Remarks)
CallbackFcnAndModule
Function called when user clicks the shortcut menu item (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 the bitmap
MenuItemTypeOption
Menu item as defined in swMenuItemType_e

Return Value

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

Example

C++
To add a section title or break to the shortcut menu:

iSwApp->AddItemToThirdPartyPopupMenu
(
registerIdPMenu1,
swDocPART,
CComBSTR(_T("Menu Break")),
CComBSTR(_T("")),
CComBSTR(_T("")),
CComBSTR(_T("")),
CComBSTR(_T("")),
swMenuItemType_Break,
&itemAdded
);

To add an icon to a menu bar above the shortcut menu:

iSwApp->AddItemToThirdPartyPopupMenu
(
registerIdPMenu1,
swDocPART,
CComBSTR(_T("")),
CComBSTR(_T("UserPopupMenus.dll@UserItem1_Menu1_Callback")),
CComBSTR(_T("")),
CComBSTR(_T("UserItem1_Menu1_Callback_hint")),
UserItem1_Menu1_bitmapFile,
swMenuItemType_Default,
&itemAdded
);

To add an actionable item to the shortcut menu:

iSwApp->AddItemToThirdPartyPopupMenu
(
registerIdPMenu1,
swDocPART,
CComBSTR(_T("UserItem1_Menu1_Callback")),
CComBSTR(_T("UserPopupMenus.dll@UserItem1_Menu1_Callback")),
CComBSTR(_T("")),
CComBSTR(_T("UserItem1_Menu1_Callback_hint")),
UserItem1_Menu1_bitmapFile,
swMenuItemType_Default,
&itemAdded
);

To add a separator bar to the shortcut menu:

iSwApp->AddItemToThirdPartyPopupMenu
(
registerIdPMenu1,
swDocPART,
CComBSTR(_T("")),
CComBSTR(_T("")),
CComBSTR(_T("")),
CComBSTR(_T("")),
CComBSTR(_T("")),
swMenuItemType_Separator,
&itemAdded
);

Remarks

This method is supported in C++ applications only, and it only works in C++ applications implemented as DLLs, not as EXEs.

Read about Add-in Shortcut Menus.

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

"dllname@function@updatefunction"

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 shortcut 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 implement your function.

updatefunction

Optional argument that controls the state of the shortcut menu item. If specified, then SolidWorks calls this function before the shortcut menu item 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 third-party shortcut menu item is controlled by the return value of the function as follows:

  • return 0 - Unchecked and disabled.
  • return 1 - Unchecked and enabled. This is the default menu state if no updatefunction is specified.
  • return 2 - Checked and disabled.
  • return 3 - Checked and enabled.

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

 

 

See Also

Availability

SolidWorks 2010 FCS, Revision Number 18.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:   AddItemToThirdPartyPopupMenu 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) 2013 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.