Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

opening a combobox without the mouse

Posted on 1998-06-12
3
Medium Priority
?
181 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 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses

704 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