 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Phoenix
Joined: 23 Sep 2005 Posts: 40
|
Posted: Fri Feb 22, 2008 12:44 pm Post subject: Getting icons from shortcut. |
|
|
| Code: |
FileGetShortcut, %A_LoopFileFullPath%,,,,, ShortIcon
msgbox, %shorticon%
If (ShortIcon <> "")
{
msgbox, test
IL_Add(ImageListID, ShortIcon,1)
}
|
I am trying to add the icon from a shortcut to an imagelist of a treeview. This code should accomplish this. But no icon is added to the imagelist? Any theories on this? |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 582 Location: MN, USA
|
Posted: Sat Feb 23, 2008 5:27 am Post subject: |
|
|
If the icon used by a shortcut is the same icon used by its target, FileGetShortcut will often return a blank value for OutIcon. To work around this, use the shortcut's target path for its icon when OutIcon is blank. Here's an example.
| Code: | ID := IL_Create()
Gui, Add, TreeView, ImageList%ID%
Loop, %A_StartMenuCommon%\Programs\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, Target,,,,Icon
If !(Icon)
Icon := Target
num := IL_Add(ID, Icon)
TV_Add(A_LoopFileName, 0, "Icon" num)
}
Gui, Show
return
GuiClose:
ExitApp |
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Phoenix
Joined: 23 Sep 2005 Posts: 40
|
Posted: Sat Feb 23, 2008 10:24 am Post subject: |
|
|
The trouble is that the target is C:\WINDOWS\system32\control.exe telephon.cpl,@0,1 so that won't return any valid icon. Instead I have manually chosen an icon for my shortcut and want to add that icon into the imagelist.
| Code: |
SplitPath, A_LoopFileName,,,,Filename
msgbox, %A_LoopFileFullPath%
FileGetShortcut, %A_LoopFileFullPath%,,,,, ShortIcon
msgbox, %shorticon%
If (ShortIcon <> "")
{
msgbox, test
IL_Add(ImageListID, ShortIcon,1)
}
|
The thing is that the msgbox, %shorticon% returns the correct path of the icon which is C:\WINDOWS\system32\telephon.cpl. But it is not added to the imagelist |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 582 Location: MN, USA
|
Posted: Sat Feb 23, 2008 5:40 pm Post subject: |
|
|
Are you sure it's not being added to the ImageList? Try assigning your IL_Add function to a variable (as in my previous example), and then report that variable in a message box to see if it's blank.
| Code: | If (ShortIcon <> "")
{
num := IL_Add(ImageListID, ShortIcon,1)
msgbox,% num
}
|
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|