How to input onclick on (self)Created object ? lazarus / 9-Editor ---------------------------------------------------------------------- GoDxNero · 2009-10-30 12:17 I got this code from idog. Code: [Select]procedure TForm1.FormCreate(Sender: TObject); var x, y, Index : Integer; begin   for x := 1 to 5 do    for y := 1 to 5 do     begin       Index := (y - 1) * 5 + x;       MyCircle[Index] := TShape.Create(Self);       with MyCircle[Index] do        begin          Parent := Self;          Shape  := stCircle;          Tag    := 0; // This is the "activation counter"          Left   := (x - 1) * 60 + 10;          Width  := 50;          Top    := (y - 1) * 60 + 10;          Height := 50;          Brush.Color := clLime;        end;     end; end; procedure TForm1.Timer1Timer(Sender: TObject); var Current, j : Integer; begin   for j := 1 to 25 do    with MyCircle[j] do     if Tag > 0 then      begin        Inc(Tag);        if Tag = 2 then        Brush.Color := clRed;        if Tag = 3 then         begin           Tag := 0;           Brush.Color := clLime;         end;      end;   repeat Current := Random(25) + 1 until MyCircle[Current].Tag = 0;   with MyCircle[Current] do    begin      Tag := 1;      Brush.Color := clYellow;    end; end; My question : How can I implant onclick when the circle's are self created. ---------------------------------------------------------------------- Dibo · 2009-10-30 13:10 Like this? Code: [Select]private   procedure MyOnClick(Sender: TObject); ........... procedure TForm1.MyOnClick(Sender: TObject); begin   //Some code end; And then: Code: [Select]procedure TForm1.FormCreate(Sender: TObject); var x, y, Index : Integer; begin   for x := 1 to 5 do    for y := 1 to 5 do     begin       Index := (y - 1) * 5 + x;       MyCircle[Index] := TShape.Create(Self);       with MyCircle[Index] do        begin          OnClick := @MyOnClick // ********** <---- Connect new event here          Parent := Self;          Shape  := stCircle;          Tag    := 0; // This is the "activation counter"          Left   := (x - 1) * 60 + 10;          Width  := 50;          Top    := (y - 1) * 60 + 10;          Height := 50;          Brush.Color := clLime;        end;     end; end;