2

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?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
DxCK
  • 4,402
  • 7
  • 50
  • 89

1 Answers1

0

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.

Community
  • 1
  • 1
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • Thanks, But how do i draw an image that has black color without making it transparent? – DxCK Jan 22 '11 at 18:47
  • @DxCK: Like I said, only black areas within the border you've specified to `DwmExtendFrameIntoClientArea` will be glass. The rest of the black on your form won't be transparent because it's not rendered as glass. If you render the *entire form* as a glass sheet (by passing -1 to the function), all black will be rendered as glass, even the text in controls. There's not much you can do about that. I haven't seen a good answer to the many [questions that have been asked](http://stackoverflow.com/questions/4258295/aero-how-to-draw-solid-opaque-colors-on-glass), and I don't see the point in trying. – Cody Gray - on strike Jan 23 '11 at 03:56