【发布时间】:2010-09-16 22:16:36
【问题描述】:
如何使我的窗口没有标题栏,但在任务栏中显示一些描述性文本? 如果你设置了表单的 .Text 属性,那么 .net 会给它一个标题栏,这是我不想要的。
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";
我找到了一个部分解决方案来覆盖 CreateParams:
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
System.Windows.Forms.CreateParams cp = base.CreateParams;
cp.Style &= ~0x00C00000; // WS_CAPTION
return cp;
}
}
但是,这会导致我的窗口被调整大小,就好像它们有一个标题栏一样,即它比它应该的高。有什么好的解决办法吗?
【问题讨论】: