C#应用程序制作托盘
using System.Runtime.InteropServices; //DllImport在该命名空间中;
//------------------------------------------------------------------------------------
[DllImport("user32.dll")]
private static extern bool IsIconic(IntPtr hWnd); //引入方法
private System.Windows.Forms.NotifyIcon HideIcon;//在该对象的可视化设计窗中设置Icon图标、Text提示信息;
//------------------------------------------------------------------------------------
//双击托盘图标事件
private void HideIcon_DoubleClick(object sender, System.EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
}
//------------------------------------------------------------------------------------
//调整窗口大小事件(最小化)
private void frmBTOnlEvlServer_Resize(object sender, System.EventArgs e)
{
if(IsIconic(this.Handle))
{
this.Visible = false;
}
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
[DllImport("user32.dll")]
private static extern bool IsIconic(IntPtr hWnd); //引入方法
private System.Windows.Forms.NotifyIcon HideIcon;//在该对象的可视化设计窗中设置Icon图标、Text提示信息;
//------------------------------------------------------------------------------------
//双击托盘图标事件
private void HideIcon_DoubleClick(object sender, System.EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
}
//------------------------------------------------------------------------------------
//调整窗口大小事件(最小化)
private void frmBTOnlEvlServer_Resize(object sender, System.EventArgs e)
{
if(IsIconic(this.Handle))
{
this.Visible = false;
}
}
//------------------------------------------------------------------------------------