# Callback Function Schemes

An object-based callback approach is a common method of using callbacks to process user events. In an object-based callback approach, you use multiple callbacks to control user interface objects. You can assign unique callback functions to each panel, control, and menu item, or you can use separate callback functions for specific groups of controls or menu items. You can use any scheme that makes sense to you. The object-based callback approach subdivides the program into small, manageable sections, each section having a specific task.

Alternatively, you can install a single callback function using InstallMainCallback to process all events.

The main callback function is the only type of callback function that responds to EVENT_END_TASK. This event occurs only under Windows when the user is trying to exit Windows. Return a non-zero value to abort the exit of Windows.

The main callback function also responds to idle events. Idle events occur on a regular basis as long as LabWindows/CVI processes events. You can set the rate at which idle events occur using SetIdleEventRate.

| Note EVENT_VAL_CHANGED, EVENT_IDLE, and EVENT_TIMER_TICK are the only events that are generated while a user holds the mouse button down on a control or pull-down menu. The operating system blocks all events (including idle events) when a top-level panel is moved or sized.

| Note In general, it is recommended that you use timer controls instead of idle events.

For even greater flexibility, you can combine the object-based callback approach with the main callback approach. Object-based callbacks are called before the main callback so that both have the opportunity to process events.