1

To use Aero Glass in my C# application I use

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. Is Aero Glass on Vista different from the one on 7?

Edit: To the person who -1 this post, because you hate Vista or what? 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.

CCCP
  • 215
  • 3
  • 14

1 Answers1

1

The MARGINS structure should be:

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

DwmExtendFrameIntoClientArea should be supported in Vista. I assume that Win7 is just being more tolerant of the truncated structure. Be very careful with unmanaged data types.

Iain Ballard
  • 4,433
  • 34
  • 39
  • Can you give more context? What have you tried and how have you set up the window in question? – Iain Ballard Feb 16 '14 at 21:09
  • I added the code you gave me and debugged my application on Vista. It still has black instead of transparent panels. – CCCP Feb 16 '14 at 21:12