Admin Production ni-theme
Current Publication

GetUserEvent

LabWindows/CVI

GetUserEvent

int GetUserEvent (int waitMode, int *panelOrMenuBarHandle, int *controlOrMenuItemID);

Purpose

Obtains the next commit event or programmer-defined event from the GetUserEvent queue. A commit event occurs when the user changes the state of a hot or validate control or selects a menu item.

Place programmer-defined events in the GetUserEvent queue by calling QueueUserEvent. Refer to QueueUserEvent for the range of valid programmer-defined event codes.

Notes   
  • When the User Interface Library handles an event that starts a tracking loop, such as the user pulling down a menu, GetUserEvent does not return until the tracking loop completes, even if you pass 0 as the waitMode parameter. In the case of pulling down a menu, the tracking loop does not complete until the user dismisses the menu. Consequently, do not call GetUserEvent in your program if you want to continue executing the subsequent lines of code even during a tracking loop.
  • To increase the speed with which the GetUserEvent function executes, consider calling the SetSleepPolicy function prior to calling the GetUserEvent function. Set the value of the sleepPolicy input of the SetSleepPolicy function to VAL_SLEEP_NONE.

Example Code

The following example code demonstrates how to use this function to respond to commit events.

.
.
.

InstallPopup (panelHandle);

while (done == FALSE)

{

/* Wait for a commit event to occur on one of the user interface controls */

GetUserEvent (1, &eventPanel, &eventCtrl);

/* Run code corresponding to what button the user clicked */

switch (eventCtrl)

{

case PANEL_OKBUTTON:

SaveFunc ();

done = TRUE;

break;

case PANEL_QUITBUTTON:

QuitFunc ();

done = TRUE;

break;

}

}

.
.
.

Parameters

Input
Name Type Description
waitMode int If you specify a nonzero value or select wait in the function panel, GetUserEvent does not return until a commit event or programmer-defined event occurs.

If you specify 0 or select no wait in the function pane, GetUserEvent returns immediately, whether or not a commit event or programmer-defined event has occurred.
Output
Name Type Description
panelOrMenuBarHandle int The handle of the panel or menu bar on which the event occurred.

Returns –1 if waitMode is zero and no event has occurred.
controlOrMenuItemID int Returns the ID of the control or menu item on which the commit event occurred.

Returns –1 if waitMode is zero and no event has occurred.

Return Value

Name Type Description
eventStatus int The event, if any, that occurred.

0 No event.
1 Commit event occurred.
1,000-10,000 Event queued by QueueUserEvent.
Negative values indicate that an error occurred.

Additional Information

Library: User Interface Library

Include file: userint.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Examples

Refer to the following examples that use the GetUserEvent function:

  • apps\uirview\uirview.cws

    Open example
  • userint\clipbord.cws

    Open example
  • userint\getuserevent.cws

    Open example