First drop a NotifyIcon onto the winform and name it "notifyIcon", add a mouse double click event handler for the notifyIcon to the winform as shown below:
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
ShowApp();
}
private void ShowApp()
{
this.WindowState = FormWindowState.Maximized;
this.ShowInTaskbar = true;
this.Show();
}
This will ensure that when the notifyIcon in the system tray is clicked, the application will be shown. Next add a resize event handler to the winform as shown below:
private void FrmCrawler_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
this.ShowInTaskbar = false;
this.Hide();
}
}
This is triggered when user click the minimize icon on the winform app, which in turns hide the app.
No comments:
Post a Comment