CJC Delphi 技巧馆's Archiver

cjc Posted at 2013-7-12 15:35

Styling only one VCL component in Delphi (XE4 only)

Styling only one VCL component in Delphi (XE4 only)

I know, that it's possible to disable custom styling for components, but how can I enable styles for only one component class? For example leave the whole form and all components on it unskinned, and skin only TButton. Like on this image.


Most of the VCL controls internally uses the StyleServices global function to get the methods to draw the control. So if you are not using the Vcl Styles, the StyleServices return an instance to the windows API functions to draw themed controls (UxTheme API's). because that there is not way to skin (apply the Vcl Styles) to only a single class control (at least which you draw the control yourself).

So the only alternative is apply a Vcl Styles and then disable for all the controls except the one type which you are looking for.

You can use something like this

procedure DisableVclStyles(Control : TControl;const ClassToIgnore:string);
  i : Integer;
  if Control=nil then

  if not Control.ClassNameIs(ClassToIgnore) then

  if Control is TWinControl then
    for i := 0 to TWinControl(Control).ControlCount-1 do
      DisableVclStyles(TWinControl(Control).Controls[i], ClassToIgnore);
Check this form with a Vcl Style

And now after of call the above method


Note : using the StyleElements property to enable o disable the vcl styles doesn't work with some component like (TStringGrid, TBitBtn, TSpeedButton and so on)

Note by cjc: XE4 now supports TBitBtn, TSpeedButton.

Page: [1]
CJC好玩背单词最新版本 - 是目前最好的背单词软件,游戏好玩,功能强大,词库众多,还有真人语音,免费下载,免费试用 !

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.