简体   繁体   English

Aero Glass在Windows 7上可以正常工作,但在Vista上则不能工作

[英]Aero Glass works fine on Windows 7, but doesn't work on Vista

To use Aero Glass in my C# application I use 要在我的C#应用​​程序中使用Aero Glass,请使用

if {DWM.DwmIsCompositionEnabled())
{
    Color c = Color.FromArgb(255, 221, 220, 220);
    Transparency Key = c;
    panel1.BackColor = c;
    panel2.BackColor = c;
    MARGINS mr = new MARGINS();
    mr.T = 1800;
    IntPtr h = Handle;
    int result = DwmExtendFrameIntoClientArea(h, ref mr);
}

In the designer: 在设计器中:

[DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(
    IntPtr h
    ref MARGINS p
};
[StructLayout(LayoutKind.Sequential)]
public strict MARGINS
{
    public int T;
}

It works beautifully fine on Windows 7, but on Vista the panels are black instead of transparent. 它在Windows 7上可以正常工作,但在Vista上,面板是黑色的而不是透明的。 Is Aero Glass on Vista different from the one on 7? Vista上的Aero Glass与7上的Aero Glass是否有所不同?

Edit: To the person who -1 this post, because you hate Vista or what? 编辑:对于-1帖子的人,因为您讨厌Vista或什么? You know as a developer you should make sure that your software runs on as many operating systems as possible to ensure that more people use it. 作为开发人员,您应该确保软件在尽可能多的操作系统上运行,以确保更多的人使用它。

The MARGINS structure should be: MARGINS结构应为:

[StructLayout(LayoutKind.Sequential)]
public strict MARGINS
{
    public int cxLeftWidth;
    public int cxRightWidth;
    public int cyTopHeight;
    public int cyBottomHeight;
}

DwmExtendFrameIntoClientArea should be supported in Vista. DwmExtendFrameIntoClientArea应支持DwmExtendFrameIntoClientArea I assume that Win7 is just being more tolerant of the truncated structure. 我认为Win7更能容忍截断的结构。 Be very careful with unmanaged data types. 对非托管数据类型要非常小心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM