Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除标题栏,但需要C#Windows窗体中的任务栏_C#_Winforms - Fatal编程技术网

删除标题栏,但需要C#Windows窗体中的任务栏

删除标题栏,但需要C#Windows窗体中的任务栏,c#,winforms,C#,Winforms,我需要从windows窗体中删除标题栏。但是当我设置 FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 我丢失了标题栏,但同时看不到任务栏 因此,我需要通过删除标题栏返回任务栏 有人能帮我吗?一种方法是告诉windows最大界限是多少。您可以通过覆盖WM_GETMINMAXINFO窗口消息的默认行为来实现这一点。因此,基本上您必须重写表单的WndProc方法 您也可以更改MaximizedBounds(protected属

我需要从windows窗体中删除标题栏。但是当我设置

FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
我丢失了标题栏,但同时看不到任务栏

因此,我需要通过删除标题栏返回任务栏


有人能帮我吗?

一种方法是告诉windows最大界限是多少。您可以通过覆盖WM_GETMINMAXINFO窗口消息的默认行为来实现这一点。因此,基本上您必须重写表单的WndProc方法

您也可以更改MaximizedBounds(protected属性)的值,而不是重写WndProc,但如果这样做,则每次将窗体移动到另一个屏幕时都必须设置此属性

    [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);
        }
    }

您应该检查
ShowInTaskbar
属性是否已在设计时或运行时关闭。默认情况下,它将显示在任务栏上,即使边框是
None

我将创建
a
struct
表单中是否有
ShowInTaskbar
属性?这是真的吗?