Sign in to follow this  
Followers 0
Damein

Best way to track an array of buttons?

7 posts in this topic

So I have an array of buttons, that might reach in the hundreds and I need a way to track when a specific one is pressed.

Currently, I have it setup like this

Func _Floor1()
    GuiCtrlSetState($Floor1Image, $GUI_SHOW)
    For $i = 1 To 8
            $RoomStatus[$i] = IniRead(@ScriptDir & "\Data\Floor1Rooms.ini", $i, "Status", "Not Found")
            $RoomImage[$i] = @ScriptDir & "\Images\" & $RoomStatus[$i] & ".bmp"
            $X = IniRead(@ScriptDir & "\Data\Floor1Rooms.ini", $i, "X", "Not Found")
            $Y = IniRead(@ScriptDir & "\Data\Floor1Rooms.ini", $i, "Y", "Not Found")
            GuiCtrlCreatePic($RoomImage[$i],$X,$Y,65,65)
            GuiCtrlSetState(-1, $GUI_SHOW)
            $CheckMaintenance = IniRead(@ScriptDir & "\Data\Floor1Rooms.ini", $i, "Maintenance", "Not Found")
            If $CheckMaintenance = 1 Then
                $MaintenanceButtonIssue[$i] = GuiCtrlCreateButton("Test",$X+12, $Y+12,40,40,$BS_BITMAP)
                GUICtrlSetImage(-1, $MaintenanceImage)
                GUICtrlSetOnEvent($MaintenanceButtonIssue[$i], "_Test")
                GuiCtrlSetState($MaintenanceButtonIssue[$i], $GUI_ONTOP)
            EndIf
        Next
EndFunc

Func _Test()
    For $i = 1 To 8
        $MaintenanceProblem[$i] = IniRead(@ScriptDir & "\Data\Service Recovery.ini", $i, "Problem", "Not Found")
        If $MaintenanceProblem[$i] > "" Then
        MsgBox(0, "Test", $MaintenanceProblem[$i])
        ExitLoop
        EndIf
    Next
EndFunc

But obviously it will stop at the first sign of MaintenanceProblem[$i] having a value. I don't wan't it to do that, I need it to track which button was pressed from the array $MaintenanceButtonIssue[$i] set in the Floor1 function.


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



You can use this to get the last button clicked

@GUI_CtrlId Last click GUI Control identifier. Only valid in an event Function. See the GUICtrlSetOnEvent function

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Okay, when using that I can get the ID of the button, but how do I use that in conjunction with an Inifile that has sections like this

[1]

Problem=Damaged

[2]

Problem=

[3]

Problem=Broken

Now what is happening the buttons are being created each time a value is assigned to Problem in the Inifile. When I click that button, I need to be able to pull that Problem's value out of the Inifile, and just that one.


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

Aaaah, I wasn't thinking about it that way.

Got it, I assigned each button the current $i value when its created and then used

$ID = @GUI_CtrlId
    $Info = GuiCtrlRead($ID)
    $ShowProblem = IniRead(@ScriptDir & "\Data\Service Recovery.ini", $Info, "Problem", "Not Found")
    MsgBox(0, "Test", $ShowProblem)

Thanks for the help!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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