sissy Posted July 1, 2007 Share Posted July 1, 2007 hi guys, im fairly new to autoit even tho i have known about it for years i never really had a need to use it until now. its abilities seem pretty sweet and im sure ill find alot more use for it now for my problem - i have a combobox with numbers 1 to 48 in it which i use to generate buttons dynamically. that part works fine, however when i choose less buttons then the previous one (ie 12 buttons to 8 buttons) and do this multiply times with different values the array seems to get confused and no longer removes the range of buttons. if i just loop through deleting all buttons everytime regardless this works fine but seems quite inefficient. expandcollapse popupDim $btn[48] Local $totalBtns = 0 $numberCombo = GUICtrlCreateCombo('', 100, 50, 145, 25) GUICtrlSetData($numberCombo, totalNumbers()) GUICtrlSetOnEvent($numberCombo, 'numberComboChange') Func totalNumbers() Local $items For $i = 1 to 48 Step 1 $items &= $i & '|' Next return $items EndFunc Func numberComboChange() $result = GUICtrlRead($numberCombo) ;If $totalBtns > 0 Then ; MsgBox(4096, '', 'start deleting') ; For $i = 1 To $totalBtns ; GUICtrlDelete($btn[$i]) ; Next ;EndIf If $result < $totalBtns Then MsgBox(4096, '', 'start deleting') MsgBox(4096, '', 'result ' & $result & ' totalBtns ' & $totalBtns) For $i = $totalBtns To $result Step - 1 GUICtrlDelete($btn[$i]) Next EndIf genrateButtons($result) EndFunc Func genrateButtons($btns) $x = 20 $y = 100 For $i = 1 To $btns $btn[$i] = GUICtrlCreateButton('Button ' & $i, $x, $y, 60, 25, 0) GUICtrlSetOnEvent(-1, 'copyNumber') $x += 65 If mod($i, 6) = 0 Then $x = 20 $y += 30 EndIf $totalBtns = $i Next EndFunc any help would be greatly appreciated. thanks Link to comment Share on other sites More sharing options...
Uten Posted July 1, 2007 Share Posted July 1, 2007 Should not this take into account the existing buttons? Func genrateButtons($btns) $x = 20 $y = 100 For $i = 1 To $btnsoÝ÷ Ù*+jØ^®Ê&zØb b殶sdgVæ2vVç&FT'WGFöç2b33c¶'Fç2¢b33c·Ò#¢b33c·Ò¢f÷"b33c¶Òb33c¶Æ7D'FâFòb33c¶'Fç0 You could save the last valide button at $btn[0] to keep track if it. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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