h34
January 13th, 2008, 11:14 AM
I have written a short program that removes "ghost icons" from the system tray (the icons that stick around after a program terminates unexpectedly).. I wanted to add functionality so that it also sets the system tray icons' tooltip z-order to "always on top" (see http://support.microsoft.com/kb/912650) however I have run into a small problem trying to do this.
HWND hShell_TrayWnd = ::FindWindow( _T("Shell_TrayWnd"), NULL );
the statement
::SetWindowPos( hShell_TrayWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
does not seem to do the trick, rather I have to use two calls,
::SetWindowPos( hShell_TrayWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
::SetWindowPos( hShell_TrayWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
and this has an unintended side effect. If a submenu of the start menu (programs, for example) happens to be open when these commands run, the submenu is moved "behind" the main portion of the start menu.
Any ideas how I can get around this?
p.s., this application is intended to run as an idle process, looping every few seconds. this is why its unacceptable to have the start menu flicker when it "does its thing"...
HWND hShell_TrayWnd = ::FindWindow( _T("Shell_TrayWnd"), NULL );
the statement
::SetWindowPos( hShell_TrayWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
does not seem to do the trick, rather I have to use two calls,
::SetWindowPos( hShell_TrayWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
::SetWindowPos( hShell_TrayWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
and this has an unintended side effect. If a submenu of the start menu (programs, for example) happens to be open when these commands run, the submenu is moved "behind" the main portion of the start menu.
Any ideas how I can get around this?
p.s., this application is intended to run as an idle process, looping every few seconds. this is why its unacceptable to have the start menu flicker when it "does its thing"...