[Lazarus] Application.Processmessages in console program?

Bo Berglund bo.berglund at gmail.com
Sat Apr 30 11:37:46 CEST 2016


I am moving some control functionality from a GUI program to a console
program in order to in the end being able to run it from cron.
In fact I have several candidates for this migration.

Now I have run across a problem regarding Application.Processmessages
which causes a compile error in the console applications. And I don't
really know if it is needed or not either, but this pops up inside
classes (non-visual) that I have used before and want to use now.
For example in this delay function:

procedure TSSRelayControl.Delay(T: LongWord);
var
  Tnow: LongWord;
begin
  Tnow := GetTickCount;
  while (GetTickCount - Tnow) < T do //Rolls over automatically
  begin
    //Application.ProcessMessages; <== Compile error!
    Sleep(1);
  end;
end;

I tried adding the CustApp unit into uses but it does not help.

In general, is there a need for Application.Processmessages only in a
GUI app and if so how can one handle this in classes that need to be
used in both GUI and non-GUI programs?


I also get a warning that I should use GetTickCount64 instead of
GetTickCount, but that seems strange since it would not fit into a
LongWord...


-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list