Page 1 of 1

Search terms: ListIconGadget

Posted: Wed Jun 29, 2005 1:15 am
by Dare2
I need some help with search terms. :oops:

I would like to do 3 things with the ListIconGadget:

1: Remove the column headers.
2: Ensure the list always shows the last items added ( stays scrolled to bottom)
3: Colour a column background.

There are sure to be code snippets for this but my searches are not getting good results.

So any terms? Or any links? Or even any code? :)

Thanks!

Number 2

Posted: Wed Jun 29, 2005 2:21 am
by Fangbeast
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.

Code: Select all

SendMessage_(GadgetID(#MyGadget), #LVM_ENSUREVISIBLE, CountGadgetItems(#MyGadget) -1, 0) ; Make sure the last line is always visible

Posted: Wed Jun 29, 2005 2:41 am
by freak
To remove the column header, include this constant in the flags when creating the gadget:

Code: Select all

#LVS_NOCOLUMNHEADER
As for the colors, this one might be a good start:
http://www.purearea.net/pb/CodeArchiv/G ... Colored.pb

Posted: Wed Jun 29, 2005 3:19 am
by Dare2
Thank you both!

Those solutions did the trick.
:D

Posted: Wed Jun 29, 2005 4:10 am
by Dare2
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."

:)

Posted: Wed Jun 29, 2005 10:29 am
by El_Choni

Code: Select all

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

Re: Search terms: ListIconGadget

Posted: Wed Jun 29, 2005 11:00 am
by yashaa
Dare2 wrote: 3: Colour a column background.
See this thread :
viewtopic.php?t=12892

for a great and easy to use userlibrary.

Would be nice this stuff to be cross compatible with the other sistems too...

Posted: Wed Jun 29, 2005 12:19 pm
by Dare2
Hi guys, and thanks!

Man, that AHA function is potent! :)

Posted: Wed Jun 29, 2005 12:26 pm
by freak
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.

Posted: Wed Jun 29, 2005 12:35 pm
by Dare2
Hi Freak,

Thanks. Just noticed that and started a simple cache-ing.


OT a bit:

Some days everything just falls into place, both brain cells are firing, and the feeling gooooood!

And then on some days .. on those days it is TG for these forums and the good feeling persists.

Today was one of the latter.

Thanks everyone!

Posted: Wed Aug 16, 2006 8:48 am
by clipper
SHGetFileInfo_(file$, 0, @sh.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_TYPENAME|#SHGFI_SHELLICONSIZE|#SHGFI_SYSICONINDEX|#SHGFI_DISPLAYNAME|#SHGFI_ICON);|#SHGFI_SMALLICON)
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.

ImageID=GetAssocIcon("*.pdf")

Posted: Wed Aug 16, 2006 9:08 am
by Bonne_den_kule
The file can be dummy.txt, you don't need any path

Code: Select all

Enumeration
  #TypeFile
  #TypeFolder
  #TypeDrive
  #TypeRemovable
EndEnumeration

Procedure GetDefaultIcon(File.s, Type.l)
  Select Type
    Case #TypeFile 
      Define shInfo.SHFILEINFO, FileType.s="."+GetExtensionPart(File)
      SHGetFileInfo_(@FileType,#FILE_ATTRIBUTE_NORMAL,@shInfo,SizeOf(SHFILEINFO),#SHGFI_USEFILEATTRIBUTES|#SHGFI_ICON|#SHGFI_SMALLICON) 
      ProcedureReturn shInfo\hIcon
      
    Case #TypeFolder, #TypeDrive, #TypeRemovable
      Define WindowsDir.s=Space(#MAX_PATH)
      GetWindowsDirectory_(@WindowsDir, #MAX_PATH+1)
      WindowsDir=Trim(WindowsDir)
      If Right(WindowsDir, 1)<>"\"
        WindowsDir+"\"
      EndIf
      Select Type
        Case #TypeFolder
          ProcedureReturn ExtractIcon_(GetModuleHandle_(0), WindowsDir+"system32\shell32.dll", 3)
        Case #TypeDrive
          ProcedureReturn ExtractIcon_(GetModuleHandle_(0), WindowsDir+"system32\shell32.dll", 8)
        Case #TypeRemovable
          ProcedureReturn ExtractIcon_(GetModuleHandle_(0), WindowsDir+"system32\shell32.dll", 7)
      EndSelect
  EndSelect

Posted: Wed Aug 16, 2006 11:27 am
by clipper
Great! Thanks a lot for your snippet Bonne_den_kule!

You come from norway! I love your country. :-)

Posted: Wed Aug 16, 2006 1:58 pm
by Bonne_den_kule
clipper wrote:Great! Thanks a lot for your snippet Bonne_den_kule!

You come from norway! I love your country. :-)
Thanks