#Singleinstance, force ILC_COLOR := 0, ILC_COLOR4 := 0x4, ILC_COLOR8 := 0x8, ILC_COLOR16 := 0x10, ILC_COLOR24 := 0x18, ILC_COLOR32 := 0x20 isize := 128 color := ILC_COLOR16 Gui, Add, ListView, w600 h600 Icon HWNDhLV, icon hIml := ImageList_Create(isize, isize, color, 100, 100) LV_SetImageList(hIml) loop, c:\windows\* { hIcon := LoadIcon(A_LoopFileFullPath, 1, isize) ; LR_LOADFROMFILE if !hIcon continue i := ImageList_AddIcon( hIml, hIcon ) LV_Add("Icon" i+1, i " "A_LoopFileName) } Gui, Show, autosize return ListView_SetImageList( hwnd, hIml, iImageList=0) { SendMessage, 0x1000+3, iImageList, hIml, , ahk_id %hwnd% return ErrorLevel } ImageList_Create(cx,cy,flags,cInitial,cGrow){ return DllCall("comctl32.dll\ImageList_Create", "int", cx, "int", cy, "uint", flags, "int", cInitial, "int", cGrow) } ImageList_Add(hIml, hbmImage, hbmMask=""){ return DllCall("comctl32.dll\ImageList_Add", "uint", hIml, "uint",hbmImage, "uint", hbmMask) } ImageList_AddIcon(hIml, hIcon) { return DllCall("comctl32.dll\ImageList_ReplaceIcon", "uint", hIml, "int", -1, "uint", hIcon) } API_ExtractIcon(Icon, Idx=0){ return DllCall("shell32\ExtractIconA", "UInt", 0, "Str", Icon, "UInt",Idx) } API_LoadImage(pPath, uType, cxDesired, cyDesired, fuLoad) { return, DllCall( "LoadImage", "uint", 0, "str", pPath, "uint", uType, "int", cxDesired, "int", cyDesired, "uint", fuLoad) } LoadIcon(Filename, IconNumber, IconSize) { DllCall("PrivateExtractIcons" ,"str",Filename,"int",IconNumber-1,"int",IconSize,"int",IconSize ,"uint*",h_icon,"uint*",0,"uint",1,"uint",0,"int") if !ErrorLevel return h_icon }
![Photo](https://secure.gravatar.com/avatar/26500d78e0b6cd27df08e87dde13dafe?s=100&d=%2F%2Fwww.autohotkey.com%2Fboard%2Fpublic%2Fstyle_images%2Fortem%2Fprofile%2Fdefault_large.png)
Showing large icons/images in Listview
Started by
majkinetor
, Dec 21 2007 11:11 AM
8 replies to this topic
This code shows you how to load icons of arbitrary size in ListView and show them with 32bit color palete. You can tweak isize & color.
#1
-
Posted 21 December 2007 - 11:11 AM
![Showing large icons/images in Listview: post #1](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Works nicely with .ico files but not with .jpg or .gif.
#2
-
Posted 21 December 2007 - 03:08 PM
![Showing large icons/images in Listview: post #2](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Yes.
I beleive the only thing that should be changed is:
ImageList_AddIcon to ImageList_Add and set flag to 0 instad 2...
![Posted Image](https://ahknet.autohotkey.com/~majkinetor/-TEMP/big2.PNG)
Code
I beleive the only thing that should be changed is:
ImageList_AddIcon to ImageList_Add and set flag to 0 instad 2...
Code
#Singleinstance, force ILC_COLOR := 0, ILC_COLOR4 := 0x4, ILC_COLOR8 := 0x8, ILC_COLOR16 := 0x10, ILC_COLOR24 := 0x18, ILC_COLOR32 := 0x20 isize := 200 color := ILC_COLOR32 Gui, Add, ListView, w600 h600 Icon HWNDhLV, icon hIml := ImageList_Create(isize, isize, color, 100, 100) LV_SetImageList(hIml) loop, C:\Windows\*.bmp { hIcon := API_LoadImage(A_LoopFileFullPath, 0, isize, isize, 0x10) ; LR_LOADFROMFILE i := ImageList_Add( hIml, hIcon ) LV_Add("Icon" i+1, i " "A_LoopFileName) } Gui, Show, autosize return ListView_SetImageList( hwnd, hIml, iImageList=0) { SendMessage, 0x1000+3, iImageList, hIml, , ahk_id %hwnd% return ErrorLevel } ImageList_Create(cx,cy,flags,cInitial,cGrow){ return DllCall("comctl32.dll\ImageList_Create", "int", cx, "int", cy, "uint", flags, "int", cInitial, "int", cGrow) } ImageList_Add(hIml, hbmImage, hbmMask=""){ return DllCall("comctl32.dll\ImageList_Add", "uint", hIml, "uint",hbmImage, "uint", hbmMask) } ImageList_AddIcon(hIml, hIcon) { return DllCall("comctl32.dll\ImageList_ReplaceIcon", "uint", hIml, "int", -1, "uint", hIcon) } API_ExtractIcon(Icon, Idx=0){ return DllCall("shell32\ExtractIconA", "UInt", 0, "Str", Icon, "UInt",Idx) } API_LoadImage(pPath, uType, cxDesired, cyDesired, fuLoad) { return, DllCall( "LoadImage", "uint", 0, "str", pPath, "uint", uType, "int", cxDesired, "int", cyDesired, "uint", fuLoad) }
#3
-
Posted 21 December 2007 - 03:29 PM
![Showing large icons/images in Listview: post #3](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Actually, I uploaded new version which doesn't make a difference. New LoadIcon load's everything.
#4
-
Posted 21 December 2007 - 06:17 PM
![Showing large icons/images in Listview: post #4](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
It seems that only bmp, ico and cur can be loaded???
#5
-
Posted 10 April 2009 - 05:26 AM
![Showing large icons/images in Listview: post #5](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
MSDN link
![:(](//www.autohotkey.com/board/public/style_emoticons/default/sad.png)
Can it be replaced by an existing function, when used on such OS? I see the API_ExtractIcon function is not used in your script.
Regardless, it doesn't work in Win9x, since the function has first been implemented in Win2000.You must destroy all icons extracted by PrivateExtractIcons by calling the DestroyIcon function.
![:(](http://www.autohotkey.com/board/public/style_emoticons/default/sad.png)
Can it be replaced by an existing function, when used on such OS? I see the API_ExtractIcon function is not used in your script.
#6
-
Posted 13 April 2009 - 04:57 PM
![Showing large icons/images in Listview: post #6](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Anyone figured out how to fix memory usage for this? I know you need DestroyIcon Function to free memory of items no longer used, but I don't know how to use it in ahk.
My script is sometimes using memory up until 500 MB or more :?
Thanks majkinetor anyway
My script is sometimes using memory up until 500 MB or more :?
Thanks majkinetor anyway
#7
-
Posted 05 May 2011 - 06:17 PM
![Showing large icons/images in Listview: post #7](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
@ Drugwash & Gruffalo
An easy and even better workaround is to use EmptyMem by heresy.
Just call the function below after you load or unload your listviews.
An easy and even better workaround is to use EmptyMem by heresy.
Just call the function below after you load or unload your listviews.
EmptyMem(PID=0){ h := DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", !PID ? DllCall("GetCurrentProcessId") : PID) DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1) DllCall("CloseHandle", "Int", h) }
#8
-
Posted 20 May 2011 - 09:00 AM
![Showing large icons/images in Listview: post #8](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I am using this script to display thumbnails for a small gallery.
I noticed when I resize the listview size the list of images do not adjust to match the new size of the listview. Is this script somehow getting the listview hieght and then fitting the images into the listview size?
#9
-
Posted 09 May 2014 - 02:10 PM
![Showing large icons/images in Listview: post #9](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)