|
Автозавершение набора URL |
|
|
Этот пример для счастливых обладателей
броузера ИнтернетЭксплорер версии от 5.0 и выше.
Помните про возможность автозавершения набора
адреса? Нет? Не беда! Установите на форме
компонент Label, компонент TextBox и CommandButton.
И вы сразу почувствуете прелесть этого примера.
Идеальный пример для работы с компонентом WebBrowser Option Explicit
Private Const SHACF_AUTOSUGGEST_FORCE_ON As Long = &H10000000
Private Const SHACF_AUTOSUGGEST_FORCE_OFF As Long = &H20000000
Private Const SHACF_AUTOAPPEND_FORCE_ON As Long = &H40000000
Private Const SHACF_AUTOAPPEND_FORCE_OFF As Long = &H80000000
Private Const SHACF_DEFAULT As Long = &H0
Private Const SHACF_FILESYSTEM As Long = &H1
Private Const SHACF_URLHISTORY As Long = &H2
Private Const SHACF_URLMRU As Long = &H4
Private Const SHACF_URLALL As Long = (SHACF_URLHISTORY Or SHACF_URLMRU)
Private Const DLLVER_PLATFORM_WINDOWS As Long = &H1 'Windows 95
Private Const DLLVER_PLATFORM_NT As Long = &H2 'Windows NT
Private Type DllVersionInfo
cbSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformID As Long
End Type
Private Declare Function SHAutoComplete Lib "Shlwapi.dll" (ByVal hwndEdit As
Long, ByVal dwFlags As Long) As Long
Private Declare Function DllGetVersion Lib "Shlwapi.dll" (dwVersion As
DllVersionInfo) As Long
Private Function GetIEVersion(DVI As DllVersionInfo) As Long
DVI.cbSize = Len(DVI)
Call DllGetVersion(DVI)
GetIEVersion = DVI.dwMajorVersion
End Function
Private Function GetIEVersionString() As String
Dim DVI As DllVersionInfo
DVI.cbSize = Len(DVI)
Call DllGetVersion(DVI)
GetIEVersionString = "Internet Explorer " & DVI.dwMajorVersion &
"." & DVI.dwMinorVersion & "." & DVI.dwBuildNumber
End Function
Private Sub Command1_Click()
Dim DVI As DllVersionInfo
If GetIEVersion(DVI) >= 5 Then
Call SHAutoComplete(Text1.hWnd, SHACF_DEFAULT)
Command1.Caption = "Автозавершение включено"
Command1.Enabled = False
Text1.SetFocus
Text1.SelStart = Len(Text1.Text)
Else
MsgBox "Простите, но у вас не установлен IE5",
vbExclamation
End If
End Sub
Private Sub Form_Load()
Dim DVI As DllVersionInfo
Label1 = "Использование Shlwapi.dll для " &
GetIEVersionString
Command1.Enabled = GetIEVersion(DVI) >= 5
Command1.Caption = "Автозавершение выключено"
End Sub
|
|
|
|
|
|
|