Switching DWM composition causes the client area to lose alpha

I have a simple windows app here:

http://www.bengoodger.com/software/chrome/dwm/app.cc

My app provides a customizable glass frame when DWM layout is active and a fully customizable frame when inactive or unavailable.

The "custom glass frame" consists of an enlarged title _

bar area, which is reported in my WM implementation of NCCALCSIZE to be part of the client area, as I would like to render transparent controls. So this "high titlebar" area of ​​my window is transparent, I fill it with transparent black (BLACK_BRUSH in the simple example above), which makes it draw like glass using DWM.

When the DWM system switches, for example. using the Appearance Options control panel to switch to Vista Basic or Windows Standard, or when an application that requires the DWM system to be disabled, my application switches to a fully customizable rendering mode, handling WM_NCPAINT, etc. When I switch back, I would expect the opposite, which is mostly happening, except that my "high heading area" is now solid black.

I found I could work around this issue by getting the placement in the window, hiding the window, and then setting the placement again in my WM_DWMCOMPOSITIONCHANGED handling, but this causes other horrible errors (the least of which is the z-order window switching).

My question is, what am I doing wrong here? It seems that the window is somehow put into a dummy state and hiding / showing it fixes it. How can I prevent this? Any guidance would be greatly appreciated.

Note. I've narrowed it down a bit. When the DWM glass is active, any part of the client area that is painted black that appears above the client area becomes transparent. We noticed that when returning to Glass from non-glass, the client area becomes solid black instead of transparent. However, when the window is maximized and then restored, the window reverts to transparency. When I then drag the size, the window is smaller, the top window remains transparent. When I drag it more, the top of the window turns black again. It's like the DWM is caching the pixels outside the window and the window size is bigger because it can't draw anything because its cache isn't big enough. I can't seem to find a DWM function to reset this state. It seems that Maximize / Minimize, Restore or SetWindowPlacement are capable of tickling it,but have other unwanted side effects.

+2


source to share


1 answer


http://www.codeproject.com/KB/dialog/rtaGlassEffectLib.aspx



As you may have noticed, the GlassEnabled property is great for testing if this feature is enabled by your system, then start using our libraries and call the ShowEffect () function to show the glass effect.Now let's assume the user has disabled / enabled the Aero theme. while your application was RUNNING !! This may cause a problem in the appearance of your application.

To solve this problem, two events were added to the library to track changes that occur to the system while the application is running, these two events are GlassEffectEnabled and GlassEffectDisabled.

Now for people who like to know how things are. I can tell that these activities were carried out by monitoring the messages coming from the system to the windows for our application for the WM_SYSCOLORCHANGE message, which indicates that the system colors have been changed. So, quickly compare the state of the GlassEnabled property before and after this message, we can decide if this feature is enabled or not.

+2


source







All Articles