doWindowEvents

doWindowEvents(waitTime: Integer);

The doWindowEvents method of the Window class processes all pending Windows events for this window and all of its children.

The doWindowEvents method for a control processes events generated by the control and its children. In addition, it processes copies of the gotFocus, lostFocus, keyDown, keyUp, and keyPress events on the control, which are also sent to the form.

When the doWindowEvents method has processed all pending Windows events it then waits, and processes any further Windows events that arrive for this window until the specified time from when the method was initiated has expired.

Use the waitTime parameter to specify in milliseconds the required interval this method is to wait.

If a parent of the window requires repainting, the doWindowEvents method will not cause the window to be repainted.

The most common use of this method is to enable a Cancel button to be monitored during lengthy processing. (See also the Application class doWindowEvents method.)

The methods in the following examples show the use of the doWindowEvents method.

btnCancel_click(btn: Button);
begin
    cancelWasClicked := true;
end;
longProcess() updating;
begin
    cancelWasClicked := false;
    while true do
        ...                            // some kind of processing
        btnCancel.doWindowEvents(0);   // allow button press
        if cancelWasClicked then
            ...                        // cancel processing
            break;
        endif;
    endwhile;
end;

Do not use the doWindowEvents method in the following situations.

Call the Application class doWindowEvents method from a server method to process server notifications and timers.

Indiscriminate use of this method can cause unwanted side effects. For example, it can change the order of Windows event processing and can allow users to click on other controls, menus, or forms that could have an impact on the current process.

It can also cause recursive loops. For example, if a keyDown event calls a doWindowEvents method and the user is holding down the key, that method will invoke another keyDown event, and so on. JADE handles this situation, by discarding messages for a specific window if there are already five such messages in the call stack.