Solved

SHAutoComplete API control for ComboBox

Posted on 2002-03-29
4
852 Views
Last Modified: 2012-05-04
I am able to run this API and get all the URL's in my History and pass it all to my ComboBox, this is actually my objective. It should have been ok but my problem is that, the Keypress Event is disabled or in other words,  the Enter Key becomes disabled. My question is how am I going to pass the control back to the ComboBox again so that it functions as normal. Thank you very much. The codes are as follows.

'Ignore registry default and force feature on
Public Const SHACF_AUTOSUGGEST_FORCE_ON  As Long = &H10000000

'Ignore registry default and force feature off.
Public Const SHACF_AUTOSUGGEST_FORCE_OFF  As Long = &H20000000

'Ignore registry default and force feature on. (Also know as AutoComplete)
Public Const SHACF_AUTOAPPEND_FORCE_ON  As Long = &H40000000

'Ignore registry default and force feature off. (Also know as AutoComplete)
Public Const SHACF_AUTOAPPEND_FORCE_OFF  As Long = &H80000000

'Currently (SHACF_FILESYSTEM | SHACF_URLALL)
Public Const SHACF_DEFAULT  As Long = &H0

'Includes the File System as well as the rest
'of the shell (Desktop\My Computer\Control Panel\)
Public Const SHACF_FILESYSTEM  As Long = &H1

'URLs in the User's History
Public Const SHACF_URLHISTORY  As Long = &H2

'URLs in the User's Recently Used list
Public Const SHACF_URLMRU  As Long = &H4

Public Const SHACF_URLALL  As Long = (SHACF_URLHISTORY Or SHACF_URLMRU)

'Identifies the platform for which the DLL was built.
Public Const DLLVER_PLATFORM_WINDOWS As Long = &H1  'Windows 95
Public Const DLLVER_PLATFORM_NT As Long = &H2       'Windows NT


Public Type COMBOBOXINFO
   cbSize As Long
   rcItem As RECT
   rcButton As RECT
   stateButton  As Long
   hwndCombo  As Long
   hwndEdit  As Long
   hwndList As Long
End Type

Public Type DllVersionInfo
   cbSize As Long
   dwMajorVersion As Long
   dwMinorVersion As Long
   dwBuildNumber As Long
   dwPlatformID As Long
End Type

Public Declare Function DllGetVersion Lib "shlwapi" _
  (dwVersion As DllVersionInfo) As Long

Public Function GetComboEditHandle(ctl As ComboBox) As Long
   Dim CBI As COMBOBOXINFO
   
   CBI.cbSize = Len(CBI)
   Call GetComboBoxInfo(ctl.hwnd, CBI)
   GetComboEditHandle = CBI.hwndEdit
End Function

Public Declare Function GetComboBoxInfo Lib "user32" _
  (ByVal hwndCombo As Long, _
   CBInfo As COMBOBOXINFO) As Long

Public Declare Function SHAutoComplete Lib "shlwapi" _
  (ByVal hwndEdit As Long, _
   ByVal dwFlags As Long) As Long


' This is the function that I use to call all the APIs
' to retrieve all the URLs in my History.
Public Function AutoLoadCombo()
    Dim DVI As DllVersionInfo
    Dim hedit1 As Long, hedit2 As Long
   
    If GetIEVersion(DVI) >= 5 Then
        'Turn on auto-complete
        hedit1 = GetComboEditHandle(cboURL1)
        Call SHAutoComplete(hedit1, SHACF_DEFAULT)
    End If
End Function
0
Comment
Question by:arnoldgh
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6906398
why don't you use a normal combobox and use this code to do a sort of autosearch:

http://www.freevbcode.com/ShowCode.Asp?ID=2266
http://www.vbcodemagician.dk/tips/internet_autocomplete.htm

0
 

Author Comment

by:arnoldgh
ID: 6927843
Hi Richie,
    I would like to thank you for your time and effort for finding solution to my problem. Your suggestion is very good which is a short version of what my code is, however, it is not exactly what I want.
    After trying some other methods, I have already found the answer. For those who might have encoutered the same problem as I had. I would suggest to use the following code. In this way, although the "Keypress" event does not recognise the "Enter" key, the "Keydown" event will surely catch it.

Private Sub cboURL1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        ctlWeb1.Navigate cboURL1.Text, Null, Null, Null, Null
    End If
End Sub


Thank you,
Arnold

I would like to seek advise from the moderator as to how am I going to give some point to Richie for his suggestion which I believe some experts will find it useful.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6928114
Glad to see you got it work!
Cheers
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7358565
Points refunded and question closed.

Netminder
CS Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now