Jump to content
Sign in to follow this  

how to use listview ?

Recommended Posts

i have a

$ListView = GUICtrlCreateListView ("Name | Exe| Cmd| State| Flag",100,170,290,400)

in my GUI and i wonder how to have it display things.

I tried to mess with guictrlsetdata but that didnt get me far enough.

I will have multiple objects in this listview and i cant figure out how to display one.

Mauybe listview is not something i need ? Maybe there is something else i can use instead ?

Can you guys give me simple example that i can understand with my low level of autoit knowledge ?

Thanks in advance.

Here is what i work on

#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region to figure out if script runs more then once.
$Compiled = "Service Maker.exe"
$ScriptFileName = FileExists (@ScriptDir & "\" & $Compiled)
If $ScriptFileName = 0 Then
   MsgBox(16,"Error", 'This is not original file name. Please rename this file back to ' &@CRLF &  '"' & $Compiled & '"')
if _Singleton($Compiled,1) = 0 Then
    Msgbox(0,"Information.","Only one instance is allowed.")
Func _GUI()
    $MainGUI = GUICreate("Service Maker",400,600)
    GUICtrlCreateGroup ("Create new service",5,5,390,145)

    GUICtrlCreateLabel ("       Name:",10,30,80,15)
    $Name = GUICtrlCreateInput ("",80,30,310,20)

    GUICtrlCreateLabel ("   Program:",10,50,80,15)
    $Exe = GUICtrlCreateInput ("",80,50,250,20)
    $BrowseEXE = GUICtrlCreateButton ("Browse",330,50,60,20)

    GUICtrlCreateLabel ("Command:",10,70,80,15)
    $CommandLine = GUICtrlCreateInput ("",80,70,310,20)

    GUICtrlCreateLabel ("        Flags:",10,90,60,15)
    $StartAtLogOn = GUICtrlCreateCheckbox ("Start at logon",80,90,80,15)
    $Hidden = GUICtrlCreateCheckbox ("Hidden",180,90,80,15)

    $AddButton = GUICtrlCreateButton ("Add specified application to the list",10,110,380,30)

    GUICtrlCreateGroup ("Manage added applications",5,150,390,140)
    $ListView = GUICtrlCreateListView ("Name         | Exe| Cmd| State| Flag",100,170,290,400)

    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
            Case $BrowseEXE
                If GUICtrlRead ($Name) = "" Then
                    MsgBox(64,"Error","Please specify service name first.")
                    $OpenFile = FileOpenDialog ("Locate executable", "", "Executable (*.bat;*.cmd;*.exe)", 1)
                    If $OpenFile = "" Then
                    ElseIf $OpenFile > "" Then
                        GUICtrlSetData ($Exe,$OpenFile)
            Case $AddButton
                If GUICtrlRead ($Name) > "" And GUICtrlRead ($Exe) > "" Then
                    IniWrite (@ScriptDir & "\settings.ini","Application",GUICtrlRead ($Name),$OpenFile)
                    IniWrite (@ScriptDir & "\settings.ini","Application",GUICtrlRead ($Name) & ' Command',GUICtrlRead ($CommandLine))
                    If GUICtrlRead ($StartAtLogOn) = 1 then IniWrite (@ScriptDir & "\settings.ini","Application",GUICtrlRead ($Name) & " Start at logon","Yes")
                    If GUICtrlRead ($Hidden) = 1 then IniWrite (@ScriptDir & "\settings.ini","Application",GUICtrlRead ($Name) & " Hidden","Yes")
                    GUICtrlSetData ($ListView,"||update","list")
                    ;GUICtrlSetData ($ListView,"Name         | Exe| Cmd| State| Flag")
                    MsgBox (64,"Error:",'"Name" and "Program:" must be set first.')

Share this post

Link to post
Share on other sites

I also had a question on how to create new variables.

for example once i or you help me to figure out how to display things in listview then how would i go about showing multiple once ?

My scripts will (i hope one day) add objects to listview and display if any from .ini file but how would i display then if i dont know how many and what the key name is in the .ini file ?

Thanks for that one too ;)

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...