unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure MyIdleHandler(Sender: TObject; var done: Boolean);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.MyIdleHandler(Sender: TObject; var done: Boolean);
begin
// do something here
// hier irgendwas tun
Self.Left := Random(Screen.Width - Self.Width);
Self.Top := Random(Screen.Height - Self.Height);
Edit1.Text := TimeToStr(now);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
dt, dtn: TDateTime;
begin
// simulate heavy calculatin with this button
// umfangreiche Berechnungen simulieren
dt := Now;
repeat
dtn := Now;
until dtn > (dt + 10 / 3600 / 24);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// assign the Handler to OnIdle of the Application
// den Handler dem OnIdle von Application zuweisen
Application.OnIdle := MyIdleHandler;
end;
end.