【问题标题】:How to apply a vcl style hook to a particular component of a form?如何将 vcl 样式挂钩应用于表单的特定组件?
【发布时间】:2012-08-22 18:58:37
【问题描述】:

我正在使用这个问题close button of a tabsheet not supporting vcl styles 的答案的 vcl 样式挂钩,并且工作正常,但关闭按钮被绘制在我的应用程序的所有 TPageControl 组件中。

我想将此选项(绘制关闭按钮)添加到仅特定表单。问题是:如何将这个钩子或任何 vcl 样式的钩子应用到特定表单的 TPageControl?

【问题讨论】:

    标签: delphi delphi-xe2 vcl-styles


    【解决方案1】:

    您可以为 TPageControl 组件使用插入器类

    检查此示例

    type
      TPageControl = class(Vcl.ComCtrls.TPageControl);
      TForm1 = class(TForm)
        PageControl1: TPageControl;
        ...
        ...
    

    然后在interposer类所在的同一个单元中注册vcl style hook

      TStyleManager.Engine.RegisterStyleHook(TPageControl, TTabControlStyleHookBtnClose);
    

    或者使用完全限定的类型名

      TStyleManager.Engine.RegisterStyleHook(Unit1.TPageControl, TTabControlStyleHookBtnClose);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-15
      • 1970-01-01
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 2019-10-18
      • 2012-01-29
      • 2019-09-12
      相关资源
      最近更新 更多