Silverfrost Logo About Us | Contact Us

Background colour - %bg[colour]

%bg is used with or without the grave accent modifier. Without the modifier, %bg changes the background colour of the main window. With the modifier, %`bg changes the background colour of the next (and only the next) control (used for example with %rd, %rf, %rs, %ed, %ls). %`bg is not used for buttons. For buttons use %bc.

By default a main window uses the background colour that the user can select from the Control Panel in the Program Manager. This colour is returned by GetSysColor(COLOR_WINDOW).

The new colour can be supplied as one of the standard colours: black, white, grey, red, green, blue, and yellow (for example: %bg[yellow]). Alternatively %bg takes one integer argument that has a value given by RGB@.

For example:


It is often desirable to base the new colour on the default by calling GetSysColor. In other words, you could create an alternative shade of the default background colour by unpacking the integer returned by GetSysColor and by modifying one or more of the (red, green, blue) components. For example:

INTEGER color,red,green,blue
color = GetSysColor(COLOR_WINDOW)
red   = AND(color,255)
green = AND(RS(color,8), 255)
blue  = AND(RS(color,16),255)
color = RGB@(red,green,blue+50)
i     = winio@('%bg',color)

This will deepen the blue component of the background colour (the new value is assumed to be less that 256). RS and AND are Salford-supplied intrinsic functions (in Fortran 90/95 you can use the standard intrinsics ISHFT and IAND).



Copyright © 1999-2019 Silverfrost Limited