cAutoComplete.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:3k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cAutoComplete"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- Private Declare Function SHAutoComplete Lib "Shlwapi.dll" (ByVal hwndEdit As Long, ByVal dwFlags As Long) As Long
- Private Declare Function DllGetVersion Lib "Shlwapi.dll" (ByRef dvi As DLLVERSIONINFO) As Long
- Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
- ByVal hWnd1 As Long, _
- ByVal hWnd2 As Long, _
- ByVal lpsz1 As String, _
- ByVal lpsz2 As String) As Long
- Private Type DLLVERSIONINFO
- cbSize As Long
- dwMajorVersion As Long
- dwMinorVersion As Long
- dwBuildVersion As Long
- dwPlatformID As Long
- End Type
- Private Const SHACF_AUTOSUGGEST_FORCE_ON = &H10000000
- Private Const SHACF_AUTOSUGGEST_FORCE_OFF = &H20000000
- Private Const SHACF_AUTOAPPEND_FORCE_ON = &H40000000
- Private Const SHACF_AUTOAPPEND_FORCE_OFF = &H80000000
- Private Const SHACF_DEFAULT = &H0
- Private Const SHACF_FILESYSTEM = &H1
- Private Const SHACF_URLHISTORY = &H2
- Private Const SHACF_URLMRU = &H4
- Private Const SHACF_URLALL = (SHACF_URLHISTORY Or SHACF_URLMRU)
- Private Const SHACF_USETAB As Long = &H8
- Private Const DLLVER_PLATFORM_WINDOWS = &H1
- Private Const DLLVER_PLATFORM_NT = &H2
- Private Const S_OK = &H0
- Private Const NOERROR = 0
- Public Enum SHACF_FLAGS
- eSHACF_AUTOSUGGEST_FORCE_ON = SHACF_AUTOSUGGEST_FORCE_ON
- eSHACF_AUTOSUGGEST_FORCE_OFF = SHACF_AUTOSUGGEST_FORCE_OFF
- eSHACF_AUTOAPPEND_FORCE_ON = SHACF_AUTOAPPEND_FORCE_ON
- eSHACF_AUTOAPPEND_FORCE_OFF = SHACF_AUTOAPPEND_FORCE_OFF
- eSHACF_DEFAULT = SHACF_DEFAULT
- eSHACF_FILESYSTE = SHACF_FILESYSTEM
- eSHACF_URLHISTORY = SHACF_URLHISTORY
- eSHACF_URLMRU = SHACF_URLMRU
- eSHACF_URLALL = SHACF_URLALL
- eSHACF_USETAB = SHACF_USETAB
- End Enum
- 'local variable(s) to hold property value(s)
- Private mvarErrDescription As String 'local copy
- Public Property Get ErrDescription() As String
- 'used when retrieving value of a property, on the right side of an assignment.
- 'Syntax: Debug.Print X.ErrDescription
- ErrDescription = mvarErrDescription
- End Property
- Public Function Assign(hwndEdit As Long, Optional nFlags As SHACF_FLAGS = eSHACF_DEFAULT) As Boolean
- Attribute Assign.VB_Description = "指定需要""自动完成""的EDIT"
- Dim dvi As DLLVERSIONINFO
- dvi.cbSize = Len(dvi)
- If DllGetVersion(dvi) <> NOERROR Then
- mvarErrDescription = "无法检测Shlwapi.dll的版本号"
- Assign = False
- Exit Function
- End If
- 'Debug.Print "dll version:", dvi.dwMajorVersion
- If dvi.dwMajorVersion >= 5 Then
- If SHAutoComplete(hEdit(hwndEdit), nFlags) <> S_OK Then
- mvarErrDescription = "无法开启自动完成功能"
- Assign = False
- Exit Function
- End If
- Else
- mvarErrDescription = "IE版本低于5"
- Assign = False
- Exit Function
- End If
- Assign = True
- End Function
- Private Function hEdit(nHwnd)
- hEdit = FindWindowEx(nHwnd, 0, "EDIT", vbNullString)
- End Function