1

私は、TFrame を拡張して独自の公開プロパティを持つことについて、stackoverflow に関する多くの記事を読みました。

私は基本的にジョン・トーマスのアプローチに従いました

ここでコードを繰り返します:

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;

新しいフレーム コンポーネントがコンポーネント パレットに表示されます。新しいフレームをフォームに追加して動作します。

ただし、ファイル - >新規 - >その他 - > vclフレームによって作成されたように、新しいフレームをスタンドアロンユニットとして使用する必要があります

私はすべてのフレームを別々のユニットで作成し、必要に応じてフォームに挿入しています。

私の新しいMyFrameがそのように機能するために何をすべきですか?

4

0 に答える 0