Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.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# 点击Notify图标重新显示窗口 我是C语言的新手,但我知道C++和C,我的问题是我不能让我的表单在被最小化到系统托盘后再次显示。_C#_Forms_System_Notifyicon_Tray - Fatal编程技术网

C# 点击Notify图标重新显示窗口 我是C语言的新手,但我知道C++和C,我的问题是我不能让我的表单在被最小化到系统托盘后再次显示。

C# 点击Notify图标重新显示窗口 我是C语言的新手,但我知道C++和C,我的问题是我不能让我的表单在被最小化到系统托盘后再次显示。,c#,forms,system,notifyicon,tray,C#,Forms,System,Notifyicon,Tray,这就是我用来隐藏它的代码: protected override void OnResize(EventArgs e) { base.OnResize(e); bool cursorNotInBar = Screen.GetWorkingArea(this).Contains(Cursor.Position); if (this.WindowState == FormWindowState.Minimized &&

这就是我用来隐藏它的代码:

    protected override void OnResize(EventArgs e)
    {
        base.OnResize(e);

        bool cursorNotInBar = Screen.GetWorkingArea(this).Contains(Cursor.Position);

        if (this.WindowState == FormWindowState.Minimized && cursorNotInBar)
        {
            this.ShowInTaskbar = false;
            notifyIcon.Visible = true;
            this.Hide();
        }
    }

在通知图标上单击事件尝试:

this.Show();
(我不确定,但这个也可以:this.Visible=true)

顺便说一下,尝试在窗体上处理OnClosing事件,而不是OnResize


(我在家里有合适的代码,当我到那里时,我会分享它)

你可以使用this.Show()在最小化后再次显示表单。如果这不起作用,请告诉我,这将提供另一种解决方案。

您需要撤消对表单所做的更改,使其隐藏…使其再次显示:

    private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Left)
        {
            this.Show();
            this.ShowInTaskbar = true;
            this.WindowState = FormWindowState.Normal;
            notifyIcon.Visible = false;
        }
    }

您如何尝试再次显示它?使用此.show()和OnClick事件。为什么要忽略不起作用的代码?在询问之前是否尝试过:(如果您不介意,可以共享您的代码,以便我尝试并让您知道。我今天解决了此问题:private void notifyIcon\u Click(object sender,EventArgs e){this.Show();this.ShowInTaskbar=true;this.WindowState=FormWindowState.Normal;this.Activate();notifyIcon.Visible=true;}感谢您提供有关鼠标单击的提示。我已尝试使用notifyIcon。单击事件失败。