Spiff59 Posted February 2, 2009 Share Posted February 2, 2009 I'd posted once a month or two ago that I thought changing a few lines in _GUICtrlComboBox_AutoComplete made it a little more functional, and possibly improved it's appearance. I got zero comments, so I'll make life easy and include a stand-alone side-by-side comparison script. The changes basically make the autocomplete driven by cursor position, rather than maintaining a portion of the string as highlighted and using that to drive the function. This changes the appearance of strings in the autocomplete, I think making them somewhat easier to read, but the main change is that basing off of cursor position allows one to process the delete and backspace characters, rather than having to ignore them. I loaded up quite a few "A" strings for testing in the array, but feel free to play. Ok, I have my body armor on... Comments? expandcollapse popup#include <WindowsConstants.au3> #include <GuiConstants.au3> #include <GuiComboBox.au3> $list = "Aaron|Ada|Adams|Adamsville|Adell|Adelman|Adenson|Akron|Appleton|Bannock|Bear Lake|Benewah|Bingham|Blaine|Boise|Bonner|Bonneville|" & _ "Boundary|Butte|Camas|Canyon|Caribou|Cassia|Clark|Clearwater|Custer|Elmore|Franklin|Fremont|Gem|G ooding|Idaho|Jefferson|Jerome|" & _ "Kootenai|Latah|Lemhi|Lewis|Lincoln|Madison|Minidoka|Oneida|Owyhee|Payette|Power|Shoshone|Teton|T win Falls|Valley|Washington" GUICreate("_GUICtrlComboBox_AutoComplete comparison",430,180) GUICtrlCreateLabel(StringReplace($list,"|"," "), 10, 10, 400, 100) GUICtrlCreateLabel("CURRENT VERSION", 10, 110, 200) $Ctrl_Combo1 = GUICtrlCreateCombo("", 10, 130, 200) GUICtrlSetData($Ctrl_Combo1, $list) GUICtrlCreateLabel("MODIFIED VERSION", 220, 110, 200) $Ctrl_Combo2 = GUICtrlCreateCombo("", 220, 130, 200) GUICtrlSetData($Ctrl_Combo2, $list) GUICtrlCreateLabel("The delete and backspace keys are functional only in the modified version.", 10, 160, 400) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd ;------------------------------------------------------------------------- Func _GUICtrlComboBox_AutoComplete2($hWnd) Local $ret, $sInputText, $sEditText, $sEditSel If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) $sEditSel = _GUICtrlComboBox_GetEditSel($hWnd) If IsArray($sEditSel) Then $sEditSel = $sEditSel[0] EndIf $sEditText = StringLeft(_GUICtrlComboBox_GetEditText($hWnd), $sEditSel) _GUICtrlComboBox_SetEditText($hWnd, $sEditText) If StringLen($sEditText) Then $ret = _GUICtrlComboBox_FindString($hWnd, $sEditText) If ($ret <> $CB_ERR) Then _GUICtrlComboBox_SetCurSel($hWnd, $ret) EndIf _GUICtrlComboBox_SetEditSel($hWnd, $sEditSel, $sEditSel) EndIf EndFunc ;==>_GUICtrlComboBox_AutoComplete2 ;------------------------------------------------------------------------- Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) ;HiWord $nID = BitAnd($wParam, 0x0000FFFF);LoWord If $nID = $Ctrl_Combo1 Then Switch $nNotifyCode Case $CBN_EDITCHANGE _GUICtrlComboBox_AutoComplete($Ctrl_Combo1) EndSwitch EndIf If $nID = $Ctrl_Combo2 Then Switch $nNotifyCode Case $CBN_EDITCHANGE _GUICtrlComboBox_AutoComplete2($Ctrl_Combo2) EndSwitch EndIf EndFunc Link to comment Share on other sites More sharing options...
BrettF Posted February 2, 2009 Share Posted February 2, 2009 Does seem a little nicer IMO, maybe have both versions in the same function, and add an option parameter as a switch to set which? My 2 cents Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now