Jump to content

Help with viewlist


Recommended Posts

Hello, i want to create a Gui where, i want to write names of tv series (e.x. Game of Thrones) and update my progress on each series(episodes watched) and each time i exit the program i want that too be saved(haven't searched that part yet. I am a newbie in autoit, and i m trying to do it by watching other posts, or the help files but im stuck

i've wrote some things this far but its nowhere close yet, and i need some help

its from an example from help files

#include 
#include 

Example()

Func Example()
Local $listview, $button, $item1, $item2, $item3, $msg

GUICreate("listview items", 420, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView("Title |Type|Score|Progress ", 10, 10, 400, 150, 0x8214);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("Add Series", 200, 200, 70, 20)
$item1 = GUICtrlCreateListViewItem("item2it must be big|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1 i am an idiot|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
GUICtrlCreateInput("", 20, 200, 150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
;GUICtrlSetData
;GUICtrlDelete

Do
$msg = GUIGetMsg()

Select
Case $msg = $button
MsgBox(0, "listview item", GUICtrlRead(GUICtrlRead($listview)), 2)
Case $msg = $listview
MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Edited by Tsimo
Link to comment
Share on other sites

im quite new.. i know autoit a long time, but i dont use it a lot. i ve only made some autoclicker, some easy bot for games and some small stuff... anyway, so i've done this so far, but i get an error at guictrlsetdata when i use variables and |. If you can help me with that or recommend an other solution. And second i want to be able to save my list and my changes each time i exit the program. and mass spamer i ve used the include its just that copy paste doesnt copy them dont know why

#include 
#include 
#include 


Watchlist()

Func Watchlist()

GUICreate("listview items", 420, 250, 100, 200, -1, $WS_EX_STATICEDGE)
GUISetBkColor(0x00E0FFFF)

$listview = GUICtrlCreateListView(" Title | Type | Score | Progress ", 10, 10, 400, 150, 0x8014)
$button1 = GUICtrlCreateButton("Add", 17, 200, 70, 40)
$button2 = GUICtrlCreateButton("Edit", 112, 200, 70, 40)
$button3 = GUICtrlCreateButton("Delete", 207, 200, 70, 40)
$button4 = GUICtrlCreateButton("OK!", 300, 170, 110, 70)

$title = GUICtrlCreateInput("", 10, 170, 150, 20)
$type = GUICtrlCreateInput("", 170, 170, 50, 20)
$score = GUICtrlCreateInput("", 230, 170, 20, 20, 0x2000)
$progress = GUICtrlCreateInput("", 260, 170, 25, 20, 0x2000)

$listviewbk = GUICtrlSetBkColor ($listview, 0xdddddd)

GUISetState()

Do
$msg = GUIGetMsg()

Select
Case $msg = $button1
$string1 = GUICtrlRead($title)
$string2 = GUICtrlRead($type)
$string3 = GUICtrlRead($score)
$string4 = GUICtrlRead($progress)
;$newitem = GUICtrlCreateListViewItem ($string1|$string2|$string3|$string4, $listview)
Case $msg = $button2
;$edititem = GUICtrlSetData ($string1|$string2|$string3|$string4, GUICtrlRead(GUICtrlRead($listview)))
GuiCtrlDelete (GuiCtrlRead($listview))
Case $msg = $button3
GuiCtrlDelete (GuiCtrlRead($listview))
Case $msg = $listview
MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc
Link to comment
Share on other sites

can't anyone help me plz? i m doing small steps on my own but still need help

#include
#include 
#include 


Watchlist()

Func Watchlist()

Local $listview, $button1, $button2, $button3, $button4, $title, $type, $score, $progress, $listviewbk
Local $string1, $string2, $string3, $string4, $sFilePath, $eof, $olditems, $edititem, $newitem, $msg

GUICreate("My Watchlist", 420, 250, 100, 200, -1, $WS_EX_STATICEDGE)
GUISetBkColor(0x00E0FFFF)

$listview = GUICtrlCreateListView(" Title | Type | Score | Progress ", 10, 10, 400, 150, 0x8014)
$button1 = GUICtrlCreateButton("Add", 17, 200, 70, 40)
$button2 = GUICtrlCreateButton("Edit", 112, 200, 70, 40)
$button3 = GUICtrlCreateButton("Delete", 207, 200, 70, 40)
$button4 = GUICtrlCreateButton("Save", 300, 170, 110, 70)

$title = GUICtrlCreateInput("", 10, 170, 150, 20)
$type = GUICtrlCreateInput("", 170, 170, 50, 20)
$score = GUICtrlCreateInput("", 230, 170, 20, 20, 0x2000)
$progress = GUICtrlCreateInput("", 260, 170, 25, 20, 0x2000)

$listviewbk = GUICtrlSetBkColor ($listview, 0xdddddd)

GUISetState()

$sFilePath = "C:UsersTsimoDesktopMy watchlist.ini"
Local $eof = _FileCountLines($sFilePath)

; $olditems =GUICtrlCreateListViewItem (IniReadSectionNames ($sFilePath), $listview)
For $i = 2 to $eof
$olditems =GUICtrlCreateListViewItem (FileReadLine($sFilePath, $i), $listview)
Next



Do
$msg = GUIGetMsg()

Select
Case $msg = $button1

$string1 = GUICtrlRead($title)
$string2 = GUICtrlRead($type)
$string3 = GUICtrlRead($score)
$string4 = GUICtrlRead($progress)
$newitem = GUICtrlCreateListViewItem ($string1 &'|'& $string2 &'|'& $string3 &'|'& $string4, $listview)
Case $msg = $button2
; maybe new small pop up window to edit
$edititem = GUICtrlSetData ($string1 &'|'& $string2 &'|'& $string3 &'|'& $string4, GUICtrlRead(GUICtrlRead($listview)))
GuiCtrlDelete (GuiCtrlRead($listview))
Case $msg = $button3
GuiCtrlDelete (GuiCtrlRead($listview))
Case $msg = $button4
IniWriteSection ($sFilePath, "section1", GuiCtrlRead(GuiCtrlRead($listview)))
Case $msg = $listview
MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE
EndFunc

Link to comment
Share on other sites

Here is how I would do it, forget the INI file because it's going to cause issues later down the road if you don't know what you're doing with it. This creates what is called a flat file database instead of using the INI. I have commented the saving section, and the reading sections that I modified, if you have any questions, please ask.

; *** Start added by AutoIt3Wrapper ***
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <GUIListView.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n
Watchlist()

Func Watchlist()
     $sFilePath = "My watchlist.ini" ; sets the file name
     $File = FileOpen($sFilePath, 0) ; open the file for read
     If $File = -1 Then ; file not found, create it below
          $File = FileOpen($sFilePath, 2)
          FileClose($File)
          $File = FileOpen($sFilePath); reopen the file for reading
          If $File = -1 Then Exit
     EndIf

     Local $listview, $button1, $button2, $button3, $button4, $title, $type, $score, $progress, $listviewbk
     Local $string1, $string2, $string3, $string4, $sFilePath, $eof, $olditems, $edititem, $newitem, $msg

     GUICreate("My Watchlist", 420, 250, 100, 200, -1, $WS_EX_STATICEDGE)
     GUISetBkColor(0x00E0FFFF)

     $listview = GUICtrlCreateListView(" Title | Type | Score | Progress ", 10, 10, 400, 150, 0x8014)
     $button1 = GUICtrlCreateButton("Add", 17, 200, 70, 40)
     $button2 = GUICtrlCreateButton("Edit", 112, 200, 70, 40)
     $button3 = GUICtrlCreateButton("Delete", 207, 200, 70, 40)
     $button4 = GUICtrlCreateButton("Save", 300, 170, 110, 70)

     $title = GUICtrlCreateInput("", 10, 170, 150, 20)
     $type = GUICtrlCreateInput("", 170, 170, 50, 20)
     $score = GUICtrlCreateInput("", 230, 170, 20, 20, 0x2000)
     $progress = GUICtrlCreateInput("", 260, 170, 25, 20, 0x2000)

     $listviewbk = GUICtrlSetBkColor($listview, 0xdddddd)

     GUISetState()

     While 1
          $Text = FileReadLine($File); read the text file line-by-line 
          If @error = -1 Then ExitLoop ; until you hit EOF, then exit this loop
          GUICtrlCreateListViewItem($Text, $listview) ; create new LV item
     WEnd
     FileClose($File)
     Do
          $msg = GUIGetMsg()
          Select
               Case $msg = $button1
                    $string1 = GUICtrlRead($title)
                    $string2 = GUICtrlRead($type)
                    $string3 = GUICtrlRead($score)
                    $string4 = GUICtrlRead($progress)
                    $newitem = GUICtrlCreateListViewItem($string1 & '|' & $string2 & '|' & $string3 & '|' & $string4, $listview)
               Case $msg = $button2 ; edit button
                    ; maybe new small pop up window to edit
                    $edititem = GUICtrlSetData($string1 & '|' & $string2 & '|' & $string3 & '|' & $string4, GUICtrlRead(GUICtrlRead($listview)))
                    GUICtrlDelete(GUICtrlRead($listview))
               Case $msg = $button3
                    GUICtrlDelete(GUICtrlRead($listview))
               Case $msg = $button4 ; save button
                    $Count = _GUICtrlListView_GetItemCount($listview) ; find out how many items are in the listview
                    $File = FileOpen($sFilePath, 2) ; reopen the file for writing
                    For $I = 0 To $Count - 1 ; loop through the items in the listview
                         $sListviewItem = _GUICtrlListView_GetItemTextString($listview, $I) ; get the text of the items one at a time
                         FileWriteLine($File, $sListviewItem) ; write that info to the file
                    Next
               Case $msg = $listview
                    MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
          EndSelect
     Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Watchlist

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This might help :

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GuiMenu.au3>
#include <array.au3>
Global $Data = "PhoneNumber.ini", $LireINIi = IniReadSection($Data, "Info")
Global $aLV_Click_Info, $hTmp_Edit, $fDblClk = False, $fInfoGUI = False
$GUI = GUICreate("Test", 730, 361)
$NVT = _GUICtrlListView_Create($GUI, "", 5, 5, 720, 351, $LVS_REPORT, $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($NVT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_BORDERSELECT))
_GUICtrlListView_InsertColumn($NVT, 0, "Title", 170, 2)
_GUICtrlListView_InsertColumn($NVT, 1, "Type", 170, 2)
_GUICtrlListView_InsertColumn($NVT, 2, "Score", 157, 2)
_GUICtrlListView_InsertColumn($NVT, 3, "Progress", 100, 2)
If $LireINIi <> 1 Then
    For $i = 1 To $LireINIi[0][0]
        $Nom = $LireINIi[$i][0]
        $DataNom = StringSplit($LireINIi[$i][1], "|")
  ;_arraydisplay($adressevilletele)
        $Adresse = $DataNom[1]
        $Ville = $DataNom[2]
        $Telephone = $DataNom[3]
        _GUICtrlListView_AddItem($NVT, $Nom, $i - 1)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Adresse, 1)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Ville, 2)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Telephone, 3)
    Next
EndIf
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
    If $hTmp_Edit <> 0 Then ; If a temporary edit exists
        If _IsPressed("0D") Then ; If ENTER pressed
            $sText = GUICtrlRead($hTmp_Edit) ; Set label to edit content
            _GUICtrlListView_SetItemText($NVT, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            GUICtrlDelete($hTmp_Edit) ; Delete temporary edit
            $hTmp_Edit = 0
        EndIf
    EndIf
    If $fDblClk Then ; If an item was double clicked
        $fDblClk = False
        GUICtrlDelete($hTmp_Edit) ; Delete any existing temporary edits
        $sTmp_Text = _GUICtrlListView_GetItemText($NVT, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Read current text of clicked label
        Switch $aLV_Click_Info[1] ; Get label position
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($NVT, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($NVT, $aLV_Click_Info[0], $aLV_Click_Info[1])
   EndSwitch
        $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 8, $aLV_Rect_Info[1] + 7, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) ; Create temporary edit
        GUICtrlSetState($hTmp_Edit, $GUI_FOCUS)
    EndIf
    If $fInfoGUI = True Then
        $fInfoGUI = False
        InfoGUI()
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Func SauveTout()
    If FileExists($Data) Then
        FileDelete($Data)
    EndIf
    For $a = 0 To _GUICtrlListView_GetItemCount($NVT) - 1
        $Nom1 = _GUICtrlListView_GetItemText($NVT, $a, 0)
        $Adresse1 = _GUICtrlListView_GetItemText($NVT, $a, 1)
        $Ville1 = _GUICtrlListView_GetItemText($NVT, $a, 2)
        $Telephone1 = _GUICtrlListView_GetItemText($NVT, $a, 3)
        IniWrite($Data, "Info", $Nom1, $Adresse1 & "|" & $Ville1 "|" $Telephone1)
    Next
EndFunc   ;==>SauveTout
Func ListView_RClick()
    Local $Ajouter = 1, $Supprimer = 2, $Effacer = 3, $Sauvegarder = 4
    $Menu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_AddMenuItem($Menu, "Add", $Ajouter)
    _GUICtrlMenu_AddMenuItem($Menu, "Del", $Supprimer)
    _GUICtrlMenu_AddMenuItem($Menu, "Dell all", $Effacer)
    _GUICtrlMenu_AddMenuItem($Menu, "")
    _GUICtrlMenu_AddMenuItem($Menu, "Save", $Sauvegarder)
    Switch _GUICtrlMenu_TrackPopupMenu($Menu, $NVT, -1, -1, 1, 1, 2)
        Case $Ajouter
            $fInfoGUI = True
        Case $Supprimer
            ConsoleWrite(_GUICtrlListView_DeleteItemsSelected($NVT))
        Case $Effacer
            _GUICtrlListView_DeleteAllItems($NVT)
        Case $Sauvegarder
            SauveTout()
EndSwitch
    _GUICtrlMenu_DestroyMenu($Menu)
EndFunc   ;==>ListView_RClick
Func InfoGUI()
    $GUI1 = GUICreate("Informations", 311, 135)
    GUICtrlCreateLabel("Name", 38, 7, 22, 20)
    $Nom = GUICtrlCreateInput("", 70, 5, 170, 20)
GUICtrlCreateLabel("Adress", 22, 32, 38, 20)
    $Adresse = GUICtrlCreateInput("", 70, 30, 170, 20)
    GUICtrlCreateLabel("City", 41, 57, 19, 20)
    $Ville = GUICtrlCreateInput("", 70, 55, 170, 20)
    GUICtrlCreateLabel("Phone", 9, 82, 51, 20)
    $Telephone = GUICtrlCreateInput("", 70, 80, 170, 20)
    $Ajoute = GUICtrlCreateButton("Add", 243, 4, 65, 47)
    $Annule = GUICtrlCreateButton("Cancel", 243, 54, 65, 47)
    GUISetState()
    While 1
       Switch GUIGetMsg()
  Case $Ajoute
   $Nom1 = GUICtrlRead($Nom)
   $Adresse1 = GUICtrlRead($Adresse)
   $Ville1 = GUICtrlRead($Ville)
   $Telephone1 = GUICtrlRead($Telephone)
   $iIndex = _GUICtrlListView_GetItemCount($NVT)
   If $iIndex = -1 Then $iIndex = 0
   _GUICtrlListView_AddItem($NVT, $Nom1, $iIndex)
   _GuiCtrlListView_AddSubItem($NVT, $iIndex, $Adresse1, 1)
   _GUICtrlListView_AddSubItem($NVT, $iIndex, $Ville1, 2)
   _GUICtrlListView_AddSubItem($NVT, $iIndex, $Telephone1, 3)
   GUISetState(@SW_HIDE, $GUI1)
   GUISwitch($GUI)
   ExitLoop
  Case $Annule
   GuiDelete($GUI1)
            ;GUISetState(@SW_HIDE, $GUI1)
   ;GUISwitch($GUI)
   ExitLoop
  Case $GUI_EVENT_CLOSE
            ;GUISetState(@SW_HIDE, $GUI1)
   GuiDelete($GUI1)
   ;GUISwitch($GUI)
   ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>InfoGUI
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $NVT
            Switch $iCode
    Case $NM_RCLICK
     ListView_RClick()
                Case $NM_DBLCLK
                    $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($NVT)
                    If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Add some item first then double click on anything then you can change it to whatever you want :)

Edited by Jayson
Link to comment
Share on other sites

Princip used by Jayson is the same as in this script (listview with possibility of edit of each column):

i dont really know how to use it... i get confused cause i just started using autoit, dont have experience in programming, and english is not my mother's tongue so i dont get some commands.. (many).

and btw i cant download it for some reasson

Link to comment
Share on other sites

i think im satisfied with jayson's program. Thanks a lot, i did a few small changes (fixes) and now i just turn it in to an exe? I Think its fine now. Thanks

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GuiMenu.au3>
#include <array.au3>

Global $Data = "The List.ini", $LireINIi = IniReadSection($Data, "Info")
Global $aLV_Click_Info, $hTmp_Edit, $fDblClk = False, $fInfoGUI = False
$GUI = GUICreate("My Watchlist", 400, 200)
$NVT = _GUICtrlListView_Create($GUI, "", 5, 5, 390, 190,Bitor($LVS_REPORT, $LVS_SORTASCENDING),$WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($NVT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_BORDERSELECT))
_GUICtrlListView_InsertColumn($NVT, 0, "Title", 180, 2)
_GUICtrlListView_InsertColumn($NVT, 1, "Type", 60, 2)
_GUICtrlListView_InsertColumn($NVT, 2, "Score", 60, 2)
_GUICtrlListView_InsertColumn($NVT, 3, "Progress", 70, 2)
If $LireINIi <> 1 Then
    For $i = 1 To $LireINIi[0][0]
        $Nom = $LireINIi[$i][0]
        $DataNom = StringSplit($LireINIi[$i][1], "|")
;_arraydisplay($adressevilletele)
        $Adresse = $DataNom[1]
        $Ville = $DataNom[2]
        $Telephone = $DataNom[3]
        _GUICtrlListView_AddItem($NVT, $Nom, $i - 1)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Adresse, 1)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Ville, 2)
        _GUICtrlListView_AddSubItem($NVT, $i - 1, $Telephone, 3)
    Next
EndIf
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
    If $hTmp_Edit <> 0 Then ; If a temporary edit exists
        If _IsPressed("0D") Then ; If ENTER pressed
            $sText = GUICtrlRead($hTmp_Edit) ; Set label to edit content
            _GUICtrlListView_SetItemText($NVT, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            GUICtrlDelete($hTmp_Edit) ; Delete temporary edit
            $hTmp_Edit = 0
        EndIf
    EndIf
    If $fDblClk Then ; If an item was double clicked
        $fDblClk = False
        GUICtrlDelete($hTmp_Edit) ; Delete any existing temporary edits
        $sTmp_Text = _GUICtrlListView_GetItemText($NVT, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Read current text of clicked label
        Switch $aLV_Click_Info[1] ; Get label position
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($NVT, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($NVT, $aLV_Click_Info[0], $aLV_Click_Info[1])
EndSwitch
        $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 8, $aLV_Rect_Info[1] + 7, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) ; Create temporary edit
        GUICtrlSetState($hTmp_Edit, $GUI_FOCUS)
    EndIf
    If $fInfoGUI = True Then
        $fInfoGUI = False
        InfoGUI()
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Func SauveTout()
    If FileExists($Data) Then
        FileDelete($Data)
    EndIf
    For $a = 0 To _GUICtrlListView_GetItemCount($NVT) - 1
        $Nom1 = _GUICtrlListView_GetItemText($NVT, $a, 0)
        $Adresse1 = _GUICtrlListView_GetItemText($NVT, $a, 1)
        $Ville1 = _GUICtrlListView_GetItemText($NVT, $a, 2)
        $Telephone1 = _GUICtrlListView_GetItemText($NVT, $a, 3)
        IniWrite($Data, "Info", $Nom1, $Adresse1 & "|" & $Ville1 & "|" & $Telephone1)
    Next
EndFunc ;==>SauveTout
Func ListView_RClick()
    Local $Ajouter = 1, $Supprimer = 2, $Effacer = 3, $Sauvegarder = 4
    $Menu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_AddMenuItem($Menu, "Add", $Ajouter)
    _GUICtrlMenu_AddMenuItem($Menu, "Delelte", $Supprimer)
    _GUICtrlMenu_AddMenuItem($Menu, "Delete all", $Effacer)
    _GUICtrlMenu_AddMenuItem($Menu, "")
    _GUICtrlMenu_AddMenuItem($Menu, "Save", $Sauvegarder)
    Switch _GUICtrlMenu_TrackPopupMenu($Menu, $NVT, -1, -1, 1, 1, 2)
        Case $Ajouter
            $fInfoGUI = True
        Case $Supprimer
            ConsoleWrite(_GUICtrlListView_DeleteItemsSelected($NVT))
        Case $Effacer
            _GUICtrlListView_DeleteAllItems($NVT)
        Case $Sauvegarder
            SauveTout()
EndSwitch
    _GUICtrlMenu_DestroyMenu($Menu)
EndFunc ;==>ListView_RClick
Func InfoGUI()
    $GUI1 = GUICreate("Information", 311, 135)
    GUICtrlCreateLabel("Title :", 36, 7, 30, 20)
    $Nom = GUICtrlCreateInput("", 70, 5, 170, 20)
GUICtrlCreateLabel("Type :", 32, 32, 38, 20)
    $Adresse = GUICtrlCreateInput("", 70, 30, 170, 20)
    GUICtrlCreateLabel("Score :", 28, 57, 40, 20)
    $Ville = GUICtrlCreateInput("", 70, 55, 170, 20, 0x2000)
    GUICtrlCreateLabel("Progress :", 15, 82, 51, 20)
    $Telephone = GUICtrlCreateInput("", 70, 80, 170, 20, 0x2000)
    $Ajoute = GUICtrlCreateButton("Add", 243, 4, 65, 47, 0x0001)
    $Annule = GUICtrlCreateButton("Cancel", 243, 54, 65, 47)
    GUISetState()
    While 1
     Switch GUIGetMsg()
Case $Ajoute
$Nom1 = GUICtrlRead($Nom)
$Adresse1 = GUICtrlRead($Adresse)
$Ville1 = GUICtrlRead($Ville)
$Telephone1 = GUICtrlRead($Telephone)
$iIndex = _GUICtrlListView_GetItemCount($NVT)
If $iIndex = -1 Then $iIndex = 0
_GUICtrlListView_AddItem($NVT, $Nom1, $iIndex)
_GuiCtrlListView_AddSubItem($NVT, $iIndex, $Adresse1, 1)
_GUICtrlListView_AddSubItem($NVT, $iIndex, $Ville1, 2)
_GUICtrlListView_AddSubItem($NVT, $iIndex, $Telephone1, 3)
GUISetState(@SW_HIDE, $GUI1)
GUISwitch($GUI)
ExitLoop
Case $Annule
GuiDelete($GUI1)
            ;GUISetState(@SW_HIDE, $GUI1)
;GUISwitch($GUI)
ExitLoop
Case $GUI_EVENT_CLOSE
            ;GUISetState(@SW_HIDE, $GUI1)
GuiDelete($GUI1)
;GUISwitch($GUI)
ExitLoop
        EndSwitch
    WEnd
EndFunc ;==>InfoGUI
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $NVT
            Switch $iCode
    Case $NM_RCLICK
     ListView_RClick()
                Case $NM_DBLCLK
                    $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($NVT)
                    If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSGEndFunc ;==>WM_NOTIFY

And another question, i made another program and turned to exe and gave it to a friend but he couldn't see the picture that i used in the program... i used the commands:

FileInstall("C:UsersTsimoPicturesPhotoshopReadyBored of Tags4567.jpg","C:UsersTsimoDocumentsTsimoAutoit ProgrammsCodingBored of Tags4567.jpg")

$bk = GUICtrlCreatePic("C:UsersTsimoPicturesPhotoshopReadyBored of Tags4567.jpg", 0, 0, 700, 500)
Edited by Tsimo
Link to comment
Share on other sites

And another question, i made another program and turned to exe and gave it to a friend but he couldn't see the picture that i used in the program... i used the commands:

FileInstall("C:UsersTsimoPicturesPhotoshopReadyBored of Tags4567.jpg","C:UsersTsimoDocumentsTsimoAutoit ProgrammsCodingBored of Tags4567.jpg")
$bk = GUICtrlCreatePic("C:UsersTsimoPicturesPhotoshopReadyBored of Tags4567.jpg", 0, 0, 700, 500)

Use relative path like this

FileInstall("C:UsersTsimoPicturesPhotoshopReadyBored of Tags4567.jpg", @ScriptDir & "Bored of Tags4567.jpg")
$bk = GUICtrlCreatePic(@ScriptDir & "Bored of Tags4567.jpg", 0, 0, 700, 500)

or look at my Resources UDF but my UDF may be more complicated for you as beginner

Link to comment
Share on other sites

thanks a lot. And a last question, when i convert to exe and use and ico do i have to do anything so that i can see the ico on other computer or it's ok automaticaly?

converting au3 to exe is called compilation ;-)

icons can be added to compiled exe by

#AutoIt3Wrapper_Icon=your_main_icon.ico
#AutoIt3Wrapper_Res_Icon_Add=your_another_icon1.ico
#AutoIt3Wrapper_Res_Icon_Add=your_another_icon2.ico

and later used by

GUICtrlSetImage(-1, @ScriptFullPath, -5, 0)

where -5 should be changed accordingly

Edited by Zedna
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...