Here's a trick that most MS Office-products use for coloring menus, controls and other GUI stuff. Maybe someone will find it useful.
The different GUI colors in Office -products are really close to, but not quite the same as the system colors you can get with GetSysColor API-function. They're usually a little brighter and not so bland as the system colors. And if you change your theme or your system color scheme, they change too. So they have to be linked to the system colors, right?
Right.
Here's the trick: MS Office creates highlights and other GUI colors by blending two of the default system colors. Using color blending creates a whole lot of new coloring possibilities while remaining consistent with the system coloring set by the user. Here's a bit of code I used to make a coloring scheme procedure for my Office-style menus. First, we need a macro for blending to colors:
Code: Select all
Macro AlphaBlend ( LColor , RColor , Alpha )
RGB ( ( ( Red ( RColor ) * Alpha + Red ( LColor ) * ( 256 - Alpha ) ) / 256 ) , ( ( Green ( RColor ) * Alpha + Green ( LColor ) * ( 256 - Alpha ) ) / 256 ) , ( ( Blue ( RColor ) * Alpha + Blue ( LColor ) * ( 256 - Alpha ) ) / 256 ) )
EndMacro
Code: Select all
Enumeration
#OfficeFaceBright
#OfficeFaceDim
#OfficeDisabled
#OfficeOutline
#OfficeSelected
#OfficeSelectedOutline
EndEnumeration
Procedure OfficeColor ( Type )
Select Type
Case #OfficeFaceBright
ProcedureReturn GetSysColor_ ( #COLOR_3DHIGHLIGHT )
Case #OfficeFaceDim
ProcedureReturn AlphaBlend ( GetSysColor_ ( #COLOR_3DFACE ) , GetSysColor_ ( #COLOR_3DHILIGHT ) , 55 )
Case #OfficeDisabled
ProcedureReturn AlphaBlend ( GetSysColor_ ( #COLOR_GRAYTEXT ) , GetSysColor_ ( #COLOR_3DHILIGHT ) , 77 )
Case #OfficeOutline
ProcedureReturn AlphaBlend ( GetSysColor_ ( #COLOR_3DDKSHADOW ) , GetSysColor_ ( #COLOR_3DFACE ) , 115 )
Case #OfficeSelected
ProcedureReturn AlphaBlend ( GetSysColor_ ( #COLOR_ACTIVECAPTION ) , GetSysColor_ ( #COLOR_3DHIGHLIGHT ) , 179 )
Case #OfficeSelectedOutline
ProcedureReturn AlphaBlend ( GetSysColor_ ( #COLOR_ACTIVECAPTION ) , GetSysColor_ ( #COLOR_3DHIGHLIGHT ) , 65 )
EndSelect
EndProcedure
By extending the procedure, changing the GetSysColor constants for LColor and RColor, and changing the alpha levels you can easily make your own system color consistent color schemes -- something that is too often overlooked these days.