Solved

SHAutoComplete API control for ComboBox

Posted on 2002-03-29
4
867 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

773 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