SHAutoComplete API control for ComboBox

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
arnoldghAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
NetminderConnect With a Mentor Commented:
Points refunded and question closed.

Netminder
CS Moderator
0
 
Richie_SimonettiIT OperationsCommented:
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
 
arnoldghAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Glad to see you got it work!
Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.