Background colour - %bg[colour]

In this section:

%bg (Background Colour) 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 (Edit Integer), %rf (Edit Floating Point), %rs (Edit String), %eb (Edit Box), %ls (List Box (or Combo Box))). %`bg is not used for buttons. For buttons use %bc (Button Background Colour).

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:

i=winio@('%bg',RGB@(0,255,255))

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 Silverfrost-supplied intrinsic functions (in Fortran 90/95 you can use the standard intrinsics ISHFT and IAND).

 

 

Basket
Empty
 
Copyright © 1999-2020 Silverfrost Limited