I am trying to use the Shell_NotifyIcon function to change the tray icon's tooltip, much like the Menu, Tray, Tip [, Text] command works. I am running into some difficulties when the text is over 64 characters. The code below illustrates the problem. I suspect the issue is with how I am using the StrPut function below.
Code: Select all
Text := ""
Loop, 100
Text .= Mod(A_Index, 10)
Menu, Tray, Tip, %Text%
MsgBox The tray tooltip should now be 100 characters long
SetTrayTip(A_ScriptHwnd, , Text)
MsgBox The tray tooltip is only 64 characters long. Why?
ExitApp
SetTrayTip(hWnd, uID := 0x404, Text := "") {
NumPut(VarSetCapacity(NID,(A_IsUnicode ? 2 : 1) * 384 + A_PtrSize * 5 + 40, 0), NID, 0, "UInt")
NumPut(hWnd , NID, (A_PtrSize = 8 ? 8 : 4), A_PtrSize ? "Ptr" : "UInt")
NumPut(uID , NID, (A_PtrSize = 8 ? 16 : 8), "UInt")
NumPut(0x4 , NID, (A_PtrSize = 8 ? 20 : 12), "UInt") ; NIF_TIP = 0x4
StrPut(Text, &NID + (A_PtrSize = 8 ? 40 : 24)) ; <<<<<
Return DllCall("shell32\Shell_NotifyIcon" (A_IsUnicode ? "W" : "A"), "UInt", 0x1, "UInt", &NID, "Int") ; NIM_MODIFY = 0x1
}
If you have any insights or advice, I would appreciate it.
Cheers!
-iPhilip