Link to home
Start Free TrialLog in
Avatar of StevenLogic
StevenLogicFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Is there a form KeyPreview event in VB6?

Hi,

I'd like to capture keys being pressed before they go into a controll (ie. text box, grid, etc.)

Example code that doesn't work is as follows:

Create a new project, a new form, and place a text control with default name 'Text1'

place this code in the form:
Private Sub Form_KeyPress(KeyAscii As Integer)
   MsgBox Chr$(KeyAscii)
End Sub

Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

No, The Form _KeyPress event is only possible if the Form itself has the focus. If there any controls on the form that can receive the focus, then the form cannot be in focus.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StevenLogic

ASKER

Great.  Thanks.