VB 版 (精华区)
发信人: bloom (├┝┞┟┠┢┣), 信区: VB
标 题: 让TextBox变成具有URL自动完成功能
发信站: 哈工大紫丁香 (2000年08月28日12:56:03 星期一), 转信
实 际 上 IE实 现 的 URL自 动 完 成 功 能 并 不 是 调 用 API实 现 的 。 你 可
以 使 用 一 个 下 拉 框 或 文 本 框 +列 表 框 的 方 式 实 现 。
下 面 是 一 个 用 下 拉 框 实 现 的 示 例 :
' *************Declarations
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Const WM_SETREDRAW As Long = &HB&
Private Const CB_FINDSTRING As Long = &H14C&
*************Here is the sub that will implement auto search
Public Sub SearchCombo(InControl As Object)
On Error GoTo trap
Dim StrPos As Long
Dim lPos As Long
Dim SearchStr As String
If TypeOf InControl Is ComboBox Then
StrPos = InControl.SelStart
SearchStr = Left$(InControl.Text, StrPos)
lPos = SendMessage(InControl.hwnd, CB_FINDSTRING, 0, ByVal SearchStr)
If lPos >= 0 Then
InControl.Text = InControl.List(lPos)
InControl.ListIndex = lPos
End If
With InControl
.SelStart = StrPos
.SelLength = Len(InControl.Text)
End With
End If
Exit Sub
trap:
MsgBox Err.Description
End Sub
'**************Implement it like this************
Private Sub cboParent_Change()
Call SearchCombo(cboParent) '<--pass the combo box to the sub by name
End Sub
--
├┝┞┟┠┢┣◣◢
∣
▆▆▆
▇▇
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: jxjdadmin.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.138毫秒