DwmExtendFrameIntoClientArea without TransparencyKey?
When using DwmExtendFrameIntoClientArea
function I need to choose Form.TransparencyKey
, a color that a glass will be drawn on instead.
The problem is that i writing image-edit tool, and when TransparencyKey
color appear inside the edited image, the user开发者_如何学编程 see glass instead.
How do i extend the glass into client area without losing some color?
There's no reason you should be using the Form.TransparencyKey
property with DWM functions. That property relates to layered windows, which has nothing to do with the Aero glass effect. I assume the fact that it might work is more a consequence of implementation detail (like all 3 RGB values of the color you've set as the TransparencyKey
are the same), rather than by design.
GDI treats black as the transparency color, so you should just paint the particular regions of your form that you want to appear as glass with a black brush. Because you're limiting the black fill to only those areas, there's no reason this should interfere with the rest of your UI.
Of course, any black text (such as that drawn on controls) that appears in the area you're rendering as glass is going to look ugly. The solution is either to switch to GDI+-based rendering or to move your controls outside of the area to be rendered as glass. If you need finer control over the area of your form that should appear glassy than provided by DwmExtendFrameIntoClientArea
(which literally just extends the frame by a set amount), look into using DwmEnableBlurBehindWindow
instead. See my more complete answer here on how to use that function.
精彩评论