Hi,
I have an app whcih I want to be 100% tray icon, no pre-launched "main"
form. I don't know how to get rid of my main form. setting it to minimized
and show-taskbar=false doesn't help the ALT-TAB situation.
how do i make sure nothing is EVER visible other than my tray icon?
thanks
Ron
Ron, you don't need a main form at all in a WinForms app. Make a new
WinForms app, delete the form, and try this pseudo-code. You will need
to supply your own icon, menu etc., this won't compile out of the box
but should give you an idea of what is needed.
static class Program {
private static NotifyIcon m_Notify;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// We don't need a form in order to create a notify icon.
m_Notify = new NotifyIcon();
m_Notify.Text = "Click me!";
// Must have an icon else we won't appear.
m_Notify.Icon = Properties.Resources.RonsIconHere;
// Handling a click is easy...
m_Notify.Click += new EventHandler(m_Notify_Click);
// Or a context menu...
//BuildContextMenu();
m_Notify.Visible = true;
// Start the windows message pump. The application will continue
// to run until Windows shuts down or your application is exited
// (you must provide the user with a way to do that).
Application.Run();
}
}