Re: Running an windows app in memory



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(false);

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

.



Relevant Pages

  • Re: How do I manually create an icon in the system tray?
    ... That would preclude the service itself from using the system tray for a ... notify icon. ... the System Tray which allows the developer to test Start / Stop, ... instantiating a NotifyIcon instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I manually create an icon in the system tray?
    ... When the form is loaded - bingo - the icon appears in the System Tray. ... I do note that the "drop a NotifyIcon onto a Form" is just a shortcut for instantiating a NotifyIcon instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Newbie question - Service and NotifyIcon
    ... puts a NotifyIcon in the system tray. ... OK but I don't get the icon in the system tray when I log in. ... for newly-logged-in desktops to add the NotifyIcon to? ...
    (microsoft.public.dotnet.languages.vb)
  • NotifyIcon "sticks" to system tray after closing
    ... NotifyIcon, the icon stays visible in the system tray. ... It only disappears ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cannt Hide Main Form Window
    ... Add a NotifyIcon component to your form and assign it a proper icon ... In the Form's load event make sure the Form's ShowInTaskbar ... I have a small c# app, when It start, Hide it self to system tray. ... _/ Shanghai Xomi Instruments Co., ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading