ProcessMouseMessages;
ProcessMouseMessages();
The ProcessMouseMessages method sends a request to process system messages addressed to the application.
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.
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.
Executing the example requires a .NET form that contains two buttons with the Button1 and Button2 identifiers. The form is set as a startup object for the .NET assembly.
Imports Prognoz.Platform.Interop.Ui;
Public Partial Class TESTForm: Prognoz.Platform.Forms.Net.ForeNetForm
Public Constructor TESTForm();
Begin
InitializeComponent();
End Constructor;
Stop: boolean;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
d: DateTime;
WinApp: WinApplication = New WinApplicationClass_2();
Begin
Self.BeginOperation("Execution");
d := DateTime.Now.AddSeconds(60);
While DateTime.Now < d Do
WinApp.ProcessMouseMessages();
If Stop Then
Break;
End If;
End While;
Stop := False;
Self.EndOperation();
End Sub;
Private Sub button2_Click(sender: System.Object; e: System.EventArgs);
Begin
Stop := True;
End Sub;
End Class;
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: