Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm using NotifyIcon for my application to be shown in system tray.

However when it starts the app's tray comes out 1 ~ 3 tray.

More than 1 tray comes out on system tray --> it's problem.

But, When I mouse over on system tray only one tray of my app remains.

And when I terminats the app, the tray doesn't disappear until I put mouse on the system tray.

I think it's refresh problem. Why this happens with .NET NotifyIcon?

All other applications on my comp doesn't give this problem.

Is there a way fix this problem?

 

PS: I'm using Win2000.

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

  • Leaders
Posted

when closing your application down , set the NotifyIcon's Icon to Nothing. eg:

'/// in your closing sub...
With NotifyIcon1
   .Icon = Nothing
   .Dispose()
End With

you can also set the Visible property to False if needed.

Posted

Thank you for reply.

I'm adding my solution..

mnuExit is menu item in ContextMenu in NotifyIcon.

 

One tip I found is:

You should call Application.Exit() before

this.notifyIcon.Icon = null;

this.notifyIcon.Dispose();

Otherwise your application process will not be terminated!!

private void mnuExit_Click(object sender, System.EventArgs e)
	{
		if(MessageBox.Show(null, "Do you want to close all service and exit?", "Confirmation", 
			MessageBoxButtons.YesNo) == DialogResult.Yes)
		{
			this.StartStopAllServices(false);

			Application.Exit();
			this.notifyIcon.Visible=false;
			this.notifyIcon.Icon = null;
			this.notifyIcon.Dispose();
		}
	}

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

Posted

I'm not that experienced, but I don't understand why your system tray icon doesn't disappear when your form closes.

 

This code:

Application.Exit();
this.notifyIcon.Visible=false;
this.notifyIcon.Icon = null;
this.notifyIcon.Dispose();

doesn't make any sense I think, because first you exit the application and then you try to hide the icon... ???

 

When my system tray icon doesn't go away, i always place

this.notifyIcon.Visible = false;
this.notifyIcon.Dispose();

in the Closing event of the form.

 

Dennis

Anon - "If you can't beat your computer at chess, try kickboxing."

 

homepage: http://www.givemehelp.co.uk/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...