Page 1 of 1

ExplorerListGadget get full path?

Posted: Thu Mar 15, 2007 10:24 am
by PB
If a user browses an ExplorerListGadget, where the path is unknown due to
the browsing, how can I get the full path to a selected file? For example, run
this code, and double-click "iexplore.exe" -- the Debug window shows that
filename, but not the path + filename, which is what I'd want. But I don't
think this is possible, because the docs for GetGadgetItemText say:
[...] returns the name of the 'Item', without the path. :(

Code: Select all

If OpenWindow(0, 200, 200, 400, 200, "test", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
  ExplorerListGadget(0, 10, 10, 380, 180, "*.*", #PB_Explorer_FullRowSelect)
  SetGadgetText(0, "C:\Program Files\Internet Explorer\")
  Repeat
    ev=WaitWindowEvent()
    If ev=#PB_Event_Gadget And EventType()=#PB_EventType_LeftDoubleClick
      Debug GetGadgetItemText(0, GetGadgetState(0), 0)
    EndIf
  Until ev=#PB_Event_CloseWindow
EndIf

Posted: Thu Mar 15, 2007 10:47 am
by Shardik
Please combine GetGadgetText() with GetGadgetItemText():

Code: Select all

Debug GetGadgetText(0) + GetGadgetItemText(0, GetGadgetState(0), 0)

Posted: Thu Mar 15, 2007 10:51 am
by PB
Many thanks! :)

Posted: Thu Mar 15, 2007 10:56 am
by netmaestro

Code: Select all

If OpenWindow(0, 200, 200, 400, 200, "test", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0)) 
  ExplorerListGadget(0, 10, 10, 380, 180, "*.*", #PB_Explorer_FullRowSelect) 
  path.s = "C:\Program Files\Internet Explorer\"
  SetGadgetText(0,path) 
  Repeat 
    ev=WaitWindowEvent() 
    If ev=#PB_Event_Gadget 
      If EventType()=#PB_EventType_Change
        curloc.s = GetGadgetText(0)
        curstate.s = GetGadgetItemText(0, GetGadgetState(0), 0)
        If curstate <> "Name" And curstate <> ".."
          curloc +curstate
        EndIf
        Debug curloc
      EndIf
    EndIf
  Until ev=#PB_Event_CloseWindow 
EndIf 
[edit] Too Late!

Posted: Wed May 02, 2007 10:23 am
by abc123
is there a way to get multiselected items?

Posted: Wed May 02, 2007 10:33 am
by srod
abc123 wrote:is there a way to get multiselected items?
You need to iterate through all the items and use GetGadgetItemState() etc.

Posted: Wed May 02, 2007 2:09 pm
by abc123
how do you do that? i am new PB

Posted: Wed May 02, 2007 2:17 pm
by srod

Code: Select all

If OpenWindow(0, 200, 200, 400, 400, "test", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0)) 
  ExplorerListGadget(0, 10, 40, 380, 340, "*.*", #PB_Explorer_FullRowSelect!#PB_Explorer_MultiSelect|#PB_Explorer_AlwaysShowSelection) 
  ButtonGadget(1, 10,10, 120, 20, "List selected...")
  path.s = "C:\Program Files\Internet Explorer\" 
  SetGadgetText(0,path) 
  Repeat 
    ev=WaitWindowEvent() 
    If ev=#PB_Event_Gadget 
      Select EventGadget()
        Case 1
          For i = 0 To CountGadgetItems(0)-1
            If GetGadgetItemState(0,i)&#PB_Explorer_Selected 
              Debug "Item " + Str(i) +" (" + GetGadgetItemText(0,i,0)+") is selected."
            EndIf
          Next
      EndSelect
    EndIf 
  Until ev=#PB_Event_CloseWindow 
EndIf