unit Tread;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type TAnzeigeTread=class(TThread)
Sender: TObject;
constructor create(CreateSuspended : boolean);
virtual;
protected
procedure execute;
override;
procedure Doetwas;
virtual;
abstract;
{ Public-Deklarationen }
end;
TForm1 =
class(TForm)
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Button2: TButton;
Button4: TButton;
Edit3: TEdit;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure etwas(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
public
{ Public-Deklarationen }
AnzeigeTread:TAnzeigetread;
end;
var
Form1: TForm1;
i:integer;
a:
string;
b:boolean;
implementation
uses Unit2;
{$R *.dfm}
constructor TAnzeigeTread.create(CreateSuspended : boolean);
begin
FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;
procedure TAnzeigeTread.Execute;
begin
i:=0;
while(
not Terminated)
do
begin
if form1.CheckBox1.Checked
then
form2.Button1Click(sender);
if b=true
then
form1.Edit1.Text:=a;
Form1.etwas(Sender);
sleep(50);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
b:=true;
AnzeigeTread:= TAnzeigeTread.create(true);
AnzeigeTread.Resume;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
AnzeigeTread.Suspend;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
AnzeigeTread.resume;
end;
procedure TForm1.etwas(Sender:TObject);
begin
i:=i+1;
a:=inttostr(i)+'
mda';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
b:=false;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
form2.show;
end;
end.