Creating Objects for a Graphical User Interface
- Updated2023-02-21
- 2 minute(s) read
Creating Objects for a Graphical User Interface
You can create Graphical User Interface (GUI) objects for your application program in the following ways:
- Create objects programmatically using function calls.
- Create objects interactively using the User Interface Editor.
After designing your GUI in LabWindows/CVI, develop a C program to process the events generated from the user interface and to control the flow of your program. LabWindows/CVI offers the following two basic methods for designing your programs:
- Callback Functions—Callback functions are individual functions in your program that are called directly by user interface controls. When any type of event is generated on a panel, menu, or control, the appropriate callback function executes. For example, you might have a function in your program called AcquireData that you assign to a button labeled Acquire. Whenever a user clicks on the Acquire button, LabWindows/CVI passes all of the event information generated by the button directly to AcquireData, where your program takes appropriate action. It is important to assign IDs and callback functions to every interface object.
- Event Loops—In an event loop, you poll for commit events by calling GetUserEvent. When a commit event is generated, GetUserEvent returns the appropriate panel, menu, or control identifier, then the program conditionally executes portions of code. Event loops can poll for commit events only. To process events other than commit events, you must install callback functions.
You can use either method in your program or combine methods for added flexibility. However, try to limit the use of event loops to the processing of events from modal dialog boxes (also called pop-up panels).
Keep in mind the following distinction regarding user interface objects:
- An ID represents an object that a higher-level object must contain. An object that is represented by an ID cannot contain other objects. For example, a control must be within a panel and cannot contain any other controls.
- A handle for a panel or menu bar represents a top-level object that can contain other objects. For example, if you call DiscardPanel on a panel handle, LabWindows/CVI not only destroys the panel itself, but also all of the controls that the panel contains.