Jump to content

IniReadSectionNames Vs. GuiCtrlCreateListViewItem


Dreu
 Share

Recommended Posts

Alright so I'm a writing little tool that will help me keep track of things... Got an issue though that I've been toying with for about an hour now.

Func _UpdateSearch()
    $Players_List_Array = IniReadSectionNames($Players_Ini)
    If @Error Then
        MsgBox(0, "Error", "1 : "&@Error); This isn't triggered.
    Else
        GuiCtrlSetData($players_list, "")
        For $i = 1 To $Players_List_Array[0]
            GuiCtrlCreateListViewItem($Players_List_Array[$i], $Players_List); This doesn't add the value to the listview.
            If @Error Then
                MsgBox(0, "Test", @Error); This isn't triggered either.
            EndIf
        Next
    EndIf
EndFunc

I've been abusing the forums search feature to find a previous topic in relation. I found a few, but those wanted the values of the section as well... thus requiring a double nested loop and the help of UBound()... I only want the section name to be displayed, so after reviewing the helpfile and hunting the forums for the last hour... I've come to believe that IniReadSectionNames() used in conjunction with a simple For $i = 1 To $array[0] look should do exactly what I need...

But my logic is obviously failed somewhere, or I wouldn't be posting this in shame XD. This is only a very small part of the script as a whole... but all in all, its fairly complete in regards to its sole intentions. Only part of this function not quite shown is where I declared $Player_List as the GUICtrlCreateListView.

Any help would be much appreciated =(

What I've done so far:

Massive about of time spent scripting error checks after error checks... It never triggers an error, but it never displays the listview O_O.

I've searched, found, and tested examples in the helpfile... and they worked... but after trying to modify them in a way that would suit my need, I'm back at sqaure #1.

Bang my head against the desk a few times

Try again.

----------

Wits end =/... and possibly on the verge of a concussion.

Edited by Dreu
Link to comment
Share on other sites

Just realized I have a GuiCtrlSetData($listview, "") ... right before it GuiCtrlSetData()'s. However, theres currently only 1 section in the ini file for testing... so in the logical order its currently scripted in, it would still display the single value, right? ( Browser incompatibility or I would use the Edit button, sorry. )

Link to comment
Share on other sites

  • Moderators

Dreu,

First, please do not bump your posts within 24 hours. ;)

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Like this ;)

Your function works just fine when I test it with the following in the ini file:

[Tom]
[Dick]
[Harry]

Using your ini file, does the following code fill the listbox:

#include <GUIConstantsEx.au3>

$Players_Ini = "Your_Ini_path"

$hGUI = GUICreate("Test", 500, 500)

$Players_List = GUICtrlCreateListView("Player", 10, 10, 200, 200)
$hButton = GUICtrlCreateButton("Load", 10, 400, 80, 30)

GUISetState()

_UpdateSearch()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            _UpdateSearch()
    EndSwitch
WEnd

Func _UpdateSearch()
    $Players_List_Array = IniReadSectionNames($Players_Ini)
    If @Error Then
        MsgBox(0, "Error", "1 : "&@Error); This isn't triggered.
    Else
        GuiCtrlSetData($players_list, "")
        For $i = 1 To $Players_List_Array[0]
            GuiCtrlCreateListViewItem($Players_List_Array[$i], $Players_List); This doesn't add the value to the listview.
            If @Error Then
                MsgBox(0, "Test", @Error); This isn't triggered either.
            EndIf
        Next
    EndIf
EndFunc

If not, what error do you get? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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