AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Form aus zweiter Unit erstellen.

Ein Thema von Zodi · begonnen am 24. Jul 2021 · letzter Beitrag vom 26. Jul 2021
 
Benutzerbild von Zodi
Zodi

Registriert seit: 18. Jul 2017
Ort: Berlin
45 Beiträge
 
Delphi XE7 Ultimate
 
#1

Form aus zweiter Unit erstellen.

  Alt 24. Jul 2021, 17:14
Hi Delphianer ich habe eine form mit einem Knopf der beim Drücken eine neue Form erstellen soll.

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private-Deklarationen }

  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 CreateNewForm('Hallo');
end;

end.
Unit 2 zum erzeugen der 2. Form

Delphi-Quellcode:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

function CreateNewForm(Message: String) : string;

var
  Form2: TForm2;

implementation

procedure Tform2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form2.Free;
end;


function CreateNewForm(Message: String) : string;

begin

  Form2 := TForm2.Create(application);
  Form2.Show;
  Form2.OnClose := Form2.FormClose; // assign onclick handler
result := '';
end;

end.
irgendwie funktioniert das nicht weis wer was ich falsch mache?


grüsse Zodi
Pascal
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz