System colors

The functions GetSysColor and SetSysColors can be used to access the system colors.
This is for example useful for displaying text in disabled native fill-in widgets.
Text in a disabled native fill-in is rendered in the system-color COLOR_GRAYTEXT, which is gray. The background color of a disabled fill-in is also gray (but not COLOR_GRAYTEXT) so it is difficult to read the text.
To make the text more readable you may want to change the RGB-value of the COLOR_GRAYTEXT system color.
There are several ways to change COLOR_GRAYTEXT:
You can set or modify the registry key

    "HKEY_CURRENT_USER\Control Panel\Colors\GrayText"

but that will only take effect after you reboot the system.
You can also consider using the SetSysColors function to modify the RGB-value of COLOR_GRAYTEXT. The advantage is that it will take effect immediately, no need to reboot the system.
The disadvantage is that it won't be written to registry so the original value is reset after reboot. Well, actually I think this is another advantage.
What I would try to do is:
on startup of the Progress session: read the current value of COLOR_GRAYTEXT
if COLOR_GRAYTEXT is not acceptable set it to something you prefer.
on close of the Progress session: restore the original value to respect other applications.
After you call SetSysColors, Windows sends a notification message to all open windows so they can repaint themselves. This takes a little time.
Read COLOR_GRAYTEXT

{windows.i}
  DEFINE VARIABLE rgbGrayText AS INTEGER NO-UNDO.
  RUN GetSysColor IN hpApi (17, /* = COLOR_GRAYTEXT */
                            OUTPUT rgbGrayText).

set COLOR_GRAYTEXT

{windows.i}
 
  DEFINE VARIABLE lpElements  AS MEMPTR.
  DEFINE VARIABLE lpRgb       AS MEMPTR.
  DEFINE VARIABLE ReturnValue AS INTEGER NO-UNDO.
 
  SET-SIZE(lpElements)   = 4.   /* = sizeof(long)   */
  SET-SIZE(lpRgb)        = 4.
  PUT-LONG(lpElements,1) = 17.  /* = COLOR_GRAYTEXT */
  PUT-LONG(lpRgb,1)      = RGB-VALUE(192,192,192).
 
  RUN SetSysColors IN hpApi (1,          /* = number of elements */
                             GET-POINTER-VALUE(lpElements),
                             GET-POINTER-VALUE(lpRgb),
                             OUTPUT ReturnValue).
 
  SET-SIZE(lpElements) = 0.
  SET-SIZE(lpRgb)      = 0.

Notes

Credits to Julian Lyndon Smith who discovered the value 192,192,192. Although it is the RGB-value for a shade of gray, it will render the text in disabled native fill-in widgets black but still does little harm to other screen-elements that are coloured in COLOR_GRAYTEXT.

Notes

(May 1999).
It now appears that setting GrayText to RGB(192,192,192) makes disabled SELECTION-LIST widgets really hard to read. Don't know why it was not noticed before... perhaps it depends on Windows 98, video card or other display settings? Anyway, GrayText=RGB(192,192,192) does not seem to be a good idea anymore.

Notes

KeithGernert 19 Jan 2004: We've found that an RGB setting of 80,80,80 looks pretty good and is less destructive to other Windows controls.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Index numbers for color elements

Where the example code references 17 for COLOR_GREYTEXT, here is a list of different values that can be used along with brief descriptions. The code can be cut and paste into an existing 4GL application with the values being referenced as {&COLOR_GREYTEXT} if the code above was to use them:

/* Windows NT and Windows 95:  These remarks do not apply.  */
&GLOB COLOR_ACTIVECAPTION            2 /* Active window title bar. Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled. */
&GLOB COLOR_GRADIENTACTIVECAPTION   27 /* Right side color in the color gradient of an active window's title bar. COLOR_ACTIVECAPTION specifies the left side color. Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled. */
&GLOB COLOR_GRADIENTINACTIVECAPTION 28 /* Right side color in the color gradient of an inactive window's title bar. COLOR_INACTIVECAPTION specifies the left side color. */
&GLOB COLOR_HOTLIGHT                26 /* Color for a hyperlink or hot-tracked item. */
&GLOB COLOR_INACTIVECAPTION          3 /* Inactive window caption.  Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled. */

/* Windows 2000/NT and Windows Me/98/95:  These values are not supported.  */
&GLOB COLOR_MENUHILIGHT             29 /* The color used to highlight menu items when the menu appears as a flat menu (see SystemParametersInfo). The highlighted menu item is outlined with COLOR_HIGHLIGHT. */
&GLOB COLOR_MENUBAR                 30 /* The background color for the menu bar when menus appear as flat menus (see SystemParametersInfo). However, COLOR_MENU continues to specify the background color of the menu popup. */

/* Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95. */
&GLOB COLOR_3DDKSHADOW              21 /* Dark shadow for three-dimensional display elements.  */
&GLOB COLOR_3DFACE                  15 /* Face color for three-dimensional display elements and for dialog box backgrounds.  */
&GLOB COLOR_3DHIGHLIGHT             20 /* Highlight color for three-dimensional display elements (for edges facing the light source.)  */
&GLOB COLOR_3DHILIGHT               20 /* Highlight color for three-dimensional display elements (for edges facing the light source.)  */
&GLOB COLOR_3DLIGHT                 22 /* Light color for three-dimensional display elements (for edges facing the light source.)  */
&GLOB COLOR_3DSHADOW                16 /* Shadow color for three-dimensional display elements (for edges facing away from the light source).  */
&GLOB COLOR_ACTIVEBORDER            10 /* Active window border.  */
&GLOB COLOR_APPWORKSPACE            12 /* Background color of multiple document interface (MDI) applications.  */
&GLOB COLOR_BACKGROUND               1 /* Desktop.  */
&GLOB COLOR_BTNFACE                 15 /* Face color for three-dimensional display elements and for dialog box backgrounds.  */
&GLOB COLOR_BTNHIGHLIGHT            20 /* Highlight color for three-dimensional display elements (for edges facing the light source.)  */
&GLOB COLOR_BTNHILIGHT              20 /* Highlight color for three-dimensional display elements (for edges facing the light source.)  */
&GLOB COLOR_BTNSHADOW               16 /* Shadow color for three-dimensional display elements (for edges facing away from the light source).  */
&GLOB COLOR_BTNTEXT                 18 /* Text on push buttons.  */
&GLOB COLOR_CAPTIONTEXT              9 /* Text in caption, size box, and scroll bar arrow box.  */
&GLOB COLOR_DESKTOP                  1 /* Desktop.  */
&GLOB COLOR_GRAYTEXT                17 /* Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.  */
&GLOB COLOR_HIGHLIGHT               13 /* Item(s) selected in a control.  */
&GLOB COLOR_HIGHLIGHTTEXT           14 /* Text of item(s) selected in a control.  */
&GLOB COLOR_INACTIVEBORDER          11 /* Inactive window border.  */
&GLOB COLOR_INACTIVECAPTIONTEXT     19 /* Color of text in an inactive caption.  */
&GLOB COLOR_INFOBK                  24 /* Background color for tooltip controls.  */
&GLOB COLOR_INFOTEXT                23 /* Text color for tooltip controls.  */
&GLOB COLOR_MENU                     4 /* Menu background.  */
&GLOB COLOR_MENUTEXT                 7 /* Text in menus.  */
&GLOB COLOR_SCROLLBAR                0 /* Scroll bar gray area.  */
&GLOB COLOR_WINDOW                   5 /* Window background.  */
&GLOB COLOR_WINDOWFRAME              6 /* Window frame.  */
&GLOB COLOR_WINDOWTEXT               8 /* Text in windows.  */