#include #include #include #include #Include #include #include Global $hGUI, $cInput, $cList, $sPartialData, $asKeyWords[100], $fShowing = True ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 400, 500) $cInput = GUICtrlCreateInput("", 5, 5, 300, 28) GUICtrlSetFont(-1, 14, 400, 0, "Verdana") $Combo1 = GUICtrlCreateCombo("Combo1", 5, 80, 265, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "item2|item3", "item3") $Edit1 = GUICtrlCreateEdit("", 5, 120, 300, 97) GUICtrlSetData(-1, "Pulse, Maeil Business Newspaper"&@CRLF&" English news service, will be dedicated"&@CRLF&" to the 21st World Knowledge Forum, "&@CRLF&"the largest annual business agenda "&@CRLF&"event held in Asia annually by South ") $cList = GUICtrlCreateList("", 5, 40, 300, 90, BitOR(0x00100000, 0x00200000)) GUICtrlSetFont($cList, 14, 400, 0, "Verdana") GUICtrlSetBkColor($cList, 0xFFCCCC) GUISetState($cList, $GUI_HIDE) $cButton = GUICtrlCreateButton("Read", 310, 3, 80, 30) $cUP = GUICtrlCreateDummy() $cDOWN = GUICtrlCreateDummy() $cENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $cUP], ["{DOWN}", $cDOWN], ["{ENTER}", $cENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sChosen = GUICtrlRead($cList) If $sChosen <> "" Then GUICtrlSetData($cInput, $sChosen) Case $cButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($cInput) If $sFinal And _ArraySearch($asKeyWords, $sFinal) >= 0 Then MsgBox($MB_SYSTEMMODAL, "Chosen", $sFinal) GUICtrlSetData($cInput, "") EndIf EndIf Case $cUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($cList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf Case $cENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($cList, $iCurrIndex) GUICtrlSetData($cInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($cInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($cInput) EndIf If GUICtrlRead($cInput) = "" And $fShowing Then GUICtrlSetState($cList, $GUI_HIDE) $fShowing = False ElseIf GUICtrlRead($cInput) <> "" And Not $fShowing Then GUICtrlSetState($cList, $GUI_SHOW) $fShowing = True EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($cInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($cList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 6 $asKeyWords[0] = "Bashful" $asKeyWords[1] = "Sleepy " $asKeyWords[2] = "Happy" $asKeyWords[3] = "Sneezy" $asKeyWords[4] = "Doc" $asKeyWords[5] = "Grumpy" $asKeyWords[6] = "Dopey" $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($cList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($cList, $iCurrIndex) EndFunc ;==>Keywords Func _PopupSelector($hMainGUI, ByRef $cListGUI, $sCurr_List) Local $cList = -1 If $sCurr_List = "" Then Return $cList EndIf $cListGUI = GUICreate("", 420, 160, 10, 120, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) ;GUICtrlSetFont(-1, 14, 400, 0, "Arial Rounded") $cList = GUICtrlCreateList("", 0, 0, 420, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetFont(-1, 13, 400, 0, "Arial Rounded") GUICtrlSetData($cList, $sCurr_List) GUISetState(@SW_SHOWNOACTIVATE, $cListGUI) Return $cList EndFunc ;==>_PopupSelector