?? main.pas
字號:
{******************************************************************************}
{紅綠燈}
{02162323}
{ 龍濤 }
{******************************************************************************}
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Unit1, Unit2, Unit3, Unit4, jpeg;
type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
Shape1: TShape;
Shape2: TShape;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag: boolean;
thread: Tthread1;
thread2: Tthread2;
thread3, thread4: Tthread3;
BUSStop: Tstop;
implementation
{$R *.dfm}
{卡車與小車 線程}
procedure TForm1.Button1Click(Sender: TObject);
begin
thread := Tthread1.Create(true);
thread2 := Tthread2.Create(true);
BUSStop := Tstop.Create(true);
thread.Resume;
thread2.Resume;
BUSStop.Resume;
Button1.Caption:='汽車行使中...';
Button1.Enabled:=false;
end;
{交通燈}
procedure TForm1.FormCreate(Sender: TObject);
begin
flag := true;
thread3 := Tthread3.Create(false, shape1, true);
thread4 := Tthread3.Create(false, shape2, false);
BUSStop := Tstop.Create(true);
end;
{釋放所有線程}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
thread.Terminate;
thread2.Terminate;
thread3.Terminate;
thread4.Terminate;
busstop.Terminate;
thread.FreeOnTerminate:=true;
thread2.FreeOnTerminate:=true;
thread3.FreeOnTerminate:=true;
thread4.FreeOnTerminate:=true;
busstop.FreeOnTerminate:=true;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -