Board index » delphi » simulate a button being pushed with the Timer???

simulate a button being pushed with the Timer???

I need to have a button pushed if the user does not push it after a
set amount of ttimer value. I did this is VB before, but have not been
able to figure it out for Delphi. I'm sure it's no big deal right?

For example if the user does not push the button after one second,
then I want the timer to push it down and execute all the code in the
button1click event.

Hopefully someone has done this and can help me - thanks alot!!

You can catch me via private email if you wish..

holi...@ihs.com

thanks!!!!!!

 

Re:simulate a button being pushed with the Timer???


On Tue, 07 May 1996 06:24:47 GMT, holid...@ix.netcom.com (Steve

Quote
Holiday) wrote:
>I need to have a button pushed if the user does not push it after a
>set amount of ttimer value. I did this is VB before, but have not been
>able to figure it out for Delphi. I'm sure it's no big deal right?

>For example if the user does not push the button after one second,
>then I want the timer to push it down and execute all the code in the
>button1click event.

>Hopefully someone has done this and can help me - thanks alot!!

>You can catch me via private email if you wish..

>holi...@ihs.com

>thanks!!!!!!

All you need to do is this:

        Button1.OnClick;

That will call the method OnClick as if the user had clicked on the
button.  If you want the Phyical appearence of the button being
"Pushed" then you might want to consider the SpeedButton since it has
an Up/Down property.  One Note:  I'm not sure what will happen if you
did not override the Virtual Method of OnClick (meaning, if there is
no code in the OnClick event handler).  It might GPF so you may want
to check to make sure a method has been assigned.  (Look in the
Component Writer's Guide, because I don't remember how to do it off
the top of my head... its something like:

if Assigned(Button1.OnClick) then

Brien King
bk...@primenet.com

Re:simulate a button being pushed with the Timer???


Quote
Steve Holiday wrote:

> I need to have a button pushed if the user does not push it after a
> set amount of ttimer value. I did this is VB before, but have not been
> able to figure it out for Delphi. I'm sure it's no big deal right?

> For example if the user does not push the button after one second,
> then I want the timer to push it down and execute all the code in the
> button1click event.

> Hopefully someone has done this and can help me - thanks alot!!

> You can catch me via private email if you wish..

> holi...@ihs.com

> thanks!!!!!!

Hello!

There is a TButton method you can use. Try calling

        Button1.Click;

Have a nice day!

        Bostjan Virant

Re:simulate a button being pushed with the Timer???


Use a SpeedButton. Give the button a unique (for that form) GroupIndex,
and set its AllowAllUp to False. The user may now push the button down,
but not get it up again. When the task is finished, the program will set
AllowAllUp:=True; Down:=False; AllowAllUp:=False again, and your'e back
where you started and the user may push the button down again.

Use a TTimer and set Interval and Enabled to False. Set Enabled:=True
when you want to start the timing. If the button is pushed within time,
set Timer1.Enabled:=False in the buttons OnClick, if not then disable
the timer in its own OnTimer event instead, and also simulate the
pushing of the button. How to do this I'm not sure, but try
SpeedButton1.Down:=True. If that doesn't trigger its OnClick, call the
OnClick method yourself.

--
Bent Tranberg, Agder College, Grimstad
Grooseveien 36, 4890 Grimstad, Norway
e-mail: Bent.Tranb...@hia.no

Re:simulate a button being pushed with the Timer???


On Tue, 07 May 1996 06:24:47 GMT, holid...@ix.netcom.com (Steve

Quote
Holiday) wrote:
>I need to have a button pushed if the user does not push it after a
>set amount of ttimer value. I did this is VB before, but have not been
>able to figure it out for Delphi. I'm sure it's no big deal right?

   btnMyButton.Click;

The above line always works when I need to fake a button press.

Regards
   Glen

Re:simulate a button being pushed with the Timer???


Quote
Abraxus wrote:

> On Tue, 07 May 1996 06:24:47 GMT, holid...@ix.netcom.com (Steve
> Holiday) wrote:

> >I need to have a button pushed if the user does not push it after a
> >set amount of ttimer value. I did this is VB before, but have not been
> >able to figure it out for Delphi. I'm sure it's no big deal right?

>    btnMyButton.Click;

> The above line always works when I need to fake a button press.

> Regards
>    Glen

Yes, that should work.  But what if you want the button to visibly
depress ?  Do you have to go into Windows API calls ?
Rgds, Iain
--
:-| :-) :-| :-( :-| :-) :-| :-( :-| :-) :-| :-( :-| :-) :-| :-( :-| :-)
Iain Duncumb,  Computer Studies,  Loughborough University,  LE11 3TU, UK
Tel: 01509 228235    Fax: 01509 610815    EMail: I.P.Dunc...@lboro.ac.uk

Re:simulate a button being pushed with the Timer???


Quote
Abraxus wrote:

> On Tue, 07 May 1996 06:24:47 GMT, holid...@ix.netcom.com (Steve
> Holiday) wrote:

> >I need to have a button pushed if the user does not push it after a
> >set amount of ttimer value. I did this is VB before, but have not been
> >able to figure it out for Delphi. I'm sure it's no big deal right?

>    btnMyButton.Click;

> The above line always works when I need to fake a button press.

> Regards
>    Glen--

Hi
Lett the timer call the buttons
"OnClick" event

Best wishes
Rune

--
Rune Olofsson     ,__@      Q
Micro Bit        _`\<,_    <\
Uppsala Sweden  (_)/ (_)  / >
Clipper->Delphi->Pinarello Treviso -85/Campa. Chorus

Other Threads