Managing Menus and Menu Items
- Aktualisiert2025-07-23
- 3 Minute(n) Lesezeit
TestStand applications that provide non-trivial menus can require a large amount of source code to build and update the state of menus and to handle events for menu items. Use the TestStand Utility (TSUtil) functions to create menu items that invoke TestStand commands to greatly reduce the amount of code required to implement menus in an application. TestStand automatically dims or enables these menu items according to the application state and sets their captions according to the language selection. The menu items execute commands automatically so that the application does not need to handle menu events or provide command implementations.
The application can also insert sets of dynamic menu items, such as a set of menu items to open files from the most recently used file list or a set of menu items that run the current sequence with each available process model entry point. To create TestStand menu items, you must first add TSUtil to the project.
Updating Menus and Menu Items
The contents of a menu can vary depending on the current selection, other user input, or asynchronous execution state changes. Instead of updating a menu in response to any event or change that might affect the menu, update the state of a menu just before the menu displays when the user opens the menu. The following table lists the notification method different application development environments (ADEs) use to notify the application when a user is about to open a menu.
| ADE | Menu Open Notification Method |
|---|---|
| LabVIEW | <This VI>:Menu Activation? event |
| LabWindows/CVI | InstallMenuDimmerCallback |
| .NET | Form.MenuStart |
| C++ (MFC) | CWnd::OnInitMenuPopup |
Use the RemoveMenuCommands, InsertCommandsInMenu, and CleanupMenu TestStand Utility (TSUtil) functions in LabVIEW and LabWindows/CVI to handle the menu open notifications and remove and reinsert TestStand menu items. You can remove and insert TestStand commands in menus that contain non-TestStand menu items.
The InsertCommandsInMenu function accepts an array of CommandKinds enumeration constants. Depending on the element value and the application state, each array element can create a single menu item, a set of several menu items, or no menu items. The CommandKinds enumeration also provides constants that expand into the full set of items commonly found in test application top-level menus, such as the File menu, Debug menu, or Configure menu.
Refer to the examples in the <TestStand>\UserInterfaces\Full-Featured directory for sample code that handles menu open notification events.