I have the following code for auto complete of a textbox. My problem is that it does not handle the backspace or delete key without having to write extra code in the keyup event.
Is there any way to handle it and have all the related code in one event?
Function JOBFORM_CUSTTXT_EN_CHANGE ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idTextControl As Long _ ' identifier of text control
) As Long
Local lIndex, Count, CursorLocation As Long
Local TempStr As String
If gBackSpace Then Exit Function
TempStr = FF_TextBox_GetText( HWND_JOBFORM_CUSTTXT)
CursorLocation = FF_TextBox_GetSelStart(HWND_JOBFORM_CUSTTXT)
TempStr = Mid$(TempStr,1,CursorLocation)
Count = UBound(gCustomers())
' Search the current item in the list
For lIndex = 0 To Count
If InStr(1, Mid$(UCase$(gCustomers(lIndex)),1,Len(TempStr)), UCase$(TempStr)) > 0 Then
FF_TextBox_SetText HWND_JOBFORM_CUSTTXT, ""
FF_TextBox_SetText HWND_JOBFORM_CUSTTXT, gCustomers(lIndex)
FF_TextBox_SetSel HWND_JOBFORM_CUSTTXT, Len(TempStr), Len(gCustomers(lIndex))
End If
Next lIndex
End Function
thanx
Bert
Forget it.
Keyboard moving before brain in gear. I put everything in Key_up works like charm.
Bert
Yeah, I wrote some autocomplete combobox code that is probably on both here and PB's forum. Here is the last version I had made for somebody in FF: (Key_Down can't be used too much cause Copy/Paste and highlighted text changes that effect more than one char)
Function FORM1_PORT_CBN_EDITCHANGE (ControlIndex As Long, hWndForm As Dword, hWndControl As Dword, idComboBox As Dword) As Long
Local searchResult As Long
Local lengthComboString As Dword
Local comboString As String
Static previousSize As Dword
Static preventLoop As Dword
If preventLoop = 0 Then
preventLoop = 1
comboString= FF_Control_GetText(HWND_FORM1_PORT)
lengthComboString = Len(comboString)
If lengthComboString > previousSize Then
searchResult= SendMessage(HWND_FORM1_PORT, %CB_SELECTSTRING, -1, StrPtr(comboString))
If searchResult = %CB_ERR Then FF_Control_SetText(HWND_FORM1_PORT, comboString)
End If
SendMessage(HWND_FORM1_PORT, %CB_SETEDITSEL, 0, MakDwd(lengthComboString,-1))
previousSize = lengthComboString
preventLoop = 0
End If
End Function
My code is for a textbox you store all the entries in a string array and will look thru the array and autofill. Simple but does what I need
thanx anyways
bert
Same concept, just using Edit Box messages instead of Combo and putting your Search functions for the string array in the "If lengthComboString > previousSize" block.