//-----------------------方式一
procedure Tfomr1.Excute_Form();
begin
with Tfomr1.Create(Application) do
begin
try
Init;
ShowModal;
finally
Free;
end;
end
end;
//-------------------------------方式二
unit UMydany;
interface
uses
System.SysUtils, Vcl.Dialogs;
type
TMydany = class
class function THIS: TMydany;
private
public
constructor Create();
destructor Destroy(); override;
procedure f1();
end;
implementation
var
_Mydany: TMydany;
constructor TMydany.Create;
begin
//
end;
destructor TMydany.Destroy;
begin
inherited;
end;
procedure TMydany.f1;
begin
showmessage('11');
end;
class function TMydany.THIS: TMydany;
begin
Result := _Mydany;
end;
initialization
begin
_Mydany := TMydany.Create();
end;
finalization
begin
if Assigned(_Mydany) then
FreeAndNil(_Mydany);
end;
end.