Icon in system tray problem

Hi, I have a program, that when minimised runs in the system tray. Everything appears to work ok, until I quit the program. The icon for the program still sits in the system tray until i move the mouse over it, then it goes. This only happens when i click the quit button in my program which just uses End. If i click on the close button in the top right hand side of the window then the icon disapears straight away.
how can i get the icon to disappear as soon as the program is terminated.

thanks in advance
MICK

mickbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crazymanCommented:
This is a very common problem and i have never seen a decent soloution.
I may be wrong so lets see if any one else can solve this.
0
watyCommented:
Use the code to put in the tray you can find on my web site :

www.geocities.com/researchtriangle/6311
0
watyCommented:
It is very easy to use, I use it for most of my app :)
And no problem :)
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

TimCotteeHead of Software ServicesCommented:
I assume that you have something similar to  
Shell_NotifyIcon NIM_DELETE, nid

in the form_unload event
0
st_steveCommented:
TimCottee is correct but he didn't give you the complete code...here's the complete code..

put this code in FOrm_Unload event

Dim lngRetVal As Long
'return the correct windows handler
lngRetVal = SetWindowLong(lngHwnd, GWL_WNDPROC, lngPrevWndProc)
       
'remove icon
Shell_NotifyIconA NIM_DELETE, nidTray

Of course you have to declare the SetWindowLong API but since you're already writing System Tray applications, I assume you know how to do that.

Let us know.

0
GordonpCommented:
mickb, your problem is your using End to stop your app.

as unloading the form using the x works ok, call

unload <FormName>

before using End.

Gordon
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mickbAuthor Commented:
Thanks gordon that worked a treat, and it was so simple.

thanks again
MICK
0
st_steveCommented:
glad someone solved the question!
0
mickbAuthor Commented:
Yes thanks to everyone who helped. hopefully it may help someone else with a similar problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.