Работает поиск 1 раз.
Если раскомментировать "Timer2.Enabled:= True;" в конце, то ищет бесконечно..
Код:
procedure TForm5.Timer2Timer(Sender: TObject);
var
a, с: integer;
s: string;
begin
Timer2.Enabled:=False;
с:= 0;
if find.checked=true then
begin
k:= strtoint(edit1.Text);
for i:= 1 to m do
begin
label1.Caption:= inttostr(i);
lbl1[i].Color:= clYellow;
application.ProcessMessages;
Sleep(100);
if lbl1[i].height=k then
begin
lbl1[i].Color:= clGreen;
lbl2[i].Font.Color:= clGreen;
с:= с+1;
s:= inttostr(с);
application.ProcessMessages;
Sleep(100);
if (i=m) and (с>0) then
begin
ShowMessage(s);
Timer2.Enabled:=False;
end;
if (i=m) and (с=0) then
begin
ShowMessage('Закончено');
Timer2.Enabled:=False;
end;
end
else
lbl1[i].Color:= clRed;
application.ProcessMessages;
Sleep(100);
if (i=m) and (с>0) then
begin
ShowMessage('Закончено');
Timer2.Enabled:=False;
end;
if (i=m) and (с=0) then
begin
ShowMessage('Таких элементов не найдено');
Timer2.Enabled:=False;
end;
end;
end;
//Timer2.Enabled:=True;
end;