StevenLogic
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
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
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.
But see the previous question which is still open:
https://www.experts-exchange.com/questions/21405238/Form-Keypress-and-Return-key-Challenge.html
https://www.experts-exchange.com/questions/21405238/Form-Keypress-and-Return-key-Challenge.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great. Thanks.