Einzelnen Beitrag anzeigen

Benutzerbild von Pseudemys Nelsoni
Pseudemys Nelsoni

Registriert seit: 24. Dez 2002
Ort: Hamburg-Harburg
3.551 Beiträge
 
#1

Memo per ButtonClick schliessen

  Alt 20. Jan 2004, 19:10
hoi

ich erstelle zur laufzeit 1 button, 1 memo, 1 tabsheet.



Delphi-Quellcode:
Type TFenster = Record
                  TabSheet: TTabSheet;
                  Memo: TMemo;
                  Button: TButton;
                end;

...

var
  dynArray: Array of TFenster;

...

procedure TForm1.ButtonClick(Button: TObject);
var
  nummer: string;
begin
  with Button as TButton do
  begin
    nummer := Name;
    delete(nummer, 1, 6); // 1-6 = 'Button'
    showmessage('Memo' + nummer);
    (FindComponent('Memo' + nummer) as TMemo).Free;
  end;
end;

...

procedure TForm1.ButtonlClick(Sender: TObject);
begin
  SetLength(dynArray, high(dynArray)+2);
  dynArray[high(dynArray)].TabSheet := TTabSheet.Create(self);
  with dynArray[high(dynArray)].TabSheet do
  begin
    Name := 'TabSheet' + IntToStr(high(dynArray)+1);
    Caption := 'hi';
    PageControl := PageControl1;
    Show;
  end;
  dynArray[high(dynArray)].Memo := TMemo.Create(self);
  with dynArray[high(dynArray)].Memo do
  begin
    Name := 'Memo' + IntToStr(high(dynArray)+1);
    Parent := dynArray[high(dynArray)].TabSheet;
    Left := 10;
    Top := 10;
    Height := dynArray[high(dynArray)].TabSheet.Height-20;
    Width := dynArray[high(dynArray)].TabSheet.Width-20;
    Show;
  end;
  dynArray[high(dynArray)].Button := TButton.Create(self);
  with dynArray[high(dynArray)].Button do
  begin
    Name := 'Button' + IntToStr(high(dynArray)+1);
    Parent := dynArray[high(dynArray)].TabSheet;
    Left := 50;
    Top := 50;
    Height := 21;
    Width := 70;
    Show;
    OnClick := ButtonClick;
  end;
end;


wies geht mein memo per Free nicht weg?
Mario
  Mit Zitat antworten Zitat