C#里面获得窗口最小化、还原事件
若以下回答无法解决问题,邀请你更新回答
推荐于2016-02-09
展开全部
/// <summary>
/// 最小化到托盘程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void notifyIcon1_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized; HiddenForm();
}
else if (this.WindowState == FormWindowState.Minimized)
{
ShowForm();
}
}
private void FrmMain_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)//最小化
{
HiddenForm();
}
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
HiddenForm();
}
/// <summary>
/// 显示窗口
/// </summary>
private void ShowForm()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
this.Activate();
} /// <summary>
/// 隐藏窗口
/// </summary>
private void HiddenForm()
{
this.Hide();
}
/// 最小化到托盘程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void notifyIcon1_Click(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
this.WindowState = FormWindowState.Minimized; HiddenForm();
}
else if (this.WindowState == FormWindowState.Minimized)
{
ShowForm();
}
}
private void FrmMain_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)//最小化
{
HiddenForm();
}
}
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
HiddenForm();
}
/// <summary>
/// 显示窗口
/// </summary>
private void ShowForm()
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
this.Activate();
} /// <summary>
/// 隐藏窗口
/// </summary>
private void HiddenForm()
{
this.Hide();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询