IDs and Handles in the User Interface Editor

When you design your GUI in the User Interface Editor, you assign resource IDs and callbacks to user interface objects. You reference objects and assign callbacks as shown in the following table. To establish the connection between your .uir files and your C source files you must include a header file with your source code. LabWindows/CVI automatically generates the necessary header file every time you save a .uir file.

Scroll down to see rules for assigning resource IDs. Be aware that resource IDs are also known as constant names.

Note   When you create your GUI programmatically, you reference objects and callbacks in different ways.

Assigning IDs and Callbacks in the User Interface Editor

User Interface Object How to Reference the Object How to Assign a Callback to the Object
Control Use a resource ID that you set in the User Interface Editor. Declare the callback in the User Interface Editor.
Menu Use a resource ID that you set in the User Interface Editor. Declare the callback in the User Interface Editor.
Submenu Use a resource ID that you set in the User Interface Editor. Declare the callback in the User Interface Editor.
Menu item Use a resource ID that you set in the User Interface Editor. Declare the callback in the User Interface Editor.
Panel To load a panel, use a resource ID that you set in the User Interface Editor. Thereafter, use the panel handles that LoadPanel or LoadPanelEx, returns. Declare the callback in the User Interface Editor.
Menu bar To load the menu bar, use a resource ID that you set in the User Interface Editor. Thereafter, use the menu bar handle that LoadMenuBar or LoadMenuBarEx returns. Declare the callback in the User Interface Editor.
Note   With the LabWindows/CVI CodeBuilder, you can create automatically complete C code that compiles and runs based on a user interface (.uir) file you are creating or editing.

The rules in the following table apply when you use the User Interface Editor to assign constant names (resource IDs) to panels and controls. When the User Interface Editor generates the include file, the Editor automatically inserts the constant name separator (an underscore character, _ ) between the a constant prefix and a constant name.

Note   When you use submenus, LabWindows/CVI concatenates all identifiers starting with the menu bar prefix. Choose brief identifiers so that constant names remain as short as possible.

Rules for Assigning Constant Names

Rule Size of String (# of Bytes) Description
You must assign a constant prefix to a panel. 10 Prefix that must be unique with respect to all other panel and menu bar constant prefixes in the same resource file. Your application program references the prefix when it loads the panel from the resource file.
You can assign a constant name to each control. 20 Name that must be unique with respect to all other control constants defined for the same panel. The name is appended to the panel prefix to generate a unique constant name. For example, if the panel prefix is SCOPE and the control prefix is POWER, the complete constant name is SCOPE_POWER. The application program uses the complete constant name to reference the control.
For menu bars, you must assign a constant prefix to the menu bar. 10 Prefix that must be unique with respect to all other panel and menu bar prefixes that you store together in a resource file. Your application program references the prefix to load the menu bar from the resource file.
For menu bars, you can assign a constant prefix to each menu. 10 Prefix that must be unique with respect to all other menu prefixes in the same menu bar. The program concatenates the constant prefix and the menu bar prefix to generate a unique constant name. For example, if the menu bar prefix is MAIN and the menu prefix is FILE, the complete constant name is MAIN_FILE. Your application program uses the complete constant name to reference the menu.
For menu bars, you can assign a constant name to each menu item. 10 Name that must be unique with respect to all other menu item constants in the same menu. The program concatenates the menu bar prefix and the menu prefix to generate a unique constant name. For example, if the menu bar prefix is MAIN, the menu prefix is FILE, and the menu item name is OPEN, the complete constant name is MAIN_FILE_OPEN. Your application program uses the complete constant name to reference the menu item.