Board index » delphi » HELP : Calling a button Click

HELP : Calling a button Click

Hi all,

I have a little problem. Maybe you can help.

at a specified time in my Delphi Program I want to simulate a button
click. i.e. I have a timer that activates every minute, it must then
do the same thing as a click on button 1.

procedure TMain.Timer..
begin

TMain.Button1Click (Tmain)              <--- this does not work.

end.

Geert.

 

Re:HELP : Calling a button Click


Quote
Geert Nijs <Geert.N...@fys.kuleuven.ac.be> wrote:
>Hi all,

>I have a little problem. Maybe you can help.

>at a specified time in my Delphi Program I want to simulate a button
>click. i.e. I have a timer that activates every minute, it must then
>do the same thing as a click on button 1.

>procedure TMain.Timer..
>begin

>TMain.Button1Click (Tmain)          <--- this does not work.

>end.

>Geert.

Try:

   TMain.Button1Click(Sender);

It should do the job...

        Alan

--
Alan GARNY                              http://www.physiol.ox.ac.uk/~gry
University Laboratory of Physiology       Job Phone: +44 (0)1865 272-501
Parks Road                                 Job  Fax: +44 (0)1865 272-554
Oxford, OX1-3PT, UK                      Home Phone: +44 (0)1865 370-240

Re:HELP : Calling a button Click


Quote
Geert Nijs <Geert.N...@fys.kuleuven.ac.be> wrote:
>Hi all,

>I have a little problem. Maybe you can help.

>at a specified time in my Delphi Program I want to simulate a button
>click. i.e. I have a timer that activates every minute, it must then
>do the same thing as a click on button 1.

>procedure TMain.Timer..
>begin

>TMain.Button1Click (Tmain)          <--- this does not work.

>end.

>Geert.

Try:

   TMain.Button1Click(Sender);

It should do the job...

        Alan

--
Alan GARNY                              http://www.physiol.ox.ac.uk/~gry
University Laboratory of Physiology       Job Phone: +44 (0)1865 272-501
Parks Road                                 Job  Fax: +44 (0)1865 272-554
Oxford, OX1-3PT, UK                      Home Phone: +44 (0)1865 370-240

Re:HELP : Calling a button Click


Quote
Geert Nijs <Geert.N...@fys.kuleuven.ac.be> wrote:
>Hi all,

>I have a little problem. Maybe you can help.

>at a specified time in my Delphi Program I want to simulate a button
>click. i.e. I have a timer that activates every minute, it must then
>do the same thing as a click on button 1.

>procedure TMain.Timer..
>begin

>TMain.Button1Click (Tmain)          <--- this does not work.

>end.

>Geert.

Try:

   TMain.Button1Click(Sender);

It should do the job...

        Alan

--
Alan GARNY                              http://www.physiol.ox.ac.uk/~gry
University Laboratory of Physiology       Job Phone: +44 (0)1865 272-501
Parks Road                                 Job  Fax: +44 (0)1865 272-554
Oxford, OX1-3PT, UK                      Home Phone: +44 (0)1865 370-240

Re:HELP : Calling a button Click


Hi!

Try out this:

Button1Click(Button1);

or

TMain.Button1Click(Button1);

Geir Bratlie
ro...@sn.no

On 12. juli 1996, Geert Nijs wrote...

Quote
> Hi all,

> I have a little problem. Maybe you can help.

> at a specified time in my Delphi Program I want to simulate a button
> click. i.e. I have a timer that activates every minute, it must then
> do the same thing as a click on button 1.

> procedure TMain.Timer..
> begin

> TMain.Button1Click (Tmain)         <--- this does not work.

> end.

> Geert.

Re:HELP : Calling a button Click


On Wed, 17 Jul 1996 16:33:03 GMT, TOMG...@PIPELINE.COM (Thomas Paul)
wrote:

Quote
>>On 12. juli 1996, Geert Nijs wrote...
>>> Hi all,

>>> I have a little problem. Maybe you can help.

>>> at a specified time in my Delphi Program I want to simulate a button
>>> click. i.e. I have a timer that activates every minute, it must then
>>> do the same thing as a click on button 1.

>>> procedure TMain.Timer..
>>> begin

>>> TMain.Button1Click (Tmain)         <--- this does not work.

>>> end.
>How about
>     Button1.Click;
>------------------------------------------------------------
>Death in the defense of liberty is no tragedy.
>--- Daniel William Cloud (killed defending the Alamo, 1836)
>------------------------------------------------------------

* Note this is a reply to Geert Nijs and not  really to Thomas
however, since I did not see the original message, I'm responding to
Thomas's.

The reason it does not work is because they were referencing the Type
"TMain" and not the actual object of "Main".

        Main.Button1.Click;

will work as well as what Thomas said.

Brien King
bk...@primenet.com

Re:HELP : Calling a button Click


Quote
>On 12. juli 1996, Geert Nijs wrote...
>> Hi all,

>> I have a little problem. Maybe you can help.

>> at a specified time in my Delphi Program I want to simulate a button
>> click. i.e. I have a timer that activates every minute, it must then
>> do the same thing as a click on button 1.

>> procedure TMain.Timer..
>> begin

>> TMain.Button1Click (Tmain)             <--- this does not work.

>> end.

How about
         Button1.Click;
------------------------------------------------------------
Death in the defense of liberty is no tragedy.
--- Daniel William Cloud (killed defending the Alamo, 1836)
------------------------------------------------------------

Re:HELP : Calling a button Click


Quote
In article <31ed6c84.3139450@news>, bk...@primenet.com (Brien King) wrote:
>>>> at a specified time in my Delphi Program I want to simulate a button
>>>> click. i.e. I have a timer that activates every minute, it must then
>>>> do the same thing as a click on button 1.

>>>> procedure TMain.Timer..
>>>> begin

>>>> TMain.Button1Click (Tmain)             <--- this does not work.

>>>> end.
>>How about
>>         Button1.Click;

[Snip Snip Snip]

Quote
>* Note this is a reply to Geert Nijs and not  really to Thomas
>however, since I did not see the original message, I'm responding to
>Thomas's.

>The reason it does not work is because they were referencing the Type
>"TMain" and not the actual object of "Main".

>    Main.Button1.Click;

>will work as well as what Thomas said.

Actualy since the original code is in a method in the TMain clas, you could
just do

       Button1Click(Self);

You can't call the OnClick eventmethos of a TButton without a Sender
parameter, but since we (as mentioned) are in the TMain clas, Self is in
scope and will work perfectly, and because of the same fact, we can
eliminate the Main at the start of the line. Neat, eh?  :-)

--
CUL8R dude!                       \|/
                                  @ @
Jens  +-----------------------oOO-(_)-OOo-----------------------+
      | Internet   jb...@image.dk     CompuServe    100437,2475 |
      | FidoNet         2:235/142     VirNet          9:451/238 |
      | OS2Net          81:445/49     Fax     +45 - 3537 - 7006 |
      +---------------------------------------------------------+

Other Threads