Solved

Speedbutton autorepeat

Posted on 2000-02-22
5
690 Views
Last Modified: 2008-03-17
Hi all,

I need a SpeedButton whith ability to execute OnClick event procedure repetitively while in Down position.
I've tried with Timer checking if SpeedButton.Down property is True, but it doesn't work.
I suppose there is some smart way to do it using standart component TSpeedButton, but don't know it.

Jo.
0
Comment
Question by:Fatman121898
5 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 50 total points
ID: 2546741
Try this:

procedure TForm1.SpeedButton1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //Start the timer
  Timer1.Enabled := TRUE;
end;

procedure TForm1.SpeedButton1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  //End the timer
  Timer1.Enabled := FALSE;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  //Do what we need to do
  Label1.Caption := IntToStr(iCount);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  iCount := iCount + 1;
  //Force a 'click'
  SpeedButton1Click(Self);
end;

This works fine for me. The code runs, and increments (and displays) iCount, putting the results into Label1.

Did you have the interval on your TTimer set correctly? In my code it's set to 100

The Neil
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2546777
FatMan,

Don't you've the FREE RX-Lib? This is a library every developer needs :-). Why? It's free and with source... Thus you can learn a lot form it.... AutoRepeat SpeedButtons are also included...

www.rxlib.com

Zif.
0
 
LVL 1

Author Comment

by:Fatman121898
ID: 2546942
The Neil got the points.
That was what I needed.

Zif, I know aboout RX, thanks.

Jo.
0
 
LVL 17

Expert Comment

by:geobul
ID: 2546962
Hi Fatman,

Set AllowAllUp to true and GroupIndex to 1. Then the timer will work.

Regards, Geo
0
 
LVL 1

Author Comment

by:Fatman121898
ID: 2547028
Hi Geo,
She imam da cherpya pri Samito :-)
Ama utre.
Jo.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 154
Using idhttp to login to instagram 2 106
Dev Express grid collapse 2 45
Wincontrol not (correctly) drawn 15 40
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question