I'm developing a C# application that supports Windows Aero in the main form.
Some applications that do not support Visual Styles, for example GoToMeeting, disable visual styles and my form is wrongly drawn while GoToMeeting is running (the Aero client area is drawn black).
How could I subscribe to a OS event that is fired when visual styles are disabled? Then I could adjust the client area in my window to be correctly drawn.
Managed and unmanaged solutions are valid for me.
Thanks in advance.
EDIT: According to Hans's answer, here is the code to manage this event:
private const int WM_DWMCOMPOSITIONCHANGED = 0x31e;
[DllImport("dwmapi.dll")]
private static extern void DwmIsCompositionEnabled(ref bool pfEnabled);
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_DWMCOMPOSITIONCHANGED)
{
bool compositionEnabled = false;
DwmIsCompositionEnabled(ref compositionEnabled);
if (compositionEnabled)
{
// composition has been enabled
}
else
{
// composition has been disabled
}
}
base.WndProc (ref m);
}
Windows sends a message to your toplevel window. You'd trap it in, say, a WndProc override for a Winforms form. Listen for WM_DWMCOMPOSITIONCHANGED, message number 0x31e.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With