Forum > LCL
[SOLVED] Strange behavior with double click in BitBtn
(1/1)
clauslack:
Strange behavior with double click in BitBtn.
I have a program for insert data with this cycle
Click a BitBtn->DoubleClick Dbgrid->Click a BitBtn->DoubleClick Dbgrid, etc, etc
But, some Newbie users, does a DoubleClick in BitBtn, and the BitBtn1Click procedure run twice
and show an Access Violation. For avoid that I do it that.
--- Code: ---procedure TForm1.FormCreate(Sender: TObject);
begin
BitBtn1.caption:='1';
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var nro:integer;
begin
BitBtn1.Enabled:=False;
nro:=StrToInt(BitBtn1.caption);
sleep(1000);
inc(nro);
BitBtn1.caption:=IntToStr(nro);
BitBtn1.Enabled:=True;
end;
--- End code ---
But with double click in BitBtn the procedure still does run twice.(nro=2)
How can I run the BitBtn1Click only one time, even when the user does a doble click in BitBtn?
Tested with Lazarus 0.9.29 svn 23817 fpc 2.5.1
Delphi 5 show the same behavior.
Any Idea?
Thanks
clauslack:
I used a simple flag for run once the code (work fine for the example above), but in the main programa still show A.V.
But I found the problem.
QueueAsyncCall
http://wiki.lazarus.freepascal.org/Asynchronous_Calls
Async call is only executed after the Button Click event has finished.
So now works fine.
Navigation
[0] Message Index