Display a grayed or ghosted icon for hidden files or folders in a menu
Posted: 19 Dec 2017, 15:03
Hi folks,
I am curious to know if it's possible to modify the script below (from the ImageHandles page) to display a grayed or ghosted icon for hidden files or folders in the resulting menu. I played around with the SHGetFileInfoW() function and it's parameters but could not find anything obvious.
I would appreciate any hints you may have.
I am curious to know if it's possible to modify the script below (from the ImageHandles page) to display a grayed or ghosted icon for hidden files or folders in the resulting menu. I played around with the SHGetFileInfoW() function and it's parameters but could not find anything obvious.
I would appreciate any hints you may have.
Code: Select all
; Show a menu of the first n files matching a pattern, and their icons.
pattern = %A_ScriptDir%\*
n = 15
; Allocate memory for a SHFILEINFOW struct.
VarSetCapacity(fileinfo, fisize := A_PtrSize + 688)
Loop, Files, %pattern%, FD
{
; Add a menu item for each file.
Menu F, Add, %A_LoopFileName%, donothing
; Get the file's icon.
if DllCall("shell32\SHGetFileInfoW", "wstr", A_LoopFileFullPath
, "uint", 0, "ptr", &fileinfo, "uint", fisize, "uint", 0x100)
{
hicon := NumGet(fileinfo, 0, "ptr")
; Set the menu item's icon.
Menu F, Icon, %A_Index%&, HICON:%hicon%
; Because we used ":" and not ":*", the icon will be automatically
; freed when the program exits or if the menu or item is deleted.
}
}
until A_Index = n
Menu F, Show
donothing:
return