DIALOG DOEVENTS statement

Purpose

Process pending window or dialog messages for MODELESS dialogs. DIALOG DOEVENTS releases the remainder of the process/thread time-slice if there are no active dialogs.

Syntax

DIALOG DOEVENTS [sleep&] [TO count&]

Remarks

DIALOG DOEVENTS is usually used to create a "message pump" for modeless dialog boxes.

The optional sleep& parameter specifies the number of milliseconds that the current thread will be paused, allowing other processes (or threads) to continue. Only the current thread pauses. If other threads are present, they will continue to execute. During the sleep period, all time-slices for the current thread are given to other threads and processes. If sleep& is zero, the remainder of the current time-slice is relinquished. 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 sleep& is not specified then the current thread will be paused for 1 mSec. See the SLEEP statement for more information.

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&

...

DO

  DIALOG DOEVENTS

  DIALOG GET SIZE hMainDlg& TO x&, x&

LOOP WHILE x& ' When x& = 0, dialog has ended

' Application code continues here...