unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, unit2;
type
TMyTest =
class
private
State: integer;
end;
TForm1 =
class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
O: TTest;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(O.Test));
TMyTest(O).State:= 1;
ShowMessage(IntToStr(O.Test));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
O:= TTest.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
O.Free;
end;
end.