[Lazarus] What to replace Application.Processmessages with?

Bo Berglund bo.berglund at gmail.com
Sun Nov 1 08:22:21 CET 2020


On Mon, 26 Oct 2020 13:00:26 +0100 (CET), Michael Van Canneyt via
lazarus <lazarus at lists.lazarus-ide.org> wrote:

>But I would create a routine
>
>Procedure HandleMainLoop;
>
>begin
>{$IFDEF NOGUI}
>   CheckSynchronize;
>{$ELSE}
>   Application.ProcessMessages;
>{$ENDIF}
>end;
>
>And call that both in GUI and NOGUI.

I decided to check how Lazaus implements Application.Processmessages.
It seems to start in the Forms unit and then redirects into
application.inc where I found this (on Windows):

{------------------------------------------------------------------------------
  TApplication ProcesssMessages  "Enter the messageloop and process
until empty"
------------------------------------------------------------------------------}
procedure TApplication.ProcessMessages;
begin
  if Self=nil then begin
    // when the programmer did a mistake, avoid getting strange errors
    raise Exception.Create('Application=nil');
  end;
  WidgetSet.AppProcessMessages;
  ProcessAsyncCallQueue;
end;

If I try to find how WidgetSet.AppProcessMessages; looks like then I
get to a dead end:

procedure AppProcessMessages; virtual; abstract; (no implementation)

And ProcessAsyncCallQueue seems to be doing the job with pretty
intricate code inside a CriticalSection shield.

QUESTION:
Is there a way in code to check if Forms is used?
So it can be used instead of {$IFDEF NOGUI}


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list