Using GetUserEvent to Respond to User Interface Events
GetUserEvent returns only commit events and events you programmatically insert with QueueUserEvent. Commit events are generated when the user finalizes an action, by performing an action such as selecting a menu item or typing number and then pressing <Enter>. Until this commit signal is received, GetUserEvent continues to loop, waiting for the user's actions to be finalized. The following figure illustrates the event-loop concept of GetUserEvent.
Event Loop Concept
The following pseudocode algorithm demonstrates a potential use for a GetUserEvent loop:
panel_handle = LoadPanel(...);
DisplayPanel(panel_handle,...);
menu_handle = LoadMenuBar(...);
while (GetUserEvent(WAIT, &handle, &control)) {
if (handle ==, PANEL) {
switch (control) {
case PANEL_CONTROL1:
. /* Code that responds to CONTROL1 on */
. /* the panel. */
break;
case PANEL_CONTROL2:
. /* Code that responds to CONTROL2 on */
. /* the panel. */
break;
}
}
if (handle == MENUBAR) {
switch (control) {
case MENUBAR_MENU1_ITEM1:
. /* Code that responds to ITEM1 in */
. /* MENU1 of the menu bar. */
break;
case MENUBAR_MENU1_ITEM2:
. /* Code that responds to ITEM2 in */
. /* MENU1 of the menu bar. */
break;
}
}
![]() |
Note You can also set up GetUserEvent to receive events other than commit events. |