[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Graphics' (#lcl)

StringToColorDef

Converts the specified string representation for a color to a TColor value using a specified default value.

Declaration

Source position: graphics.pp line 1924

function StringToColorDef(

  const S: shortstring;

  const DefaultValue: TColor

):TColor;

Arguments

S

  

String with the color identifier or hexadecimal byte values converted in the routine.

DefaultValue

  

Default TColor value used when S is not a valid representation for a color.

Function result

TColor value for the specified string, or the default value when S does not contain a valid representation for a color.

Description

StringToColorDef is used to convert the string in S to its value as a TColor type. The S argument can contain a color identifier like 'clRed' or 'clForm', or a hexadecimal string with the bytes for the color in GBR byte order like '$00D7FF'. The DefaultValue argument contains the default value used when S is not a valid color string.

The return value contains the LongInt value for the color. When S is a valid color identifier, the corresponding color constant is returned; e.g. clRed or clForm. If S is not a color identifier, it is converted to an Integer value and cast to the TColor type for use as the return value. The default return value is specified in the DefaultValue argument.

See also

StringToColor

  

Converts the specified string representation for a color to a TColor value.

ColorToString

  

Gets a string representation for the specified TColor value.

IdentToColor

  

IdentToColor - given a color identifier (name) returns the color value.


Version 4.0 Generated 2025-05-03 Home