Jump to content

Order ListView


Recommended Posts

Hi, how can I order a listView?

$Listado = GUICtrlCreateListView("Archivo|Tamaño|Fecha de modificación",10,60,620, 410,$LVS_SHOWSELALWAYS)

_GUICtrlListView_JustifyColumn($Listado, 0,0)

_GUICtrlListView_JustifyColumn($Listado, 1,1)

_GUICtrlListView_JustifyColumn($Listado, 2,0)

A function

Func ListView1Click()

EndFunc

Link to comment
Share on other sites

This example may help you. Default password is 123.

;Codded by  Vitas.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile_type=a3x
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ProgressConstants.au3>
#include <GuiListView.au3>
#Include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
;#RequireAdmin
Global $string[100], $ListView1, $Item, $shown = False, $Saving = "", $file,$Progress1,$SaveListTo, $ListEmpty = True
$mainpassword = InputBox("Enter password to login", "Enter your password below:", "", "*")
If $mainpassword = "123" Then  ; type your password here, and remember it:)Also it will be used for encryption!
main()
Else
    Exit
EndIf
Func main()
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 484, 265, 409, 526)
$ListView1 = GUICtrlCreateListView("Program name|Password|Location", 16, 16, 457, 177, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
$CP = GUICtrlCreateButton("Change password", 168, 200, 65, 49, $BS_MULTILINE)
GUICtrlSetState($CP, $GUI_DISABLE)
$pass = GUICtrlCreateInput("Input1", 16, 200, 145, 21)
$passconf = GUICtrlCreateInput("Input2", 16, 224, 145, 21)
$Save = GUICtrlCreateButton("Save settings", 240, 200, 65, 49, $BS_MULTILINE)
GUICtrlSetState(-1, $GUI_DISABLE)
$Load = GUICtrlCreateButton("Load list form file", 312, 200, 65, 49, BitOR($BS_CENTER,$BS_MULTILINE))
$SaveTo = GUICtrlCreateButton("Save encrypted list to file", 384, 200, 89, 49, $BS_MULTILINE)
GUICtrlSetState(-1, $GUI_DISABLE)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$Add = GUICtrlCreateMenuItem("Add...", $ListView1context)
$Clear = GUICtrlCreateMenuItem("Clear list", $ListView1context)
$Progress1 = GUICtrlCreateProgress(16, 256, 457, 9)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    ;Sleep(100)
    If GUICtrlRead($pass) = GUICtrlRead($passconf) And(GUICtrlRead($pass)<>"" And GUICtrlRead($passconf)<>"") And $shown = False And _GUICtrlListView_GetItemCount($ListView1) > "0" Then
        GUICtrlSetState($CP, $GUI_ENABLE)
        $shown = True
    ElseIf GUICtrlRead($pass) <> GUICtrlRead($passconf) And(GUICtrlRead($pass)<>"" And GUICtrlRead($passconf)<>"") And $shown = True And _GUICtrlListView_GetItemCount($ListView1) > "0" Then
        GUICtrlSetState($CP, $GUI_DISABLE)
        $shown = False
    EndIf

    If _GUICtrlListView_GetItemCount($ListView1) > "0" And $ListEmpty = True Then
        GUICtrlSetState($Save, $GUI_ENABLE)
        GUICtrlSetState($SaveTo, $GUI_ENABLE)
        $ListEmpty = False
    ElseIf _GUICtrlListView_GetItemCount($ListView1) = "0" And $ListEmpty = False Then
        GUICtrlSetState($Save, $GUI_DISABLE)
        GUICtrlSetState($SaveTo, $GUI_DISABLE)
        $ListEmpty = True
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Add
            $AddToList = FileOpenDialog("Select file for add to list...", @DesktopDir & "\", "Any files(*.*)", 1,"",$Form1)
            If $AddToList <> "" Then
                $string = StringSplit($AddToList,"\")
                $filename = StringLen($string[$string[0]])
                $location = StringTrimRight($AddToList, $filename)
                GUICtrlCreateListViewItem($string[$string[0]] & "||" & $location, $ListView1)
            EndIf
        Case $Clear
            $cnt = _GUICtrlListView_GetItemCount($ListView1)
            If $cnt > "0" Then
            $ms = MsgBox(4,"Confirm action","Are you sure want ot delete all(" & $cnt & ") items?","",$Form1)
                If $ms = 6 Then
                    _GUICtrlListView_DeleteAllItems($ListView1)
                EndIf
            EndIf
        Case $CP
            $cnt = _GUICtrlListView_GetItemCount($ListView1)
            For $i = 0 To $cnt Step 1
                If _GUICtrlListView_GetItemChecked($ListView1,$i) Then
                $Item = _GUICtrlListView_GetItemTextArray($ListView1,$i)
                _GUICtrlListView_SetItemText($ListView1, $i, $Item[1] & "|" & GUICtrlRead($pass) & "|" & $Item[3],-1)
                EndIf
            Next
        Case $Save
            If $SaveListTo <> "" Then
            SaveList($SaveListTo)
            EndIf
        Case $Load
            $SaveListTo = FileOpenDialog("Select file that contains encrypted passwods...", @DesktopDir & "\", "Password lists (*.pwl)", 1,"",$Form1)
            If $SaveListTo <> "" Then
                $From = $SaveListTo
                LoadList($From)
            EndIf
        Case $SaveTo
            $SaveListTo = FileSaveDialog("Select file to save data in...", @DesktopDir, "Password lists (.pwl)","","*.pwl", $Form1)
            If $SaveListTo <> "" Then
                SaveList($SaveListTo)
            EndIf
    EndSwitch
WEnd
EndFunc

Func SaveList($SaveListTo)
        FileDelete ($SaveListTo)
        $file = FileOpen($SaveListTo, 1)
            If $file = -1 Then
                MsgBox(0, "Error", "Unable to open file.")
            Else
                GUICtrlSetState($Progress1,$GUI_SHOW)
                $cnt = _GUICtrlListView_GetItemCount($ListView1)
                For $i = 0 To $cnt-1 Step 1
                    GUICtrlSetData($Progress1, 100/($cnt-1)*$i)
                    $line = _StringEncrypt(1, _GUICtrlListView_GetItemTextString($ListView1,$i), $mainpassword)
                    FileWrite($file, $line & @CRLF)
                Next
                FileClose($file)
                Sleep(600)
                GUICtrlSetState($Progress1,$GUI_HIDE)
            EndIf
EndFunc

Func LoadList($From)
        $file = FileOpen($From, 0)
        While 1
            $line = FileReadLine($file)
            If @error = -1 Then ExitLoop
            GUICtrlCreateListViewItem(_StringEncrypt(0, $line, $mainpassword), $ListView1)
        Wend
        FileClose($file)
EndFunc

_____________________________________________________________________________

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...