VCL Styles Overview

From RAD Studio
Jump to: navigation, search

Go Up to Working with VCL Styles


What Is a Style

You can change the appearance of a VCL application by using a style. A style is:

  • A set of graphical details that define the look and feel of a VCL application.
  • Similar to a theme in Windows.

A style permits you to change the appearance of every part and state of a control. VCL controls are made up of parts and states. A VCL style consists of a set of values for each of these parts and states. For instance, a scroll bar has the following parts: frame, slider, and the two side buttons for each direction. The side buttons, for example, have the following states: pressed, disabled, hot, normal.

To set a style for your VCL application, select the style in Project > Options > Application > Appearance. See Application Appearance for more details.

Note: The VCL style changes the appearance of the application in run-time. However, the Form Designer does not show these changes.

Location of Style Files (.vsf Files):

  • The VCL styles that ship with the product are available in:
    C:\Users\Public\Documents\Embarcadero\Studio\23.0\Styles.
  • You can get new VCL styles that are available in the VCL premium style pack.
  • In addition, you can redistribute any of the styles (VCL or FireMonkey) with your applications. The redistributable style files are located in your product installation directory at:
    \Redist\styles.

Bitmap Style Designer

You can create your own styles or modify the existing ones by using the Bitmap Style Designer, available in the Tools menu. For more details, see Creating a Style using the Bitmap Style Designer.

The Bitmap Style Designer also supports conversion of a VCL style to a FireMonkey style, and provides test applications to test VCL styles, FireMonkey styles, and FireMonkey Metro Styles.

Managing a Style

You can use the Vcl.Themes.StyleServices function to programmatically access information about the current style. Using StyleServices you can obtain information about the styled controls and elements and can perform drawing of controls. See Vcl.Themes.TCustomStyleServices for a better understanding of the Vcl.Themes.StyleServices interface.

Use the Vcl.Themes.TStyleEngine class to register style hook classes for your custom VCL components. A style hook is a class that you must implement to provide custom message handling for your custom control. If you have a custom control that needs special visual processing, create a style hook class that processes messages by inheriting from Vcl.Themes.TStyleHook.

Use the Vcl.Themes.TStyleManager class to load, register, and select styles or to get, register, and unregister a style engine.

Per-control Styling

With the VCL styling capabilities, you can use multiple VCL styles in different forms within a single application, or even use different visual controls that are on the same form.

You can also use third-party un-styled controls within a styled VCL application. For example, you can easily define a different style for each button on your form.

You Must Define Control Ownership

In styled VCL applications, it is especially important that all controls are created with a valid owner, such as the form where they belong, so that the VCL can identify them as part of the styled application and apply the configured style to them accordingly.

Limitations

The use of VCL styles has some limitations. This section lists these limitations:

  • The VCL styles are not painted when using the autosuggest option of a TComboBoxEx control. In this case, the autosuggest drop-down list is always painted with the Windows theme, even when a VCL style is active. However, the VCL style is painted correctly when using the normal drop-down list.
  • Windows provides a scroll when using popup menus that are bigger than the screen height. However, when you use VCL styles the scroll is not provided. To solve this problem you can use the TMenuItem.Break property to create a menu with columns.

Topics

See Also