# 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. Refer to the IDs and handles in a user interface program topic to learn how to reference these objects.
- Create objects interactively using the User Interface Editor. Refer to the IDs and handles in the User Interface Editor topic to learn how to reference these objects.

After you design your GUI in LabWindows/CVI, you must 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—With callback functions, you write 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 which 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.
- 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, and 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. In general, however, avoid using event loops except for processing events from modal dialog boxes (also called pop-up panels).

| Note One of your most important tasks in designing a GUI is to assign IDs and callback functions to every interface object.

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 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 destroys the panel and all of the controls that the panel contains.