Solved

Speedbutton autorepeat

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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