Solved

Using KeyPress event without invoking Click event at ComboBox control

Posted on 1998-05-06
3
350 Views
Last Modified: 2008-03-04
This is on VB4.0 (32-bit) enterprise version

I was wondering if there is a way that I can get the keypress event from the combobox control (with the setting of 2 ie dropdown list). say for example, inside my combobox has a few items :-
Add
Last
New
Next
Pass
Previous
Stop

when I click on the combobox, it would dropdown and show me this items, so instead of just using click event where after I click on an item using the mouse, eg "First", it would do some process in the click event, I wish to use the keypress event as well, however the process of doing something only starts when I have decided that this is the item I wish to select.
Eg. click on combobox, dropdown list with the items.
Keypress "n", it should highlight "New" item first, since this is not the one that I want to select (no process should
start), I will keypress "n" again, and this time it will highlight on "Next" item, and since this is the one that
I wish to select, the process job starts now.

of course, I wish to have the click event there as well, incase I decide to use the mouse to choose the item.

any help will grateful.
0
Comment
Question by:wsm
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 100 total points
ID: 1442006
wsm,

Yes there is a way by using a flag, check the following example.

Example
=======

Dim Key_Press As Boolean

Private Sub Combo1_Click()
 If Not Key_Press Then
  'Do the process now.
  MsgBox Combo1.Text
 End If
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
 If KeyAscii = 13 Then
  Key_Press = False
  Combo1_Click
 Else
  Key_Press = True
 End If
End Sub


Best regards
Bin Huwairib
0
 

Author Comment

by:wsm
ID: 1442007
wsm,

Why don't you use "Microsoft Forms 2.0 Object Libaray" (FM20.DLL)?


Bin Huwairib
0
 
LVL 5

Expert Comment

by:bin_huwairib
ID: 1442008
This is even worst.. I change the normal combobox (from windows common controls active x - comctl32.ocx) to microsoft forms 2.0 object library.

when I click on the combobox (of fm20.dll) it causes invalid page fault with fm20.dll

isn't there a way that I can manipulate the comctl32.ocx's combobox without changing it to fm20.dll's combobox.

I am not sure, if it is because fm20.dll may not very stable in vb4.0 (32-bit)?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 59
VBA to copy paste columns form one file to other 20 88
Copy a row 12 62
backup program with robocopy 6 22
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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.
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…

809 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