Admin Production ni-theme
Current Publication

Assigning IDs and Callbacks in the User Interface Editor

LabWindows/CVI

Assigning IDs and Callbacks in the User Interface Editor

When designing a GUI in the User Interface Editor, it is important to assign resource IDs and callbacks to all user interface objects. The following table shows how to reference objects and assign callbacks. To establish the connection between .uir files and your C source files, include a header file with your source code. LabWindows/CVI automatically generates the necessary header file every time you save a .uir file.

Note Note  
  • Resource IDs are also known as constant names.
  • When you create your GUI programmatically, you reference objects and callbacks differently.
  • With the LabWindows/CVI CodeBuilderCodeBuilder, you can create complete C code based on your user interface (.uir) file.
User Interface Object How to Reference the Object How to Assign a Callback to the Object
Control Use a resource ID that you specify in the User Interface Editor. Declare the callback in the User Interface Editor.
Menu Use a resource ID that you specify in the User Interface Editor. Declare the callback in the User Interface Editor.
Submenu Use a resource ID that you specify in the User Interface Editor. Declare the callback in the User Interface Editor.
Menu item Use a resource ID that you specify in the User Interface Editor. Declare the callback in the User Interface Editor.
Panel To load a panel, use a resource ID that you specify in the User Interface Editor. Thereafter, use the panel handles that LoadPanel or LoadPanelEx return. Declare the callback in the User Interface Editor.
Menu bar To load the menu bar, use a resource ID that you specify in the User Interface Editor. Thereafter, use the menu bar handle that LoadMenuBar or LoadMenuBarEx returns. Declare the callback in the User Interface Editor.

Rules for Assigning Constant Names

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, LabWindows/CVI automatically inserts the constant name separator (an underscore character, _) between the a constant prefix and a constant name.

NoteNote  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.
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. The 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. The 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. The 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. The application program uses the complete constant name to reference the menu item.