How to disable VCL styles in Delphi

浪子不回头ぞ 提交于 2019-11-27 22:02:27
RRUZ

The VCL Styles apply a skin to all of the VCL application, but you can disable the VCL Styles for a particular control class. So if you want disable the VCL Styles for a particular form, you can use the RegisterStyleHook function passing the type of the form and the TStyleHook class which is a empty style hook class.

This line of code will disable the VCL Styles in all the forms of the type TFormChild:

TStyleManager.Engine.RegisterStyleHook(TFormChild, TStyleHook);

Now, if you run this code all controls of the form, TFormChild will still painted with the VCL Styles, so to fix that you must disable the default Style hook for all the controls of the form using a trick like this

unit uChild;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TButton   = class(Vcl.StdCtrls.TButton); //This declaration is only for disabling the TButton of this form
  TFormChild = class(TForm)
    Button1: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

and now you can disable the VCL Styles of the TButton of this form as well with this code

TStyleManager.Engine.RegisterStyleHook(uChild.TButton, TStyleHook);

If you want more information about the use of the TStyleHook Class, check the article Exploring Delphi XE2 – VCL Styles Part II.

Removing (uncheck) the seClient option from the StyleElements property of the Splash Form did the trick for me (Delphi XE10).

The easiest way is to put the splash-form in a seperate DLL. That way the styler won't touch it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!