Always send this message after you add a new item. You can always replace "CountGadgetItems(#MyGadget)" with the exact number you want the list to scroll to if you wish.
Very low priority and as much out of curiosity as anything else:
Some progs (winZip, smartFTP for eg) somehow know the icons that are associated with files they display. How do they do this?
Things like (winapi) "ExtractAssociatedIcon" function seem to expect the icon is in the file. So data files like .txt, .html, .doc would need finding association and then finding icons. I am guessing.
Is there some smart api function that says "AHA! For this file type use this icon!" or even "AHA! This file is associated with this exe."
If OpenWindow(0, 0, 0, 300, 300, #PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget, "Small associated icon")
If CreateGadgetList(WindowID())
file$ = "C:\WINDOWS\win.ini"
; This is the AHA! API function ;) uncomment the last flag to retrieve the small icon
SHGetFileInfo_(file$, 0, @sh.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_TYPENAME|#SHGFI_SHELLICONSIZE|#SHGFI_SYSICONINDEX|#SHGFI_DISPLAYNAME|#SHGFI_ICON);|#SHGFI_SMALLICON)
ImageGadget(0, 0, 0, 64, 64, sh\hIcon)
Repeat:Until WaitWindowEvent()=#PB_EventCloseWindow
EndIf
EndIf
End
Note that this function is quite slow.
So if you are retrieving the icons for many files you should add some sort
of caching of known file extensions to speed things up.
After i added a cache to the Explorer gadgets, the displaying of large
directories became almost 5x faster, so this really is a bottleneck.
This code works great if I want to show the associated Icon in a ListView.
My Problem is, that I havn´t a file on a disk. I want to get the Associated Icon not from a real existing file but from the fileextension.