Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Colors and Fonts : Accessing the current color and font tables : COLOR-TABLE handle
 
COLOR-TABLE handle
The NUM–ENTRIES attribute sets and returns the number of colors available in the color table. The following methods allow you to read existing color definitions and to set new definitions for dynamic colors:
*The GET–RED–VALUE(n), GET–GREEN–VALUE(n), and GET–BLUE–VALUE(n) methods let you read the red, blue, and green values for a specified color number. This example gets the red value of the 16th color in the color table:
DEFINE VARIABLE red-val AS INTEGER NO-UNDO.
red-val = COLOR-TABLE:GET-RED-VALUE(16)
*You can determine whether a color is dynamic by reading the GET–DYNAMIC(n) method. You can make a color dynamic or nondynamic by using the SET–DYNAMIC(nlogical) method. This example makes color 16 dynamic if it is not already set:
IF NOT COLOR-TABLE:GET-DYNAMIC(16) THEN
  COLOR-TABLE:SET-DYNAMIC(16, TRUE).
*You can change the red, blue, and green values of a dynamic color by using the SET–RED–VALUE(ninteger), SET–GREEN–VALUE(ninteger), and SET–BLUE–VALUE(ninteger) methods. Note that these methods change the effective color values of a color number in the current color table. Thus, every visible widget set to the specified color number changes to the corresponding colors immediately. However, this does not change the color definitions originally specified in the current environment. If you restart the application with the current environment, the original colors reappear. This example sets color 16 to a blue value of 192:
COLOR-TABLE:SET-BLUE-VALUE(16, 192).
*There is an efficient alternative to calling the SET–RED–VALUE(ninteger), SET–GREEN–VALUE(ninteger), and SET–BLUE–VALUE(ninteger) methods to change the RGB values of a dynamic color. You can specify the SET–RGB–VALUE() method to substitute for all three of these methods. You can determine a combined RGB value using the RGB–VALUE function or by accessing a color property from an ActiveX control. For example:
COLOR-TABLE:SET-RGB-VALUE (16, RGB-VALUE (128, 0, 128)).
The GET–RGB–VALUE() method returns an INTEGER that represents a combination of the red, green, and blue values associated with the nth entry. This combined RGB value is most useful for setting colors in an ActiveX control.
For more information on the COLOR–TABLE handle, see OpenEdge Development: ABL Reference.