Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
Delphi 11 Alexandria
|
AW: Form-Event global für alle Formulare überschreiben?
20. Apr 2018, 12:53
So sollte das gehen.....
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;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{Private-Deklarationen}
FmyForm2 : Tcustomform;
public
{Public-Deklarationen}
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
(*
Forminstance muss var sein !!!!!
*)
procedure CreateAndShowForm( const AFormClass: TFormClass; var AFormInstance: TCustomForm);
begin
if not Assigned(AFormInstance) then
AFormInstance := AFormClass.Create(Application);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateAndShowForm(TForm2, FmyForm2);
FmyForm2.Show;
end;
end.
Fritz Westermann
|
|
Zitat
|