Hi All

I'd like to create a toolbar button "highlighting" effect on mouseover with TB_SETHOTIMAGELIST, and rather than create a new set of resource bitmaps I'd like to modify the existing toolbar image list to produce a nice effect, and I'm not sure exactly how I should handle it.

I have a rebar/toolbar combination with the bitmaps loaded into an Imagelist. Before storing them in the image list I use a technique discussed here before of sampling the first pixel of the bitmap and flood filling the background to match the button color, as determined by the users default colors. This works great even if the user chooses some shocking hot pink color scheme!

invoke GetSysColor, COLOR_BTNFACE
invoke CreateSolidBrush, eax
mov hBrush, eax
invoke SelectObject, mDC, hBrush
mov hOldBrush, eax
invoke GetPixel, mDC, 1, 1
invoke ExtFloodFill, mDC, 1, 1, eax, FLOODFILLSURFACE

I already handle TBN_HOTITEMCHANGE (return 0) which maintains the 'raised button' effect on mouseover, but beyond this what I'd like to try is perhaps "brightening" the bitmaps, while still maintaining the background floodfill of course, and these would become the image list for TB_SETHOTIMAGELIST that would take effect on mouseover to highlight them.

I'm not sure if I should treat each bitmap with some bitmap function before loading them into another image list, or whether I could work on a copy of the original "non-hot" image list directly with something like ImageList_Draw and using a blending mask.

Whatever the effect might be I figure it should show up and look reasonable no matter what the users default color scheme is. I thought maybe 'lightening' the RGB value of each pixel by a few degrees might be the safest way to achieve this. Can this be done with a mask? I haven't played much with modifying graphics at this level and I'm not sure what would look good or exactly how to go about achieving the effect and I was hoping for a few pointers in that direction.

Thanks for any input,
Posted on 2003-01-11 18:21:58 by Kayaker
Common Control Macro Library

Take a look at \cocomac\example\Tabs\Tabs.exe example.
It's not a toolbar but may be can help you.
Posted on 2003-01-12 03:53:51 by Four-F
well, that helped ME alot! thanks:))
Posted on 2003-01-12 19:31:10 by DZA
Thanks Four-F, your cocomac library is nice. The example uses 2 sets of bitmaps for the mouseover effect but I'm trying to create a somewhat similar effect by modifying just 1 set of bitmaps in memory. I suspect I'll have to get into some alpha blending routine to slightly highlight the colors. I've been playing with a photo editor, creating a single pixel bitmap and applying various color adjustments to it and noting the RGB changes, along with running an API monitor in parallel to try to make sense of what calls are used to create the change. I don't really care about the toolbar, it was just an excuse to mess with some GDI stuff.

Just wanted to say thanks for the suggestion. If I come up with a nice effect I'll post some code.

Posted on 2003-01-13 22:57:14 by Kayaker