unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls,unit2;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
UpDown1: TUpDown;
UpDown2: TUpDown;
UpDown3: TUpDown;
Button1: TButton;
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
ball1,ball2,ball3:TSquareThread;{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.CheckBox1Click(Sender: TObject);
var x,y:integer;
begin
if(checkbox1.checked)=true then
begin
x:=160;
y:=checkbox1.top+checkbox1.height div 2;
ball1:=TSquareThread.Create(clred,x,y);
ball1.resume;
end
else
ball1.terminate;
end;
procedure TForm1.CheckBox2Click(Sender: TObject);
var x,y:integer;
begin
if(checkbox2.checked)=true then
begin
x:=160;
y:=checkbox2.top+checkbox2.height div 2;
//edit2.text:='4';
ball2:=TSquareThread.Create(clyellow,x,y);
ball2.resume;
end
else
ball2.terminate;
end;
procedure TForm1.CheckBox3Click(Sender: TObject);
var x,y:integer;
begin
if(checkbox3.checked)=true then
begin
x:=160;
y:=checkbox3.top+checkbox3.height div 2;
ball3:=TSquareThread.Create(clblue,x,y);
ball3.resume;
end
else
ball3.terminate;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if((Edit1.Text='2')and(ball1<>nil))then
ball1.priority:=tpLowest;
if((edit1.text='3')and (ball1<>nil))then
ball1.priority:=tplower;
if((edit1.text='4')and(ball1<>nil))then
ball1.Priority:=tpnormal;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
if((Edit1.Text='2')and(ball2<>nil))then
ball2.priority:=tpLowest;
if((edit1.text='3')and (ball2<>nil))then
ball2.priority:=tplower;
if((edit1.text='4')and(ball2<>nil))then
ball2.Priority:=tpnormal;
end;
procedure TForm1.Edit3Change(Sender: TObject);
begin
if((Edit1.Text='2')and(ball3<>nil))then
ball3.priority:=tpLowest;
if((edit1.text='3')and (ball3<>nil))then
ball1.priority:=tplower;
if((edit1.text='4')and(ball3<>nil))then
ball3.Priority:=tpnormal;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if(ball1<>nil)then
ball1.x2:=160;
if(ball2<>nil)then
ball2.x2:=160;
if(ball3<>nil)then
ball3.x2:=160;
end;
end.
是同一类型的线程实例