Search code examples
c#winformsaero-glass

How do I get more of win7 aero-glass area by decreasing main control container? (C#)


By default, the form has a limited size title area to which the aero-glass effect is applied. I'd like to increase that area, not only at the title, but at the bottom and the sides of my form. scheme


Solution

  • Use DwmExtendFrameIntoClientArea:

    [StructLayout(LayoutKind.Sequential)]
    struct MARGINS {
        int Left;
        int Right;
        int Top;
        int Bottom;
    }
    
    [DllImport("user32.dll")]
    public static extern IntPtr DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
    

    Call DwmExtendFrameIntoClientArea with your form's Handle and a MARGINS structure. Just set Left, Right, Top and Bottom to the amount you want the respective borders extended by.

    Oh, and set the BackColor of your form to Black. (Thanks, @HansPassant!)

    Sorry if I got the extern syntax wrong. I haven't ever done this in C#...