I am trying to write an application that runs in the system tray, so I am
using a NotifyIcon not associated with a Form. My "main" class has an
instance of the NotifyIcon, and its ContextMenu, as well as other dialogs etc
that are accessed through the ContextMenu.
However, since there is no window open, the main thread completes after
initializing everything and the application exits. I tried to add a keep
alive thread that runs until you select "Exit" from the ContextMenu. I have
no idea why, but adding that thread screws up the ContextMenu. When you
select an item from the menu, it won't perform the event until you click on
the NotifyIcon again. Very strange. This only happens when I have the keep
alive thread running (the keep alive thread simply is while(threadSho uldRun)
{ Thread.sleep(50 0); }, threadShouldRun is set when you select "Exit".
Is there a better way to keep the NotifyIcon persistant? I also tried a
workaround of adding an empty form with the opacity = 0, and ShowDialog() on
it. That works fine, but seems like a very poor way to accomplish what I am
trying to do.
Any ideas? I am using C#.... 1 1982
Never mind...I ate my Idiot-O's this morning...
Simply throw in an Application.Run () and everything works perfectly.
"Chris Melnick" wrote: I am trying to write an application that runs in the system tray, so I am using a NotifyIcon not associated with a Form. My "main" class has an instance of the NotifyIcon, and its ContextMenu, as well as other dialogs etc that are accessed through the ContextMenu.
However, since there is no window open, the main thread completes after initializing everything and the application exits. I tried to add a keep alive thread that runs until you select "Exit" from the ContextMenu. I have no idea why, but adding that thread screws up the ContextMenu. When you select an item from the menu, it won't perform the event until you click on the NotifyIcon again. Very strange. This only happens when I have the keep alive thread running (the keep alive thread simply is while(threadSho uldRun) { Thread.sleep(50 0); }, threadShouldRun is set when you select "Exit".
Is there a better way to keep the NotifyIcon persistant? I also tried a workaround of adding an empty form with the opacity = 0, and ShowDialog() on it. That works fine, but seems like a very poor way to accomplish what I am trying to do.
Any ideas? I am using C#.... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hal Vaughan |
last post by:
In the app I'm working on, there is a need, from all classes, to get
configuration information. Much of that info is stored in single line
files (which may be put in the Preferences structure in java.util.prefs
later). I've experimented with different ways to access these modes. Part
of the problem is that I have to be sure the "home" mode is set so the
Config class can always read the config directory (and the files in it)
from within...
|
by: Artur Kowalski |
last post by:
I have a NotifyIcon in my Windows Service project and I am trying to
add a ContextMenu to this NotifyIcon or use some of the mouse events.
Everything isn't working. I think so base class of the service
System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or
timer messages. Any Idea?
Thanks,
|
by: Claus Konrad |
last post by:
Hi
How would you "force" the ToolTip text to be displayed on a NotifyIcon?
I want to inform the user that an action has happened in the "background",
and would like to present this text using the taskbar control (NotifyIcon).
It is not possible to inherit from System.Windows.Forms.NotifyIcon and
thereby creating an event to do this stuff, and there is no native event
called "MouseOver" or something like that...
|
by: Glen |
last post by:
Can anyone tell me if there is a workable method to get the mouse cursor
position on the screen or the NotifyIcon position? I need to display a
context menu for the NotifyIcon when clicked and I'd like it to display
based on the relative position of the tray icon or mouse pointer if
possible (whichever method works).
Any help would be much appreciated.
- Glen
|
by: Chris Melnick |
last post by:
I am trying to write an application that runs in the system tray, so I am
using a NotifyIcon not associated with a Form. My "main" class has an
instance of the NotifyIcon, and its ContextMenu, as well as other dialogs etc
that are accessed through the ContextMenu.
However, since there is no window open, the main thread completes after
initializing everything and the application exits. I tried to add a keep
alive thread that runs until...
| |
by: Marcel Brekelmans |
last post by:
Hello,
I have an application with a notifyIcon. When my application's main form is
hidden by some other window I would like to bring it in front by
single-clicking the NotifyIcon. However, I can't get it done. In the Click
event I've used all sorts of methods:
this.SetTopLevel(true);
this.Show();
this.Focus();
|
by: celestialgal86 |
last post by:
Hi everyone...
I'm a starter at .Net programming, and I need some help.
I was asked to develop a console app that will auto-hide the console window and show a system tray icon.
And by default, the system tray icon on click is supposed to show the console window
I know window apps are usually the better solution for handling NotifyIcon class, but I would really like to know how to do it in console apps
|
by: Mrozu |
last post by:
Hi,
VB.NET 2003
I'v got NotifyIcon, on minimize button click, my app is hiding to tray
by following code:
ni.Visible = True
Me.Hide()
Me.WindowState = FormWindowState.Minimized
|
by: \Ji Zhou [MSFT]\ |
last post by:
Hello Jason,
Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou
and I will be working on this issue with you.
I have tried to but cannot reproduce your issue on my side. From your
codes, I think the logical is, every time the Timer's elapsed event fires,
we call the Check_For_Version_Update() function. From the
Check_For_Version_Update() function, we judge a condition statement, and
determine whether to call...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |