Click to See Complete Forum and Search --> : transparent/round edged owner drawn button?


flyingcowofdoom
March 20th, 2006, 10:50 AM
I would like to have an owner drawn button that is transparent. The button is in a window on which I draw a gradient. I would like the gradient to show through the button, which will just have a border and the button text. The problem I am having is that windows always draws a flat grey rectangle over the button's rectangle.

If tranparency is difficult, I would even settle for the button's edges to be round. I can draw a rounded rectangle on the button, but the grey rectangle is still drawn underneath.

TIA!

--FCOD

NoHero
March 20th, 2006, 11:00 AM
I haven't really done this before, but it should work easily with the following:

- Create a custom drawn button
- And lay a transparent bitmap over it. You can achieve transparency via the AlphaBlend (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_6ig4.asp) function.

flyingcowofdoom
March 20th, 2006, 11:33 AM
I tried your suggestion, but it just blends the transparent bitmap with the grey rectangle that windows paints. Any ideas?

TIA!

--FCOD

NoHero
March 20th, 2006, 02:36 PM
Do you want both (button and dialog) be transparent?

flyingcowofdoom
March 20th, 2006, 02:54 PM
I want the button to be transparent with a border. See attached example. I'd like the gradient to show through the button (instead of gray) but have the border still show.

--FCOD

kkez
March 22nd, 2006, 07:15 AM
With the code you provided, if you
1) subclass the button
2) handle WM_ERASEBKGND inside the button subclass proc, return 1 (that tell Windows you "handled" it, even if you didn't)

the button now has no gray background.


Attached a screenshot and the modified source file.

flyingcowofdoom
March 22nd, 2006, 09:17 AM
kkez, you're awesome. That's exactly what I needed. Thank you!

--FCOD