473,499 Members | 1,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running an windows app in memory

Okay well maybe my heading isn't exactle right but what i want to do
is create a windows application that loads when the machine starts up
but instead of having it on the screen i just want it to be an icon on
the start bar in the right corner eg. Like where speaker volume
control is for instance. On top of this i also want to display a
message from that icon like a pop up warning.Is this possible
Feb 6 '08 #1
5 1677
btw, to add an exit menu:

[etc]
using (NotifyIcon icon = new NotifyIcon())
using (ContextMenuStrip menu = new ContextMenuStrip())
{
menu.Items.Add("Exit", null, delegate
{Application.Exit();});
icon.ContextMenuStrip = menu;
icon.Visible = true;
[etc]
Feb 6 '08 #2
On Feb 6, 10:59 am, Marc Gravell <marc.grav...@gmail.comwrote:
btw, to add an exit menu:

[etc]
using (NotifyIcon icon = new NotifyIcon())
using (ContextMenuStrip menu = new ContextMenuStrip())
{
menu.Items.Add("Exit", null, delegate
{Application.Exit();});
icon.ContextMenuStrip = menu;
icon.Visible = true;
[etc]
Thanks a mil just the answer i wanted
Feb 6 '08 #3
Marc Gravell wrote : a nifty example of using a NotifyIcon in the
Program.cs at the start of a WinForms application (code snipped for
brevity).

Hi Marc,

In my development environment (Win XP, VS 2005, .NET 2.0) the call to :

Application.SetCompatibleTextRenderingDefault(fals e);

Must also occur before encountering any code that creates a WinForms object,
like a NotifyIcon.

I find the setting of the ShowBalloonTip of the icon parameter makes no
difference : the BalloonTip persists the same amount of time. This is true
whether I am running from within Visual Studio 2005 in debug mode, or if I
am running the application from a compiled .exe file.

A click event handler for the Icon does work nicely when added to your
example :

// note : using this "as is" does not filter out context-clicks,
// so if you are using a ContextMenuStrip on the NotifyIcon
// you need to write code to prevent a mess ...
//
icon.Click += new EventHandler
(
delegate
{
// Console.WriteLine("notify icon clicked");
icon.ShowBalloonTip(4000);
}
);

A side-effect, also, is sometimes ending up having more than one copy of the
icon in the taskbar, or having the icon persist in the system tray after you
close the app : although when you go mouse over the system tray, the
"ghosts" disappear. Refresh issue ?

I believe I experimented with a similar technique some months ago, and ended
up concluding that it was better to "go the whole hog" and write some
minimize to system tray code.

Does wrapping Application.Run in the clause of a Using statement have any
side-effects : it appears not, but I wonder ...

best, Bill Woodruff
dotScience
Chiang Mai, Thailand

"The greater the social and cultural differences between people, the more
magical the light that can spring from their contact." Milan Kundera,
Testaments Trahis

Feb 6 '08 #4
The side-effect of orphaned task icons happens when a process exits
unexpectedly; this is common when hitting "stop" in the debugger. The
app I'm working on at the moment has a tray icon; the last time I
glanced I had ~20 orphans from debugging sections of code ;-p Of
course, a wave of the mouse removes them. It shouldn't be a big
problem in live unless you routinely use task manager to kill exes.

The dispose should make no difference; the Run() will block until
Exit() is called, at which point you *want* everything to be
Dispose()d.

I wasn't sure how much of the rest was statement, and how much was
question/problem; is there anything else you need help with?

Marc
Feb 6 '08 #5
Hi Marc,

The problem I mentioned with the BalloonToolTip not going away as you might
expect depending on its timer value is, evidently, a well-known problem :

http://blog.lyalin.com/2007/12/showb...otifyicon.html

Has nothing to do with your code.

I found this link by going to MSDN and looking at the NotifyIcon docs.
Should have checked that first ! : sorry.

The issue of detecting a right-click in such a context is more interesting :
I thought I had once done that by testing the return value of the static
System.Windows.Forms.Control.MouseButtons in the usual way, but in that
place in the start-up process the mousebuttons state remains "none" (because
there's no Form ? no message pump ? duhhh ?). Maybe have to use an API ?

best, Bill Woodruff

Feb 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2169
by: Dave 2 | last post by:
Yes, another memory limit question. Our PHP application is running with PHP 4.3.9 running in CGI mode under Windows IIS 5. When a user tries to download a file that is 'too large', the...
5
6655
by: Jesper Carstensen | last post by:
We are running an ASP application. That is fairly simple. It selects from one table (15.000 records), and updates into another table. But when we execute the ASP script, it reports the...
0
1312
by: Oleg Medyanik | last post by:
Hello, All I have a question regarding running .NET application on W2k SP4 server in Terminal Service client, After we installed SP4 we face the exception when closing .NET app in Terminal...
0
565
by: Martijn Remmen | last post by:
I have developed a service which exposes a COM object. This service is running perfect on Windows 2000 Server and Windows 2000 Professional under the SYSTEM account. When the service is...
5
4051
by: Chris Dugan | last post by:
Hi, has anybody come across a solution to running an Access97 database on Windows XP. The situation I have is an Access 97 database that runs perfectly from Win95/98 clients running Access97, the...
7
8102
by: Rob | last post by:
I am an Access developer and have done many Access databases in the standard Front-end on the workstations, backend on the server (over a LAN) but have never worked with Access over Citrix, though...
3
3468
by: kuldeep | last post by:
Hi all, I have a application developed in C# .net. The problem I face is I am unable to shutdown my machine when the exe is running. Windows is unable to close this exe an shut down. Can anyone...
6
2182
by: dspfun | last post by:
I would like to analyze my running c-program. What I would like to know for example is the range of the entire address space of my running c-program (memory reserved for/by the running program),...
11
2292
by: sunil | last post by:
Dear All, I have created a .Net service in 2.0 and running it on a machine that has a Quad Processor. It is failing with the following error. "Error 1053: The service did not respond to the start...
4
1669
by: needshade | last post by:
Platform : Windows XP Language : Visual Basic 6 Hi, I have a peculiar problem here. I created a VB6 program that during runtime when it is minimize, I can maxmise it by clicking my icon on...
0
7130
marktang
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,...
0
7007
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...
0
7171
Oralloy
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,...
0
7220
jinu1996
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...
1
6893
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...
1
4918
isladogs
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...
0
4599
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...
0
3098
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...
0
295
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.