IWinApplication.ProcessMouseMessages

Syntax

ProcessMouseMessages;

Description

The ProcessMouseMessages method sends a request to process system messages addressed to the application.

Comments

Method calling results in checking a queue of mouse and keyboard system messages and messages causing rerendering of application window. If the queue contains some objects, the messages are immediately processed. After processing the messages are deleted from the queue.

The method can be used to interrupt long-term processes by processing pressed keys or mouse clicks on the components.

Example

Executing the example requires a form that contains two buttons with the Button1 and Button2 identifiers.

Class TESTForm: Form
    Button1: Button;
    Button2: Button;
    Stop: Boolean = False;

    Sub StartOnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        d: DateTime;
        WinApp: IWinApplication;
    Begin
        Self.BeginOperation("Execution");
        d := DateTime.AddSeconds(DateTime.Now, 60);
        WinApp := WinApplication.Instance;
        While DateTime.Now < d Do
            WinApp.ProcessMouseMessages;
            If Stop Then
                Break;
            End If;
        End While;
        Stop := False;
        Self.EndOperation;
    End Sub StartOnClick;

    Sub StopOnClick(Sender: Object; Args: IMouseEventArgs);
    Begin
        Stop := True;
    End Sub StopOnClick;

End Class TESTForm;

Clicking the Button1 button starts a 60-second long process, during which mouse system messages are processed. Clicking the Button2 button interrupts the started process. If the process is started without processing mouse system messages, it cannot be interrupted by clicking the Button2 button.

See also:

IWinApplication