开发者

Delphi, Override Custom controls setCaption

开发者 https://www.devze.com 2022-12-19 23:49 出处:网络
i have a custom control, with the Ancestor being another custom control, who\'s Ancestor is a TPanel;

i have a custom control, with the Ancestor being another custom control, who's Ancestor is a TPanel; i.e.

开发者_开发百科TNotMyCustomControl = class(Tpanel);

TMyCustomControl    = class(TNotMyCustomControl);

Is i possible to react when the Caption is being set (run time or design time), and still have the changed passed to the Ancestor controls?


It is possible. Just add a CMTextChanged message handler to your custom TPanel:

type
  TMyPanel = class(TPanel)
  private
    procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
  end;

{ ... }

procedure TMyPanel.CMTextChanged(var Message: TMessage);
begin
  inherited;
  ShowMessage('caption has been changed');
end;
0

精彩评论

暂无评论...
验证码 换一张
取 消