Re: passing Delphi controls as objects
Posted by WAllison on January 08, 2003 at 19:57:24:
In Reply to: passing controls as objects posted by Vaishnavi on January 07, 2003 at 07:04:45:
: How do i pass controls for example edit, labels as objects to procedures??
I hope this helps, but your post was a bit cryptic
type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private procedure TestProc(Sender: TObject); public end;
procedure TForm1.TestProc(Sender: TEdit); begin If Sender is TEdit Then ShowMessage(TEdit(Sender).Text); //or If Sender is TEdit then ShowMessage((Sender as TEdit).Text); //Theres probably loads of ways to do this. end;
procedure TForm1.Button1Click(Sender: TObject); begin TestProc(Edit1); end;