Using DwmEnableBlurBehindWindow to blur a specific region |
|
Hi,
We have a logo on our app sitting on a toolbar on the top right of the
screen. I'd quite like to extend Vista's glass/blur effect into this area
on the top right - for no particular reason, I just think it'd look cool.
I'm using BDS2006 so there's no inbuilt glass support, so I'm doing this
manually via the Vista APIs. I've tried two different ways, but both have
problems:
1. Using DwmEnableBlurBehindWindow passing in a region which is located
where the logo is (and painting that area with an alpha channel so Vista
blurs)
2. Using DwmExtendFrameIntoClientArea, pulling the whole frame down by 20
pixels or so (the height of the toolbar the logo is on)
The first works perfectly, except that the entire window area that /isn't/
in the specified region draws very oddly - black text is transparent; other
areas with controls on are saturated almost to white or are drawn
transparently but without blurring. The way I interpret MSDN's doco on
DwmEnableBlurBehindWindow using a region is that it only applies to the area
within the specified region, so why is it affecting the drawing of other
areas on screen?
The second again works well, except that the rest of the items on the
toolbar draw with black text being transparent - though in this case this is
what I'd expect. I just thought I'd try it to see.
I would have expected the first method to work perfectly, and from reading
the docs I don't understand why it isn't. I've probably missed something
obvious. Can anyone point out what it is, please? I'm eagerly awaiting the
"doh" moment :)
Cheers,
David
PS: btw, the code I'm using for the first method is something along the
lines of:
HRGN hRegion = ::CreateRectRgn(tbarLogo->Left, 0, tbarLogo->Width,
tbarLogo->Height);
oBlurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED |
DWM_BB_BLURREGION;
oBlurBehind.fEnable = TRUE;
oBlurBehind.fTransitionOnMaximized = FALSE;
oBlurBehind.hRgnBlur = hRegion;
Dwm_EnableBlurBehindWindow(Handle, &oBlurBehind);
and as I said, this blurs behind tbarLogo but also oddly affects the rest of
the window.
|