I'm Currently Working in Windows Application.
I just created a tray Icon while closing the Form, Tray Icon is visible in System Tray.
While Left Click the Tray Icon Form is maximized to normal state.
Right Click Event is not working in Release Mode, but working in Debug Mode.
After Building this application Right Event is not working, the output.exe file from Debug mode.
Any help would be appreciated. Thanks in Advance.
In form Load
private void MainRelease_Load(object sender, EventArgs e)
{
TrayIcon.Visible = false;
TrayMenu.Items.Add("Exit");
TrayMenu.Items[0].Click += new System.EventHandler(this.Dispose_Click);
}
In button close Event
private void btnClose_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
TrayIcon.Visible = true;
ShowInTaskbar = false;
}
In Tray Icon mouse click Event
private void TrayIcon_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
this.WindowState = FormWindowState.Normal;
TrayIcon.Visible = false;
ShowInTaskbar = true;
}
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
TrayMenu.Show(Cursor.Position.X, Cursor.Position.Y);
}
}
Tray Menu dispose event
private void Dispose_Click(object Sender, EventArgs e)
{
TrayIcon.Visible = false;
TrayIcon.Icon = null;
TrayIcon.Dispose();
Application.Exit();
}
While in Release Mode Tray Icon Mouse Right Click Event is not working . But in Debug Mode its working.
Please Help me to solve this Issue.