Make your own free website on Tripod.com

Getting Systemcolors in Powerscript

Back Up Next

Author: Eric Aling (18 aug 1999)
Accessed:

In PowerBuilder you have the possibility to use systemcolor such as buttonface, windows background etc. But not all. There are much more colors in the windows appearance which you can alter in the screen properties dialog box.

These colors are stored in the registry, as strings, containing three colors, red, green and blue like "255 255 255" (which is the color white). The colors are stored in the key HKEY_CURRENT_USER\Control Panel\Colors, followed by the specific color you want such as 'ButtonFace'. So, what we have to do is using the RegistryGet() function to get the string value, parse it to three long values with which we use the RGB() function to create the colorvalue.

Here's the code:

String ls_Value
String ls_Color
Integer li_pos1
Integer li_pos2
Long ll_r
Long ll_g
Long ll_b
Long ll_Color
// For instance getting the value for ActiveTitle
Ls_Color = ‘ActiveTitle’
if RegistryGet("HKEY_CURRENT_USER\Control Panel\Colors", ls_Color, RegString!, ls_Value) > 0 then
// Get RGB values from string
li_pos1	= pos(ls_Value,' ',1)
ll_r	= long(mid(ls_Value,1,li_Pos1 - 1))
li_pos2	= pos(ls_Value,' ',li_pos1 + 1)
ll_g	= long(mid(ls_Value,li_pos1 + 1,li_Pos2 - li_pos1))
ll_b 	= long(mid(ls_Value,li_pos2))
// ll_Color will be the value of the wanted color
ll_Color= rgb(ll_r,ll_g,ll_b)
end if

The registry contains the following colors:

Scrollbar
Background
ActiveTitle
InactiveTitleMenu
Window
WindowFrame
MenuText
WindowText
TitleText
ActiveBorder
InactiveBorder
AppWorkspace
Hilight
HilightText
ButtonFace
ButtonShadow
GrayText
ButtonText
InactiveTitleText
ButtonHilight
ButtonDkShadow
ButtonLight
InfoText
InfoWindow
ButtonAlternateFace
HotTrackingColor
GradientActiveTitle
GradientInactiveTitle

Now, if you want your application react on a change in windows appearance, you should map an userevent to pbm_syscolorchange (which is WM_SYSCOLORCHANGE). In that event you can get the new values of the colors you want and apply to your controls and windows.

Good luck!

 

Back Up Next