Welcome
Collapse Getting StartedGetting Started
Overview
Expand Types of SolidWorks API ApplicationsTypes of SolidWorks API Applications
Expand SolidWorks API Object Model and Class HierarchySolidWorks API Object Model and Class Hierarchy
Collapse Programming with the SolidWorks APIProgramming with the SolidWorks API
Collapse Add-insAdd-ins
API Dependent on SolidWorks Being Visible
Arrays
Attributes Imported from ACIS SAT Files
Bitmasks
Block Definitions and Block Instances
Bodies in Body Folders
BOOL and VARIANT_BOOL
Bounding Box and Note Text
COM vs. Dispatch
CommandManager and CommandGroups
Components, Configurations, and Suppression States
Compound Note
ComVisibleAttribute in VSTA macros
Controls, Visual Basic 6.0, and Windows XP
Expand Double Arrays and Integer PairsDouble Arrays and Integer Pairs
Drawing Views and Model Entities
Early and Late Binding
Expand EventsEvents
Features of Components
Helper Functions
Hole Wizard Features and Objects
IDispatch Object Arrays as Input in .NET
Implementation Guidelines
Import and Export File Options
In-process Methods
Instantiate ActiveX Controls as Tabs
Interface Pointers
Keystrokes and Accelerator Keys
Library Features and Objects
Lightweight Components
Line Attributes for View::GetPolyLinesAndCurves
Line Weights
Long vs. Integer
Expand Macro FeaturesMacro Features
Manipulators
Mass Properties
Expand Multibody PartsMultibody Parts
Option Explicit Statement
Partition Rollback and API Handles
Persistent Reference IDs
Presentation Transforms
Expand PropertyManager PagesPropertyManager Pages
.NET Interop Assemblies
Quick Tips and Bubble ToolTips
Return Values
Expand SafeArraysSafeArrays
Selection Criteria
Selection Lists
Selections that Define Features
Setup Project to Distribute SolidWorks Add-in
Smart Pointers
SolidWorks Objects
Sorting Tables
SQLite
STL Container Classes and Smart Pointers
Suspend Automatic Rebuilds
System Options and Document Properties
Tessellation and Edges
Tracking IDs
Expand Type LibrariesType Libraries
Units
Unmanaged C++ and C++/CLI Code
VBA and SolidWorks x64
Examples and Projects
Expand SolidWorks API HelpSolidWorks API Help
Expand FeatureWorks API HelpFeatureWorks API Help
Expand SolidWorks Costing API HelpSolidWorks Costing API Help
Expand SolidWorks Document Manager API HelpSolidWorks Document Manager API Help
Expand SolidWorks Routing API HelpSolidWorks Routing API Help
Expand SolidWorks Simulation API HelpSolidWorks Simulation API Help
Expand SolidWorks Sustainability API HelpSolidWorks Sustainability API Help
Expand SolidWorks Toolbox API HelpSolidWorks Toolbox API Help
Expand SolidWorks Utilities API HelpSolidWorks Utilities API Help
Expand SolidWorks Workgroup PDM API HelpSolidWorks Workgroup PDM API Help
Expand eDrawings API HelpeDrawings API Help
Hide Table of Contents

Add-in Shortcut Menus

To create and display a shortcut (pop-up) menu in a SolidWorks add-in, create a SolidWorks C++, VB.NET, or C# add-in project in Visual Studio and do the following:

 

  1. In SwAddin.AddCommandManager():

    1. Add a menu and menu item to the SolidWorks main menu by calling ISldWorks::AddMenu and ISldWorks::AddMenuItem4 (C++ add-ins only). When selected, the menu item will launch the shortcut menu.

    2. Add a third-party icon to a context-sensitive menu by calling IFrame::AddMenuPopupIcon (C++ add-ins) or IFrame::AddMenuPopupIcon2 (VB.NET or C# add-ins). When clicked, the icon will launch the shortcut menu.

    3. Create and register your shortcut menu by calling ISldWorks::RegisterThirdPartyPopupMenu.

    4. Call ISldWorks::AddItemToThirdPartyPopupMenu (C++ add-ins) or ISldWorks::AddItemToThirdPartyPopupMenu2 (VB.NET or C# add-ins) one or more times to create one or more menu items in the shortcut menu. Uniquely specify the item argument for each menu item, menu break, and separator bar in the menu. Do not specify the item argument for menu bar icons.

  2. In the menu and toolbar callback region of SwAddin:

    1. Implement the callback and enable functions for each shortcut menu item and each menu bar icon that was created in step 1d. See Add-in Callback and Enable Methods.

    2. Implement the callback and enable functions for the menu item and third-party icon that were created in steps 1a and 1b. From the callback functions of the icon and menu item, call ISldWorks::ShowThirdPartyPopupMenu to display the shortcut menu at a specific location in the SolidWorks graphics area. See Add-in Callback and Enable Methods.

  3. Remove menu items from the shortcut menu at runtime by calling ISldWorks::RemoveItemFromThirdPartyPopupMenu from an event handler of the add-in.

  4. In SwAddin.DisconnectFromSW():

    1. Call ISldWorks::RemoveMenu to remove the menu from the SolidWorks main menu bar, if added in step 1a (C++ add-ins only).

    2. Call IFrame::RemoveMenuPopupIcon to remove the third-party icon from the context-sensitive menu, if added in step 1b.

To learn more about add-ins and their menu items and toolbars:



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:   Add-in Shortcut Menus
*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.