where : ibrtses delphi
Delphi - start/stop processing
disclaimer
Sometimes a longer processing should be stopped.
Have a TButton, name:=StartStopBtn, caption:='start';
Have a var Stop:boolean :=true;
procedure TForm1.StartStopBtnClick(..);
begin
if stop then begin //start processing
StartStopBtn.caption:='stop';
Stop:=false;
while not stop do begin // almost endless loop
// do your processing here
Eg :
image1.draw(processing_list.next);
..
..
Application.processmessages; // let the user stop the process
end; // while
StartStopBtn.caption:='start';
end //
else begin // stop the processing
StartStopBtn.caption:='start';
Stop:=true;
end;
end;
notes
Only a basic frame is shown, it can be extended :
- The endless loop is terminated when the processing is complete.
- The code can be changed that the stopped processing can be resumed.
- The caption of the button can show a loop counter
Feedback is welcome
sponsored links
Delphi
home
last updated: 7.april.99
Copyright (99,2000) Ing.Büro R.Tschaggelar