unit4.pas
来自「一个交通红绿灯线程」· PAS 代码 · 共 66 行
PAS
66 行
unit Unit4;
interface
uses
Classes, SysUtils, Graphics, Dialogs;
type
Tstop = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
implementation
uses main, Unit1, Unit2;
{ Tstop }
procedure Tstop.Execute;
var
fl, ff: boolean;
begin
fl := false;
ff := false;
while not terminated do
begin
{卡车停车限制}
if Form1.shape1.Brush.Color = clRed then
if ((Form1.Image3.Top >= 110) and (Form1.Image3.Top <= 180)) then
begin
thread.Free;
thread := Tthread1.Create(true);
fl := true;
end;
if (Form1.shape1.Brush.Color = clLime) and (fl = true) then
begin
thread.Resume;
fl := false;
end;
{小车停车限制}
if Form1.Shape2.Brush.Color = clRed then
if ((Form1.image2.Left > 307) and (Form1.image2.Left <= 355)) then
begin
thread2.Free;
thread2 := Tthread2.Create(true);
ff := true;
end;
if (Form1.Shape2.Brush.Color = clLime) and (ff = true) then
begin
thread2.Resume;
ff := false;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?