How to apply vcl style binding to a specific form component?

I use the vcl style hook of the answer to this question close button of a tabsheet not supporting vcl stylesand it works fine, but the close button is to draw in all components of TPageControl of my application.

enter image description here

And I want to add this option (draw a close button) only to a specific form. The question arises: how can I apply this hook or any vcl style hook only to a TPageControl of a certain shape?

+3
source share
1 answer

You can use an intermediate element class for the TPageControl component

check this sample

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

And then register the vcl style hook in the same block as the interpolator class

  TStyleManager.Engine.RegisterStyleHook(TPageControl, TTabControlStyleHookBtnClose);

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

Source: https://habr.com/ru/post/1542374/


All Articles