Hi All,

    Another way to do much the same thing is to use
the TButton's tag property (all components have this
property). Say, for example, you have 4 TButton's:
TButton1 to 4. Set the Tag property to a different
number for each, e.g. Button1.Tag := 1, Button2.Tag :=
2 ... etc. I normally do this at design time with the
Object Inspector.

    Then you can do something like this for all the
buttons (e.g. set all of TButton's OnClick event to
the same procedure):

procedure TForm1.AllButtonsClick(Sender: TObject);
begin
  case (Sender as TButton).Tag of 
    1 : { do something with button1 };
    2 : { do something with button2 };
    3 : { do something with button3 };
    4 : { do something with button4 };
    // etc
  end; // case
end;

   Note: Tag is just an integer. It does not have a
specific purpose but is there in case the user wants
it for anything.

Regards,
      Peter W. :-)))
Sandy Bay, Hobart, Tas, AU.


--- In [email protected], David Smith
<[EMAIL PROTECTED]> wrote:
> Execute the event as you would any other routine. If
you double click on a button1 control and type in some
code, you've created an event. To execute that event,
call it programmatically like this:
>  
> Buttonclick1(nil);
>  
>   nil represents Sender which is the button that was
clicked. If you wanted to centrallize this code to a
bunch of different buttons, you could refer to Sender
in the button click code like this:
>  
> If Sender = Button1 Then
> begin
>    some code
> end
> else If Sender = button2 then
> begin
>    some different code
> end;
>  
> sometimes that can be very useful.
>  
> Dave
> 
> Vic Fraenckel <[EMAIL PROTECTED]> wrote:
> I want to fire a button on-click event in software.
How do I do this?
> 
> Any enlightenment will be appreciated.
> 
> TIA
> 
> Vic


                
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com


-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to