Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#8

Re: Eigene Kompo / Dynamisch erstellt / Form best. erkennen

  Alt 18. Feb 2007, 14:28
Delphi-Quellcode:
TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
   //...
  private
    { Private-Deklarationen }
  public
    DynMyKompo: Array[0..2] of TMyKompo;
    procedure MyOnClick(Sender: TObject);
  end;

//...

var
  Selected: TMyKompo;

//...

procedure TForm1.MyOnClick(Sender: TObject);
begin
  Selected := TMyKompo(Sender);
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:= 0 to 2 do
  begin
    DynMyKompo[i] := TMyKompo.Create(Self);
    DynMyKompo[i].Parent := Self;
    DynMyKompo[i].OnClick := MyOnClick;
    DynMyKompo[i].x := i*100;
   end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Selected.Caption := Edit1.Text;
end;
Verstanden ? *g*

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat