| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
Hello all,
I have quite a strange problem. My program is based on MFC dialog but modeless. It starts hidden and creates a tray icon. The user can exit it in two ways: if the program is visible the user can press the exit button; if the program is not visible the user can right click on the tray icon and press exit. Both of these message handle routines call CWnd: estryWindow which calls my OnDestroy which calls Shell_NotifyIcon( NIM_DELETE, ... ). On XP and 7 everything works fine but on Vista when the app is exiting through the tray icon message handler the call to Shell_NotifyIcon( NIM_DELETE, ... ) returns FALSE with GetLastError() returning 0. The result is that the icon does not disappear with the exiting of the app but only when the tray bar is refreshed (the mouse goes over it).Any ideas will be highly appreciated. |
|
#2
|
|||
|
|||
|
Re: Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
I don't know about vista, but typically in a tray app, I use PostQuitMessage(); rather than DestroyWindow().
|
|
#3
|
||||
|
||||
|
Re: Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
Quote:
__________________
Victor Nijegorodov
|
|
#4
|
|||
|
|||
|
Re: Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
Why not? Beats me. I just looked at some working code and I used PostQuitMessage() in that case.
|
|
#5
|
|||
|
|||
|
Re: Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
To my opinion it really doesn't matter which route you take to exit the app. CWnd :: DestryWindow eventually calls PostQuitMessage which generates WM_QUIT message and the app exits. With modeless dialogs we should not call EndDialog. WM_CLOSE message is sent even before and it calls DestroyWindow. So, this is really not the issue.
|
|
#6
|
||||
|
||||
|
Re: Shell_NotifyIcon( NIM_DELETE, ... ) fails on app exit
I don't know about Vista, but I have discovered (back with W2K) that the Message Loop needs to still be going for the Shell_NotifyIcon() calls to work. Make sure you are calling it early enough before the ExitInstance().
-Erik |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|