Fill class

The colour or gradient that paints a region — background of a control, body of a border, fill of a grid line, foreground of text. A Fill has two parts: a Pattern that picks the gradient direction (or tbPatternNone for transparent), and a ColorPoints collection of one or more colour stops that supply the actual colours.

A single solid colour is just a one-stop fill: call ColorPoints.SetSolidColor with a Long colour, or SetSimplePattern on the parent Fill for a two-colour gradient.

btnGo.NormalState.BackgroundFill.ColorPoints.SetSolidColor vbBlue
btnGo.HoverState.BackgroundFill.SetSimplePattern vbBlue, vbWhite, _
        Pattern:=tbGradientNorthToSouth

For three or more colour stops, build FillColorPoint instances and pass them to SetColorPoints. The stops accept fully-opaque ARGB literals (&HFF alpha in the high byte) — see ColorRGBA for the encoding:

With pnlHeader.BackgroundFill
    .Pattern = tbGradientNorthToSouth
    .ColorPoints.SetColorPoints _
        New FillColorPoint(&HFFF3E58F, 0), _
        New FillColorPoint(&HFF99CCFF, 50), _
        New FillColorPoint(&HFF014C99, 100)
End With

Properties

ColorPoints

The FillColorPoints collection holding the gradient stops. Always present and pre-allocated; assigning new stops is done by calling methods on this object rather than replacing the collection.

Pattern

How the colours in ColorPoints are mapped across the region. A member of FillPattern. Default: tbGradientNorthToSouth. Use tbPatternNone to make the Fill transparent.

Methods

SetSimplePattern

Replaces the colour stops with a two-stop gradient between two solid colours, optionally adjusting the Granularity and Pattern at the same time. The colours are given as ordinary Long values (the vb… colour constants or a hex literal); the opaque alpha mask is OR-ed in automatically.

Syntax: object.SetSimplePattern Value1RGB, Value2RGB [, Granularity [, Pattern ] ]

Value1RGB
required A Long RGB colour for the first gradient stop (position 0).
Value2RGB
required A Long RGB colour for the second gradient stop (position 100).
Granularity
optional The colour-table size assigned to Granularity. Default: 100.
Pattern
optional A member of FillPattern. Default: tbGradientNorthToSouth.

SetSimplePatternRGBA

Same as SetSimplePattern but accepts raw 32-bit ColorRGBA values with their own alpha channels rather than three-byte RGB colours.

Syntax: object.SetSimplePatternRGBA Value1RGBA, Value2RGBA [, Granularity [, Pattern ] ]

Value1RGBA
required A ColorRGBA (ABGR) value for the first gradient stop.
Value2RGBA
required A ColorRGBA (ABGR) value for the second gradient stop.
Granularity
optional The colour-table size assigned to Granularity. Default: 100.
Pattern
optional A member of FillPattern. Default: tbGradientNorthToSouth.

Events

OnChanged

Raised whenever Pattern is assigned or the ColorPoints collection raises its own OnChanged.

FillColorPoints class

The collection of FillColorPoint stops that drive a Fill’s colour gradient. Reached as Fill.ColorPoints. Internally an array of FillColorPoint plus a Granularity integer.

Granularity

The size of the generated colour table that interpolates the stops. Higher values give smoother gradients; a value of 2 produces a hard transition between just two colours regardless of how many stops the collection holds. Long. Default: 100.

Values

The array of FillColorPoint gradient stops. Read-write, but in practice you populate it through the SetSolidColor, SetSolidColorRGBA, SetColorPoints, or SetColorPointsArray methods rather than assigning the array directly.

SetSolidColor

Replaces the stop array with a single fully-opaque stop. Takes a three-byte Long colour and OR-s in the opaque alpha mask.

Syntax: object.SetSolidColor ValueRGB

ValueRGB
required A Long RGB colour.

SetSolidColorRGBA

Replaces the stop array with a single stop whose alpha is taken from the supplied value rather than forced opaque.

Syntax: object.SetSolidColorRGBA ValueRGBA

ValueRGBA
required A ColorRGBA (ABGR) value.

SetColorPoints

Replaces the stop array with the supplied FillColorPoint values, in order.

Syntax: object.SetColorPoints ColorPoint1 [, ColorPoint2, … ]

ColorPoint1, ColorPoint2, …
required One or more FillColorPoint objects, passed as Variants through a ParamArray.

SetColorPointsArray

Replaces the stop array with the contents of an existing array of FillColorPoint.

Syntax: object.SetColorPointsArray ColorPoints ( )

ColorPoints
required An array of FillColorPoint. Uninitialised or empty arrays leave the collection unchanged.

OnChanged

Raised when the array of stops is reassigned or when any single stop raises its own OnChanged, or when Granularity is assigned. The parent Fill listens for this event and re-raises its own.

FillColorPoint class

A single gradient stop — a colour together with the position (0–100 %) at which the colour applies along the gradient. Elements of the FillColorPoints.Values array.

Color

The stop’s colour as a 32-bit ABGR value. ColorRGBA.

PositionPercent

The stop’s position along the gradient, as a percentage from 0 to 100. Double. A two-stop gradient typically has stops at 0 and 100; intermediate stops at 25 / 50 / 75 produce smooth multi-colour transitions.

New

Constructs a FillColorPoint. The parameterless overload sets neither field; the two-argument overload sets both.

Syntax: New FillColorPoint [ ( ColorRGBA, PositionPercent ) ]

ColorRGBA
optional A ColorRGBA value to assign to Color.
PositionPercent
optional A Double to assign to PositionPercent.

OnChanged

Raised when either Color or PositionPercent is assigned. The parent FillColorPoints listens for this event.