nlta1992 Posted March 24, 2017 Posted March 24, 2017 I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next. Thanks.
Moderators Melba23 Posted March 24, 2017 Moderators Posted March 24, 2017 nlta1992, Something like this perhaps? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Array to hold button ControlIDs Global $aButton[11] $hGUI = GUICreate("Test", 500, 500) ; A double loop to space out the buttons - but you could very easily have a single one instead For $i = 0 To 1 For $j = 1 To 5 $iIndex = ($i * 5) + $j ; Create button using a suitable algorithm to locate it $aButton[$iIndex] = GUICtrlCreateButton("Button " & $iIndex, 10 + (250 * $i), ($j * 50) - 30, 80, 30) Next Next GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case Else ; See if a button was pressed For $i = 1 To 10 If $iMsg = $aButton[$i] Then ; Do what is necessary MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i) ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd M23 nlta1992 and Skysnake 2 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
antonioj84 Posted March 28, 2017 Posted March 28, 2017 Hey Melba, Can you show a quick example how would you do that with a check radio button, starting state will be uncheck. Thanks
Moderators Melba23 Posted March 28, 2017 Moderators Posted March 28, 2017 antonioj84, Simply replace GUICtrlCreateButton with GUICtrlCreateRadio. M23 antonioj84 1 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
antonioj84 Posted March 28, 2017 Posted March 28, 2017 adding unique name radio button ; Array to hold button ControlIDs ;Global $aButton[11] ; 4x 5 = 21 Global $aButton[11] Global $aName[11]=["0","Ajohn","Bjohn","Cjohn","Djohn","Ejohn","Fjohn","Jjohn","Hjohn","Ijohn","Jjohn"] $hGUI = GUICreate("Test", 500, 500) ; A double loop to space out the buttons - but you could very easily have a single one instead For $i = 0 To 1 ; 0 to 3 x4 For $j = 1 To 5 $iIndex = ($i * 5) + $j ; Create button using a suitable algorithm to locate it $aButton[$iIndex] = GUICtrlCreateRadio($aName[$iIndex] &$iIndex, 10 + (150 * $i), ($j * 50) - 30, 80, 30) ; $index,20 Next Next GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case Else ; See if a button was pressed For $i = 1 To 10 ;20 If $iMsg = $aButton[$i] Then ; Do what is necessary MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i) ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd
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