Question about ExplorerListGadget Column Functions

Just starting out? Need help? Post your questions and find answers here.
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Question about ExplorerListGadget Column Functions

Post by offsides »

I'm not sure if "functions" is the right word but here's my problem/question:

The ExplorerListGadget()'s custom columns only seem to treat files as "files" and "directories" if the file listing appears in column 0. When that's the case (left side, below), you can navigate around by double clicking on a file, dir or "..", etc. If the file listing occurs in column 1 or higher, it no longer works that way.

I would like to have a narrow column to the left of file/dir names for info tags while being able to navigate the Explorer in the conventional way.

Here's a simple demo. I hope I'm missing something (again).
Thanks for any help.
Bill

Code: Select all

ExpFlags = #PB_Explorer_FullRowSelect|#PB_Explorer_AlwaysShowSelection
Dir$ = "c:\*.*"

OpenWindow(0,0,0,500,400,"", #PB_Window_ScreenCentered| #PB_Window_SystemMenu)

ExplorerListGadget(1, 10, 10, 200, 300, Dir$, ExpFlags)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
SetGadgetItemAttribute(1, 0, #PB_Explorer_ColumnWidth , 180 , 0)
; --------------------------------------------------

ExplorerListGadget(2, 250, 10, 230, 300, Dir$, ExpFlags )
RemoveGadgetColumn(2, 1)
RemoveGadgetColumn(2, 1)
RemoveGadgetColumn(2, 1)
RemoveGadgetColumn(2, 0)

AddGadgetColumn(2, 0, "x", 30) 
AddGadgetColumn(2, 1, #PB_Explorer_Name, 180) 

SetGadgetText(2, Dir$)

; --- A "just for example" item in column 0 ----------
SetGadgetItemText(2, 5, "X", 0)
; --------------------------------------------------

Repeat
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
          ; =================                  
        Case 2
          
          ; --- ? ---
          
      EndSelect
  EndSelect
   
Until event = #PB_Event_CloseWindow
PB 5.72 (32-bit) on Win 10.
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: Question about ExplorerListGadget Column Functions

Post by offsides »

If the deafening silence is due to fact I didn't actually ask a question (:D ), here it is:

The PB docs state that "the 'Name' column doesn't need to be the first one in the gadget". But when it isn't, you can't navigate the listing in the accepted way.

AddGadgetColumn(2, 0, #PB_Explorer_Name, 180) produces a listing in which you can do all the things Explorer is supposed to do.
AddGadgetColumn(2, 1, #PB_Explorer_Name, 180) does not.

What am I missing? I'm stuck.

Bill
PB 5.72 (32-bit) on Win 10.
ebs
Enthusiast
Enthusiast
Posts: 530
Joined: Fri Apr 25, 2003 11:08 pm

Re: Question about ExplorerListGadget Column Functions

Post by ebs »

I don't think you're missing anything.
I tried it and it doesn't seem to work properly for files/folders except when in column 0.

Regards,
Eric
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Question about ExplorerListGadget Column Functions

Post by RASHAD »

Workaround
Tried not to use any API

Code: Select all

ExpFlags = #PB_Explorer_FullRowSelect|#PB_Explorer_AlwaysShowSelection 
Dir$ = "c:\*.*"

OpenWindow(0,0,0,500,400,"", #PB_Window_ScreenCentered| #PB_Window_SystemMenu)

ExplorerListGadget(1, 10, 10, 200, 300, Dir$, ExpFlags)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
SetGadgetItemAttribute(1, 0, #PB_Explorer_ColumnWidth , 180 , 0)
; --------------------------------------------------
ContainerGadget(#PB_Any,250,10,230,300,#PB_Container_Single)
  ExplorerListGadget(2, -10,0, 238, 300, Dir$, ExpFlags | #PB_Explorer_BorderLess)
CloseGadgetList()
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)

AddGadgetColumn(2, 0, #PB_Explorer_Name, 0)
AddGadgetColumn(2, 1, "    x", 30)
AddGadgetColumn(2, 2, #PB_Explorer_Name, 190)

SetGadgetText(2, Dir$)

; --- A "just for example" item in column 0 ----------
SetGadgetItemText(2, 5, "X", 0)
; --------------------------------------------------

Repeat
  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
          ; =================                 
        Case 2
         
          ; --- ? ---
         
      EndSelect
  EndSelect
   
Until event = #PB_Event_CloseWindow
Egypt my love
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: Question about ExplorerListGadget Column Functions

Post by offsides »

ebs: Thanks for the confirm. Nice to know it wasn't just me.

RASHAD: How clever!
I was hoping I might drag you into this. It's always a pleasure to see your work.
OTOH, I was hoping there was a way to retain all the "0 column" functionality in columns to the right together with the folder icons, etc.
I will keep trying.

Thanks,
Bill
PB 5.72 (32-bit) on Win 10.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Question about ExplorerListGadget Column Functions

Post by RASHAD »

# 1 :

Code: Select all

ExpFlags = #PB_Explorer_FullRowSelect|#PB_Explorer_AlwaysShowSelection
Dir$ = "c:\*.*"

OpenWindow(0,0,0,500,400,"", #PB_Window_ScreenCentered| #PB_Window_SystemMenu)

ExplorerListGadget(1, 10, 10, 200, 300, Dir$, ExpFlags)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
SetGadgetItemAttribute(1, 0, #PB_Explorer_ColumnWidth , 180 , 0)
; --------------------------------------------------
ContainerGadget(3,250,10,30,30)
CloseGadgetList()

ContainerGadget(4,250,10,230,300,#PB_Container_Single)
  ExplorerListGadget(2, 0,0, 220, 300, Dir$, ExpFlags )
CloseGadgetList()

RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)

AddGadgetColumn(2, 0, #PB_Explorer_Name, 20)
AddGadgetColumn(2, 1, #PB_Explorer_Name, 190)

SetGadgetText(2, Dir$)

; --- A "just for example" item in column 0 ----------
SetGadgetItemText(2, -1, "X", 0)
; --------------------------------------------------

Repeat
  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
          ; =================                 
        Case 2
         
          ; --- ? ---
         
      EndSelect
  EndSelect
   
Until event = #PB_Event_CloseWindow
# 2 : With Windows API

Code: Select all

ExpFlags = #PB_Explorer_FullRowSelect|#PB_Explorer_AlwaysShowSelection
Dir$ = "c:\*.*"

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents 
  Select uMsg
   Case #WM_NOTIFY
    *NMHDR.NMHDR = lParam
       If *NMHDR\hWndFrom = GetWindow_(GadgetID(2),#GW_CHILD) And *NMHDR\code = #HDN_ITEMCHANGING
          *phdn.NMHEADER = lParam                 
          If  *phdn\iItem = 0                          ; Column 1 fixed
                ProcedureReturn 1
          EndIf
       EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,500,400,"", #PB_Window_ScreenCentered| #PB_Window_SystemMenu)

ExplorerListGadget(1, 10, 10, 200, 300, Dir$, ExpFlags)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
RemoveGadgetColumn(1, 1)
SetGadgetItemAttribute(1, 0, #PB_Explorer_ColumnWidth , 180 , 0)
; --------------------------------------------------
;ContainerGadget(#PB_Any,250,10,230,300,#PB_Container_Single)
  ExplorerListGadget(2, 250,10, 220, 300, Dir$, ExpFlags )
;CloseGadgetList()
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)
RemoveGadgetColumn(2, 0)

AddGadgetColumn(2, 0, #PB_Explorer_Name, 20)
AddGadgetColumn(2, 1, #PB_Explorer_Name, 190)

SetGadgetText(2, Dir$)

; --- A "just for example" item in column 0 ----------
SetGadgetItemText(2, -1, "X", 0)
; --------------------------------------------------
SetWindowCallback(@WinCallback())
Repeat
  Event = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_Gadget
      Select EventGadget()
          ; =================                 
        Case 2
         
          ; --- ? ---
         
      EndSelect
  EndSelect
   
Until event = #PB_Event_CloseWindow
Edit : Added another snippet
Egypt my love
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: Question about ExplorerListGadget Column Functions

Post by offsides »

RASHAD, thank you again. Either one does the trick.
What I needed was a way to have a narrow column to the immediate left of the dir/file listing which can be populated with letters or symbols denoting some file characteristic. For example, if there is a memo associated with the file, there might be an "M".

In either of your examples, this can be done simply by:

Code: Select all

AddGadgetColumn(2, 0, #PB_Explorer_Name, 20)
AddGadgetColumn(2, 1, "M", 20)
AddGadgetColumn(2, 2, #PB_Explorer_Name, 190)
In any event, it all works perfectly now and thanks once again for your help.

Bill
PB 5.72 (32-bit) on Win 10.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Question about ExplorerListGadget Column Functions

Post by RASHAD »

@offsides
You are welcome :)
Egypt my love
ebs
Enthusiast
Enthusiast
Posts: 530
Joined: Fri Apr 25, 2003 11:08 pm

Re: Question about ExplorerListGadget Column Functions

Post by ebs »

I think there may be a problem with the "X" in column 1.

I added this code to put an "X" on the first three items in the list:

Code: Select all

; --- A "just for example" item in column 0 ----------
SetGadgetItemText(2, 1, "X", 1)
SetGadgetItemText(2, 2, "X", 1)
SetGadgetItemText(2, 3, "X", 1)
; --------------------------------------------------
Initially, it works fine. But if you double-click on one of the folder icons to open it and then double-click on ".." to return, the "X"s are gone.
This might be the case only for my ancient Windows XP system, but I thought I would mention it.

Regards,
Eric
Post Reply