如何使一个窗口有任务栏的文本,但没有标题栏任务栏、标题栏、文本、窗口

由网友(恋上你的床)分享简介:我怎样才能让我的窗口没有标题栏,但似乎与一些描述性文字任务栏?如果您设置窗体的。文属性,然后.NET给它一个标题栏,这是我不想要的。How can I make my window not have a title bar but appear in the task bar with some descripti...

我怎样才能让我的窗口没有标题栏,但似乎与一些描述性文字任务栏? 如果您设置窗体的。文属性,然后.NET给它一个标题栏,这是我不想要的。

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";

我已经找到了部分解决方案,覆盖的CreateParams:

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?

推荐答案

一种方法寻找到可能是设置的 FormBorderStyle 属性的(而不是 FixedDialog )。

One approach to look into might be to set the FormBorderStyle property of your Form to None (instead of FixedDialog).

的缺点这种方法的缺点是你失去了你的窗口的边框和标题栏。这样做的结果是,你失去的形式重新定位/调整的逻辑,你通常会得到免费使用Windows窗体;你需要通过实现自己的形式移动/形式的的MouseDown和MouseMove事件处理程序调整的逻辑来处理这个问题。

The drawback to this approach is that you lose the borders of your window as well as the Titlebar. A result of this is that you lose the form repositioning/resizing logic that you normally get "for free" with Windows Forms; you would need to deal with this by implementing your own form move/resize logic in the form's MouseDown and MouseMove event handlers.

我也有兴趣听到更好的解决方案。

I would also be interested to hear about better solutions.

阅读全文

相关推荐

最新文章