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. -
-
-
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;
-
}
-
}
-
-
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.
6 2526 Plater 7,872
Recognized Expert Expert
I usually just use menu.Visible=!menu.Visible to toggle the window. I'm not sure what all the other stuff yo uare doing is all about
If your reply of menu.Visible was meant to replace the if(menuOpen == false), I appreciate it, I feel rather stupid not thinking of it. And actually, well thinking of other ways of describing my problem, I found my solution, which is
TopMost = true;
TopMost = false;
Simple, effective, and it gets the job done. Thank you though for your advice.
Plater 7,872
Recognized Expert Expert
I wasn't really clear on what you problem was.
An example of what i do would be like this: -
private void ShowHideIcon_MouseUp(object sender, MouseEventArgs e)
-
{
-
if(e.Button==MouseButtons.Left)menu.Visible=!menu.Visible;
-
}
-
I don't mess around with window position though.
Okay, I see what you mean. But I have actually found out my fix, didn't fix everything.
When my program starts, my Menu Form stays in the same spot of all programs, so lets say I open two other programs, those will be in front of my Menu Form, if I click the NotifyIcon, it shows and hides, but it doesn't come in front of the other programs. With the
TopMost = true;
TopMost = false;
It comes to the front like I want, but if it was open, it needs to be double clicked, so that it will close, and then open on top.
Is there any event that will activate when my application is not the top window?
Plater 7,872
Recognized Expert Expert
Why not leave topmost always true and then just show/hide the window?
All I want is it to hide when it's not in use. Like when you click the volume icon, the menu appears, but when you select anything else, it hides.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joop |
last post by:
Hi all,
I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-)
So, here's my problem :
I've created a table in my document, presenting a list of items, one
can 'select' by clicking...
|
by: DD |
last post by:
Hi when i open a form, then walk away from the computer and my screensaver comes on.
When i clear the screensaver infront of me is the code window
Is this a problem that can be fixed or ?????
...
|
by: Andrew |
last post by:
I recently copied an old form and modified it with new fields and
such, and now when I try to simply open the form (view it to enter
data) there is nothing but the header showing! The header is...
|
by: juli jul |
last post by:
Hello,
I need to place those controls in the form in the order that I am
writing:
1)ListView (aligned dock to "Fill")
2)Spliter aligned to left(dock=left).
3)TreeView aligned to...
|
by: tim |
last post by:
I have an vb application that is started/stopped using the
System.Diagnostics.Process class. The application has both a form,
and a notifyicon. (The form is displayed when the user clicks the...
| |
by: insomniux |
last post by:
Hi,
I have an Access 2000 database with one main form in which all subforms
are embedded. In this form I have a timer which closes the form,
detaches the linked (ODBC) tables and reopens the same...
|
by: Raj Wall |
last post by:
Hi,
I have an application which, when running, is to be seen only in the system
tray as a right-clickable icon.
However I want the main Form window itself to immediately disappear without...
|
by: udivitelno |
last post by:
Here is the problem:
part of the form elements is replaced using Ajax. After this new input elements getting lost from the form so nothing can be POSTed through these input fields. But if I try to...
|
by: th12345 |
last post by:
I have implemented the form authentication in my application. whenever i tried to go particular page . It is automaticaly is going to login page of another application. Because I am trying to go...
|
by: bruno_guedesav |
last post by:
This has ocurred before, but if the person had find a way to solve it
or not, I've got no clue. So, here I am to ask for help.
I've created a form via pure PHP, basically a bunch of prints...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |