VB 6.0 - Command Buttons And KeyDown
Author |
Message |
D_homes
|
Posted: Sun Oct 23, 2011 1:06 pm Post subject: VB 6.0 - Command Buttons And KeyDown |
|
|
I'm having an issue with the KeyDown function that is caused by having a command button on the form.
The button is automatically highlighted during run time (if there was more than one button then using the arrow keys would switch between them), this prevents any use of the KeyDown function for me.
I've tried messing around with the 'TabIndex' and 'TabStop' properties of the command button, but nothing has worked.
i.e
code: |
Public Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then 'If the user presses the Up arrow
'Do Stuff
ElseIf KeyCode = vbKeyDown Then
'Do Stuff
End If
End Sub
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Numbah51
|
Posted: Wed Nov 30, 2011 2:57 pm Post subject: Re: VB 6.0 - Command Buttons And KeyDown |
|
|
Hi,
As far as I'm aware, the form itself can never have focus as long as there are controls on it which can have focus. For what you're looking to do, you can set the Form's KeyPreview property to true which will allow the form to recieve keyboard event before those other controls. However, say you have a command button and it has focus by default, then you will not be able to get the key state of the enter button (as the enter button will press the command button). Hope this helped.
-Mike |
|
|
|
|
|
|
|