The following code makes the Form(menu) appear, and disappear, but if I select a opened window or anything besides the Form(menu) or NotifyIcon, the Form(menu) disappears and will not come back from clicking the NotifyIcon. I would much appreciate if someone could give me a solution to this problem, otherwise there isn't really a point to continue building my program.
The Form, that is called StartUp, is invisible to everyone, and this code that is placed in the StartUp Form, is only to show and hide the Form called Menu.
I'm pretty sure nothing from my Form called Menu is causing the problem, but if you think seeing that code would help, let me know.
Code:
public static bool menuOpen = false;
public static int mouseUpXPosition;
public static Menu menu;
public StartUp()
{
InitializeComponent();
SystemTrayIcon = new NotifyIcon();
SystemTrayIcon.Icon = Properties.Resources.Icon;
twSystemTrayIcon.MouseUp += new MouseEventHandler(this.ShowHideIcon_MouseUp);
SystemTrayIcon.Visible = true;
menu = new Menu();
}
private void ShowHideIcon_MouseUp(object sender, MouseEventArgs e)
{
switch(e.Button)
{
case MouseButtons.Left:
if (menuOpen == false)
{
if (MousePosition.X < Screen.PrimaryScreen.WorkingArea.Width - (menu.Width / 2))
{
mouseUpXPosition = MousePosition.X;
menu.Location = new Point(mouseUpXPosition - menu.Width / 2, Screen.PrimaryScreen.WorkingArea.Height - menu.Height);
menu.Show();
menuOpen = true;
}
else
{
menu.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - menu.Width, Screen.PrimaryScreen.WorkingArea.Height - menu.Height);
menu.Show();
menuOpen = true;
}
}
else
{
menu.Hide();
menuOpen = false;
}
break;
}
}
I'm pretty sure nothing from my Form called Menu is causing the problem, but if you think seeing that code would help, let me know.
Comment