Jump to content

ListView Save & Load help...


mafioso
 Share

Recommended Posts

I need help to finish Save & Load functions...can somebody help me, please ? Save will read the listview and save it like .ini file, and load should read .ini file and modify listview...

Global $YC
Global $XC
Global $Name



#include <GUIListView.au3>
#include <GUIConstants.au3>

Global $CoordListItem[101]
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\save.kxf
$Form1 = GUICreate("coords", 219, 300, 193, 115)
$XC = GUICtrlCreateInput("", 40, 216, 33, 21)
$Label1 = GUICtrlCreateLabel("X", 24, 216, 12, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Y", 80, 216, 13, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$YC = GUICtrlCreateInput("", 96, 216, 33, 21)
$Enter = GUICtrlCreateButton("Enter", 136, 216, 59, 25, 0)
$CoordList = GUICtrlCreateListView("#|X|Y", 24, 40, 171, 163, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))
For $i = 1 To UBound($CoordListItem)-1
    $CoordListItem[$i] = GUICtrlCreateListViewItem($i & "||",$CoordList)
Next
$Save = GUICtrlCreateButton("Save", 16, 256, 59, 25, 0)
$Load = GUICtrlCreateButton("Load", 88, 256, 51, 25, 0)
$OK = GUICtrlCreateButton("OK", 152, 256, 51, 25, 0)
$WalkToName = GUICtrlCreateInput("", 24, 8, 169, 21)
_GUICtrlListViewSetColumnWidth ($CoordList, 1, 60)
_GUICtrlListViewSetColumnWidth ($CoordList, 2, 60)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
       
    Case $CoordList
    Case $Enter
        If GUICtrlRead($XC) = "" Or GUICtrlRead($YC) = "" Then
                MsgBox(0,"Error","Fill In X & Y Inputs Please")
                Else
        GUICtrlSetData($CoordListItem[_GUICtrlListViewGetSelectedIndices($CoordList)+1],_GUICtrlListViewGetSelectedIndices($CoordList)+1 & "|" & GUICtrlRead($XC) & "|" & GUICtrlRead($YC))
        EndIf
       
   Case $OK
       $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
       MsgBox(64,"Error", "You must have a path loaded or it wont work")
   Else
       $X1 = _GUICtrlListViewGetItemText ($CoordList, 1,1)
       $Y1 = _GUICtrlListViewGetItemText ($CoordList, 1,2)
       
       MsgBox(64,"faf", "You are using the walkback path named : " & $Name)
       GUISetState(@SW_HIDE)
   EndIf
   
   Case $Save
       $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
           $Name = "Untitled"
       EndIf
       FileDelete(@ScriptDir & "\Paths\" & $Name)
      $CoordsList = GUICtrlRead($CoordListItem[1])
       FileWriteLine(@ScriptDir & "\Paths\" & $Name,$CoordsList)
       $CoordsList = GUICtrlRead($CoordListItem[2])
DirCreate (@ScriptDir)
;~ Needs to be finished


Case $Load
    $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
           MsgBox(64,"Error", "Enter a name up top")
       EndIf
;~     Needs to be finished
       
       $line = FileReadLine(@ScriptDir & "\Paths\" & $Name,1)
       GUICtrlSetData($CoordListItem[1],$line)
 $line = FileReadLine(@ScriptDir & "\Paths\" & $Name,2)
       GUICtrlSetData($CoordListItem[2],$line)
;~     Needs to be finished
       

    EndSwitch
Link to comment
Share on other sites

I need help to finish Save & Load functions...can somebody help me, please ? Save will read the listview and save it like .ini file, and load should read .ini file and modify listview...

Global $YC
Global $XC
Global $Name
#include <GUIListView.au3>
#include <GUIConstants.au3>

Global $CoordListItem[101]
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\save.kxf
$Form1 = GUICreate("coords", 219, 300, 193, 115)
$XC = GUICtrlCreateInput("", 40, 216, 33, 21)
$Label1 = GUICtrlCreateLabel("X", 24, 216, 12, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Y", 80, 216, 13, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$YC = GUICtrlCreateInput("", 96, 216, 33, 21)
$Enter = GUICtrlCreateButton("Enter", 136, 216, 59, 25, 0)
$CoordList = GUICtrlCreateListView("#|X|Y", 24, 40, 171, 163, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_BORDER))
For $i = 1 To UBound($CoordListItem)-1
    $CoordListItem[$i] = GUICtrlCreateListViewItem($i & "||",$CoordList)
Next
$Save = GUICtrlCreateButton("Save", 16, 256, 59, 25, 0)
$Load = GUICtrlCreateButton("Load", 88, 256, 51, 25, 0)
$OK = GUICtrlCreateButton("OK", 152, 256, 51, 25, 0)
$WalkToName = GUICtrlCreateInput("", 24, 8, 169, 21)
_GUICtrlListViewSetColumnWidth ($CoordList, 1, 60)
_GUICtrlListViewSetColumnWidth ($CoordList, 2, 60)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
       
    Case $CoordList
    Case $Enter
        If GUICtrlRead($XC) = "" Or GUICtrlRead($YC) = "" Then
                MsgBox(0,"Error","Fill In X & Y Inputs Please")
                Else
        GUICtrlSetData($CoordListItem[_GUICtrlListViewGetSelectedIndices($CoordList)+1],_GUICtrlListViewGetSelectedIndices($CoordList)+1 & "|" & GUICtrlRead($XC) & "|" & GUICtrlRead($YC))
        EndIf
       
   Case $OK
       $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
       MsgBox(64,"Error", "You must have a path loaded or it wont work")
   Else
       $X1 = _GUICtrlListViewGetItemText ($CoordList, 1,1)
       $Y1 = _GUICtrlListViewGetItemText ($CoordList, 1,2)
       
       MsgBox(64,"faf", "You are using the walkback path named : " & $Name)
       GUISetState(@SW_HIDE)
   EndIf
   
   Case $Save
       $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
           $Name = "Untitled"
       EndIf
       FileDelete(@ScriptDir & "\Paths\" & $Name)
      $CoordsList = GUICtrlRead($CoordListItem[1])
       FileWriteLine(@ScriptDir & "\Paths\" & $Name,$CoordsList)
       $CoordsList = GUICtrlRead($CoordListItem[2])
DirCreate (@ScriptDir)
;~ Needs to be finished
Case $Load
    $Name = GUICtrlRead($WalkToName)
       If $Name = "" Then 
           MsgBox(64,"Error", "Enter a name up top")
       EndIf
;~     Needs to be finished
       
       $line = FileReadLine(@ScriptDir & "\Paths\" & $Name,1)
       GUICtrlSetData($CoordListItem[1],$line)
 $line = FileReadLine(@ScriptDir & "\Paths\" & $Name,2)
       GUICtrlSetData($CoordListItem[2],$line)
;~     Needs to be finished
       

    EndSwitch

GuiList Management >>> help file

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