   delphi button.create
  why can''t i do, it gives an error btnButton : tButtonprocedure Tform1.create(....)begin  btnButton.create(form1);  <---------endthanx in advance 
  Is it this??btnButton := tButton.create(form1);still does not work, it doesn't display the button   [edited by - Pillejunior on February 16, 2004 6:28:06 AM];quote:Original post by Pillejunior  Is it this??btnButton := tButton.create(form1);still does not work, it doesn''t display the button   [edited by - Pillejunior on February 16, 2004 6:28:06 AM]That''s the right syntax.IIRC you should set the Parent property to actually display the button on your form. Not sure, it''s been a while since I used Delphi.btnButton.Parent := Form1; ;  now i want to do thisbtnButton."whenclickedon" := drukSender; <------procedure drukSender(sender : tObject)begin  statusbar.panel[0].text := sender.classname;endhow do i give the procedure the right sender which it can use in the procedure ;  You don''t have to.  You''re just interested in the event itself -- its parameters are generated somewhere else for you to use.  In this case, any time your event is called and you enter the procedure specified, the sender will be the TButton that caused the event.The reason is quite simple.  When writing events, you do the following:1) Declare an event "of object" -- this is just a basic procedure with whatever parameters you require2) Declare a variable of this type (e.g. "FOnWhatever: TNotifyEvent")3) Declare a property of the same type (e.g. "property Blah: TNotifyEvent read FOnWhatever write FOnWhatever").Now, the outside world sees the property and can freely assign it (what you''re seeing with OnClick).  As a result, you''ve got a pointer to whatever code you want - e.g. to your own procedure drukSender.  The class with this event, though, doesn''t have to care about who it''s pointing to.  It just does this:if Assigned(FOnWhatever) then  FOnWhatever(parameters...);In the case of a TNotifyEvent, the parameter there will be "self", pointing to the current object, for the sender.  This means that you''ll always end up with the current object except in the following two circumstances: someone''s written a component badly and doesn''t pass appropriate things (unusual); or someone manually calls your procedure "drukSender" as a normal procedure (not really recommended) -- in which case, the sender will be whatever the person (you, I''d assume) passed in, which might be nil or a button on the form.Internally, events are function pointers that can point whereever.  Get into the habit of just using them - it''s the component''s job to generate the parameter list, but you don''t care _how_.  Visit my Delphi site or I''ll bite you! | DGDev Delphi Community;  but my program gives an errorthe code in the procedure isif sender is tButton thenstatusbar.panel[0].text := (sender as tbutton).nameetc etcit says it is an inaccessible value the .name value ;  Nope, that code should work fine - I just tested something similar.  If we''re to solve this then more context is required. ;  I declare the button in varbtnButton : tButtonI create the button in form.createbtnButton := tButton.create(form1)then setboundsbtnButton.setbounds(400,100,50,40)then the binding to procedurebtnButton.onclik := drukSender;druksender is declared in public section under typeand looks like thisprocedure drukSender(sender: tObject)beginif sender is tButton thenstatusbar1.panels[0].text := (sender as tButton).nameend;  Nope, I just tried exactly that and it worked fine.  Email some code to akeys [at] icscotland [dot] net and I'll take a look at it.EDIT: well, I added a "form1." prefix to drukSender for its actual code "procedure TForm1.drukSender(Sender: TObject)...", obviously, but aside from that, it was identical...   [edited by - Alimonster on February 16, 2004 9:40:22 AM];  THE WHOLE CODE:unit uCreate;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, stdctrls, ComCtrls;type  TForm1 = class(TForm)    StatusBar1: TStatusBar;    procedure FormCreate(Sender: TObject);  private    { Private declarations }  public    { Public declarations }    procedure druksender(Sender: tObject);  end;var  Form1: TForm1;  btn : TButton;  edt : TEdit;  lbl :Tlabel;implementation{$R *.dfm}procedure TForm1.druksender(Sender: tObject);begin  statusbar1.Panels[0].Text := sender.ClassName;end;procedure TForm1.FormCreate(Sender: TObject);begin  btn := tButton.create(form1);  edt := tEdit.create(form1);  lbl := tLabel.create(form1);  btn.Parent := form1;  edt.parent := form1;  lbl.Parent := form1;  btn.SetBounds(100,50,100,40);  edt.SetBounds(100,100,50,40);  lbl.SetBounds(100,200,50,40);  lbl.caption := ''haloha'';  btn.whenclickedon := druksender;  edt.whenclickedon := druksender;  lbl.whenclickedon := druksender;end;end.