オートコンプリート          <TOP>


SHAutoComplete オートコンプリートをエディットボックスに使うように指定
DllGetVersion Shell32.dllのバージョン取得
 

 

'================================================================
'= オートコンプリート
'=    (SHAutoComplete.bas)
'================================================================
#include "Windows.bi"

#define SHACF_DEFAULT &H0                  '(SHACF_FILESYSTEM Or SHACF_URLALL)
#define SHACF_FILESYSTEM &H1               '仮想フォルダをなどファイル一覧を含む
#define SHACF_URLHISTORY &H2               'ユーザの履歴内のURLを含む
#define SHACF_URLMRU &H4                   '最近使ったURLリスト内のURLを含む
#define SHACF_USETAB &H8                   'Tabキーを押すことにより自動補完リストから選択できる
#define SHACF_FILESYS_ONLY &H10
#define SHACF_URLALL (SHACF_URLHISTORY Or SHACF_URLMRU)
#define SHACF_AUTOSUGGEST_FORCE_ON  &H10000000 'レジストリ値を無視し、自動補助機能をオンにする
#define SHACF_AUTOSUGGEST_FORCE_OFF &H20000000 'レジストリ標準の値を無視し、自動補助機能をオフにする
#define SHACF_AUTOAPPEND_FORCE_ON &H40000000   'レジストリ値を無視し、自動補完機能を強制的にオンにする
#define SHACF_AUTOAPPEND_FORCE_OFF -2147483648 '標準の設定を無視し、自動補完機能を強制的にオフにする
#define S_OK &H0                               '

#define DLLVER_PLATFORM_WINDOWS &H1            'Windows 95
#define DLLVER_PLATFORM_NT &H2                 'Windows NT

Type DllVersionInfo
    cbSize         As Long
    dwMajorVersion As Long                     'メジャーバージョン
    dwMinorVersion As Long                     'マイナーバージョン
    dwBuildNumber  As Long                     'ビルド番号
    dwPlatformID   As Long
End Type

' オートコンプリートをエディットボックスに使うように指定
Declare Function Api_SHAutoComplete& Lib "shlwapi" Alias "SHAutoComplete" (ByVal hwndEdit&, ByVal dwFlags&)

' Shell32.dllのバージョン取得
Declare Function Api_DllGetVersion& Lib "shlwapi" Alias "DllGetVersion" (dwVersion As DLLVERSIONINFO)

Var Shared Text1 As Object
Var Shared Edit1 As Object
Var Shared Button1 As Object

Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14
Edit1.Attach GetDlgItem("Edit1") : Edit1.SetFontSize 14
Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14

Var Shared dvi As DLLVERSIONINFO

'================================================================
'=
'================================================================
Declare Function GetIEVersion(dvi As DLLVERSIONINFO) As Long
Function GetIEVersion(dvi As DLLVERSIONINFO) As Long
    Var Ret As Long

    dvi.cbSize = Len(dvi)
    Ret = Api_DllGetVersion(dvi)

    GetIEVersion = dvi.dwMajorVersion
End Function

'================================================================
'=
'================================================================
Declare Function GetIEVersionString() As String
Function GetIEVersionString() As String
    Var Ret As Long
   
    dvi.cbSize = Len(dvi)
    Ret = Api_DllGetVersion(dvi)

    GetIEVersionString = "IE Version:" & Trim$(Str$(dvi.dwMajorVersion)) & "." & Trim$(Str$(dvi.dwMinorVersion)) & "." & Trim$(Str$(dvi.dwBuildNumber))
End Function

'================================================================
'=
'================================================================
Declare Sub MainForm_Start edecl ()
Sub MainForm_Start()
    Text1.SetWindowText GetIEVersionString

    Button1.SetWindowText "オートコンプリート Off"
    Edit1.SetFocus
End Sub

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var Ret As Long

    If GetIEVersion(dvi) >= 5 Then
        Ret = Api_SHAutoComplete(Edit1.GethWnd, SHACF_URLHISTORY Or SHACF_URLMRU)
        Button1.SetWindowText "オートコンプリート On"
        Button1.EnableWindow 0
        Edit1.SetFocus

        Edit1.SetSelText 0, -1
    Else
        A% = MessageBox("", "IE5以上が必要です", 0, 2)
    End If
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End