03-15-2012, 06:51 PM
Function EnumTrayIcons
I welcome any comments and/or upgrading instructions
;/
function hwnd ARRAY(TRAYICON)&a
;Gets tray icon data for all icons. The data contains button id, tooltips and visible/hidden state.
;hwnd - tray toolbar control handle or 0.
;EXAMPLE
;out
;type TRAYICON str'tooltip !hidden idCommand
;ARRAY(TRAYICON) a
;EnumTrayIcons 0 a
;int i
;for i 0 a.len
,;if(!a[i].hidden)
,,;out a[i].tooltip
,,
;2nd example
;out
;type TRAYICON str'tooltip !hidden idCommand
;ARRAY(TRAYICON) a
;EnumTrayIcons 0 a
;int i
;for i 0 a.len
,;out "%i - %i - %i - %s" i a[i].hidden a[i].idCommand a[i].tooltip
a.redim
if(!hwnd) hwnd=child("" "ToolbarWindow32" "+Shell_TrayWnd" 0x1)
int i n=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
if(!n) ret
__ProcessMemory m.Alloc(hwnd 1000)
TBBUTTON b
str s
for i 0 n
,if(!SendMessage(hwnd TB_GETBUTTON i m.address)) continue
,m.Read(&b sizeof(b))
,int t=SendMessage(hwnd TB_GETBUTTONTEXTW b.idCommand m.address+100)
,if(t<=0) continue
,TRAYICON& ti=a[]
,m.ReadStr(s t*2 100 1)
,ti.tooltip=s
,ti.idCommand=b.idCommand
,ti.hidden=b.fsState&TBSTATE_HIDDEN!0I welcome any comments and/or upgrading instructions
