質問

TPanelのような振る舞いをするTCustomControlを作成する方法例えば、MyCustomComponent、私は同じラベル、画像などのコンポーネントを削除することができます。

役に立ちましたか?

解決

TCUSTOMPANELのこのコードは、

です。
constructor TCustomPanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ControlStyle := [csAcceptsControls {, ... } ];
//...
end;
.

csAcceptsControlsプロパティにControlStyleを持つことができる多くのVCLコントロールがあります。

あなたがあなた自身のコントロールでこれをしたいのであれば、そのようなVCLコントロールから降りない場合は、次のようにしてください。

  1. Create Constructor
  2. をオーバーライドする
  3. csAcceptsControlsプロパティ
  4. ControlStyleを追加

    このサンプルコードのように:

    //MMWIN:MEMBERSCOPY
    unit _MM_Copy_Buffer_;
    
    interface
    
    type
      TMyCustomControl = class(TSomeControl)
      public
        constructor Create(AOwner: TComponent); override;
      end;
    
    
    implementation
    
    { TMyCustomControl }
    
    constructor TMyCustomControl.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      ControlStyle := ControlStyle + [csAcceptsControls {, ...} ];
    //...
    end;
    
    
    end.
    
    .

    - jeroen

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top