delphidelphi-xe3tform

get error with just a 'public' at delphi TForm class


TForm1 = class(TForm)
  Button1:TButton;
  Memo1:TMemo;
end;

that's normal code about delphi form.

TForm1 = class(TForm)
  public
    Button1:TButton;
    Memo1:TMemo;
end;

just add a public keyword.

get a runtime error.

i am very confused about this.


Solution

  • If you don't specify visibility then members are published which means they are public and get RTTI (Run Time Type Information) generated for them. The RTTI is needed for the form streaming to work. By making them public you are removing the RTTI so things will fail.