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 2536 Plater 7,872
Recognized Expert Expert
I usually just use menu.Visible=!m enu.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 on it... (Kinda like a menu, you make your
choice from) But since this table can get very long, I've put
something of a 'search-form' on top, which enables the user to make a
|
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 ?????
Thanks
DD
|
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 only
3/4" tall and the size of the form is correct, but there is nothing on
it. If, in design view, I move some fields around that stretch the
form, the big empty box I have changes accordingly, but still nothing
but the header appearing. Any...
|
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 left(dock=left).
How can I do it?
(I tried to add them first without docking in the order 1),2),3) but
after doing the dock it wasn't ok)
|
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
notifyicon, and hidden when the user minimizes the form)
The problem I've run into is that Process class is unable to close the
application using either the CloseMainWindow() or Close() method, when
the form is hidden. It seems that the form's...
| |
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 form with a
login dialog (initiated in onOpen).
When I open the application the form maximizes (as it should). But when
the code reopens the form, the form is not maximized. I have
DoCmd.Maximize in onOpen,onLoad,onActivate. What else can I try...
|
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
having to be minimized.
I have tried putting
this.Hide();
in the Load method, but that doesn't work (the form still comes up and needs
|
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 append these fields to form using appendChild - they are moved from their places in page and placed diectly after <form> tag. And sure they vanish from the browser and can't be edited.
How shall I append these fields to form to not to lose them and...
|
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 respective page without authentication and authroization process.
I have given my hyper link in my page to go another application. When tried this one, It is going login page , because tried application has form authentication.
Here I have to...
|
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 together
making a form. But somthing strange goes on: the form will only pass
it's fields forward under method GET, but not on POST.
Here's a snippet of code, just the basics:
print "<form name=\"postcomment\" action=\"".HTTP_ROOT."/pages/
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |