Creating a custom TFrame descendant as component

1.5k views Asked by At

I read many articles on stackoverflow about extending TFrame to have its own published properties.

I have followed basically the aproach of John Thomas

Repeating the code here:

unit myUnit;

uses
 ...

type
  TmyComp = class(TFrame) //set your frame name to be the name your component 
    ToolBar1: TToolBar; //different components added in the form designer
    aliMain: TActionList;
    ...
  published //this section is added by hand
    property DataSource: TDataSource read FDataSource write SetDataSource; //some     published properties added just for exemplification
    property DefFields: string read FDefFields write SetDefFields;
    ...
  end;


procedure Register; //added by hand

implementation

{$R *.DFM}

procedure Register;
begin
  RegisterComponents('MyFrames', [TmyComp]); //register the frame in the desired component category
end;

The new frame component shows up on the component pallete just fine. I can add the new frame to a form and works.

However I need to work with my new frame as a standalone unit, like created by file->new->other->vcl frame

I have my frames all created like, in separated units, then inserted on a form when needed.

What should be done for my new MyFrame works like that?

0

There are 0 answers