version 2004 (Modified)
SET RGB COLORS ({*; }object; foregroundColor; backgroundColor{; altBackgrndColor})
Parameter | Type | Description | |
* | If specified, Object is an Object Name (String) | ||
If omitted, Object is a Field or a Variable | |||
object | Form Object | Object Name (if * is specified), or | |
Field or Variable (if * is omitted) | |||
foregroundColor | Number | RGB color value for Foreground color | |
backgroundColor | Number | RGB color value for Background color | |
altBackgrndColor | Number | RGB 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):
Byte | Description |
3 | Must be zero if absolute RGB color |
2 | Red component of the color (0..255) |
1 | Green component of the color (0..255) |
0 | Blue component of the color (0..255) |
The following table shows some examples of RGB color values:
Value | Description |
0x00000000 | Black |
0x00FF0000 | Bright Red |
0x0000FF00 | Bright Green |
0x000000FF | Bright Blue |
0x007F7F7F | Gray |
0x00FFFF00 | Bright Yellow |
0x00FF7F7F | Red Pastel |
0x00FFFFFF | White |
Alternatively, you can specify one of the "system" colors used by 4D for drawing objects whose colors are set automatically. The following predefined constants are provided by 4D:
Constant | Type | Value |
Foreground color | Long Integer | -1 |
Background color | Long Integer | -2 |
Dark shadow color | Long Integer | -3 |
Light shadow color | Long Integer | -4 |
Highlight text background color | Long Integer | -7 |
Highlight text color | Long Integer | -8 |
Highlight menu background color | Long Integer | -9 |
Highlight menu text color | Long Integer | -10 |
Disable highlight item color | Long Integer | -11 |
These colors (on a standard system) are shown here:
WARNING: These automatic colors are system dependent. If you change your system colors, 4D 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.
When executed, the form looks like this:
See Also
Bitwise Operators, Select RGB Color, SET COLOR.