I have a window with 2 buttons. One Start and one Stop. When clicking on start the…
Sebastian Kraft wrote 17 lines
In the form class declaration, Introduce a boolean variable FStopped:
Private
FStopped : Boolean;The start button onclick handler works as follows:
procedure TTestwin.StartClicked(Sender: TObject);
begin
FStopped:=False;
repeat
writeln('xxx');
Application.ProcessMessages; // Process pending messages.
until FStopped;
end;The stop button onclick handler works as follows:
procedure TTestwin.StopClicked(Sender: TObject);
begin
FStopped:=True;
end;The most important part is the
Application.ProcessMessages;This makes sure that the click on the stop button is registered.
Michael.
