我在timer的事件里这样写
var
xh:integer//定义一个全局变量
procedure TClient.Timer5Timer(Sender: TObject);
pdc:HDC;
i,j:integer;
begin
pdc:=GetDc(0);
for i:=400 to 450 do
for j:=300 to 350 do
begin
if Getpixel(pdc,i,j)=0 then
begin
timer5.enablid:=false;//终止当前这个记时器
timer6.enabled:=true;//跳转到另外一个记时器里
break;//退出整个for循环
end;
end;
xh:=xh+1;
if xh=1 then setcursorpos(30,30)
else if xh=2 then setcursorpos(40,40)
else if xh=3 then setcursorpos(50,50)
else if xh=4 then
begin
xh:=0
timer5.enablid:=false;
timer6.enablid:=true;
end;
end;
_________________________________
我要实现的是.
当timer5的记时器开启时.让for以及if同时循环.
当for里的Getpixel(pdc,i,j)=0为真时.直接timer5停止.然后跳转到我要做事的timer6里.如果for里的Getpixel(pdc,i,j)=0不真的话.当if的xh+到4的时候.也是停止timer5.在跳转到timer6里.
////
试了一个晚上
我在打开这个记时器的时候.整个系统就停顿了一下.我觉得是for的问题..要等3~5秒才会恢复正常.但是我用vb写的话.一切正常.大家帮小弟解决一下.(代码临时在这里写的.如果代码那里错了.莫见怪.我只是想知道是那里出问题.让系统会停顿.)