Einzelnen Beitrag anzeigen

delphicoder123

Registriert seit: 14. Feb 2019
102 Beiträge
 
#11

AW: VCL Formular in ein Panel einbetten

  Alt 11. Jun 2019, 22:23
Hallo,

alt
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1 := TForm1.Create(Panel1);
neu
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Form2 := TForm2.Create(Panel1);

Ich müsste noch mindestens einen Fehler haben. Zwar wird jetzt, dass Formular angezeigt aber das Form2 ist immer noch nicht im Panel von Form1. Gerne können auch andere antworten, wenn man die Antwort weiß.
Hier nochmal der aktuelle Code.

Code:
unit parent;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, child;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form2 := TForm2.Create(Panel1);
  with Form2 do
    Parent := Panel1;
    Width := 500;
    Height := 500;
    Top := 10;
    Left := 10;
    Show;
end;

end.
Code:
unit child;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    btnCalc: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    procedure btnCalcClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.btnCalcClick(Sender: TObject);
begin
edit3.Text:=edit1.Text+edit2.Text;
end;

end.
  Mit Zitat antworten Zitat