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: *
- Set the
MdiParent
Property of the child form. - Set the
FormBorderStyle
property of the child form toFormBorderStyle.None
. - Set the
Dock
property of the child form toDockStyle.Fill
. Note: This must come after setting theMdiParent
or else it won't work. - 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:
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.
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.
//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
How to Translate Cultureinfo Language Names
Static Property Using Inotifypropertychanged. C#
Retrieve the Respective Coordinates of All Words on the Page with Itextsharp
Check If List<T> Contains Any of Another List
What's the Fastest Way to Bulk Insert a Lot of Data in SQL Server (C# Client)
How to Make Chrome Headless After I Login Manually
Mvvm: Binding to Model While Keeping Model in Sync with a Server Version
Create Web Service Proxy in Visual Studio from a Wsdl File
Add a Package with a Local Package File in 'Dotnet'
How to Solve Disturbance in My Bot in C#
How to Await a List of Tasks Asynchronously Using Linq
Basic Simple ASP.NET + Jquery + JSON Example
How to Multiple Insert Multiple Records
How to Clear Cookies Using ASP.NET MVC 3 and C#