D
dazzling
Unregistered / Unconfirmed
GUEST, unregistred user!
//窗体单元
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
GroupBox1: TGroupBox;
a: TEdit;
b: TEdit;
c: TEdit;
d: TEdit;
e: TEdit;
f: TEdit;
GroupBox2: TGroupBox;
btStart: TButton;
btContinue: TButton;
btStop: TButton;
GroupBox3: TGroupBox;
st: TStaticText;
spOpen: TShape;
spClose: TShape;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
flush: TTimer;
procedure btStartClick(Sender: TObject);
procedure btStopClick(Sender: TObject);
procedure btContinueClick(Sender: TObject);
procedure stClick(Sender: TObject);
procedure flushTimer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit1;
{$R *.dfm}
procedure TForm1.btStartClick(Sender: TObject);
begin
Randomize;
//随机种子
a1:= strToInt(a.Text);
b1:= strToInt(b.Text);
c1:= strToInt(c.Text);
d1:= strToInt(d.Text);
e1:= strToInt(e.Text);
f1:= strToInt(f.Text);
myT:=TT.Create(false);
//建立线程(只有1个);false参数代表立即响应
btStart.Enabled:=false;
end;
procedure TForm1.btStopClick(Sender: TObject);
begin
myT.Suspend;
flush.Enabled:=true;
spClose.Brush.Color:=rgb(255,0,0);
end;
procedure TForm1.btContinueClick(Sender: TObject);
begin
myT.Resume;
spOpen.Brush.Color:=rgb(0,255,0);
spClose.Brush.Color:=rgb(100,0,0);
flush.Enabled:=false;
end;
procedure TForm1.stClick(Sender: TObject);
begin
st.Caption:='Current:'+intToStr(h);
showmessage('Current:'+intToStr(h));
end;
procedure TForm1.flushTimer(Sender: TObject);
begin
//闪烁
flush.Tag :=-flush.Tag ;
if flush.Tag =1 then
spOpen.Brush.Color:=rgb(0,255,0) else
spOpen.Brush.Color:=rgb(0,100,0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
flush.Enabled:=false;
spOpen.Brush.Color:=rgb(0,100,0);
spClose.Brush.Color:=rgb(255,0,0);
end;
end.
//线程窗体
unit Unit1;
interface
uses
Windows, SysUtils, Classes;
type
TT = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
end;
var myT:TT;
a,b,c,d,e,f,g,h:integer;
a1,b1,c1,d1,e1,f1:integer;
implementation
uses main;
procedure TT.Execute;
begin
form1.spOpen.Brush.Color:=rgb(0,255,0);
form1.spClose.Brush.Color:=rgb(100,0,0);
freeOnTerminate:=true;
while truedo
begin
a:=random(16)+1;
b:=random(16)+1;
c:=random(16)+1;
d:=random(16)+1;
e:=random(16)+1;
f:=random(16)+1;
g:=random(16)+1;
h:=random(16)+1;
if (a>a1) and (f<f1) and (b=b1) and (c=c1) and (d=d1) and (e=e1) then
begin
myT.Suspend;
form1.btStart.Enabled:=true;
form1.st.Caption:='Code:'+intToStr(h);
form1.spOpen.Brush.Color:=rgb(0,100,0);
form1.spClose.Brush.Color:=rgb(255,0,0);
end;
// form1.Label1.Caption:=inttostr(h);
end;
end;
end.
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
GroupBox1: TGroupBox;
a: TEdit;
b: TEdit;
c: TEdit;
d: TEdit;
e: TEdit;
f: TEdit;
GroupBox2: TGroupBox;
btStart: TButton;
btContinue: TButton;
btStop: TButton;
GroupBox3: TGroupBox;
st: TStaticText;
spOpen: TShape;
spClose: TShape;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
flush: TTimer;
procedure btStartClick(Sender: TObject);
procedure btStopClick(Sender: TObject);
procedure btContinueClick(Sender: TObject);
procedure stClick(Sender: TObject);
procedure flushTimer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit1;
{$R *.dfm}
procedure TForm1.btStartClick(Sender: TObject);
begin
Randomize;
//随机种子
a1:= strToInt(a.Text);
b1:= strToInt(b.Text);
c1:= strToInt(c.Text);
d1:= strToInt(d.Text);
e1:= strToInt(e.Text);
f1:= strToInt(f.Text);
myT:=TT.Create(false);
//建立线程(只有1个);false参数代表立即响应
btStart.Enabled:=false;
end;
procedure TForm1.btStopClick(Sender: TObject);
begin
myT.Suspend;
flush.Enabled:=true;
spClose.Brush.Color:=rgb(255,0,0);
end;
procedure TForm1.btContinueClick(Sender: TObject);
begin
myT.Resume;
spOpen.Brush.Color:=rgb(0,255,0);
spClose.Brush.Color:=rgb(100,0,0);
flush.Enabled:=false;
end;
procedure TForm1.stClick(Sender: TObject);
begin
st.Caption:='Current:'+intToStr(h);
showmessage('Current:'+intToStr(h));
end;
procedure TForm1.flushTimer(Sender: TObject);
begin
//闪烁
flush.Tag :=-flush.Tag ;
if flush.Tag =1 then
spOpen.Brush.Color:=rgb(0,255,0) else
spOpen.Brush.Color:=rgb(0,100,0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
flush.Enabled:=false;
spOpen.Brush.Color:=rgb(0,100,0);
spClose.Brush.Color:=rgb(255,0,0);
end;
end.
//线程窗体
unit Unit1;
interface
uses
Windows, SysUtils, Classes;
type
TT = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
end;
var myT:TT;
a,b,c,d,e,f,g,h:integer;
a1,b1,c1,d1,e1,f1:integer;
implementation
uses main;
procedure TT.Execute;
begin
form1.spOpen.Brush.Color:=rgb(0,255,0);
form1.spClose.Brush.Color:=rgb(100,0,0);
freeOnTerminate:=true;
while truedo
begin
a:=random(16)+1;
b:=random(16)+1;
c:=random(16)+1;
d:=random(16)+1;
e:=random(16)+1;
f:=random(16)+1;
g:=random(16)+1;
h:=random(16)+1;
if (a>a1) and (f<f1) and (b=b1) and (c=c1) and (d=d1) and (e=e1) then
begin
myT.Suspend;
form1.btStart.Enabled:=true;
form1.st.Caption:='Code:'+intToStr(h);
form1.spOpen.Brush.Color:=rgb(0,100,0);
form1.spClose.Brush.Color:=rgb(255,0,0);
end;
// form1.Label1.Caption:=inttostr(h);
end;
end;
end.