自动完成的TextBox,类似Windows的运行框

Option Explicit On

Public Enum SHAutoCompleteFlags
    SHACF_DEFAULT = &H0
    SHACF_FILESYSTEM = &H1
    SHACF_URLHISTORY = &H2
    SHACF_URLMRU = &H4
    SHACF_USETAB = &H8
    SHACF_URLALL = (SHACF_URLHISTORY Or SHACF_URLMRU)
    SHACF_FILESYS_ONLY = &H10
    SHACF_FILESYS_DIRS = &H20
    SHACF_AUTOSUGGEST_FORCE_ON = &H10000000
    SHACF_AUTOSUGGEST_FORCE_OFF = &H20000000
    SHACF_AUTOAPPEND_FORCE_ON = &H40000000
    SHACF_AUTOAPPEND_FORCE_OFF = &H80000000
End Enum

Private Declare Function SHAutoComplete Lib "shlwapi.dll" ( _
      ByVal hwndEdit As Long, ByVal dwFlags As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
      (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As String, _
      ByVal lpszWindow As String) As Long

Private Const S_OK = 0

Public Function AutoComplete( _
            ByVal hWnd As Long, _
            ByVal eFlags As SHAutoCompleteFlags _
      )
    Dim lR As Long
    lR = SHAutoComplete(hWnd, eFlags)
    AutoComplete = (lR <> S_OK)
End Function

'Get Edit Control from ComboBox
Public Function GetComboBoxEdithWnd(ByVal hWnd As Long) As Long
    GetComboBoxEdithWnd = FindWindowEx(hWnd, 0, "EDIT", vbNullString)
End Function

'To Completed Test,you can add one TextBox Control and add ComboBox Control from toolbox

'and then test input "c:/" in textbox ,you can see it :)

Private Sub Form_Load()
    AutoComplete(Text1.hWnd, SHACF_FILESYS_ONLY)
    AutoComplete(GetComboBoxEdithWnd(Combo1.hWnd), SHACF_FILESYS_ONLY)
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值