Abort a Delphi For/While/Repeat Loop by Pressing a Key
var j : integer; begin for j:=0 to 9999999 do begin Label1.Caption := IntToStr(j) ; {.... loop main body here ...} Application.ProcessMessages; {ESC key stops the loop} if GetKeyState(VK_Escape) AND 128 = 128 thenbreak; end; end;
Delphi tips navigator:
» How to "HotTrack" any control
« Scrolling Memo text from code