Solved

opening a combobox without the mouse

Posted on 1998-06-12
3
176 Views
Last Modified: 2010-05-03
i have a combobox that i want the user will be able to display the combo list without clicking the mouse, but by pressing a combinations of keybords keys, for example shift + a. how do i do this?
any help will be much appriciated!
yny
0
Comment
Question by:yny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
peterwest earned 200 total points
ID: 1463189
Hi there,

First of all put the following in a module:

Public Const CB_SHOWDROPDOWN = &H14F

Public Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)


Now set the keypreview property for the form you are working on to true and put this code in the KeyDown event of the form:

    'Declare local variables
    Dim lRetVal As Long

    'If alt was held down then...
    If Shift = 4 Then
       
        'Look at the key that was pressed with ALT
        Select Case KeyCode
        Case 64 'A pressed with ALT
             lRetVal= SendMessageByNum(Combo1.hWnd,CB_SHOWDROPDOWN,0,0)

        End Select

     End If


You should now find that if the user pressed ALT+A when any control on the form has focus then the Combo1 combobox will drop down.

Hope this is what you're after.

Pete

0
 

Author Comment

by:yny
ID: 1463190
that was exactly what i was looking for.
just a small remark: in order to show the dropdown list, the third parameter of the function must be 1 (nonzero).
thanks very much
yny
0
 
LVL 2

Expert Comment

by:peterwest
ID: 1463191
Cheers,

Sorry about that last param - I was in a bit of a rush to get the answer sorted out and didn't read the API manual properly.

Pete

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

636 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