[Lazarus] animated splash screen for lengthy operation, works with windows, doesn't with linux

Luca Olivetti luca at wetron.es
Mon Mar 27 09:46:01 CEST 2023


Hello,

I'd like to show a splash screen with an animation during a lengthy 
operation.
I cannot rely on a timer to show the animation since the message loop 
isn't running, so I'm using a thread to directly paint over the form, i.e.:


WaitForm.Show;
Application.ProcessMessages;

...

procedure TWaitForm.FormShow(Sender: TObject);
begin
   FUpdateThread:=TUpdateThread.Create(self);
end;

...

procedure TUpdateThread.Execute;
begin
   while not Terminated do
   begin
     FWaitForm.ShowProgress;
     Sleep(30);
   end;
end;

...

procedure TWaitForm.ShowProgress;
begin
   PaintBox1.Canvas.Clear;
   //WaitAnimation is an image list
   WaitAnimation.Draw(PaintBox1.Canvas,0,0,FImageIndex);
   FImageIndex:=FImageIndex+1;
   if FImageIndex>=WaitAnimation.Count then
     FImageIndex:=0;
end;


This works wonderfully under windows (which is my intended target, so no 
problem here), but under Linux it doesn't work (tested with gtk2, gtk3 
and qt5). In fact, even the "Show; Application.ProcessMessages" is 
erratic, sometimes it shows the form, sometimes it doesn't.

Lazarus 2.2.6/fpc 3.2.2

Any idea?

Bye
-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007


More information about the lazarus mailing list