帮助我最小化Windows窗体到系统托盘的位置. [英] Help me in minimizing the windows form to system tray....
本文介绍了帮助我最小化Windows窗体到系统托盘的位置.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试最小化系统托盘中的表格.我写了一段代码.但是我面临的唯一问题是,当我尝试从系统托盘还原窗口时. Win Form出现在任务栏中,但是失去了焦点,这意味着它没有自动出现在屏幕上,我必须单击任务栏上的才能将其还原....
这是我的代码
I am trying to minimize the form to system tray. I have written a piece of code. But the only problem i am facing is that when i try to restore the window from system tray. Win Form appears in taskbar but has lost focused means it doesnt appear on the screen automatically i have to click on taskbar to restore it....
Here is my code
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
this.Hide();
}
else if (this.WindowState == FormWindowState.Normal)
{
notifyIcon1.Visible = false;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
}
推荐答案
在从系统托盘还原表单时捕获显示该表单的事件,并将此行添加到事件处理程序中. >
Catch the event that displays the form when you''re restoring it from the systray, and add this line to the event handler.
this.WindowState = FormWindowState.Normal;
这篇关于帮助我最小化Windows窗体到系统托盘的位置.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文