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

  1. #include <GuiConstants.au3>
  2. #include <GuiListView.au3>
  3.  
  4. ;~ Const $LVS_SORTDESCENDING = 0x0020
  5. opt('MustDeclareVars', 1)
  6. Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
  7. GUICreate("ListView Insert Item", 392, 322)
  8.  
  9. $listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
  10. GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
  11. GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
  12. GUICtrlCreateListViewItem("line1|data1|more1", $listview)
  13. GUICtrlCreateListViewItem("line2|data2|more2", $listview)
  14. GUICtrlCreateListViewItem("line3|data3|more3", $listview)
  15. GUICtrlCreateListViewItem("line4|data4|more4", $listview)
  16. GUICtrlCreateListViewItem("line5|data5|more5", $listview)
  17. _GUICtrlListViewSetColumnWidth ($listview, 0, 75)
  18. _GUICtrlListViewSetColumnWidth ($listview, 1, 75)
  19. _GUICtrlListViewSetColumnWidth ($listview, 2, 75)
  20. GUICtrlCreateLabel("Enter Item # to Insert To:", 90, 190, 130, 20)
  21. $Input_Index = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
  22. $Btn_Insert = GUICtrlCreateButton("Insert Item", 150, 230, 90, 40)
  23. $Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
  24. $Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
  25.  
  26. GUISetState()
  27. While 1
  28.    $msg = GUIGetMsg()
  29.    Select
  30.       Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
  31.          ExitLoop
  32.       Case $msg = $Btn_Insert
  33.          If (StringLen(GUICtrlRead($Input_Index)) > 0) Then
  34.             $ret = _GUICtrlListViewInsertItem ($listview, Int(GUICtrlRead($Input_Index)), "test|1|2")
  35.             If ($ret <> $LV_ERR) Then
  36.                GUICtrlSetData($Status, 'Inserted Item at: ' & $ret)
  37.             Else
  38.                GUICtrlSetData($Status, 'Failed to Insert Item')
  39.             EndIf
  40.          Else
  41.             GUICtrlSetData($Status, 'Must enter a Item Index to insert')
  42.          EndIf
  43.    EndSelect
  44. WEnd
  45. Exit
  46.