Is there any way I can use VB to hide a specific system tray icon? I found this API code that will hide the whole collection of tray icons, but I can't seem to figure out how to pull a single icon out of this so I can hide it.
Public Function HideTaskBarIcons()
Dim FindClass As Long, Handle As Long
FindClass& = FindWindow("Shell_TrayWnd"
Handle& = FindWindowEx(FindClass&, 0, "TrayNotifyWnd", vbNullString)
ShowWindow Handle&, 0
I also found this code that I think I can modify to do what I want, but I haven't figured out how exactly to get the buttons to hide. I had to modify the API calls like this to get the list to work:
hWndTray = FindWindow("Shell_TrayWnd"
hWndTray2 = FindWindowEx(hWndTray, 0, "TrayNotifyWnd", vbNullString)
hWndTray3 = FindWindowEx(hWndTray2, 0, "SysPager", vbNullString)
hWndToolBar = FindWindowEx(hWndTray3, 0, "ToolbarWindow32", vbNullString)
I tried adding a For..Next loop to go through all the buttons, it finds the button I want to hide, but I haven't figured out how exactly to hide it. Either that, or the system tray needs to be refreshed or something after it's hidden.
Dim Ob As IAccessible
ByVal hWndToolBar, OBJID_CLIENT, UID1, Ob
For iBtnIndex = 0 To iTrayButtonsCount
If Ob.accName(Av(iBtnIndex)) = "PeerGuardian" Then
SendMessage hWndToolBar&, TB_HIDEBUTTON, iBtnIndex, 0
SendMessage hWndToolBar&, TB_SAVERESTOREA, True, vbNull