Private Declare Function LockWindowUpdate Lib "User32" (Byval Hwndlock As System.Intptr) AS LONG
Private structure size
DIM CX As Long
DIM CY As Long
End structure
Public Sub Lockwindow (Byval Hwnd As System.InTptr)
Dim Lret As Long
Lret = lockWindowUpdate (hwnd)
End Sub
Private sub ReleaseWindow ()
Dim Lret As Long
Lret = lockwindowupdate (Nothing)
End Sub
Private subcombodropdown (Byref Comboobj As ComboBox)
Call sendMessage (Comboobj.handle, CB_Showdropdown, 1, 0 &)
End Sub
Private subcomboretract (byref comboobj as comboBOX)
Call sendMessage (Comboobj.handle, CB_Showdropdown, 0, 0 &)
End Sub
Public Function Comboautocomplete (Byref Comboobj As ComboBox) AS Boolean
DIM LNGITEMNUM AS Long
Dim lngselectedLENGTH AS Long
DIM LNGMATCHLENGTH AS Long
DIM STRCURRENTTEXT AS STRING
DIM STRSEARCHTEXT AS STRING
DIM STYPEDTEXT AS STRING Const CB_LOCKED = & H255
Try
With (Comboobj)
If .text = Nothing Then
EXIT FUNCTION
END IF
Call lockwindow (.handle)
IF ((INSTEXTCOMPARE) <> 0 and len (.tag) = len (.text) - 1) or (.text, 1) <> left (.tag, 1 ) And .tag <> nothing))))) and .tag <> cstr (cb_locked) THEN
StrsearchText = .text
LNGSelectedLength = LEN (STRSEARCHTEXT)
LNGITEMNUM = .findstring (strSearchtext)
Comboautocomplete = not (LNGITEMNUM = -1)
IF Comboautocomplete Then
LNGMATCHLENGTH = LEN (.Items.Item (LNGITEM (LNGITEMNUM)) - LNGSELECTEDLENGTH .TAG = CB_LOCKED
STYPEDTEXT = STRSEARCHTEXT
.Text = .text & right (.Items.Item (LNGITEMNUM), LNGMATCHLENGTH)
.SeLectionStart = lngselectedLength
DIM TEMP AS INTEGER TEMP = LNGMatchLength .SerectionLength = Temp
'.Text = .text & right (.items.Item (LNGITEMNUM), LNGMATCHLENGTH) .TAG = STYPEDTEXTEND IF
Elseif.tag <> cstr (cb_locked) THEN
.Tag = .text
END IF
Call releasewindow ()
End with
Catch Err as Exception
MsgBox (Err.Message & Err.stackTrace)
END TRY
END FUNCTION