Why don't you use the tag property of the TButton;
 
Procedure From1.Create(Sender : TObject);
var
  C : integer;
begin
  for C := 1 to 20 do
  Knop[C] := TButton.Create;
  Knop[C].tag:= C;
  Knop[C].OnClick := @DoSomethingBright; 
end;


Procedure Form1.DoSomethingBright(Sender : TObject);

begin
  case (Sender as TButton).tag of
  1 : blabla;
  2 : different blabla;
  3 : more blabla;



  end;
end;

 
  ----- Original Message ----- 
  From:   Ger   Remmers 
  To: lazarus@miraclec.com 
  Sent: Monday, March 19, 2007 14:27
  Subject: [lazarus] Changing TObject
  

Hi all,

I would like to add a numeric property,   ObjectNumber, to TObject (for my 
internal use only).
This property needs to   be read/write and default to 0 (zero).
How/where do I go about doing   this?

example use 

Knop : array[1..20] of   TButton;

Procedure From1.Create(Sender : TObject);
var
  C :   integer;
begin
  for C := 1 to 20 do
  Knop[C] :=   TButton.Create;
  Knop[C].ObjectNumber := C;
  Knop[C].OnClick   := @DoSomethingBright; 
end;


Procedure   Form1.DoSomethingBright(Sender : TObject);

begin
  case   Sender.ObjectNumber of
  1 : blabla;
  2 : different   blabla;
  3 : more blabla;



    end;
end;

or is there another (more elegant) way of doing the same   thing without 
messing around with TObject;


-- 
Ger

 
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

Reply via email to