我在stackoverflow上阅读了很多关于扩展TFrame以获得自己的已发布属性的文章。
我基本上遵循了John Thomas
的方法在此处重复代码:
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;
新的框架组件显示在组件托盘上就好了。我可以将新框架添加到表单中并起作用。
但是我需要将我的新框架作为独立单元使用,例如由file-> new-> other-> vcl frame
创建我的所有框架都是以分开的单位创建的,然后在需要时插入到表单上。
我的新MyFrame应该做些什么呢?