How to create Dynamic form in Delphi - Getting Resource TForm not found error

When we call the TForm.Create() constructor that loads the TForm contents from a DFM, but our project does not have a DFM for TForm, which is why we are getting the resource error. To skip that, we need to use the TForm.CreateNew() constructor instead.


procedure TForm1.Button1Click(Sender: TObject);
var
  a: TForm2;
begin
  a := TForm2.CreateNew(nil, 0);
  ...
end;

No comments:

Post a Comment

Pages