Solved

Speedbutton autorepeat

Posted on 2000-02-22
5
677 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now