Search terms: ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Search terms: ListIconGadget

Post 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!
@}--`--,-- A rose by any other name ..
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Number 2

Post 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
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Thank you both!

Those solutions did the trick.
:D
@}--`--,-- A rose by any other name ..
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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."

:)
@}--`--,-- A rose by any other name ..
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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
El_Choni
yashaa
User
User
Posts: 19
Joined: Sun Jun 12, 2005 8:19 pm

Re: Search terms: ListIconGadget

Post 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...
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi guys, and thanks!

Man, that AHA function is potent! :)
@}--`--,-- A rose by any other name ..
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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.
quidquid Latine dictum sit altum videtur
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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!
@}--`--,-- A rose by any other name ..
clipper
User
User
Posts: 44
Joined: Fri Aug 29, 2003 7:47 am
Location: Germany

Post 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")
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post 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
clipper
User
User
Posts: 44
Joined: Fri Aug 29, 2003 7:47 am
Location: Germany

Post by clipper »

Great! Thanks a lot for your snippet Bonne_den_kule!

You come from norway! I love your country. :-)
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post 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
Post Reply