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(); // showing error in this line }
notifyIcon1.ContextMenu = trayMenu;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)