Jump to content

Gui list


Gianluca
 Share

Recommended Posts

What I want to reach is a Gui in which are listed a specific type of file (in the example below I used txt files); with these files I addictionally want to interact.

The main problem I have is this: how can I set a number of item that I don't previously know? I mean:

$item1 =

$item2 =

etc. I thought I can use array but I don't exactly know how... :)

Local $x = 0
    $Form1 = GUICreate("", 663, 514, 192, 124)
    $Group1 = GUICtrlCreateGroup("", 11, 96, 641, 401)
    $view = GUICtrlCreateButton("Read item selected", 366, 464, 147, 25)
    $new = GUICtrlCreateButton("New", 95, 464, 147, 25)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Search", 167, 16, 329, 65)
    $Button1 = GUICtrlCreateButton("Search", 407, 40, 75, 25)
    $Date1 = GUICtrlCreateDate("2011/03/30 19:18:4", 183, 40, 186, 21)
    $listview = GUICtrlCreateListView("     Date        |       Time        ", 23, 112, 617, 337,$LVS_SORTDESCENDING)
    ; Here starts the "listing phase"
    $search = FileFindFirstFile($global_path&"*.txt")
    If $search = -1 Then ; Check if the search was successful
        MsgBox(0, $title, "No file found.")
        Exit
    EndIf
    While 1
        $a = FileFindNextFile($search)
        If @error Then ExitLoop
; ####### HERE THE PROBLEM ########
        $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
; #################################
        $x += 1
    WEnd    
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit

        EndSwitch
    WEnd
Link to comment
Share on other sites

  • Moderators

Gianluca,

Welcome to the AutoIt forum. :)

Firstly, use _FileListToArray to get an array of the files you are looking for - much simpler than using FileFindFirst/NextFile. :P

Then use a simple loop to run through the file names - for each one you can use FileGetTime to get the date and time of the file (which looks to be what you want to display) and then use GUICtrlCreateListViewItem to add a row to the ListView to show what you get. :)

Give it a go and see if you can get it to work. If not you know where we are! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Gianluca,

Welcome to the AutoIt forum. :)

Firstly, use _FileListToArray to get an array of the files you are looking for - much simpler than using FileFindFirst/NextFile. ;)

Then use a simple loop to run through the file names - for each one you can use FileGetTime to get the date and time of the file (which looks to be what you want to display) and then use GUICtrlCreateListViewItem to add a row to the ListView to show what you get. :)

Give it a go and see if you can get it to work. If not you know where we are! :)

M23

M23,

Thank you VERY VERY VERY much for you quick and exaustive answer. I'll try and post the result if I'll make it, otherwise I'll report issues :P Thanks bro:):D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...