?
Solved

Using KeyPress event without invoking Click event at ComboBox control

Posted on 1998-05-06
3
Medium Priority
?
355 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
[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 5

Accepted Solution

by:
bin_huwairib earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

741 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