Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by RASHAD »

Tested with PB 5.30 x 86 XP SP2 - Windows 7 x86 - Windows 8.1 x64
- Use any size more than 32
- Do not delete IconCache.db in windows 8.1

Code: Select all

Procedure Resizewindow_EX()
  ResizeWindow(0,#PB_Ignore,#PB_Ignore,WindowWidth(0), WindowHeight(0)) 
  ResizeGadget(0,#PB_Ignore,#PB_Ignore,#PB_Ignore, WindowHeight(0)-20)
  ResizeGadget(1,#PB_Ignore,#PB_Ignore,WindowWidth(0)-230,WindowHeight(0)-20)
   ResizeGadget(2,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0)-20)
EndProcedure
 
 OpenLibrary(0,"Shell32.dll")
*FileIconInit = GetFunctionEntry(0,660)
*SystemGetIL = GetFunctionEntry(0,71)
If CallFunctionFast(*FileIconInit,1)
      CallFunctionFast(*SystemGetIL,@LargeIL,@SmallIL)
EndIf
Count = ImageList_GetImageCount_(LargeIL) - 1
newLargeIL = ImageList_Create_(64,64,#ILC_COLOR32| #ILC_MASK, 0, Count)
Icon_0 = ImageList_GetIcon_(LargeIL,0,#ILD_NORMAL)
    For x = 0 To Count
         If ImageList_GetIcon_(LargeIL,x,#ILD_NORMAL) = 0
             ImageList_AddIcon_(newLargeIL,ImageList_GetIcon_(LargeIL,0, #ILD_NORMAL))
         Else
             ImageList_AddIcon_(newLargeIL,ImageList_GetIcon_(LargeIL,x, #ILD_NORMAL))
         EndIf 
    Next
     
If OpenWindow(0,0,0,600,400,"Large Image List",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_SizeGadget)
    ExplorerTreeGadget(0, 0,0,0,0, "*.*") 
    ExplorerListGadget(1,0,0,0,0, "*.*",#PB_Explorer_NoFolders |#LVS_SHAREIMAGELISTS)
    SplitterGadget(2, 10, 10, 580, 380, 0,1, #PB_Splitter_Vertical|#PB_Splitter_Separator)
    SetGadgetState(2,180)

    SendMessage_(GadgetID(1),#LVM_SETVIEW,#LV_VIEW_ICON,0)
    SendMessage_(GadgetID(1),#LVM_SETIMAGELIST,#LVSIL_NORMAL, newLargeIL)
   
    BindEvent(#PB_Event_SizeWindow,@Resizewindow_EX())
Repeat
      Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
                  ImageList_Destroy_(newLargeIL)
                  Quit = 1
                 
          Case #PB_Event_Gadget
                Select EventGadget()
                  Case 0                         
                          Select EventType()
                             Case #PB_EventType_Change
                                      SetGadgetText(1,"*.*")
                                      Text$ = GetGadgetText(0)
                                      SetGadgetText(1,Text$)
                          EndSelect
                   
                  Case 1
                    Select EventType()
                              Case #PB_EventType_LeftDoubleClick
                                       ShellExecute_(0,"open",GetGadgetText(1)+GetGadgetItemText(1, GetGadgetState(1) ,0),0,0,1)
                              EndSelect
          EndSelect
      EndSelect
Until Quit = 1
If IsLibrary(0)
    CloseLibrary(0)
EndIf
EndIf
Edit :More enhancement
Edit 2:More enhancement
Edit 3:Modified
Last edited by RASHAD on Mon Oct 06, 2014 5:03 pm, edited 4 times in total.
Egypt my love
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: ExplorerList Gadget with Large Icons [Windows]

Post by electrochrisso »

Hi Rashad, I try your code but quite a few of the large icons do not display with various extensions like xlsx, docx, ods, ini, exe, mov, wav, sys, bat etc. They display as small icons on the left hand side though.
PureBasic! Purely the best 8)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: ExplorerList Gadget with Large Icons [Windows]

Post by RASHAD »

Hi electrochrisso
Previous post updated
Check and report
Egypt my love
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by RASHAD »

Ver 2.0
Looks exactly like the original (I guess so) :P
New approach
Have fun

Code: Select all

Icon_WH = 48
Icon_NO = 1024

Procedure Resizewindow_EX()
  ResizeWindow(0,#PB_Ignore,#PB_Ignore,WindowWidth(0), WindowHeight(0))
  ResizeGadget(10,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0)-50) 
  ;ResizeGadget(0,#PB_Ignore,#PB_Ignore,#PB_Ignore, WindowHeight(0)-50)
  ;ResizeGadget(1,#PB_Ignore,#PB_Ignore,WindowWidth(0)-230,WindowHeight(0)-50)
  ResizeGadget(2,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0)-50)
  ResizeGadget(3,#PB_Ignore,WindowHeight(0)-30,#PB_Ignore,#PB_Ignore)
EndProcedure

  If OpenWindow(0,0,0,600,400,"Large Image List",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_SizeGadget |#PB_Window_Invisible)
    SetWindowColor(0,$AAAAAB)
    ContainerGadget(10, 10, 10, 580, 350, #PB_Container_Raised)
        ExplorerTreeGadget(0, 0,0,0,0, "*.*",#PB_Explorer_NoFiles)
        SetGadgetColor(0, #PB_Gadget_BackColor, $D2D2D2)
        ExplorerListGadget(1, 0,0,0,0, "",#PB_Explorer_NoFolders|#PB_Explorer_NoParentFolder)
        SetGadgetColor(1, #PB_Gadget_BackColor, $EFEFEF)
        SplitterGadget(2, 0, 0, 580, 350, 0,1, #PB_Splitter_Vertical|#PB_Splitter_Separator)
        SetGadgetState(2,160)
    CloseGadgetList()
    ButtonGadget(3,10,370,80,22,"Change IL")
    
  SendMessage_(GadgetID(1),#LVM_SETVIEW,#LV_VIEW_ICON,0)
  IL = SendMessage_(GadgetID(1),#LVM_GETIMAGELIST,#LVSIL_NORMAL, 0)
  Large_IL = ImageList_Create_(Icon_WH,Icon_WH,#ILC_COLOR32|#ILC_MASK, 0, Icon_NO)  
  CreateImage(0,Icon_WH,Icon_WH,24)     
  Icon.ICONINFO 
  Icon\fIcon = 1
  Icon\hbmMask = ImageID(0) 
  Icon\hbmColor = ImageID(0) 
  Dummy_icon = CreateIconIndirect_(Icon) 
  For x = 0 To Icon_NO
        ImageList_AddIcon_( Large_IL,Dummy_icon)
  Next
  SetGadgetText(1,GetGadgetText(0))
  For x = 0 To CountGadgetItems(1)-1
         SHGetFileInfo_(GetGadgetText(0) +GetGadgetItemText(1, x ,0),0,fi.SHFILEINFO,SizeOf(fi),#SHGFI_ICON)
        ImageList_ReplaceIcon_( Large_IL,fi\iIcon,fi\hIcon)
  Next
   SendMessage_(GadgetID(1),#LVM_SETIMAGELIST,#LVSIL_NORMAL, Large_IL)
   HideWindow(0,0)   
   BindEvent(#PB_Event_SizeWindow,@Resizewindow_EX()) 
  Repeat 
      Select WaitWindowEvent() 
          Case #PB_Event_CloseWindow 
                  ImageList_Destroy_(Large_IL) 
                  Quit = 1
                  
          Case #PB_Event_Gadget 
                Select EventGadget() 
                  Case 0
                          Select EventType()
                             Case #PB_EventType_Change
                               SetGadgetText(1,GetGadgetText(0))
                               For x = 0 To CountGadgetItems(1)-1
                                      SHGetFileInfo_(GetGadgetText(0) + GetGadgetItemText(1, x ,0),0,fi.SHFILEINFO,SizeOf(fi),#SHGFI_ICON)
                                      ImageList_ReplaceIcon_( Large_IL,fi\iIcon,fi\hIcon)
                               Next
                                      
                          EndSelect 
                    
                  Case 1
                    Select EventType()
                              Case #PB_EventType_LeftDoubleClick 
                                     ShellExecute_(0,"open",GetGadgetText(1)+GetGadgetItemText(1, GetGadgetState(1) ,0),0,0,1) 
                              EndSelect 
                              
                  Case 3
                         Run ! 1
                         If Run = 1
                            SendMessage_(GadgetID(1),#LVM_SETIMAGELIST,#LVSIL_NORMAL,IL)
                         Else
                            SendMessage_(GadgetID(1),#LVM_SETIMAGELIST,#LVSIL_NORMAL, Large_IL)
                         EndIf   
          EndSelect 
      EndSelect
  Until Quit = 1 
  EndIf 
  
Edit :Modified to not depend on IconCache.db (Windows 8.1)
Edit 2:Modified for speed and appearance
Last edited by RASHAD on Tue Oct 07, 2014 8:15 pm, edited 2 times in total.
Egypt my love
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by IdeasVacuum »

...v2 doesn't show image or exe icons? v1 does......
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by RASHAD »

Sorry IV
Previous post updated

Tested with Windows 8.1,Windows 7 & Windows XP
Works fine NOW
Egypt my love
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by IdeasVacuum »

No need to be sorry Rashad! I don't actually need the functionality, but I always read your posts because there is always something of value to learn from them.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by electrochrisso »

8) RASHAD you fixed it, I will need to test on 8.1 to be sure, good work. :)
PureBasic! Purely the best 8)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by RASHAD »

With speedy compact flexible tool like PB you can test what you have in your mind in no time
Thanks TEAM

Ver 2.0 snippet post modified again
Egypt my love
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by electrochrisso »

RASHAD wrote:With speedy compact flexible tool like PB you can test what you have in your mind in no time
Thanks TEAM

Ver 2.0 snippet post modified again
I agree, PB is so logical you can be laying in bed and think about the code to be written or modified in your mind, get up the next morning and type it in. :)
PureBasic! Purely the best 8)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Ver 2.0 :ExplorerList Gadget with Large Icons [Windows]

Post by IdeasVacuum »

I agree, PB is so logical you can be laying in bed and think about the code to be written or modified in your mind, get up the next morning and type it in.
:mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply