Jump to content

Creating labels from array


Basti756
 Share

Recommended Posts

Hi,

I'm trying to create a GUI with several labels on it. The labels should be created dynamically, depeding on the key/value pairs of a section of an INI file.

Here's the code I got so far:

#include <GUIConstantsEx.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)

$x = @DesktopWidth
$y = @DesktopHeight
$a = 15
GUICreate("",$x,$y,0,0)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$aUserNames = IniReadSection ("users.ini","users")
_ArrayDisplay ($aUserNames)
    For $i=1 To $aUserNames[0][0]
        For $a=15 To $y-200 Step 15
        GUICtrlCreateLabel ($aUserNames[$i][1], 10,$a,100,30)
        Next
    Next

GUISetState (@SW_SHOW)

While 1
    Sleep (1000)
Wend


Func CLOSEClicked()
    Exit
EndFunc

The problem I'm having is that only the last value of the INI file is displayed - even more than . I bet I did something like that once before but I can't remember how. So if somebody could point me to the right direction please? >_<

Thanks in advance

Link to comment
Share on other sites

Not Tested...

#include <GUIConstantsEx.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)

$x = @DesktopWidth
$y = @DesktopHeight
$a = 10
$b = 15
GUICreate("", $x, $y, 0, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$aUserNames = IniReadSection("users.ini", "users")
_ArrayDisplay($aUserNames)
For $i = 1 To $aUserNames[0][0]
    GUICtrlCreateLabel($aUserNames[$i][1], $a, $b, 100, 15)
    $b += 15
    If $b >= ($y - 15) Then
        $a += 120
        $b = 15
    EndIf
Next

GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
WEnd


Func CLOSEClicked()
    Exit
EndFunc   ;==>CLOSEClicked

8)

Edited by Valuater

NEWHeader1.png

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