unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, thread2;
type
TForm1 =
class(TForm)
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
TrackBar3: TTrackBar;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
PaintBox3: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Th1: TLineThread;
Th2: TRectThread;
Th3: TCircThread;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Th1 := TLineThread.Create(PaintBox1, tpNormal);
Th2 := TRectThread.Create(PaintBox2, tpNormal);
Th3 := TCircThread.Create(PaintBox3, tpNormal);
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
var
tH: TThread;
begin
if Sender
is TTrackBar
then
with TTrackBar(Sender)
do begin
case Tag
of
1: Th := Th1;
2: Th := Th2;
3: Th := Th3;
end;
case Position
of
1: Th.Priority := tpIdle;
2: Th.Priority := tpLowest;
3: Th.Priority := tpLower;
4: Th.Priority := tpNormal;
5: Th.Priority := tpHigher;
6: Th.Priority := tpHighest;
7: Th.Priority := tpTimeCritical;
end;
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
var
Th: TThread;
begin
if Sender
is TCheckBox
then
with TCheckBox(Sender)
do begin
case Tag
of
1: Th := Th1;
2: Th := Th2;
3: Th := Th3;
end;
if Th.Suspended
then Th.Resume
else Th.Suspend;
end;
end;
end.