ExplorerListGadget get full path?

Just starting out? Need help? Post your questions and find answers here.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

ExplorerListGadget get full path?

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post by Shardik »

Please combine GetGadgetText() with GetGadgetItemText():

Code: Select all

Debug GetGadgetText(0) + GetGadgetItemText(0, GetGadgetState(0), 0)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Many thanks! :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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!
BERESHEIT
abc123
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Apr 18, 2007 9:27 pm

Post by abc123 »

is there a way to get multiselected items?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

abc123 wrote:is there a way to get multiselected items?
You need to iterate through all the items and use GetGadgetItemState() etc.
I may look like a mule, but I'm not a complete ass.
abc123
Enthusiast
Enthusiast
Posts: 195
Joined: Wed Apr 18, 2007 9:27 pm

Post by abc123 »

how do you do that? i am new PB
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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 
I may look like a mule, but I'm not a complete ass.
Post Reply