I want a menu while I am clicking the icon in system tray.
My code is:
public ContextMenu traymenu;
public Form()
{
InitializeComponent();
this.Resize += new EventHandler(Login_Resize);
}
private void Form_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.Visible = false;
}
private void Login_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowIcon = false;
this.ShowInTaskbar = false;
notifyIcon1.Visible = true;
notifyIcon1.BalloonTipTitle = "Minimized to Start Menu Bar";
notifyIcon1.BalloonTipText = " Chat App minimized";
notifyIcon1.ShowBalloonTip(15);
traymenu = new ContextMenu();
traymenu.MenuItems.Add("Logout", OnExit);
this.Hide();
}
else if (FormWindowState.Normal == this.WindowState)
{
notifyIcon1.Visible = false;
}
}
private void OnExit(object sender, EventArgs e)
{
System.Environment.Exit(0);
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
traymanu.Show();
}
solution need:
I need the contextmenu to be displayed while I am clicking the notify icon