Rogue5099 Posted August 27, 2011 Posted August 27, 2011 (edited) I want to make the following checkboxes into an array. I know I could just do Checkbox[1], Checkbox[2] but I would like to simplify it to a loop. $Checkbox1 = GUICtrlCreateCheckbox("1", 240, 136, 33, 17) $Checkbox2 = GUICtrlCreateCheckbox("2", 280, 136, 33, 17) $Checkbox3 = GUICtrlCreateCheckbox("3", 240, 160, 33, 17) $Checkbox4 = GUICtrlCreateCheckbox("4", 280, 160, 33, 17) $Checkbox5 = GUICtrlCreateCheckbox("5", 240, 184, 33, 17) $Checkbox6 = GUICtrlCreateCheckbox("6", 280, 184, 33, 17) $Checkbox7 = GUICtrlCreateCheckbox("7", 240, 208, 33, 17) $Checkbox8 = GUICtrlCreateCheckbox("8", 280, 208, 33, 17) My problem is the 240-280 and the 2x 136, 160, 184 other wise i could just do 136+24 EDIT: Ok so far I have gotten this far on my own: For $i = 1 To 8 If Mod($i, 2) = 0 Then $Checkbox[$i] = GUICtrlCreateCheckbox($i, 280, 136, 33, 17) Else $Checkbox[$i] = GUICtrlCreateCheckbox($i, 240, 136, 33, 17) EndIf Next Edited August 27, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats
Moderators Melba23 Posted August 27, 2011 Moderators Posted August 27, 2011 rogue5099, I will let you work out how I did it: #include <GUIConstantsEx.au3> Global $aCheck[8] $hGUI = GUICreate("Test", 500, 500) For $i = 0 To 3 For $j = 0 To 1 $aCheck[($i * 2) + $j] = GUICtrlCreateCheckbox(($i * 2) + $j + 1, 240 + (40 * $j), 136 + (24 * $i), 33, 17) Next Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $aCheck[0] To $aCheck[7] ConsoleWrite("You actioned Checkbox " & $iMsg - $aCheck[0] + 1 & @CRLF) EndSwitch WEnd M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
UEZ Posted August 27, 2011 Posted August 27, 2011 (edited) Here the one liner loop from M23's example : For $i = 0 To 7 $aCheck[$i] = GUICtrlCreateCheckbox($i + 1, 240 + Mod($i, 2) * 40, 136 + ($i + 1 + Floor(Mod($i + 1, 2) - 2)) * 12, 33, 17) Next Br, UEZ Edited August 27, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Moderators Melba23 Posted August 27, 2011 Moderators Posted August 27, 2011 UEZ, And back to you! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Rogue5099 Posted August 27, 2011 Author Posted August 27, 2011 Nice UZE and you too Melba23. I just dont have the brain power to come up with these algorithms! My projects: Inventory / Mp3 Inventory, Computer Stats
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now