开发者

C# Windows Application Doesnt Show In System Tray Correctly

i am trying to get a c# winforms application to startup only in the system tray but when i use the following commands it shows in the system tray but also shows as a little title bar just above the taskbar on the left hand side above the start button (windows xp)

The funny thing is that it only happens when i run the application outside of visual studio.

Does anyone know what im doing wrong开发者_开发问答?

Constructor or Form_Load....

this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
this.Hide();


Add an event handler for the form's Resize event that will hide the application when it's minimized. That way, it won't appear on the task bar.

private void Form1_Resize(object sender, System.EventArgs e)
{
   if (FormWindowState.Minimized == WindowState)
      Hide();
}


Try this

this.Resize +=new EventHandler(Form1_Resize);
private void Form1_Resize(object sender, EventArgs e)
{
    if (this.WindowState == FormWindowState.Minimized)
    {
        this.Hide();
    }
}


private void ntfIcon_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button==MouseButtons.Left)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Show();
                    this.WindowState = FormWindowState.Normal;
                }
                else
                {
                    this.WindowState = FormWindowState.Minimized;
                    this.Hide();
                }
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜