郁闷了, 大家帮我看看这段代码那里有问题啊? unit scan;interfaceuses
……type…… public
{ Public declarations }
MyEvent:THandle;
end;
TMyThread = class(TTHread)
protected
procedure Execute();override;
end;
var
Form1: TForm1;
auto_start:Integer;
i:Integer;
implementation{$R *.dfm}……
procedure TForm1.pingClick(Sender: TObject);
const
outtime=2000;
var
……
begin
……
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
icount:Integer;
begin
icount:=StrToInt(Edit3.Text); if (ping_num<icount) or (icount=0) then
begin
if ping_state=0 then
begin
StatusBar1.Panels[0].Text:='正在检测...';
ping_num:=ping_num+1;
ProgressBar1.Position:=ping_num;
ping.Click;
end;
end
else
begin
Timer1.Enabled:=False;
ProgressBar1.Position:=0;
StatusBar1.Panels[0].Text:='状态:';
SetEvent(MyEvent);
end;
end;
procedure TMyThread.Execute;
begin
Form1.ADOQuery1.Open;
Form1.ADOQuery1.First;
Form1.Timer1.Interval:=1
while not form1.ADOQuery1.Eof do
begin
Form1.Edit1.Text:='';
for i:=0 to Form1.ADOQuery1.FieldCount-1 do
begin
Form1.Edit1.Text:=Form1.Edit1.Text+ ' ->'+form1.ADOQuery1.Fields[i].AsString;
end;
if windows.WaitForSingleObject(Form1.MyEvent,INFINITE) <> WAIT_FAILED then
ShowMessage('ok');
Form1.ADOQuery1.next;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
mytest:TMyThread;
begin
Form1.Update;
ProgressBar1.Position:=0;
ProgressBar1.Max:=StrToInt(Edit3.Text);
try
MyEvent:=Windows.CreateEvent(nil,False,False,nil);
finally
mytest:=TMyThread.Create(False);
end;……
end;
……type…… public
{ Public declarations }
MyEvent:THandle;
end;
TMyThread = class(TTHread)
protected
procedure Execute();override;
end;
var
Form1: TForm1;
auto_start:Integer;
i:Integer;
implementation{$R *.dfm}……
procedure TForm1.pingClick(Sender: TObject);
const
outtime=2000;
var
……
begin
……
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
icount:Integer;
begin
icount:=StrToInt(Edit3.Text); if (ping_num<icount) or (icount=0) then
begin
if ping_state=0 then
begin
StatusBar1.Panels[0].Text:='正在检测...';
ping_num:=ping_num+1;
ProgressBar1.Position:=ping_num;
ping.Click;
end;
end
else
begin
Timer1.Enabled:=False;
ProgressBar1.Position:=0;
StatusBar1.Panels[0].Text:='状态:';
SetEvent(MyEvent);
end;
end;
procedure TMyThread.Execute;
begin
Form1.ADOQuery1.Open;
Form1.ADOQuery1.First;
Form1.Timer1.Interval:=1
while not form1.ADOQuery1.Eof do
begin
Form1.Edit1.Text:='';
for i:=0 to Form1.ADOQuery1.FieldCount-1 do
begin
Form1.Edit1.Text:=Form1.Edit1.Text+ ' ->'+form1.ADOQuery1.Fields[i].AsString;
end;
if windows.WaitForSingleObject(Form1.MyEvent,INFINITE) <> WAIT_FAILED then
ShowMessage('ok');
Form1.ADOQuery1.next;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
mytest:TMyThread;
begin
Form1.Update;
ProgressBar1.Position:=0;
ProgressBar1.Max:=StrToInt(Edit3.Text);
try
MyEvent:=Windows.CreateEvent(nil,False,False,nil);
finally
mytest:=TMyThread.Create(False);
end;……
end;
解决方案 »
- fastreport 打印文本文件 十万火急
- delphi 键盘上的@,#,$,%之类的键盘值是多少
- FTP文件备份功能开发
- 请问怎样在数据表中求某一字段的和?
- 如何在COM中返回数据集?在线等~~~~~~~
- 聘delphi+sql开发(兼职)
- 请问ADO访问access数据库时,对于AutoIncrement字段如何在insert a record后取得该值?
- 哪位朋友有Delphi5的函数手册,若是CHM版则更好,谢谢。
- 如果我做的部件要用到dll,该怎么注册该组件?
- 动态库以及第三方控件的问题,请高手帮忙!!
- 求助!!关于字符排列!
- 【难题】delphi能开发出SSH功能的客户端软件吗?
public
{ Public declarations }
MyEvent : THandle;
end;
TMyThread = class(TTHread)
protected
procedure Execute();Override;
end;
var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
self.Memo1.Lines.Add('Test');
self.Timer1.Enabled := False;
setEvent(MyEvent);end;
procedure TMyThread.Execute();
var
I : Integer;
begin
for I := 0 to 1000 do
begin
if I > 10 then Exit;
Form1.Timer1.Enabled;
//sleep(0);
Application.ProcessMessages;
if windows.WaitForSingleObject(Form1.MyEvent,INFINITE) <> WAIT_FAILED then end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
MyTest : TMyThread;
begin
MyTest := TMyThread.Create(False);end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MyEvent := windows.CreateEvent(nil,False,False,nil);
end;end.
你让它怎么继续做下去呢?
var
I : Integer;
begin
for I := 0 to 1000 do
begin
if I > 10 then Exit;
Form1.Timer1.Enabled;
//sleep(0);
Application.ProcessMessages;
if windows.WaitForSingleObject(Form1.MyEvent,INFINITE) <> WAIT_FAILED then end; 楼主试试把这东西放个你想放的地方吧
Application.ProcessMessages; 这个在线程做啥?