Listview

Just starting out? Need help? Post your questions and find answers here.
Switchblade
User
User
Posts: 17
Joined: Mon Apr 05, 2004 1:27 am
Contact:

Listview

Post by Switchblade »

Thats the filesystem example :

Code: Select all

If EventGadgetID() = 1 ; Read

        ClearGadgetItemList(2)  ; Clear all the items found in the ListView

        If ExamineDirectory(0, GetGadgetText(0), "*.*")

          Repeat

            FileType = NextDirectoryEntry()
            If FileType
              FileName$ = DirectoryEntryName()
              If FileType = 2 ; Directory type
                FileName$ = "(DIR) "+FileName$  
              EndIf
            
              AddGadgetItem(2, -1, FileName$)
            EndIf

          Until FileType = 0 
          
        Else
          MessageRequester("Error","Can't examine this directory: "+GetGadgetText(0),0)
        EndIf

      EndIf
    EndIf

Ive got a path requester and the listview gadget is showing only the .exe files ....... but know Im trying to create for each exe file a directory.

Example :

file1.exe ------> file1 (directory)
file2.exe ------> file2 (directory)
file3.exe ------> file3 (directory)


but only with filename$ its not workin and i dont know how to use getgadgetitemtext for this problem (and i even dont know if this is the solution for my problem)
AMD 2800+ , 1024DDR 400, Nvidia FX 5600 Pro 256DDR, Hersules Game Theater 7.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Take a look at this code and see if it's close to what you're looking for.

Code: Select all

If OpenWindow(0, 0, 0, 320, 300, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "File name to Dir name")
 If CreateGadgetList(WindowID())
    StringGadget(0,  10, 10, 220, 25, "", #PB_String_ReadOnly)
    ButtonGadget(1, 240, 10, 70 , 25, "Browse")
    ListViewGadget(2, 10, 40, 300, 250)
  EndIf
EndIf

Repeat
  event = WaitWindowEvent()
  If event = #PB_EventGadget
    Select EventGadgetID()
      Case 1
        current_path$ = PathRequester("Choose a Directory", "c:\")
        If current_path$
          SetGadgetText(0, current_path$)
          ClearGadgetItemList(2)
          If ExamineDirectory(0, GetGadgetText(0), "*.exe"); looking for .exe only
            Repeat
              file_type = NextDirectoryEntry()
                If file_type
                  file_name$ = DirectoryEntryName()
                  If file_type = 1 ; it's a file
                    AddGadgetItem(2, -1, file_name$)
                  EndIf
                EndIf
            Until file_type = 0 
          Else
            MessageRequester("Oops...", "Did not find any .exe files in: " + Chr(10)+Chr(13) + GetGadgetText(0),0)
            SetGadgetText(0, "")
          EndIf
        EndIf
      Case 2
        convert$ = GetGadgetText(2) ; get the current selction
        new_dir$ = StringField(convert$, 1, ".") ; toss out the .exe
        new_path$ = current_path$ + new_dir$ ; combine current path with the new dir name
        do_it = MessageRequester("Create new directory?", new_path$ + "\", #PB_MessageRequester_YesNo)
        If do_it = 6 ; Yes button
          ;- un-comment the next line to actually create the directory
          ;result = CreateDirectory(new_path$)
          If result
            MessageRequester("Info...", new_path$ + "\" + Chr(10) + Chr(13) + "has been created")
          Else
            MessageRequester("Error!", new_path$ + "\" + Chr(10) + Chr(13) + "has not been created")
          EndIf
        Else
          MessageRequester("Info...", new_path$ + "\" + Chr(10) + Chr(13) + "has not been created")
        EndIf
    EndSelect
  EndIf
Until event = #PB_EventCloseWindow
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply