Solved

Low Impact System Tray Application

Posted on 2004-09-13
2
237 Views
Last Modified: 2010-04-15
Basically, I want the source of this program:
<a href="http://toolbar.google.com/gmail-helper/">Gmail Notifier</a>
I am recreating it, and just getting started, but I'm stuck already.
Here's my main:
[STAThread]
static void Main()
{
      Form1 mainForm = new Form1();                  
      Application.Run();
}
Here's my Form1 constructor:
public Form1()
{ }
Absolutely nothing has been done, but it's already using more memory than the Gmail Notifier. Four MB's more (Windows Task Manager says so). I opened Microsoft Spy++, clicked "Processes", and here's the specs.
Gmail Notifier: 10 threads
--Windows: All the threads but two show nothing. The other two:
----Number one: "" GoogleGmailNotifySysTray
----Number two: "MCI command handling window" #43
My Form: 3 threads
--No Windows
My question: Is there another way to have a program run in the system tray, without all the windows forms mess? I want this program to use very little resources. I am pretty sure that the Gmail Notifier is made with .NET, so, I know that there IS a way to do it using less resources. I don't need the windows forms at all: I plan to have the program read logins and passwords out of a local xml file, then login with those and if there's new mail, change the icon (just like Gmail Notifier). I am confidant that I know how to do that, so all I'm asking is the system tray question.
--------------------------------------------------------------------------------------------------------------
How do I get an icon in the system tray without a System.Windows.Forms.Form and NotifyIcon?
--------------------------------------------------------------------------------------------------------------
Thanks in advance,
-Chris
0
Comment
Question by:klexys
2 Comments
 
LVL 14

Assisted Solution

by:AvonWyss
AvonWyss earned 100 total points
ID: 12048171
What makes you think that Gmail Notifier is made with .NET? Note that all .NET apps have a quite large footprint if loaded into a separate process since they are running a complete CLR environment (including the whole garbage collector and jit compiler stuff). To see the really minimal footprint of a .NET app, create a console application that just waits for a keypress and remove all references to Windows.Forms, Windows.XML etc. You'll see that this app still needs quite some resources to start with.
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 400 total points
ID: 12049872
> How do I get an icon in the system tray without a System.Windows.Forms.Form and NotifyIcon?

You are not going to get an Icon in the try without using a NotifyIcon object (unless you want to work with the Windows API), but you can have a notify icon without using a System.Windows.Forms.Form by using the following code:


    static void Main()
    {
      System.ComponentModel.Container components;
      components = new System.ComponentModel.Container();
      using(components)
      {
        System.Windows.Forms.ContextMenu contextMenu;
        contextMenu = new System.Windows.Forms.ContextMenu();

        contextMenu.MenuItems.Add("&Close", new EventHandler(CloseMenuItem_Click));

        System.Windows.Forms.NotifyIcon notifyIcon;
        notifyIcon = new System.Windows.Forms.NotifyIcon(components);
        notifyIcon.Icon = System.Drawing.SystemIcons.Warning;
        notifyIcon.ContextMenu = contextMenu;
        notifyIcon.Visible = true;

        System.Windows.Forms.Application.Run();
      }
    }

    private static void CloseMenuItem_Click(object sender, EventArgs e)
    {
      System.Windows.Forms.Application.Exit();
    }
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now