Internet Explorer version 5 introduced a text box 'auto complete' feature. The support is part of the Shlwapi.dll. I have seen various requests in the news group asking how to add support for this feature. So I encapsulated the code into a class I call 'clsSHAutoComplete', wrote a demo program and made it the January 2003 tip of the month.
Credits: I don't know where I found the basis for this code but various references can be found by searching Google for SHAutoComplete or one of its constants, for example: SHACF_AUTOAPPEND_FORCE_ON.
The demo screen. Type a slash in either text box. You should see auto completion information.
Click the 'Auto Complete Off' button to toggle support for the feature.
Shlwapi.dll version information is shown in the status bar.
Auto Completing a URL.
Auto Completing a File.
Auto Complete [Shlwapi.dll] not Supported
Either the dll was not found or it is earlier than version 5.
Perform the following steps to use the auto complete class.
- Define a new reference for the object.
- Check to make sure Shlwapi.dll supports auto completion [use the 'Supported' method].
- Use 'StartAutoComplete' to add auto completion support for the specified text box. A 'supported' test is made in this method.
Private mobjSH As New clsSHAutoComplete 'define it in Declarations
... In form load somewhere
If mobjSH.Supported Then
DoAutoComplete mobjSH, True
Private Sub DoAutoComplete(objSH As clsSHAutoComplete, bOn As Boolean)
If bOn Then
objSH.StartAutoComplete Me.Text1 'turn it on for these text boxes
objSH.EndAutoComplete Me.Text1 'turn it off for these text boxes
Method Description Sample .Supported Returns True if Shlwapi.dll is version 5 or higher. If objSH.Supported Then... .StartAutoComplete textbox Start auto complete for the named text box. objSH.StartAutoComplete Me.Text1 .EndAutoComplete textbox End auto completion for the named text box. objSH.EndAutoComplete Me.Text1 .ShlwapiVersionToString Return the dll's version in string format. "6.0.2800.1" Class_Initialize The dll's version information is retrieved
and stored in a local structure [mVersionInfo].
Using the Routines
Add the following class module to your application if you want to use the auto complete feature:
Module Description clsSHAutoComplete.cls The class module used to supply auto complete support.
Used in the demo, not needed in your application:
Module - Click for More Info Description Used in the Demo To modConnectToWebsite.bas Connect to a web site Show this info when Help/Info is selected from the demo. modInfoAbout.bas Info and about help. Provide help via the web and 'about' info. modStatusV2.bas Show information in a status bar. Show status information.
Download VB Code
Click here to download the VB 6 Source Code [9k].
Previous Tip Tip Index Next Tip First Tip