RunPopupMenu
- Updated2023-02-21
- 2 minute(s) read
int RunPopupMenu (int menuBarHandle, int menuID, int panelHandle, int top, int left, int pinTop, int pinLeft, int pinHeight, int pinWidth);
Purpose
Displays a menu and tracks mouse and keyboard events on the menu.
If the user selects an item from the menu, the following actions occur:
- If a callback function is associated with the menu item, RunPopupMenu calls the function.
- RunPopupMenu returns the ID of the menu item the user selected.
In most cases, call this function from a User Interface panel or control callback function that has received a LEFT_CLICK, RIGHT_CLICK, or KEYPRESS event.
Parameters
Input | ||
Name | Type | Description |
menuBarHandle | int | Specifier for a particular menu bar that is currently in memory. You can obtain
this handle from functions such as LoadMenuBar and NewMenuBar. If the menu bar was automatically loaded through LoadPanel, use GetPanelMenuBar to get the menu bar handle. |
menuID | int | ID for a particular menu within a menu bar. The ID must be a constant name, located in the .uir header file, that you assign in the User Interface Editor or a value that you obtain from functions such as NewMenu and NewSubMenu. |
panelHandle | int | Handle for the panel over which you want the menu to appear. You can obtain this
handle from functions such as LoadPanel and NewPanel. The top, left, pinLeft, and pinRight parameters are relative to the top, left corner of this panel. |
top | int | Vertical coordinate at which to place the upper left corner of the menu. The coordinate must be an integer value from –32,768 to 32,767. The coordinate represents the pixel offset from the top of the panel that panelHandle specifies. |
left | int | Horizontal coordinate at which to place the upper left corner of the menu. The coordinate must be an integer value from –32,768 to 32,767. The coordinate represents the pixel offset from the left edge of the panel that panelHandle specifies. |
pinTop | int | The pin area is obsolete and is ignored. The menu remains visible wherever the user releases the mouse button. |
pinLeft | int | The pin area is obsolete and is ignored. The menu remains visible wherever the user releases the mouse button. |
pinHeight | int | The pin area is obsolete and is ignored. The menu remains visible wherever the user releases the mouse button. |
pinWidth | int | The pin area is obsolete and is ignored. The menu remains visible wherever the user releases the mouse button. |
Return Value
Name | Type | Description | ||||
menuItemSelected | int | If the user selects a menu item, the function returns the ID of the menu item. If the user releases the pop-up menu without selecting an item, the function returns 0. If an error occurs, the function returns a negative value.
|
Additional Information
Library: User Interface Library
Include file: userint.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to apps\uirview\uirview.cws for an example of using the RunPopupMenu function.