ExplorerListGadgets and actioning items

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

ExplorerListGadgets and actioning items

Post by BarryG »

Is there a way to make ExplorerListGadgets react to actions like double-clicking a file to open it, or pressing F2 on a file to rename it, pressing Del to delete a file, dragging a file from one gadget to another to move it, etc? Or do I have to code all these actions manually? That's what I'm currently doing, but it feels like I'm basically writing a file manager app when I didn't really intend to, or even want to. Surely the OS itself can do these actions when the user interacts on the files/folders in the gadget?
Last edited by BarryG on Sun Jun 20, 2021 1:14 pm, edited 2 times in total.
User avatar
mk-soft
Addict
Addict
Posts: 3110
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ExplorerListGadgets and actioning items

Post by mk-soft »

The ExplorerListGadget is only an output (The same as the ListIconGadget).
All actions must be programmed by the user.
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4038
Joined: Sun Apr 12, 2009 6:27 am

Re: ExplorerListGadgets and actioning items

Post by RASHAD »

You are a Windows user so it's easy to do it in one piece of code
Just SubClass your ExplorerList
Egypt my love
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

mk-soft wrote: Sat Jun 19, 2021 1:08 pmAll actions must be programmed by the user.
But there's so many: mouse clicks, mouse drags, Enter key pressed, Alt+Enter keys pressed, F2 pressed, Ctrl+C, Ctrl+V, etc.
RASHAD wrote: Sat Jun 19, 2021 2:28 pmJust SubClass your ExplorerList
Just to be clear: do you mean I still need to code all possible actions in a subclass procedure? That's what I want to totally avoid, if at all possible, because of all the actions mentioned above (plus more).
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4038
Joined: Sun Apr 12, 2009 6:27 am

Re: ExplorerListGadgets and actioning items

Post by RASHAD »

Yes :)
But it will be very easy and much fun
Next is an example every mouse click is supported ,every keyboard click is supported
Also [Non English Keyboard is supported]
Do your homework Barry then posted here for the benefit of all of us :D

Code: Select all

Global oldCallback

Procedure ExpList(hwnd, uMsg, wParam, lParam)
  Select uMsg
    Case #WM_LBUTTONDOWN
      Debug "LB Down"
    
    Case #WM_LBUTTONDBLCLK
      Debug "DblLB Down"
    
    Case #WM_RBUTTONDOWN
      Debug "RB Down"
    
    Case #WM_CHAR                                        ;Char & Ctrl + Char
        Debug Chr(wParam) 

    Case #WM_KEYUP                                        ;F1.....F12
        Debug "#KEYUP:   " + Str(wParam) 

    Case #WM_SYSKEYUP 
        Debug "#SYSKEYUP:   " + Str(wParam)
        
    Case #WM_SYSCHAR                                      ;Alt + Char                                         
        Debug "#SYSCHAR:   " + Str(wParam) 
             
   EndSelect
   
  ProcedureReturn CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
EndProcedure

If OpenWindow(0, 0, 0, 800, 400, "ExplorerListGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 ExplorerListGadget(0, 10, 10, 760, 360, "*.*", #PB_Explorer_MultiSelect)
 oldCallback = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @ExpList())
 
   Repeat
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 0
             Select EventType() 
             EndSelect
         EndSelect       
     EndSelect
   Until Event = #PB_Event_CloseWindow
EndIf
End 
Egypt my love
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

Hi Rashad. What you've posted is pretty much what I'm already doing, and it's what I wanted to avoid. Like, I check for an F2 keypress on a file but then I have to use InputRequester() to ask for the new filename, instead of the user directly typing the new name in the gadget (the Windows way). Things like that are what I was hoping the gadget could do (instead of InputRequester), by sending the file op message to the OS instead to handle it. But it appears not possible.
User avatar
mk-soft
Addict
Addict
Posts: 3110
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ExplorerListGadgets and actioning items

Post by mk-soft »

With API you can make the columns editable. This was done a long time ago and is a little more time-consuming because you have to evaluate the event end edit (callback).
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
firace
Enthusiast
Enthusiast
Posts: 698
Joined: Wed Nov 09, 2011 8:58 am

Re: ExplorerListGadgets and actioning items

Post by firace »

A nice, little-known trick is to simply use the below. Of course you will still have to implement some details, but the great thing is that you do get all the default actions and drag & drop implemented for free.

Code: Select all

OpenWindow(12, 100, 100, 530, 510, "")

ExplorerComboGadget(11, 0, 0, WindowWidth(12) - 20, 22,             "C:\")  
WebGadget(10, 0, 25,          WindowWidth(12)-20, WindowHeight(12), "C:\") 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 

Here you can test drag and drop between 2 gadgets:

Code: Select all

OpenWindow(12, 100, 100, 730, 510, "")

ExplorerComboGadget(11, 0,0                   , WindowWidth(12)/2-20, 22, "C:\")
ExplorerComboGadget(21, WindowWidth(12)/2+10,0, WindowWidth(12)/2-20, 22, "D:\")
WebGadget(10, 0, 40,                    WindowWidth(12)/2-20, WindowHeight(12), "C:\") 
WebGadget(20, WindowWidth(12)/2+10, 40, WindowWidth(12)/2-20, WindowHeight(12), "D:\") 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

firace just beat me to it, but I just saw the same question that I asked, here:

https://www.vbforums.com/showthread.php ... er-Control

The advice there is to use web controls as well. This is a fantastic solution that only uses two lines of code (two gadgets) to do all the file actions!

Code: Select all

If OpenWindow(0, 200, 200, 790, 500, "File Manager", #PB_Window_SystemMenu)
  WebGadget(1, 10, 10, 380, 480, "C:\")
  WebGadget(2, 400, 10, 380, 480, "C:\Windows\")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I do have one question, though: the WebGadget shows the drive in Thumbnail format, instead of Details. Is there a way to force the view type in the WebGadget? I'd prefer to see Details view all the time, without changing to Details view in Windows Explorer as well.
firace
Enthusiast
Enthusiast
Posts: 698
Joined: Wed Nov 09, 2011 8:58 am

Re: ExplorerListGadgets and actioning items

Post by firace »

BarryG wrote: Sun Jun 20, 2021 12:12 pm I do have one question, though: the WebGadget shows the drive in Thumbnail format, instead of Details. Is there a way to force the view type in the WebGadget? I'd prefer to see Details view all the time, without changing to Details view in Windows Explorer as well.
This works for me: (based on a solution posted a long time ago by RSBasic if I'm not mistaken)

Code: Select all

OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(1, 0, 0, WindowWidth(0), WindowHeight(0), "C:\")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
            Case #PB_EventType_DownloadEnd
              Handle = FindWindowEx_(GadgetID(1), 0, "Shell Embedding", 0)
              Handle = FindWindowEx_(Handle, 0, "SHELLDLL_DefView", 0)
              Handle = FindWindowEx_(Handle, 0, "SysListView32", 0)
              
              SendMessage_(Handle, #LVM_SETVIEW, #LV_VIEW_DETAILS, 0)
         EndSelect
      EndSelect
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver

BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

firace wrote: Sun Jun 20, 2021 3:51 pmThis works for me: (based on a solution posted a long time ago by RSBasic if I'm not mistaken)
Unfortunately that doesn't work here for me; it results in this when using my D: drive:

Image
firace
Enthusiast
Enthusiast
Posts: 698
Joined: Wed Nov 09, 2011 8:58 am

Re: ExplorerListGadgets and actioning items

Post by firace »

Another example that might work better for you:

Code: Select all

Procedure$ GetParentDirectory(Path$)  ;; by Sicro 
  
  Select Right(Path$, 2)
    Case "./" : ProcedureReturn Path$ + "../"
    Case ".\" : ProcedureReturn Path$ + "..\"
  EndSelect
  
  Select Right(Path$, 3)
    Case "../" : ProcedureReturn Path$ + "../"
    Case "..\" : ProcedureReturn Path$ + "..\"
  EndSelect
  
  Path$ = GetPathPart(Left(Path$, Len(Path$) - 1))
  
  ProcedureReturn Path$
  
EndProcedure

OpenWindow(0, 0, 0, 640, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

WebGadget(1, 0, 50, WindowWidth(0), WindowHeight(0)-50, "C:\")
ButtonGadget(12, WindowWidth(0)-50, 0, 30, 22, "Up")
AddKeyboardShortcut(0, #PB_Shortcut_Back, 123)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Menu
      SetGadgetText(1, GetParentDirectory( GetGadgetText(1)))
      SetFocus_(handle)
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 12
          SetGadgetText(1, GetParentDirectory( GetGadgetText(1)))
          SetFocus_(handle)
        Case 1
          Select EventType()
            Case #PB_EventType_DownloadEnd
              Handle = FindWindowEx_(GadgetID(EventGadget()), 0, "Shell Embedding", 0)
              Handle = FindWindowEx_(Handle, 0, "SHELLDLL_DefView", 0)
              Handle = FindWindowEx_(Handle, 0, "SysListView32", 0)
              
              SendMessage_(Handle, #LVM_SETVIEW, #LV_VIEW_DETAILS, 0)
              SetWindowLongPtr_(Handle, #GWL_STYLE, GetWindowLongPtr_(Handle, #GWL_STYLE) | #LVS_REPORT)
              SendMessage_(Handle, #LVM_SETCOLUMNWIDTH, 0, 170)
              SendMessage_(Handle, #LVM_SETCOLUMNWIDTH, 1, 170)
              SendMessage_(Handle, #LVM_SETCOLUMNWIDTH, 2, 110)
              SendMessage_(Handle, #LVM_SETCOLUMNWIDTH, 3, 110)
              
              SetWindowTitle(0, GetGadgetText(1))
              SetFocus_(handle)
          EndSelect
      EndSelect
    Case #PB_Event_CloseWindow
      End
  EndSelect
Forever
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

Doesn't help, unfortunately. I still get the same folder view as my screenshot above (large icons).

I found this thread with a technique -> https://stackoverflow.com/questions/674 ... in-c-sharp

Can someone have a go at converting it? The animated gif there seems to show that it works. Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4038
Joined: Sun Apr 12, 2009 6:27 am

Re: ExplorerListGadgets and actioning items

Post by RASHAD »

Hi Barry
Maybe you will be lucky this time :)

Code: Select all

OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(1, 0, 0, WindowWidth(0), WindowHeight(0), "C:\")

While WindowEvent():Wend

Repeat
  shellH = FindWindowEx_(GadgetID(1), 0, "Shell Embedding", 0)
  hShellViewWin = FindWindowEx_(shellH, 0, "SHELLDLL_DefView", 0);
Until hShellViewWin <> #Null And shellH <> #Null   
hDesktopListView = FindWindowEx_(hShellViewWin, 0, "SysListView32", 0);

SendMessage_(hDesktopListView, #LVM_SETVIEW, #LV_VIEW_DETAILS, 0)
              
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
         EndSelect
      EndSelect
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver

Egypt my love
BarryG
Addict
Addict
Posts: 1556
Joined: Thu Apr 18, 2019 8:17 am

Re: ExplorerListGadgets and actioning items

Post by BarryG »

Thanks for trying Rashad, but it didn't help. The view is still the same as my screenshot above. I'm thinking I may have to give up on this idea, even though it shouldn't be this hard.

As mentioned, I'm testing all this on my D: drive. When I use C:, it does show Details view. But obviously I need it to work for all drive letters.
Post Reply