Advertisement
7_2009-2012 Windows API Call/ Explanation #229588

Find faster a String in Combo or ListBox while typing (Using SendMessage API)

This code is useful to look at a string inside a ComboBox or ListBox, while you typing it

AI

AI சுருக்கம்: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

மூலக் குறியீடு
original-source
Private Sub Combo1_KeyPress(KeyAscii As Integer)
 Dim CB As Long
 Dim FindString As String
 Const CB_ERR = (-1)
 Const CB_FINDSTRING = &H14C
 If KeyAscii < 32 Or KeyAscii > 127 Then Exit Sub
 If Combo1.SelLength = 0 Then
 FindString = Combo1.Text & Chr$(KeyAscii)
 Else
 FindString = Left$(Combo1.Text, Combo1.SelStart) & Chr$(KeyAscii)
 End If
 CB = SendMessage(Combo1.hWnd, CB_FINDSTRING, -1, ByVal FindString)
 If CB <> CB_ERR Then
 Combo1.ListIndex = CB
 Combo1.SelStart = Len(FindString)
 Combo1.SelLength = Len(Combo1.Text) - Combo1.SelStart
 End If
 KeyAscii = 0
End Sub
அசல் கருத்துகள் (3)
வேபேக் மெஷினிலிருந்து (Wayback Machine) மீட்டெடுக்கப்பட்டது