还不如这样: var t:dword; msg:tmsg; begin t:=gettickcount; while getmessage(msg,0,0,0) do begin translatemessage(msg); dispatchmessage(msg); if gettickcount-t>=5000 then begin close; exit; end; end; exitprocess(0); end;
定义一个全局变量i:integer; 在form的oncreat 事件中加入初始化 i:=0; 在ontimer中加入 Timer1.Interval:=1000; i:=i+1; if i=1 then form2.show; if i=6 then begin form2.close timer1.enabled:=false; end;
begin
Timer1.Interval:=5000;
Timer1.Enabled:=true;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
close;
end;
你在timer的事件里写。if count>5 Then
self.close
else count:=inc(count);
application.processmessages;
sleep(5000);
form2.close;
呵呵
sleep(5000);
close;
var
t:dword;
msg:tmsg;
begin
t:=gettickcount;
while getmessage(msg,0,0,0) do
begin
translatemessage(msg);
dispatchmessage(msg);
if gettickcount-t>=5000 then
begin
close;
exit;
end;
end;
exitprocess(0);
end;
在form的oncreat 事件中加入初始化
i:=0;
在ontimer中加入
Timer1.Interval:=1000;
i:=i+1;
if i=1 then form2.show;
if i=6 then
begin
form2.close
timer1.enabled:=false;
end;