2

我可以以某种方式禁用我的 WPF 应用程序窗口的玻璃/透明度吗?

注意:我不想禁用 Aero,只禁用玻璃/透明度,对于我的窗户,而不是整个系统。

像这样的东西(Enable Transparency复选框),但仅适用于我的应用程序:

在此处输入图像描述

这可能吗?

4

1 回答 1

1

我知道这已经晚了,但对于其他人来说,你可以使用以下内容。它可能不会严格回答这个问题,因为这可能被认为是“禁用 Aero”,但它确实禁用了客户端窗口的透明度。

[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));
}

您可以在此处找到更多信息DwmSetWindowAttribute 函数

于 2015-12-10T20:59:25.693 回答