How can I make my window not have a title bar but appear in the task bar with some descriptive text? If you set the Form's .Text property then .net gives it a title bar, which I don't want.
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = true;
this.Text = "My title for task bar";
I've found a partial solution, to override CreateParams:
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cp.Style &= ~0x00C00000; // WS_CAPTION
return cp;
}
}
However this causes my window to be resized as if they have a title bar, ie it's taller than it should be. Is there any good solution to this?
In my case I have a Form with FormBorderStyle = FormBorderStyle.SizableToolWindow
and the following CreateParams
override did the trick (i.e. I now have a form without caption and without additional margin for the title, but it keeps the title in the task bar):
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
var parms = base.CreateParams;
parms.Style &= ~0x00C00000; // remove WS_CAPTION
parms.Style |= 0x00040000; // include WS_SIZEBOX
return parms;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With