Archive: How to refresh the tray area?


How to refresh the tray area?
Hi.
My setup stops and then starts an application that has an icon in the tray area.
The problem is that after the application is stopped the tray icon doesn't automatically disappear from the tray area, so when the application is restarted, I get two icons of the same application, one in the stopped state and the other in the started state.
If I roll the mouse over the "stopped" tray icon it disappears.

How can I refresh the tray area automatically from the NSIS setup so that only the right icon in the right state is present?


i'm not sure how you'd do that but in all honesty with the program isn't removing the tray icon when it's closed then i think there's a bug in that program since it should remove it itself when closed (unless you're forcing the program to close so that it can't call it's normal exit function(s) )

-daz


Indeed i'm forcing the program to close. I am killing it's process and disable it's services.
Nevertheless there should be some API to use to refresh the tray area. Something similar to this:

System::Call 'user32.dll::RedrawWindow(i 0, i 0, i 0, i 0x0085) i .r1'

This one refreshes the desktop.


you might be able to replicate the required Shell_NotifyIcon(..) call for the NIM_DELETE action which the app would be expected to do (ref) though force killing an app is never ideal to do since it can't free up allocated resources, etc like tray icons but each to their own ;)

-daz


Can you give me an example how to do that?


I am still unable to achieve this goal...Anyone with ideas (preferably some example script)? :) Thanks


Well, below some code I was working on... no time to finish it, and it was back then not so important to me to do it by NSIS system calls, I created a plugin (I sadly are not allowed to share that code)

Do a search on MSDN on some API call word and find more info.

If you get it to work via NSIS system calls, please post your solution in the forum.

-------------------------------------
;ABM_ACTIVATE = &H6
;ABM_GETAUTOHIDEBAR = &H7
;ABM_GETSTATE = &H4
;ABM_GETTASKBARPOS = &H5
;ABM_NEW = &H0
;ABM_QUERYPOS = &H2
;ABM_REMOVE = &H1
;ABM_SETAUTOHIDEBAR = &H8
;ABM_SETPOS = &H3
;ABM_WINDOWPOSCHANGED = &H9
;ABN_FULLSCREENAPP = &H2
;ABN_POSCHANGED = &H1
;ABN_STATECHANGE = &H0
;ABN_WINDOWARRANGE = &H3

;WM_USER = &H400
;WM_ACTIVATE = &H6
;WM_WINDOWPOSCHANGED = &H47
;GWL_WNDPROC = (-4)

;!define ABN_POSCHANGED 0x00000001
;Var i
;Function RefreshTrayIcons
; System::Call 'shell32.dll::SHAppBarMessage(i, i, 1, i)'
;PostMessage(HWND_BROADCAST, RegisterWindowMessage(TEXT("TaskbarCreated")), 0, 0);
;FunctionEnd

; !define SHCNE_ASSOCCHANGED 0x08000000
; !define SHCNF_IDLIST 0

; ; By jerome tremblay - april 2003
; System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
; (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
;FunctionEnd