Solved

Using KeyPress event without invoking Click event at ComboBox control

Posted on 1998-05-06
3
349 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help in WHSCRIPT 9 47
Saving history changes to sub form 4 36
MS SQL store procedure to calculate and return result 6 49
VB6 - Convert HH:MM into Decimal 8 51
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now