Sign in to follow this  
Followers 0
Del

Listview Help

6 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm new to AutoIt and I like what I've seen so far :)

I'm having trouble populating a ListView box. This is the routine I've written for this purpose:

; ... Code cut for clarity

; Create Display Area

$ListView=GUICtrlCreateListView("",5,40,390,200,$LVS_NOCOLUMNHEADER)
$c = StringSplit($Comps,"|"); $c now = 1 dimensional array with 50 elements
SetList($c)

GUISetState (@SW_SHOW)

; ... Code cut for clarity

Func SetList(ByRef $a)
local $size, $iter
$size = UBound($a, 1)
Global $ListItem[$size]
for $iter = 1 to $size - 1
   $ListItem[$iter] = GUICtrlCreateListViewItem($a[$iter], $ListView)
next
EndFunc

No text is placed in the ListView box but a vertical scroll bar is present!

What am I doing wrong.

I've read the help file (which didn't help me in this case) and searched the forum but didn't find any posts with this problem.

Edited by Del

Share this post


Link to post
Share on other sites



What does the variable $Comps consist of?


F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

I'm new to AutoIt and I like what I've seen so far :)

I'm having trouble populating a ListView box. This is the routine I've written for this purpose:

; ... Code cut for clarity

; Create Display Area

$ListView=GUICtrlCreateListView("",5,40,390,200,$LVS_NOCOLUMNHEADER)
$c = StringSplit($Comps,"|"); $c now = 1 dimensional array with 50 elements
SetList($c)

GUISetState (@SW_SHOW)

; ... Code cut for clarity

Func SetList(ByRef $a)
local $size, $iter
$size = UBound($a, 1)
Global $ListItem[$size]
for $iter = 1 to $size - 1
   $ListItem[$iter] = GUICtrlCreateListViewItem($a[$iter], $ListView)
next
EndFunc

No text is placed in the ListView box but a vertical scroll bar is present!

What am I doing wrong.

I've read the help file (which didn't help me in this case) and searched the forum but didn't find any posts with this problem.

My assumption is your array wasn't an array... anyway.. I cleaned it up a tad... take a look at this to see if it helps
#include <guiconstants.au3>
$Comps = ''
For $i = 1 To 50
    $Comps = $Comps & $i & '|'
Next
$MAINGUI = GUICreate('main', 400, 250)
$ListView = GUICtrlCreateListView("BLAH", 5, 40, 390, 200, $LVS_NOCOLUMNHEADER)
$c = StringSplit(StringTrimRight($Comps, 1),"|"); $c now = 1 dimensional array with 50 elements
SetList($c)

GUISetState(@SW_SHOW)
While 1
    If GUIGetMsg() = - 3 Then Exit
    Sleep(10)
WEnd

; ... Code cut for clarity
Func SetList($a)
    Local $size = UBound($a)
    Global $ListItem[$size]
    For $iter = 1 To $size - 1
        $ListItem[$iter] = GUICtrlCreateListViewItem($a[$iter], $ListView)
    Next
EndFunc ;==>SetList
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for the replies :) They are very much appreciated :mellow:

I haven't studied them in any detail yet and I will post back here in a few days.

After posting my first message we had a family tragedy and this will have to take a back seat for a while.

Thanks again for your replies.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

to take my mind off things I've come back to this. Here is the full piece of code. The answer didn't work I'm afraid so I must assume I'm doing something silly.

An ini file is needed but if it is not present it will be created.

Somehow or other I've now managed to break the combo box as well.

Here's the full piece of code:

#cs
================================================================
GUI for SystemSherlock from www.kephyr.com/systemsherlocklite/index.phtml
This is for my own personal use.
If $DEBUG is True dummy arrays for testing are created.
Now I've broken the Combo Box :(
================================================================
#ce
#include <GUIConstants.au3>
#Include <process.au3>
#Include <file.au3>
#Include <Array.au3>
#Include <process.au3>
; Set Constants
Const $true = 1, $false = 0
; Set options
Opt("GUIOnEventMode", 1)
$DEBUG = $true

; Find Previous Scans - read List Of Files From ...\comp
if $DEBUG = $false then
    ReadCompFiles()
else
    $Comps = Debug_SetDummyData(10)
endif
_ArrayDisplay($Comps, "$Comps")

; Find GUI start up settings
$IniFile = "System Sherlock.ini"
if not FileExists($IniFIle) then
    IniWrite($iniFile, "Ignore", "UseIgnoreFile", "0")
    IniWrite($iniFile, "Ignore", "IgnoreFile", "ignore.txt")
endif

$IgnoreStatus = IniRead($IniFile, "Ignore", "UseIgnoreFile", "Not Found")
$IgnoreFile = IniRead($IniFile, "Ignore", "IgnoreFile", "Not Found")

BuildGUI()
GUISetState()
; Run the GUI for 10 seconds and exit, I keep forgetting to close the windows :)
sleep(10000)
#cs
================================================================
BuildGUI
Created Vars:
   Global(s):
      MainWin      : CtrlID : main window
      IgnoreSelect  : CtrlID : ID for 'Use Ignore File' checkbox
      IgnoreFileID  : CtrlID : input box for ignore file
      IgnoreBrowse  : CtrlID : Browse for ignore file
      CompFileCombo : CtrlID : Select Comparison file
      ListView    : CtrlID : Comparison Results

   local(s)
      ignorelabel   : CtrlID : label for ignore block
      debug      : Var  : General var for debug use
   Param(s):
      None
   Notes:
      Creates Main GUI and sets initial GUI 'status'
================================================================
#ce
Func BuildGUI()
;
Global $MainWin, $IgnoreSelect, $IgnoreLabel, $IgnoreFileID, $IgnoreBrowse, $CompFileCombo
Global $ListView
local $debug, $ignorelabel
;
$MainWin = GUICreate("System Sherlock")
;
; Ignore Section
$IgnoreSelect = GUICtrlCreateCheckbox("Use Ignore File", 5, 10)
GUICtrlSetState($Ignoreselect, $IgnoreStatus); Set box to the value in INI file
$ignorelabel = GUICtrlCreateLabel("Ignore File Location:", 5, 35)
$IgnoreFileID = GUICtrlCreateInput($IgnoreFile, 5, 55, 300, 20)
$IgnoreBrowse = GUICtrlCreateButton("Browse", 325, 55, 50, 20)
GUICtrlSetOnEvent($IgnoreSelect, "ToggleIgnore")
; Set initial state of ignore block : ToggleIgnore fails until initialisation.
if $IgnoreStatus = 0 then
    GUICtrlSetState($IgnoreLabel,  $GUI_DISABLE)
    GUICtrlSetState($IgnoreFileID, $GUI_DISABLE)
    GUICtrlSetState($IgnoreBrowse, $GUI_DISABLE)
endif

; Comparison File Choice
$CompFileCombo = GUICtrlCreateCombo("Choose a file to compare", 5, 85, 390)
GUICtrlSetData($CompFileCombo, $Comps); Why doesn't this work now?
GUICtrlSetOnEvent($CompFileCombo, "GetCompFile")

; Create Result Display Area
; This control will not be populated until a scan has been completed hence the need for
; a dummy array for testing

$ListView = GUICtrlCreateListView("", 5, 115, 390, 200, $LVS_NOCOLUMNHEADER)
$debug = Debug_SetDummyData(50)
_ArrayDisplay($debug, "$debug")
SetList($debug)

EndFunc
#cs
================================================================
ToggleIgnore()
Created Vars:
   Global(s)
      None
   local(s)
      None
   Parameter(s)
      None
   Notes
      Switches state of Ignore block between enabled and disabled
================================================================
#ce
Func ToggleIgnore()
$IgnoreStatus = not($IgnoreStatus)
if $IgnoreStatus = 0 then
    GUICtrlSetState($IgnoreLabel, $GUI_DISABLE)
    GUICtrlSetState($IgnoreFileID, $GUI_DISABLE)
    GUICtrlSetState($IgnoreBrowse, $GUI_DISABLE)
else
    GUICtrlSetState($IgnoreLabel, $GUI_ENABLE)
    GUICtrlSetState($IgnoreFileID, $GUI_ENABLE)
    GUICtrlSetState($IgnoreBrowse, $GUI_ENABLE)
endif
EndFunc
#cs
================================================================
ReadCompFiles
Created Vars:
   Global(s)
      $Comps      : String Array  : Storage for results of DOS dir.
                                    Names of files containing the results of previous scans
   local(s)
      $temp_file  : String      : File name of temp storage for results piped from DOS dir
      $temp_array : String Array  : UNUSED, NEEDS REMOVING
   Parameter(s)
      None
   Notes
      Dumps the contents of c:\progra~1\system sherlock\comps to an array.
      Requires the initial output of 'dir' to be piped to a temporary file.
================================================================
#ce
Func ReadCompFiles()
local $n, $temp_array, $temp_file
Global $Comps
$temp_file = _TempFile()
_RunDOS("dir /b c:\progra~1\system~1\comps\*.* > " & $temp_file)
_FileReadToArray($temp_file, $Comps)
_RunDOS("del " & $temp_file)
EndFunc
#cs
================================================================
GetCompFile
Created Vars:
   Global(s)
      $CompFile : String : Selected file name for the sys. sherlock comparison function
   local(s)
      None
   Parameter(s)
      None
   Notes
      Reads the selected file from c:\progra~1\system sherlock\comps and assigns it to $CompFile
================================================================
#ce
Func GetCompFile()
$CompFile = GUICtrlRead($CompFileCombo)
EndFunc
#cs
================================================================
SetList
Created Vars:
   Global(s)
      $ListItem : String Array : Items to be displayed with in the ListView result box
   local(s)
      $size  : Numeric Var  : Upper boundery of array $ListIem
   Parameter(s)
      $a        : String Array : Array to be placed in ListView box
   Notes
      Takes an array, places it in Global $ListItem and displays it.
================================================================
#ce
Func SetList(ByRef $a)
local $iter, $size
$size = UBound($a, 1)
Global $ListItem[$size]
for $iter = 1 to $size - 1
    $ListItem[$iter] = GUICtrlCreateListViewItem($a[$iter], $ListView)
next
EndFunc
#cs
================================================================
 Debug_SetDummyData
Created Vars:
    Global(s)

    Local(s)
      Debug_Array : String Array : Contains dummy data for testing purposes

    Parameter(s)
     $size     : Numeric var  : Size of returned array
    Notes
================================================================
#ce
Func Debug_SetDUmmyData($size)
local $Debug_Array[$size], $x
for $x = 1 to $size - 1
    $Debug_Array[$x] = "Test String No. " & $x
next
return $Debug_Array
EndFunc

All help will be appreciated.

Edited by Del

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

I've fixed the ListView problem, I was using an empty string in:

GUICtrlCreateListView ( "text", left, top, width, height, style)

for the text. Never thought it would be something as simple as that. I said I was doing something silly.

Why was this causing problems?

Just got to try and figure out why the combo box is broken now :(

Edit: I was using an array rather than a delimited string :)

Trust me, I know what I'm doing :think:

I'll be back, I will have so many more questions to ask ;)

Edited by Del

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  
Followers 0