How to add a TFrame in code

I have created a frame in the IDE and using the Frame from the component palette can add it using the IDE, but I have not been able to add it using code.

In Delphi (VCL for X86) I can execute this

procedure TForm3.FormCreate(Sender: TObject);
begin
FFrame := TFrame1.Create(self);
FFrame.Top := 20;
FFrame.Left := 20;
FFrame.Parent := self;
end;

and a frame is placed on the form at the desired location. If I execute the same code in WEB Core, the frame does not appear.

Is there something else I need to do to have it appear ?

Here there is one extra call needed:

procedure TForm3.FormCreate(Sender: TObject);
begin
FFrame := TFrame1.Create(self);
FFrame.LoadFromForm;
FFrame.Top := 20;
FFrame.Left := 20;
FFrame.Parent := self;
end;
1 Like

Hi Bruno,

That did it. All working now thanks !

Regards,
Andrew

Possibly worth to mention "LoadFromForm" including your sample in TMSWEBCoreDevGuide.pdf, esp. since it's "invisible" for the LSP.

The "Frame" chapter only explains hwo to insert Frames at design time...

  1. We applied an improvement to make the LSP work with Frame.LoadFromForm
  2. We added the code example to the doc
1 Like