views:

56

answers:

2

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?

Exampel: http://localhostr.com/files/d2e951/Captionless.jpg

A: 

I don't have VS right now so I can't give you an exact answer, sorry.

In the window's property pane look for border style, one of them will allow you to set one similar :)

Edit: I knew I was missing something... First, look for the properties "ControlBox", "MaximizeBox" and "MinimizeBox" and set them to false and choose one of the sizable options in "FormBorderStyle" property -yes, it cannot look like the one in the pic and also be fixed-size, at least not without PinVoke AFAIK-.

Also remember to leave the "Text" property blank.

Hope this helps :)

pedro_cesar
+1  A: 

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

Rafael Rivera