The Scope of Visual Styles

There are two ways of setting a visual style: using the VisualStyle property or the VisualStyleOfParent property:

By default, the VisualStyle of components is set to *NULL and their VisualStyleOfParent is set to True. This means that the components use whatever style has been assigned to their parent component. Typically the parent component is the form.

In most circumstances it is best that you do not change this default. This is because if you assign a visual style to your form and keep the VisualStyleOfParent of all the other components set to True, you can change the style of all the components on the form simply by changing one value (the value of the form's VisualStyle property).

As an example, you might want to change the font size of the text the whole application. Let's say your form is using visual style VS_Norm which specifies an 8-point font:

The easiest way to change the font size to 12 points for all the components on this form would be to assign the visual style VS_Large as the VisualStyle property of the form. Provided that you had kept the VisualStyleOfParent set to True in the other components, they would automatically inherit this style:

Of course there are cases when you want to change the visual style of an individual component such as for a label, for example. In these cases you set the VisualStyleOfParent to False.

Styles can be set at design time or when the program is running. To change a visual style at run-time you specify:

SET COM(#MY_LABEL) VisualStyle('#VS_WARN')