You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Static and dynamic color values.

SRP understands the importance of a consistent interface, and color plays a large role in achieving an interface that appears to belong in its environment. SRP designed Color properties to easily establish a variety of color related effects using a single property value.

Static Color Value

A color property accepts static color values in three ways: as a single integer value, as RGB components, or as HSL components. The integer value can be calculated using the following formula:

IntegerVal = (B * 65536) + (G * 256) + R


To set the color to RGB components, use the format:

RGB(R,G,B)


The RGB keyword tells the property to treat the input as RGB components. If you omit the RGB keyword and use only the braces, then RGB is assumed. However, the braces cannot be omitted, since the input will then be treated as a single integer value. The advantage to the RGB component format is that the property calculates the color for you.

To set the color to HSL components, use the format:

HSL(H,S,L)


HSL is similar to RGB in that is calculate a color, but HSL components have different meaning. The H component is Hue, which is any of 255 base colors. There is generally no way to interpret what color this component might represent, but you can use MS Paint's Color Palette window to determine the value of a hue you're interested in. Why use HSL then? Because you may want to garauntee that any color be of a certain darkness or grayness. This is where the other two components come in. The S component is Saturation, or the purity of the color. When saturation is 255, then the hue is at it's purest, while a saturation level of 0 is pure gray. Any value in between is a blend of the hue with a corresponding amount of gray. The final component, L, is Luminance. A value of 255 for luminance results in pure white, while a value of 0 results in pure black. Any value in between results in a brighter or darker version of the color.

To complete the explaination of static colors, here are four ways of setting the Color property to bright blue:

Color = 16711680                ;* Single Integer 
Color = 255 * 65536             ;* Expression Evaluation into a Single Integer 
Color = "RGB(0, 0, 255)"        ;* RGB Components 
Color = "HSL(160, 255, 127)"    ;* HSL Components

Regardless of how a static color is set, the color is always returned in RGB(R,G,B) format.

System Color

Sometimes you may want your OLE control to blend in with the end user's current desktop theme colors. Therefore, Color properties accept system color names, so even if the end user changes his/her desktop theme colors, the OLE control will dynamically change to match. Acceptable system color names and their abbreviations are:

NameAbbr.Description
3DFace3DFace color for 3D display elements.
3DLight3DLLight color for 3D display elements (for edges facing the light source).
3DHilight3DHHighlight color for 3D display elements (for edges facing the light source).
3DShadow3DSShadow color for 3D display elements (for edges facing away from the light source).
3DDkShadow3DDKDark shadow color for 3D display elements (for edges facing away from the light source).
3DText3DTText color for 3D display elements.
ActiveTitleATActive window's title bar.
ActiveTitle1AT1Same as ActiveTitle.
ActiveTitle2AT2Right side color in the color gradient of an active window's title bar. Same as ActiveTitle if no gradient theme is set.
ActiveTitleTextATTActive window's title bar text.
ActiveWindowBorderAWBActive window's border.
AppBackgroundABKBackground color of multiple document interface (MDI) applications.
DesktopDTDesktop background color.
GrayTextGTGrayed (disabled) text.
HotItemHOTColor for a hot-tracked item.
InactiveTitleITInactive window's title bar.
InactiveTitle1IT1Same as InactiveTitle.
InactiveTitle2IT2Right side color in the color gradient of an inactive window's title bar. Same as "InactiveTitle" if no gradient theme is set.
InactiveTitleTextITTInactive window's title bar text.
InactiveWindowBorderIWBInactive window's border.
MenuMMenu background.
MenuTextMTText in menus.
ScrollBarSBScroll bar gray area.
SelectSItem(s) selected in a control.
SelectTextSTText of item(s) selected in a control.
ToolTipTTBackground color for tool tip controls.
ToolTipTextTTTText color for tool tip controls.
WindowWWindow background.
WindowFrameWFWindow frame.
WindowTextWTText in windows.

Color properties are not case-sensitive, so these names are accepted regardless of their case.

Office Colors

In addition to specifying standard system colors by name, you can also specify MS Office theme colors. These colors are used within Office XP and Office 2003.

NameAbbr.Description
Office3DFaceO3DXP face color for three- dimensional display elements and for dialog box backgrounds.
Office3DShadowO3DSXP shadow color for three-dimensional display elements (for edges facing away from the light source).
OfficeCheckedTextOCTXP color for text displayed in a checked button.
OfficeDisabledODXP menu icon disabled color.
OfficeEditBorderOEBXP color for the border color of edit controls.
OfficeFrameOFOffice 2003 frame color.
OfficeGrayTextOGTXP menu item disabled text color.
OfficeIconShadowOISXP menu item icon shadow.
OfficeLabelOLXP label control color.
OfficeMenuOMXP menu item text background color.
OfficeMenuBorderOMBXP menu border color.
OfficeMenuExpandedOMEXP hidden menu commands background color.
OfficeMenuTextOMTXP menu item text color.
OfficePushedTextOPTXP toolbar pushed text color.
OfficeSelectOSXP menu item selected color.
OfficeSelectBorderOSBXP menu item selected border color.
OfficeSelectCheckedOSCXP menu item checked color.
OfficeSelectCheckedBorderOSCBXP menu item checked border color.
OfficeSelectPushedOSPXP menu item pushed color.
OfficeSelectPushedBorderOSPBXP border color for pushed in 3D elements.
OfficeSelectTextOSTXP menu item selected text color.
OfficeSeparatorOSEPXP toolbar separator color.
OfficeSplitterOSPLXP splitter face color.
OfficeStaticFrameOSFWinXP Static frame color
OfficeTabInactiveOTIXP inactive tab background color.
OfficeTabInactiveTextOTITXP inactive tab text color.
OfficeToolbarOTBXP toolbar background color.
OfficeToolbarGripperOTBGXP toolbar gripper color.
OfficeToolbarTextOTBTXP toolbar text color.

HTML Colors

As an added convenience, you may specify any standard HTML color name. The currently available colors are listed below:

 

 

 

Color NameColor
AliceBlue

 

AntiqueWhite

 

Aqua

 

Aquamarine

 

Azure

 

Beige

 

Bisque

 

Black

 

BlanchedAlmond

 

Blue

 

BlueViolet

 

Brown

 

BurlyWood

 

CadetBlue

 

Chartreuse

 

Chocolate

 

Coral

 

CornflowerBlue

 

Cornsilk

 

Crimson

 

Cyan

 

DarkBlue

 

DarkCyan

 

DarkGoldenRod

 

DarkGray

 

DarkGrey

 

DarkGreen

 

DarkKhaki

 

DarkMagenta

 

DarkOliveGreen

 

DarkOrange

 

DarkOrchid

 

DarkRed

 

DarkSalmon

 

DarkSeaGreen

 

DarkSlateBlue

 

DarkSlateGray

 

DarkSlateGrey

 

DarkTurquoise

 

DarkViolet

 

DeepPink

 

DeepSkyBlue

 

DimGray

 

DimGrey

 

DodgerBlue

 

FireBrick

 

FloralWhite

 

ForestGreen

 

Fuchsia

 

Gainsboro

 

GhostWhite

 

Gold

 

GoldenRod

 

Gray

 

Grey

 

Green

 

GreenYellow

 

HoneyDew

 

HotPink

 

IndianRed

 

Indigo

 

Ivory

 

Khaki

 

Lavender

 

LavenderBlush


LawnGreen

 

LemonChiffon

 

LightBlue

 

LightCoral

 

LightCyan

 

LightGoldenRodYellow

 

LightGray

 

LightGrey

 

LightGreen

 

LightPink

 

LightSalmon

 

LightSeaGreen

 

LightSkyBlue

 

LightSlateGray

 

LightSlateGrey

 

LightSteelBlue

 

LightYellow

 

Lime

 

LimeGreen

 

Linen

 

Magenta

 

Maroon

 

MediumAquaMarine

 

MediumBlue

 

MediumOrchid

 

MediumPurple

 

MediumSeaGreen

 

MediumSlateBlue

 

MediumSpringGreen

 

MediumTurquoise

 

MediumVioletRed

 

MidnightBlue

 

MintCream

 

MistyRose

 

Moccasin

 

NavajoWhite

 

Navy

 

OldLace

 

Olive

 

OliveDrab

 

Orange

 

OrangeRed

 

Orchid

 

PaleGoldenRod

 

PaleGreen

 

PaleTurquoise

 

PaleVioletRed

 

PapayaWhip

 

PeachPuff

 

Peru

 

Pink

 

Plum

 

PowderBlue

 

Purple

 

Red

 

RosyBrown

 

RoyalBlue

 

SaddleBrown

 

Salmon

 

SandyBrown

 

SeaGreen

 

SeaShell

 

Sienna

 

Silver

 

SkyBlue

 

SlateBlue

 

SlateGray

 

SlateGrey

 

Snow

 

SpringGreen

 

SteelBlue

 

Tan

 

Teal

 

Thistle

 

Tomato

 

Turquoise

 

Wheat

 

White

 

Yellow

 

WhiteSmoke

 

YellowGreen

 

Color Modifiers

System and HTML colors are great for basic look and feel, but you may want to only use these predefined colors as a base while still having the flexibility to achieve the look and feel you desire without sacrificing conformity to these colors. For instance, you may want to use the system highlight color for selected cells in the SRP OLE EditTable, but you may also want it to always be light enough to display black text in front of it. Color modifiers provide the means to achieve this and other effects. The color modifier format is:

ColorName Modifier=Value


ColorName is one of the system or HTML color names listed above. Modifier is one of the available single-character modifiers listed below. Value is a number indicating the modifier's new value to be applied to the system color. The available modifiers are:

ModifierValueDescription
L0 - 100Luminance modifier. Luminance is a measurement of light applied to the color. 0 is darkest (black) and 100 is lightest (white).
S0 - 100Saturation modifier. Saturation is a measurement of purity applied to the color. 0 is pure grey and 100 is the pure color.
Cn/aCompliment modifier. Modifies the predefined color to be its complimentary color. Always applied first.
Gn/aGrayscale modifier. Modifies the predefined color to be grayscale. This is more accurate than setting S=0. Always applied last.

Here is a side-by-side comparison of a single system color modified using the available modifiers:

Here are the same values as above but with the grayscale modifier applied.

Any modifier that can be set to a value, such as the Luminance modifier, can be set to a relative value as well. Do this by using the += or the -= operators. The += operator increases the attribute while the -= decreases it. Let's use Luminance as an example:

For convenience, color modifiers can also be applied to Static colors as well.

Auto Values

Color properties can also receive three other string values: "Auto", "None", and "Transparent". The "Auto" value sets the color property to its default value, which is decided by the OLE control. The "None" value is accepted by some Color properties to specify no color. The results of these values depend on the OLE control's implementation.

The "Transparent" value is similar to "None" in that it represents no color, however, while "None" will be interpreted by some controls as don't-draw-anything, "Transparent" will be interpreted as draw something invisible. For example, when using swatches in the Tree control, "None" means no swatch whereas "Transparent" means an invisible swatch. This is useful for making sure tree items still line up but leaving empty spaces for items with no swatch.

Additionally, The Color Fill technology can accept "Transparent" as one of the colors in a gradient, thus allowing you to fade a color into nothing for some interesting effects.

In all cases unrecognized or Null values are treated as "Auto" values.

See Also

Formatted StringColor Fill

 

  • No labels