2

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

user1306322
  • 8,561
  • 18
  • 61
  • 122

1 Answers1

3

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#...

Ry-
  • 218,210
  • 55
  • 464
  • 476
  • Looks like what I'm looking for, but I just can't seem to make it work :x Could you please add a working example? – user1306322 May 06 '12 at 18:58
  • It isn't enough, you also have to draw it black: http://www.danielmoth.com/Blog/Vista-Glass-In-C.aspx – Hans Passant May 06 '12 at 19:03
  • @HansPassant since you linked to that website, could you please explaing what is `g` in `g.FillRectangle(blackBrush, 0, 0, this.ClientSize.Width, marg.Top);` and how do I use it correctly? Also I see white background instead of described black, is it ok? – user1306322 May 06 '12 at 19:15
  • That was a hint to @minitech to help him improve his answer :) – Hans Passant May 06 '12 at 19:18
  • @HansPassant: Thanks, I forgot that part :) Actually, any color except the default will work. – Ry- May 06 '12 at 19:19
  • @user1306322: Just set the `BackColor` of your form to `Black`, it has the same effect. Of course, then you'll want to put a `Panel` with the usual color back over top of it so that everything looks normal. – Ry- May 06 '12 at 19:19