Jump to content

Array For Checkbox


tlokz
 Share

Recommended Posts

I wan't to know if you use like

Dim $CheckBox[5]

For $i = 0 To 4
    $Checbkox[$i] = GUICtrlCreateCheckbox("", 45, 45) 
Next

Or something like that. I read a lua file and parse it and want to put them into a GUI. I don't wanna use set checkboxes because the wut the lua will have is random. Heres the func I have atm

Func _Populate()
   Local $Quality, $String, $Temp
   $Count = 55
   Dim $includes
   _FileReadToArray($luaincludes, $includes)
   For $i = 1 To $includes[0]
      If StringInStr($includes[$i], "Lua") <> 0 Then
         If StringInStr($includes[$i], "Magic") <> 0 Then
            $Quality = "Magics"
         ElseIf StringInStr($includes[$i], "Other") <> 0 Then
            $Quality = "Others"
         ElseIf StringInStr($includes[$i], "Rare") <> 0 Then
            $Quality = "Rares"
         ElseIf StringInStr($includes[$i], "Set") <> 0 Then
            $Quality = "Sets"
         ElseIf StringInStr($includes[$i], "Unique") <> 0 Then
            $Quality = "Uniques"
         ElseIf StringInStr($includes[$i], "White") <> 0 Then
            $Quality = "Whites"
         EndIf
         If $Quality <> "" Then
            $String = (StringLen($includes[$i]) - StringInStr($includes[$i], "lua")) + 2
            $String = StringTrimRight($includes[$i], $String)
            $Temp = StringInStr($String, StringTrimRight($Quality, 1))
            $String = StringTrimLeft($String, $Temp + StringLen($Quality))
            $Temp = StringUpper(StringLeft($String, 1))
            $String = StringTrimLeft($String, 1)
            $String = _StringInsert($Temp, $String, 1)
            If _GUICtrlTab_FindTab($GUITab, $Quality) = -1 Then
               GUICtrlCreateTabItem($Quality)
               $count = 55
            EndIf
            GUICtrlCreateCheckbox($string, 45, $count)
            $count += 20
         EndIf
      EndIf
   Next
   GUISetState(@SW_SHOW, $GUI)
EndFunc

If you need all the code or the lua file I'm parsing lmk. Thanks in advance!

Edited by tlokz
Link to comment
Share on other sites

Dim $CheckBox[5]

For $i = 0 To 4
    $Checbkox[$i] = GUICtrlCreateCheckbox("", 45, 45) 
Next

This is the correct way to do it.

By creating the checkboxes this way, every checkbox will be clearly identified and unique; you will need this later in your script when you have to set/read their state.

If GUICtrlRead($Checkbox[1] = $GUI_CHECKED Then Msgbox(0, "Is Checked", "Checkbox[1]")

If you do it this way:

GUICtrlCreateCheckbox($string, 45, $count)

you will see them all in your GUI but you can't identify them (think how can you check/read status of a control which doesn't have a handle?)

If GUICtrlRead(???handle??? = $GUI_CHECKED Then Msgbox(0, "Is Checked", "Checkbox")

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

It's not about an array holding a checkbox, that's impossible. :P

The array holds only the handles for checkboxes.

ahhh, now wut if I add a

GUICtrlSetOnEvent(-1, "_MyEvent")

after, is there a way to find the text of the checkbox that called the func? or wuld I have to jus do a complex save func? Save probably the proper way anyways

Link to comment
Share on other sites

You can add that line of code - that way every checkbox will call that function.

Depending on how you want your script to run (OnEventMode or not) you will have to use either @GUI_CtrlId or GUIGetMsg to detect where the event comes from.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

You can add that line of code - that way every checkbox will call that function.

Depending on how you want your script to run (OnEventMode or not) you will have to use either @GUI_CtrlId or GUIGetMsg to detect where the event comes from.

tyvm for all your help, u have helped out a lot!

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