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

  1. #include <GUIConstants.au3>
  2. #include <GuiList.au3>
  3.  
  4. Opt ('MustDeclareVars', 1)
  5.  
  6. Dim $msg, $ret
  7. Dim $input, $listbox, $button, $label, $button2
  8.  
  9. GUICreate("ListBox Find String Demo", 400, 250, -1, -1)
  10. GUICtrlCreateLabel("Enter item to add", 25, 15)
  11. $input = GUICtrlCreateInput("", 125, 10, 180, 25)
  12.  
  13. $listbox = GUICtrlCreateList("", 125, 40, 180, 120)
  14. GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
  15. $button = GUICtrlCreateButton("Begins with", 85, 160, 120, 40)
  16. $button2 = GUICtrlCreateButton("Exact Match", 215, 160, 120, 40)
  17. $label = GUICtrlCreateLabel("Item #", 150, 210, 120)
  18.  
  19. GUISetState()
  20. While 1
  21.     $msg = GUIGetMsg()
  22.     Select
  23.         Case $msg = $GUI_EVENT_CLOSE
  24.             ExitLoop
  25.         Case $msg = $button
  26.             If (StringLen(GUICtrlRead($input)) > 0) Then
  27.                 $ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input))
  28.                 If ($ret == $LB_ERR) Then
  29.                     MsgBox(16, "Error", "Unknown error from _GUICtrlListFindString")
  30.                 Else
  31.                     GUICtrlSetData($label, "Item #: " & $ret)
  32.                 EndIf
  33.             EndIf
  34.         Case $msg = $button2
  35.             If (StringLen(GUICtrlRead($input)) > 0) Then
  36.                 $ret = _GUICtrlListFindString($listbox, GUICtrlRead($input), 1)
  37.                 If ($ret == $LB_ERR) Then
  38.                     MsgBox(16, "Error", "Unknown error from _GUICtrlListFindString")
  39.                 Else
  40.                     GUICtrlSetData($label, "Item #: " & $ret)
  41.                 EndIf
  42.             EndIf
  43.     EndSelect
  44. WEnd
  45.