SET RGB COLORS

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004 (Modified)


SET RGB COLORS ({*; }object; foregroundColor; backgroundColor{; altBackgrndColor})

ParameterTypeDescription
*If specified, Object is an Object Name (String)
If omitted, Object is a Field or a Variable
objectForm ObjectObject Name (if * is specified), or
Field or Variable (if * is omitted)
foregroundColorNumberRGB color value for Foreground color
backgroundColorNumberRGB color value for Background color
altBackgrndColorNumberRGB color value for Alternating background
color

Description

The SET RGB COLORS command changes the foreground and background colors of the objects specified by object and the optional * parameters. When the command is applied to a List box object, an additional parameter lets you modify the alternating color of the rows.

If you specify the optional * parameter, you indicate an object name (a string) in object. If you omit the optional * parameter, you indicate a field or a variable in object. In this case, you specify a field or variable reference (field or variable objects only) instead of a string. For more information about object names, see the section Object Properties.

The optional altBackgrndColor parameter lets you set an alternate background color for even-numbered rows. This parameter is only used when the object specified is a List box or a column of the List box. When this parameter is used, the backgroundColor parameter is only used for odd-numbered rows. Using alternating colors makes lists easier to read.

If object specifies a List box object, alternating colors are used for the entire List box. If object specifies a column of the List box, only the column will use the colors set.

You indicate RGB color values in foregroundColor, backgroundColor and altBackgrndColor. An RGB value is a 4-byte Long Integer whose format (0x00RRGGBB) is described in the following table (bytes are numbered from 0 to 3, from right to left):

ByteDescription
3Must be zero if absolute RGB color
2Red component of the color (0..255)
1Green component of the color (0..255)
0Blue component of the color (0..255)

The following table shows some examples of RGB color values:

ValueDescription
0x00000000Black
0x00FF0000Bright Red
0x0000FF00Bright Green
0x000000FFBright Blue
0x007F7F7FGray
0x00FFFF00Bright Yellow
0x00FF7F7FRed Pastel
0x00FFFFFFWhite

Alternatively, you can specify one of the "system" colors used by 4th Dimension for drawing objects whose colors are set automatically. The following predefined constants are provided by 4th Dimension:

ConstantTypeValue
Foreground colorLong Integer-1
Background colorLong Integer-2
Dark shadow colorLong Integer-3
Light shadow colorLong Integer-4

Highlight text background colorLong Integer-7
Highlight text colorLong Integer-8
Highlight menu background colorLong Integer-9
Highlight menu text colorLong Integer-10
Disable highlight item colorLong Integer-11

These colors (on a standard system) are shown here:

WARNING: These automatic colors are system dependent. If you change your system colors, 4th Dimension will adjust its automatic colors accordingly. Use the automatic color values for setting objects to the system colors, not for setting them to the example colors shown above.

Examples

This form contains the two non-enterable variables vsColorValue and vsColor as well as the three thermometers: thRed, thGreen, and thBlue.

Here are the methods for these objects:

      ` vsColorValue non-enterable Object Method
   Case of 
      : (Form event=On Load)
         vsColorValue:="0x00000000"
   End case 
      ` vsColor non-enterable variable Object Method
   Case of 
      : (Form event=On Load)
         vsColor:=""
         SET RGB COLORS(vsColor;0x00FFFFFF;0x0000)
   End case 
 
      ` thRed Thermometer Object Method
   CLICK IN COLOR THERMOMETER 

      ` thGreen Thermometer Object Method
   CLICK IN COLOR THERMOMETER 

      ` thBlue Thermometer Object Method
   CLICK IN COLOR THERMOMETER 

The project method called by the three thermometers is:

      ` CLICK IN COLOR THERMOMETER Project Method
   SET RGB COLORS(vsColor;0x00FFFFFF;(thRed << 16)+(thGreen << 8)+thBlue)
   vsColorValue:=String((thRed << 16)+(thGreen << 8)+thBlue;"&x")
   If (thRed=0)
      vsColorValue:=Substring(vsColorValue;1;2)+"0000"+Substring(vsColorValue;3)
   End if 

Note the use of the Bitwise operators for calculating the color value from the thermometer values.

In the User or Custom Menus environments, the form looks like this:


See Also

Bitwise Operators, SET COLOR.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next