Search code examples
c#.netwindowborderaero

How to achieve a captionless bordered Aero window?


I know how I can remove the border of my form, but I simply want to remove the caption. Googling for P/Invokes didn't give me much results, so I'm wondering, how can I achieve such a result?

alt text


Solution

  • Coming from unmanaged development, I'd P/Invoke {Get/Set}WindowLong, etc. etc. -- which was my initial response -- but there's a managed way to deal with this.

    You'll want to override the CreateParams property in your form, removing the bordering style and adding the thick frame style, as such:

    ...
    const UInt32 WS_THICKFRAME = 0x40000;
    const UInt32 WS_BORDER = 0x800000;
    ...
    
    protected override CreateParams CreateParams
    {
      get
      {
        CreateParams p = base.CreateParams;
        p.Style |= WS_THICKFRAME;
        p.Style &= ~WS_BORDER;
    
        return p;
      }
    }
    



    Suggested reading list

    Window Styles http://msdn.microsoft.com/en-us/library/ms632600%28VS.85%29.aspx

    Form::CreateParams Property http://msdn.microsoft.com/en-us/library/system.windows.forms.form.createparams.aspx