Advertisement
AZJIO

Событие для однотипных элементов

Feb 13th, 2013
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.24 KB | None | 0 0
  1. ; Пример показывает, что не обязательно использовать цикл проверки событий для однотипных элементов. Достаточно указать диапазон в конструкции Switch
  2. ; The example shows that it isn't obligatory to use separate events in a loop for the same elements. Sufficient to indicate the range in design Switch
  3.  
  4. $hGui = GUICreate('My Program', 450, 400)
  5. GUICtrlCreateGroup("", 88, 20, 233, 273)
  6.    
  7. $iCount = 30 ; Количество пунктов      (The number of items)
  8. $iRows = 10 ; Количество строк       (The number of rows)
  9. Global $BoxConfig[$iCount + 1] = [$iCount], $a[10] = [0, 0, $iRows, 96, 36, 26, 70, -1, 1]
  10. ; a[0] - X-координата элемента        (The X-coordinate of the element)
  11. ; a[1] - Y-координата элемента        (The Y-coordinate of the element)
  12. ; a[2] - Количество строк в блоке      (The number of rows in the block)
  13. ; a[3] - X-координата блока      (The X-coordinate of the box)
  14. ; a[4] - Y-координата блока      (The Y-coordinate of the box)
  15. ; a[5] - Вертикальный шаг в блоке      (Vertical step in block)
  16. ; a[6] - Горизонтальный шаг в блоке      (Horizontal step in block)
  17. ; a[7] - Индекс текущей колонки     (The index of the current column)
  18. ; a[8] - Индекс пункта следующей колонки        (Index of item of the next column)
  19. For $i = 1 To $iCount
  20.     _NextItem($a, $i)
  21.     $BoxConfig[$i] = GUICtrlCreateRadio("Check " & $i, $a[0], $a[1], 62, 17)
  22. Next
  23. $a = 0
  24. GUICtrlCreateGroup("", -99, -99, 1, 1)
  25. GUISetState()
  26.  
  27. While 1
  28.     $nMsg = GUIGetMsg()
  29.     Switch $nMsg
  30.         Case $BoxConfig[1] To $BoxConfig[$BoxConfig[0]]
  31.             $j = $nMsg - $BoxConfig[1] + 1
  32.             MsgBox(0, 'Check', $j, 0, $hGui)
  33.         Case -3
  34.             Exit
  35.     EndSwitch
  36. WEnd
  37.  
  38. Func _NextItem(ByRef $a, $i)
  39.     If $i = $a[8] Then
  40.         $a[8] += $a[2]
  41.         $a[7] += 1
  42.     EndIf
  43.     $a[0] = $a[7] * $a[6] + $a[3] ; X
  44.     $a[1] = $a[4] + Mod($i - 1, $a[2]) * $a[5] ; Y
  45. EndFunc   ;==>_NextItem
  46.  
  47. ; Func _NextItem2(ByRef $a, $i)
  48.     ; $a[0] = (Ceiling($i / $a[2]) - 1) * $a[6] + $a[3] ; X
  49.     ; $a[1] = $a[4] + Mod($i - 1, $a[2]) * $a[5] ; Y
  50. ; EndFunc   ;==>_NextItem2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement