CreateContextMenu Event

TestStand 2019 Help

Edition Date: May 2019

Part Number: 370052AA-01

»View Product Info
Download Help (Windows Only)


ControlName_CreateContextMenu ( menuHandle, x, y)

Applies To



Occurs when you right-click the control so the application can build a context menu from which you can select commands. Even though you can implement context menus in most environments without using this event, some environments do not provide any other way to create a context menu. Also, creating a context menu using this event is less complicated in most environments, especially when the context menu contains only TestStand commands.


menuHandle As Long

[In] Specifies the Microsoft Windows menu handle (HMENU). When you add menu items to the menu handle, the control displays them in a context menu. Use the Commands.InsertIntoWin32Menu method to insert TestStand commands into the menu.

You can also use the menu functions in the Windows Software Development Kit (SDK) to add other menu items; however, these menu items do not have an associated TestStand command. When you select an item without a TestStand command, the control creates and executes a Command object of kind CommandKind_Custom. The control stores the menu item identifier, such as resource ID or command ID, as a long in the Command.UserData property, and as a decimal string in the command display name. You can handle either the ApplicationMgr.PreCommandExecute or ApplicationMgr.PostCommandExecute event to receive a notification when the user selects a menu item you insert with the Windows SDK.

When you close the context menu, the control disposes of the menu items. You do not need to dispose of the menu items you insert.

x As long

[In] Specifies the horizontal position of right-clicking, relative to the control.

y As long

[In] Specifies the vertical position of right-clicking, relative to the control.

See Also






Not Helpful