home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / shareware / autoit-v3-setup.exe / Examples / Helpfile / _GUICtrlListViewGetSelectedIndices.au3 < prev    next >
Encoding:
Text File  |  2006-06-20  |  1.7 KB  |  46 lines

  1. #include <GuiConstants.au3>
  2. #include <GuiListView.au3>
  3.  
  4. Opt ('MustDeclareVars', 1)
  5. Dim $listview, $Btn_Exit, $msg, $Status, $Btn_piped, $Btn_array
  6. GUICreate("ListView Get Selected Indices", 392, 322)
  7.  
  8. $listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
  9. GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
  10. GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
  11. GUICtrlCreateListViewItem("line1|data1|more1", $listview)
  12. GUICtrlCreateListViewItem("line2|data2|more2", $listview)
  13. GUICtrlCreateListViewItem("line3|data3|more3", $listview)
  14. GUICtrlCreateListViewItem("line4|data4|more4", $listview)
  15. GUICtrlCreateListViewItem("line5|data5|more5", $listview)
  16. $Btn_piped = GUICtrlCreateButton("Return string", 75, 210, 90, 30)
  17. $Btn_array = GUICtrlCreateButton("Return array", 180, 210, 90, 30)
  18. $Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
  19. $Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
  20. GUISetState()
  21. While 1
  22.     $msg = GUIGetMsg()
  23.     Select
  24.         Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
  25.             ExitLoop
  26.         Case $msg = $Btn_piped
  27.             Local $s_indices =  _GUICtrlListViewGetSelectedIndices($listview)
  28.             If($s_indices == $LV_ERR) Then
  29.                 GUICtrlSetData($Status, "Not Items Selected")
  30.             Else
  31.                 MsgBox(0,"Selected", $s_indices)
  32.             EndIf
  33.         Case $msg = $Btn_array
  34.             Local $a_indices = _GUICtrlListViewGetSelectedIndices($listview,1)
  35.             If(IsArray($a_indices))Then
  36.                 Local $i
  37.                 For $i = 1 To $a_indices[0]
  38.                     MsgBox(0,"Selected", $a_indices[$i])
  39.                 Next
  40.             Else
  41.                 GUICtrlSetData($Status, "Not Items Selected")
  42.             EndIf
  43.     EndSelect
  44. WEnd
  45. Exit
  46.