[lazarus] Get button state
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Dec 16 09:10:29 EST 2003
On Tue, 16 Dec 2003 14:47:35 +0000 Sebastian Kraft <sebastian_kraft at gmx.de>
wrote:
> Hi all,
>
> I have a window with 2 buttons. One Start and one Stop. When clicking on
> start the program begins to write some lines to the commandline. How can I
> find out when the button stop is pressed? Seems the event isn't handled
> when the Program is still hanging in the start-button event...
>
> Should look kind of that...
>
> procedure TTestwin.startClicked(Sender: TObject);
> begin
> repeat writeln('xxx') until "button stop pressed";
> end;
>
> But I've no idea who to build that in Pascal code...
>
> Can anyone help?
You have to give the LCL event queue some processing time.
procedure TTestwin.startClicked(Sender: TObject);
begin
ButtonStopPressed:=false;
repeat
writeln('xxx');
Application.ProcessMessages;
until ButtonStopPressed;
end;
procedure TTestwin.stopClicked(Sender: TObject);
begin
ButtonStopPressed:=true;
end;
OR:
Put your writeln in an Application.OnIdle event.
Mattias
More information about the Lazarus
mailing list