因為工作需求,要撰寫Win 常駐程式
看完微軟的MSDN,其已有配套的元件NotifyIcon
把這個控制項拉到Win form 上~設定相關的Text和Icon顯示圖片(有訊息圖片和最小化圖片)
就可以了!
接下來是程式的實作
private void frmMaster_Load(object sender, EventArgs e)
{
if (loadCount == 0)
{
this.WindowState = FormWindowState.Minimized;
//win 工作列表顯示
this.ShowInTaskbar = false;
loadCount++;
}
}
//Form 大小化時觸發
private void frmMaster_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(3000);
this.Hide();
}
else {
notifyIcon1.Visible = false; }
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
請先 登入 以發表留言。