Toolbar button background color 
Author Message
 Toolbar button background color

I have an application that has a toolbar containing toolbar buttons.
The buttons have a grey background.  When I run the application
on one machine, it looks fine (the button background matches the
toolbar color).  However, when I run the application on another
machine, that has a Window's Theme applied, the toolbar displays
in shade of grey that is slighly different and does not match the
button background color.  Thus, the buttons no longer "blend" into
the toolbar.

The toolbar buttons are bitmaps, and I don't believe that bitmaps
support a transparent color.

However, when I look at the Dolphin Class Browser running on
the two machines, it does not have this problem.  Somehow
the toolbar button background color automagically adjusts to
match the toolbar.  Can anyone explain how the Class Browser
(as well as the other Dolphin development tools) does this?  Thanks.



Sat, 15 Nov 2003 13:53:13 GMT  
 Toolbar button background color
Rodney,

Quote:
> However, when I look at the Dolphin Class Browser running on
> the two machines, it does not have this problem.  Somehow
> the toolbar button background color automagically adjusts to
> match the toolbar.  Can anyone explain how the Class Browser
> (as well as the other Dolphin development tools) does this?  Thanks.

If you look at the Bitmap class you will find a method called
#setMap3dColors: which Dolphin automatically invokes when it loads a
ToolbarButton (see senders of the above method).

This next bit is copied from MSDN and documents a flag for the LoadImage
api.

-~-~-~-~

LR_LOADMAP3DCOLORS
Searches the color table for the image and replaces the following
    shades of gray with the corresponding 3-D color:

Color                                         Replaced with
Dk Gray, RGB(128,128,128)     COLOR_3DSHADOW
Gray,RGB(192,192,192)             COLOR_3DFACE
Lt Gray, RGB(223,223,223)         COLOR_3DLIGHT

Do not use this option if you are loading a bitmap with a color
    depth greater than 8bpp.

-~-~-~-~

That's not going to format very well but the middle bit just shows a table
of mappings that Windows uses if LR_LOADMAP3DCOLORS is requested for an
image load (via Bitmap>>setMap3dColors). So if an image is loaded that
contains Gray then Windows automatically replaces it with the system colour
COLOR_3DFACE (Dolphin's Color class>>face3d).

The idea is that Windows can use different RGB values for the various parts
of the toolbar, depending on the target machines OS/colour scheme or
whatever, but if you create your bitmap using RGB192,192,192 then you can be
sure that the bitmap's background will automagically be made to match the
toolbar's background(COLOR_3DFACE) when the bitmap is loaded.

By using RGB192,192,192 when you create your bitmap buttons the colours
should be portable and always match.  I think the same substitutions are
done for dialog backgrounds, but don't quote me on that.

Having said all this, I'm not convinced that it always works as intended. I
have seen situations, especially after I upgraded from Win95 to Win2000,
where the toolbar colour and button colour didn't match.  It may just have
been that I wasn't consistent in using 192,192,192 and used COLOR_3DFACE
directly (which is 212,208,200 on my Win2000 machine) so the automatic
mapping wasn't done .... but maybe not <g>

Regards
    Ian



Sat, 15 Nov 2003 17:06:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. conflicts between button colors and background color

2. Background colors of Menubar and Toolbar

3. setting button background color

4. VA 4.0 Push Button Background color

5. Button's background color..

6. Color Button Background

7. Radio buttons on color background

8. TK42 Cascade menu's buttons background color

9. background color of buttons/menu items is black

10. background color on push buttons

11. setting button background color

12. Setting a web hex color as background color for a canvas

 

 
Powered by phpBB® Forum Software