Einzelnen Beitrag anzeigen

nuclearping

Registriert seit: 7. Jun 2008
708 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

AW: Form (zur Laufzeit erstellt) richtig schliessen.

  Alt 30. Sep 2015, 14:02
Delphi-Quellcode:
function TFormNeu.Aufgabe : string;
begin
  Form := TForm.Create(Form1);
    with Form do
      begin
        BorderStyle := bsDialog;
        Width := 350;
        Height := 322;
        Left := Form1.Left + Form1.Width;
        Top := Form1.Top;
        Caption := FListeEingang.Strings[1];
        OnClose := FormClose;
        Show;
      end;

  GroupBoxArt := TGroupBox.Create(Form);
    with GroupBoxArt do
      begin
        Parent := Form;
        Caption := ' Wert-Wahl';
        Width := 342;
        Height := 59;
        Left := 1;
        Top := 4;
        Show;
      end;

  Radio1 := TRadioButton.Create(Form);
    with Radio1 do
      begin
        Parent := GroupBoxArt;
        Checked := True;
        Caption := 'Wert1';
        Left := 8;
        Top := 21;
        Show;
      end;

  Radio2 := TRadioButton.Create(Form);
    with Radio2 do
      begin
        Parent := GroupBoxArt;
        Checked := False;
        Caption := 'Wert2';
        Left := 8;
        Top := 37;
        Show;
      end;

  ButtonRadioWahl := TButton.Create(Form);
    with ButtonRadioWahl do
      begin
        Parent := GroupBoxArt;
        Caption := 'Wert aktivieren';
        Width := 100;
        Height := 18;
        Left := 94;
        Top := 37;
        OnClick := NeuerWert;
        Show;
      end;


  FormNeuLabel := TLabel.Create(Form);
    with FormNeuLabel do
      begin
        Width := Form.Width - 50;
        Height := 20;
        Left := 15;
        Top := 200;
        Caption := 'Label für sonstwas';
        Parent := Form;
      end;

  FormNeuEdit := TEdit.Create(Form);
    with FormNeuEdit do
      begin
        Width := Form.Width - 50;
        Height := 20;
        Left := 15;
        Top := 225;
        Text := FListeEingang.Strings[0];
        Parent := Form;
        //PasswordChar := '*';
      end;

  OkButton := TButton.Create(Form);
    with OKButton do
      begin
        Width := 80;
        Height := 25;
        Left := FormNeuEdit.Left;
        Top := FormNeuEdit.Top + FormNeuEdit.Height + 10;
        Caption := 'OK';
        Parent := Form;
        Default := True;
        OnClick := WertSenden;
      end;

  CancelButton := TButton.Create(Form);
    with CancelButton do
      begin
        Width := 80;
        Height := 25;
        Left := FormNeuEdit.Left + FormNeuEdit.Width - 80;
        Top := FormNeuEdit.Top + FormNeuEdit.Height + 10;
        Caption := 'EXIT';
        Parent := Form;
        OnClick := Exit;
        Cancel := True;
      end;
    try
      try
       FListeAusgang.Add(FormNeuEdit.Text); //Beim Erstellen der Form gebe ich paar Parameter zurück
      except
        on E:Exception do Result := 'Fehler: ' + E.Message;
      end;
    finally
      //...
    end;
end;
Sowas solltest du dir erst garnicht angewöhnen. Es ist nicht nur umständlich, sondern auch extrem wartungs- und erweiterungsunfreundlich.
  Mit Zitat antworten Zitat