Posts: 1,058
Threads: 367
Joined: Oct 2007
There exist cases than I get the following run-time error in EnumTrayIcons:
Error (RT) in "EnumTrayIcons /522"oEnumTrayIcons: cannot get shared memory address
After executing : TBBUTTON* be=share(hwnd)
I would appreciate any suggenstions
Regards
Posts: 12,086
Threads: 142
Joined: Dec 2002
NOTE: Look for updated function in
EnumTrayIcons Error
or
Collected QM apps, functions, samples
Did you notice some specific conditions when it happens? For example, only when computer is busy, or only when some program is running.
Is it on Vista? If yes, is QM running as User (Options -> General).
How if you replace EnumTrayIcons code to this:
Function EnumTrayIcons
;/
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
a.redim
if(!hwnd) hwnd=child("" "ToolbarWindow32" "+Shell_TrayWnd" 0x1)
int i n=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
if(!n) ret
TBBUTTON* bq=share
for i 0 1000
,TBBUTTON* be=share(hwnd)
,err if(i=999) end ES_FAILED; else 0.01; continue
,break
word* tq=bq+sizeof(TBBUTTON)
word* te=be+sizeof(TBBUTTON)
for i 0 n
,if(!SendMessage(hwnd TB_GETBUTTON i be)) continue
,if(SendMessage(hwnd TB_GETBUTTONTEXTW bq.idCommand te)<0) continue
,TRAYICON& ti=a[]
,ti.tooltip.ansi(tq)
,ti.hidden=bq.fsState&TBSTATE_HIDDEN!0
,ti.idCommand=bq.idCommand
Posts: 1,058
Threads: 367
Joined: Oct 2007
Thanks for this reply. I will try the suggested code and I will let you know accordingly.
Concerning the conditions requested :
1. It is not Vista, but XP-SP2
2. Yes, it happens when the computer is rather busy.
Posts: 1,058
Threads: 367
Joined: Oct 2007
3. The code proposed worked, but with an increased delay (0.05).
Posts: 12,086
Threads: 142
Joined: Dec 2002
Thank you, it will help me to find and fix this bug in share().
Posts: 1,058
Threads: 367
Joined: Oct 2007
Function EnumTrayIcons
;/
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!0
I welcome any comments and/or upgrading instructions
Posts: 26
Threads: 3
Joined: Apr 2011
Hello,
For me, it works well for the icons visible, but dont shows me the icons hidden!
Tried both examples, but no sucess.
Im using windows 7 64bits.
Any advice?
Posts: 12,086
Threads: 142
Joined: Dec 2002
Windows 7 shows hidden icons in a separate temporary window. This function cannot get them.
Posts: 26
Threads: 3
Joined: Apr 2011
OK.
I will explain my ideia and ask some help on this.
The final file is a generated exe.
At run time, i add a tray icon using 'AddTrayIcon' function to know that the program is running.
In a regular way, i want to show some messages using the ballon tooltip, pointing to the icon created by the exe.
It works ok if the icon is visible, but if the icon is hidden, the code to show the ballon, fails because dont find the icon.
i tried to 'force' the icon to show before send the message, using 'HideTrayIcon "dialog name" 0 ', but it seams its not working either!!
Any ideas?
Posts: 12,086
Threads: 142
Joined: Dec 2002
When fails to find icon, handle the error and show balloon above clock.
Posts: 26
Threads: 3
Joined: Apr 2011
Thanks.
I did it pointing to the arrow that you click when you want to view all the tray icons
|