DIALOG DOEVENTS statement

Purpose | Process pending window or dialog messages for MODELESS dialogs. If there are no pending messages, DIALOG DOEVENTS pauses execution of the current thread for a length of time specified by the programmer.
Syntax | DIALOG DOEVENTS [sleep&] [TO count&]
Remarks | DIALOG DOEVENTS is usually used to create a "message pump" for modeless dialog boxes. If a window message is pending, it is processed appropriately. If no messages are pending, execution of the current thread is paused for the time specified by the sleep& parameter. If sleep& is zero (0), the remainder of the current time slice is relinquished to other threads or processes. If sleep& is greater than zero, the current thread is paused for that number of milliseconds to allow other threads or processes to continue. If sleep& is not specified, it defaults to a value of one (1). During the sleep period, all time-slices for the current thread are given to other threads and processes. If there are no other threads of equal priority, execution continues immediately. The time-slice duration (also known as the Quantum) can vary from version to version of Windows, ranging from 20 mSec to 120 mSec. If the optional TO clause is included, the number of active dialogs is returned in the count& variable, once all of the pending messages have been processed.
Restrictions | The DIALOG DOEVENTS loop must run for the duration of the modeless dialog(s), or they will not respond or be redrawn correctly.
See also | Dynamic Dialog Tools, DIALOG NEW, DIALOG SHOW MODELESS, SLEEP
Example | ' Single modeless dialog message pump example. ' (Assume dialog already created with DIALOG NEW) DIALOG SHOW MODELESS hDlg CALL DlgCallback DO DIALOG DOEVENTS 0 TO Count& LOOP WHILE Count& ' Application code continues here... ' Multiple modeless dialog message pump example. ' In some applications, the number of modeless dialogs can vary at any given moment, ' we want to break the message loop when the 'main' dialog is closed. ' (Assume dialogs already created with DIALOG NEW) DIALOG SHOW MODELESS hMainDlg& CALL DlgCallback DIALOG SHOW MODELESS hChildDlg1& DIALOG SHOW MODELESS hChildDlg2& [statements] DO DIALOG DOEVENTS LOOP WHILE ISWIN(hMainDlg&) ' Application code continues here...