Nur dummerweise erscheint es erst, nach dem die 3s verstrichen sind. Auch wird das Form1 nich für 3s grün, es wird dann direkt blau.
Wie kann ich es erzwingen, das das "Bitte warten "- Form vorher erscheint ?
Geht dies überhaupt ?
Ich habe es mit Update, Invalidate, ProcessMessage probiert, aber ohne Erfolg.
Code: Alles auswählen
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
// "Bitte warten" Form
type
TMyForm = class(TForm)
constructor CreateNew(TheOwner: TComponent);
end;
constructor TMyForm.CreateNew(TheOwner: TComponent);
var
p: TPanel;
begin
inherited CreateNew(TheOwner);
p := TPanel.Create(Self);
p.Caption:='Bitte warten...';
p.Parent := Self;
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
f: TMyForm;
begin
f := TMyForm.CreateNew(self);
f.Update; // Bringt alles nichts
f.Invalidate;
Application.ProcessMessages;
f.Show;
Color := clGreen;
sleep(3000); // Mache etwas
Color := clBlue;
// f.free;
end;
end.