Hi Ken,
You may try this way:
1. set the WindowState to minimized;
2. Set ShowInTaskBar to false;
3. handle the corresponding events such as some context menu commands and
the double-
click on the notifyicon. Note you should also check the WindowState
property, since setting
Visible to true will take no effect on a minimized window with
ShowInTaskBar set to false.
here is a simple snippet,
<code>
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
Visible = ! Visible;
if(Visible)
{
if(WindowState == FormWindowState.Minimized)
WindowState = FormWindowState.Normal;
}
}
</code>
Does this answer your question?
Please let me know, if you still have problems on it.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
--------------------
| From: "Ken" <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Subject: Application.run issue
| Date: Fri, 24 Oct 2003 12:30:41 -0400
| Organization: Posted via Supernews,
http://www.supernews.com
| Message-ID: <
[email protected]>
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| X-Complaints-To: (e-mail address removed)
| Lines: 15
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-post-01!supernews.com!corp.sup
ernews.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55194
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have an application that I do NOT want the form to be visible as this
is a
| background application. I set the forms Visible property to false in the
| forms constructor. The application places an icon in the System Tray that
| has a menu to show the form if the user wishes to see it. I'm displaying
| the form by calling Application.Run ( form ). This forces the form to be
| visible. I overrode the OnVisibleChanged event in the form and it is
called
| immedialely after the Application.Run call.
|
| Does anyone know a way to keep the form hidden?
|
| Thanks in advance
|
| Ken
|
|
|