Re: System Tray Application
hi there,
I'm not sure if this is what you are looking for but if you put this in your Main() method, it should work...
Code:
NotifyIcon tray = new NotifyIcon();
// Used to grab the embedded bitmap
System.Reflection.Assembly assembly =
System.Reflection.Assembly.GetCallingAssembly();
// The bitmap
Bitmap trayBitmap = (Bitmap)Bitmap.FromStream
(assembly.GetManifestResourceStream("KeyStroke.MacJournal.ico"));
// Convert Bitmap to Icon
Icon trayIcon = Icon.FromHandle(trayBitmap.GetHicon());
tray.DoubleClick += new EventHandler(tray_DoubleClick);
tray.Icon = trayIcon;
trayIcon = null;
tray.Visible = true;
while(true)
{
Application.DoEvents();
}
You could then use something like a Context Menu to add a menu to your tray application and use the double click event to show the form, which would be something like:
Code:
private static void tray_DoubleClick(object sender, EventArgs e)
{
// Fire a new instance main form
Form1 mainForm = new Form1();
mainForm.Show();
// Hide the tray Icon
((NotifyIcon)sender).Visible = false;
}
Re: System Tray Application
When the form first Loads, is there an alternate way of hiding the form, because
Application.DoEvents();
causes unwanted outcome when responding to user events...
this.Hide();
doesn't work, so
How else can i just hide the form from the users eyes???