Reputation: 877
I need to remove the title bar from my windows form. But when I set the
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
I have lost the title bar ,but at the same time I can’t see the task bar.
So I need task bar back by removing the title bar.I need the from to be like as in the attached pic
Can anyone help me please?
Upvotes: 4
Views: 1060
Reputation: 4828
You should check if ShowInTaskbar
property has been turned off, either in design time or run time. It will show at task bar by default even if the border is None
.
Upvotes: 1
Reputation: 430
One way to go about it is to tell windows what the maximum bounds are. You can do that by overriding the default behaviour for WM_GETMINMAXINFO window message. So basically you will have to override WndProc method for the form.
You can also change the value of MaximizedBounds (protected property) instead of overriding the WndProc but if you do so, you will have to set this property everytime the form is moved to another screen.
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
public int x;
public int y;
public POINT()
{
}
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
}
[StructLayout(LayoutKind.Sequential)]
public class MINMAXINFO
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
const int WM_GETMINMAXINFO = 0x0024;
if (m.Msg == WM_GETMINMAXINFO)
{
MINMAXINFO minmaxinfo = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
var screen = Screen.FromControl(this);
minmaxinfo.ptMaxPosition = new POINT(screen.WorkingArea.X, screen.WorkingArea.Y);
minmaxinfo.ptMaxSize = new POINT(screen.WorkingArea.Width, screen.WorkingArea.Height);
Marshal.StructureToPtr(minmaxinfo, m.LParam, false);
}
}
Upvotes: 1