Disabling Aero glass/transparency for WPF window?

Go To StackoverFlow.com

2

Can I somehow disable the glass/transparency for my WPF application window?

Note: I don't want to disable Aero, just the glass/transparency, and for my window, not the entire system.

Something like this (the Enable Transparency checkbox), but just for my application:

enter image description here

Is this possible?

2012-05-20 15:01
by Tower
That's easy: just switch to Windows 8 and all transparency is gone. ;- - dtb 2012-05-20 15:06
@dtb I know, it's sad, but I need a real answer though : - Tower 2012-05-20 15:13
Pinvoke required: http://msdn.microsoft.com/en-us/library/windows/desktop/aa969524%28v=vs.85%29.asp - Hans Passant 2012-05-20 16:08
I don't think you can do this. The only way is to create your own custom titlebar and disable the system one - Alexandru Dicu 2012-12-12 09:13


0

I know this is late, but for others looking you can use the following. It might not strictly answer the question as this could be considered "disabling Aero", but it does disable transparency for the client window alone.

[DllImport("DwmApi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute);

private const int DWMWA_NCRENDERING_POLICY = 2;
private const int DWMNCRP_DISABLED = 1;

private void OnLoaded(object sender, RoutedEventArgs e)
{
    var mainWindowHandle = new WindowInteropHelper(this).Handle;
    var policyParameter = DWMNCRP_DISABLED;

    DwmSetWindowAttribute(mainWindowHandle, DWMWA_NCRENDERING_POLICY, ref policyParameter, sizeof(int));
}

You can find more information here DwmSetWindowAttribute function.

2015-12-10 20:59
by AdamRossWalker
Ads