다음을 통해 공유


SysColorCtrl.GetDerivedHex method

The GetDerivedHex method derives a color based on a starting color, a color to move toward, and a percentage to move toward that color. It is returned as a hexadecimal value.

Syntax

SysColorCtrl.GetDerivedHex( _
  ByVal pszFrom, _
  ByVal pszTo, _
  ByVal pszFormat, _
  ByVal nPercent _
)

Parameters

pszFrom [in]

A string that contains the color you want to use as the starting color. The contents of the string depend on the format specified in the pszFormat parameter.

pszTo [in]

A string that contains the color to move toward.

pszFormat [in]

A string that contains the name of the format that is being passed in the pszFrom and pszTo parameters.

CSS

Name of the display element whose color you want to specify. See System Color Values for Color Derivation Methods.

HEX

Hexadecimal form of the color. For example, specify FFFFFF for white.

RGB

RGB form of the color. For example, specify 16777215 for white.

nPercent

An integer that represents the percentage (0 to 100) between the pszFrom and pszTo colors. This value represents what percentage of the pszTo color should be blended with the pszFrom color. For example, a value of 0 would return the pszFrom color, a value of 50 would return a color that was halfway between pszFrom and pszTo, and a value of 100 would return the pszTo color. This value must be between 0 and 100.

Return value

A string that contains the hexadecimal value for the derived color specified by the method's parameters.

Examples

The following HTML page embeds the SysColorCtrl control as an object and uses the GetDerivedHex method to set the background color of the page to color that is 50% between the system color settings for activecaption and activeborder.

<html>
<head>
<object 
    ID="SysColorX"
    classid="clsid:C47195EC-CD7A-11D1-8EA3-00C04F9900D7"
    width=0
    height=0>
</object>
 
<script language=javascript>
function init() {
    color1 = "activecaption";
    color2 = "activeborder";
    pcnt = 50;
    document.body.bgColor=SysColorX.GetDerivedHex(color1, color2,'CSS',pcnt);
}
</script>
</head>
<body onload="init()">
</body>
</html>

Requirements

Redistributable
MMC 1.1 or later
DLL
Cic.dll