用c#做的窗体,当按显示桌面时,该窗体不会在桌面中消失!
来源:百度知道 编辑:UC知道 时间:2024/06/11 21:59:34
急啊··· 注意是c#编写的 哦!!很急啊·····
先放一个notifyIcon控件,表示图标,比如你说的迅雷图标
//在窗体中找到Deactivate事件,表示窗体最小化,小图标出现
private void form1_Deactivate(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;
}
}
// notifyIcon1控件事件,表示点击任务栏中显示的小图标窗体显示正常的大小
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.Activate();
this.notifyIcon1.Visible = false;
}
在窗体的Deactivate事件中加入:
MessageBox.Show("哥们雄风依旧!");
这样当你的窗体被停用(按下'显示桌面')时就会跳出警告框,确定后窗体依然显示.
引用:
using System.Runtime.InteropServices;
在定义部分引入下面两个函数:
[DllImport("user32")]
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32")]