Solved

Using KeyPress event without invoking Click event at ComboBox control

Posted on 1998-05-06
3
348 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
Comment Utility
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
Comment Utility
wsm,

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


Bin Huwairib
0
 
LVL 5

Expert Comment

by:bin_huwairib
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now