JoshuaLoman Posted February 3, 2012 Share Posted February 3, 2012 Still experimenting with autoit.. dont know how to get the following to work I have a GUI, where i need to create multiple(like 50) checkboxes under or next to each other. Until now i have this code: Global $CheckboxCount = "50" For $CheckboxCounter = 1 to $CheckboxCount GUICtrlCreateCheckbox("TS00" & $CheckboxCounter & "",5,10) Next So i need to create multiple checkboxes with the name TS001, TS002, TS003 etc. Well i think this counter does that job. The following problem is, how to place the checkboxes under eacher other, so the height must count up with 20 for examples, so it makes height 10, 30, 50 etc. any help would be appreciated Link to comment Share on other sites More sharing options...
Robjong Posted February 3, 2012 Share Posted February 3, 2012 (edited) Untested, but it should get you started ; the 3 in %03d is the length of the number including leading zeros you want ; 8 + ($i * 20) Local $CheckboxCount = 10 For $CheckboxCounter = 1 to $CheckboxCount GUICtrlCreateCheckbox(StringFormat('TS%03d', $CheckboxCounter), 5, 8 + ($CheckboxCounter * 20)) ; 8 is starting offset, 20 is assumed height Next Edited February 3, 2012 by Robjong Link to comment Share on other sites More sharing options...
JoshuaLoman Posted February 3, 2012 Author Share Posted February 3, 2012 Works great thanks! I understand what you are doing.. But the next thing is.. what is want now is that the checkboxes after 20, form a new row next to the row 1 til 20.. so it will adjust the width automatically for 21 til 30 etc.. Cant figure it out with if then else.. Link to comment Share on other sites More sharing options...
Robjong Posted February 3, 2012 Share Posted February 3, 2012 (edited) how about something like this (again untested) Local $CheckboxCount = 30, $iOffsetLeft = 5, $iOffsetTop = 10 For $CheckboxCounter = 1 to $CheckboxCount GUICtrlCreateCheckbox(StringFormat('TS%03d', $CheckboxCounter), $iOffsetLeft, $iOffsetTop) ; 8 is starting offset, 20 is assumed height $iOffsetTop += 20 If IsInt($CheckboxCounter / 10) Then $iOffsetLeft += 150 ; this was item 10, 20 30 etc. so we update offset from the left $iOffsetTop = 10 EndIf Next Edit: forgot to reset top offset before Edited February 3, 2012 by Robjong Link to comment Share on other sites More sharing options...
JoshuaLoman Posted February 3, 2012 Author Share Posted February 3, 2012 Thanks, works! Link to comment Share on other sites More sharing options...
JoshuaLoman Posted February 6, 2012 Author Share Posted February 6, 2012 (edited) The checkboxes are created well, but now the problem is that i want to read the $GUI_CHECKED from a particular checkbox when i click the function ButtonServersOk. Apparently i cannot use GUICTRLRead with arrays so i cannot do the $GUI_CHECKED check. Cant get it to work. Global $CheckboxArray[50] Func ButtonServers() Local $CheckboxCount = 50, $iOffsetLeft = 5, $iOffsetTop = 10 $ServersPopup = GUICreate("Servers",270,440) GUISetIcon("icon.ico") TraySetIcon("icon.ico") $btnServersOk = GUICtrlCreateButton("Ok",5,415,90,20) GUICtrlSetOnEvent($btnServersOk, "ButtonServersOk") GUISetOnEvent($GUI_EVENT_CLOSE, "ClosePopup") GUICtrlCreateCheckbox("Alle servers",100,415) For $CheckboxCounter = 1 to $CheckboxCount GUICtrlCreateCheckbox(StringFormat("TS%03d", $CheckboxCounter), $iOffsetLeft, $iOffsetTop) $iOffsetTop += 20 If IsInt($CheckboxCounter / 20) Then $iOffsetLeft += 70 $iOffsetTop = 10 EndIf $CheckboxArray[$CheckboxCounter -1] = $CheckboxCounter Next GUISetState(@SW_SHOW, $ServersPopup) EndFunc Func ButtonServersOk() $CheckboxChecked = GUICtrlRead($CheckboxArray[1]) If $CheckboxChecked = $GUI_CHECKED Then MsgBox(0,"", $CheckboxChecked) EndIf EndFunc Edited February 6, 2012 by JoshuaLoman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 6, 2012 Moderators Share Posted February 6, 2012 JoshuaLoman, i cannot use GUICTRLRead with arraysOf course you can - but you need to loop through the elements like this: expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $ServersPopup, $CheckboxCount = 50, $CheckboxArray[$CheckboxCount + 1] ButtonServers() While 1 Sleep(10) WEnd Func ButtonServers() Local $iOffsetLeft = 5, $iOffsetTop = 10 $ServersPopup = GUICreate("Servers", 270, 440) GUISetOnEvent($GUI_EVENT_CLOSE, "ClosePopup") ;GUISetIcon("icon.ico") ;TraySetIcon("icon.ico") $btnServersOk = GUICtrlCreateButton("Ok", 5, 415, 90, 20) GUICtrlSetOnEvent($btnServersOk, "ButtonServersOk") GUICtrlCreateCheckbox("Alle servers", 100, 415) For $CheckboxCounter = 1 To $CheckboxCount GUICtrlCreateCheckbox(StringFormat("TS%03d", $CheckboxCounter), $iOffsetLeft, $iOffsetTop) $iOffsetTop += 20 If IsInt($CheckboxCounter / 20) Then $iOffsetLeft += 70 $iOffsetTop = 10 EndIf $CheckboxArray[$CheckboxCounter - 1] = $CheckboxCounter Next GUISetState(@SW_SHOW, $ServersPopup) EndFunc ;==>ButtonServers Func ButtonServersOk() For $i = 1 To $CheckboxCount If GUICtrlRead($CheckboxArray[$i]) = 1 Then MsgBox(0, "", GUICtrlRead($CheckboxArray[$i], 1) & " checked") EndIf Next EndFunc ;==>ButtonServersOk Func ClosePopup() GUIDelete($ServersPopup) Exit EndFunc All clear? M23 P.S. Please post code that actually works if you want help - not everyone is prepared to add the necessary additional lines for it to run. 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 Link to comment Share on other sites More sharing options...
JoshuaLoman Posted February 6, 2012 Author Share Posted February 6, 2012 Works, great!! Very clear to me About the code, will do it right next time Link to comment Share on other sites More sharing options...
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