Remove the Title Bar in Windows Forms

Remove Title Bar from Windows Form (Windows 10 style)

What you are observing is not a title bar but sizing border.

My question is what is causing such a difference between the way this is rendered in windows 10 vs windows 7?

The cause is different look and feel implementation on different versions of Windows.

In case you are interested how to get rid of the sizing border even on Windows 10: Remove the WS_THICKFRAME flag.

Alternatively (and perhaps more preferable) you can change your form's FormBorderStyle to some other value. Test whatever works best for you.

However there is nothing what defines the overall form border precisely. It's up to the look and feel (theme). Technically you cannot expect that form's border won't differ under different implementation. You can only ensure by testing.

Hiding title bar in windows form application

I'm almost certain this has been asked/answered over 9000 times, but the simplest way is to remove the window border in it's entirety.

this.FormBorderStyle = FormBorderStyle.None; // Assuming this code is in a method on your form

Remove top bar on child form

Option 1: *

As mentioned in this answer, you can add a MenuStrip control to your MDI parent form, set its Visible property to false, and you should be good to go. The MDI child forms won't have a title bar displayed as long as they are maximized.


Option 2: *

  1. Set the MdiParent Property of the child form.
  2. Set the FormBorderStyle property of the child form to FormBorderStyle.None.
  3. Set the Dock property of the child form to DockStyle.Fill. Note: This must come after setting the MdiParent or else it won't work.
  4. That's it, you don't need to change any other properties (WindowState, ControlBox, etc.). Just maintain the order of the steps above.

Here's an example:

private void OpenAndDockMdiChild()
{
Form2 childForm = new Form2();
childForm.MdiParent = this; // This must come **before** setting
// the `Dock` property.
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
childForm.Show();
}

private void Form1_Load(object sender, EventArgs e)
{
OpenAndDockMdiChild();
}

Result:

Sample Image
Hope that helps.


* Tested with .NET 4.5.2 on both Windows 7 and Windows 10.

Metro Form remove title bar

I assume you want to remove the title bar.

This can be done by selecting the None option in FormBorderStyle property under Form properties.

Sample Image

Removing the Title bar of external application using c#

No need to inject anything, you can just modify the windows style bits as using the API, e.g. this works for Notepad, however YMMV depending on the app you're playing with.

alt text

//Get current style
lCurStyle = GetWindowLong(hwnd, GWL_STYLE)

//remove titlebar elements
lCurStyle = lCurStyle And Not WS_CAPTION
lCurStyle = lCurStyle And Not WS_SYSMENU
lCurStyle = lCurStyle And Not WS_THICKFRAME
lCurStyle = lCurStyle And Not WS_MINIMIZE
lCurStyle = lCurStyle And Not WS_MAXIMIZEBOX

//apply new style
SetWindowLong hwnd, GWL_STYLE, lCurStyle

//reapply a 3d border
lCurStyle = GetWindowLong(hwnd, GWL_EXSTYLE)

SetWindowLong hwnd, GWL_EXSTYLE, lCurStyle Or WS_EX_DLGMODALFRAME

//redraw
SetWindowPos hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_FRAMECHANGED


Related Topics



Leave a reply



Submit