Sign in to follow this  
Followers 0
Basti756

Creating labels from array

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks a lot. You made my day >_

Share this post


Link to post
Share on other sites

Welcome!!

You were gone so long, I didn't think you were going to see the code I wrote.

8)


NEWHeader1.png

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