ActiveX Color Settings

Many ActiveX controls use a special type named OLE_COLOR to represent colors. Methods and properties that accept a color specification of OLE_COLOR type expect that specification to be a number representing an RGB color value. An RGB color value specifies the relative intensity of red, green, and blue in a specific color to be displayed.

The intensities of red, green, and blue are each represented by a number between 0 and 255. These three numbers are combined to form a single OLE_COLOR.

OLE_COLOR is treated internally as a 32-bit integer. The least significant byte is the value representing the red component of the color. The second least significant byte represents the green component, and the third least significant byte represents the blue component.

The following table lists some standard colors and the red, green, and blue values they include:

Color Red Value Green Value Blue Value
Black 0 0 0
Blue 0 0 255
Green 0 255 0
Cyan 0 255 255
Red 255 0 0
Magenta    255 0 255
Yellow 255 255 0
White 255 255 255

To construct an OLE_COLOR from the red, green, and blue numbers, use the following formula:

OLE_COLOR = red + (green * 256) + (blue * 65536)

or using hexadecimal literals:

OLE_COLOR = red + (green * x#100) + (blue * x#10000)

As a convenience, eight standard colors have been defined in ACTIVEX.DEF.

*Standard OLE_COLOR Values:
78  OLE-BLACK               VALUE X#000000
78  OLE-BLUE                VALUE X#0000FF
78  OLE-GREEN               VALUE X#00FF00
78  OLE-CYAN                VALUE X#00FFFF
78  OLE-RED                 VALUE X#FF0000
78  OLE-MAGENTA             VALUE X#FF00FF
78  OLE-YELLOW              VALUE X#FFFF00
78  OLE-WHITE               VALUE X#FFFFFF