Bug or Feature? 
Author Message
 Bug or Feature?

I try to catch and handle all keyinputs of a form in a sub. Therefore I set
the forms KeyPreview property to True and everything works well. But when a
ButtonControl on the form holds the focus, neither the Form1_KeyPress nor
the Form1_KeyDown gets fired, when the Enter-key ist pressed. All other keys
work as expected.

I would like to know, if this behaviour is a bug or if it is by design. Is
there a workaround?



Tue, 07 Dec 2004 16:17:25 GMT  
 Bug or Feature?

Quote:
> I try to catch and handle all keyinputs of a form in a sub.
> Therefore I set the forms KeyPreview property to True and
> everything works well. But when a ButtonControl on the form
> holds the focus, neither the Form1_KeyPress nor the
> Form1_KeyDown gets fired, when the Enter-key ist pressed. All
> other keys work as expected.

> I would like to know, if this behaviour is a bug or if it is by
> design. Is there a workaround?

It's by design. The enter key is as "command key". You can overwrite
ProcessCmdKey to handle it:

   Protected Overrides Function ProcessCmdKey( _
      ByRef msg As System.Windows.Forms.Message, _
      ByVal keyData As System.Windows.Forms.Keys) _
      As Boolean

      If keyData = Keys.Enter Then
         Debug.WriteLine("enter pressed")
         Return True
      End If

   End Function

Whether you have to Return True depends (see docs for
ProcessCmdKey)

Armin



Tue, 07 Dec 2004 16:45:26 GMT  
 Bug or Feature?
Hi Armin,

thanks for the code, it does exactly what I need.



Tue, 07 Dec 2004 17:21:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DoCmd.Close (Bug or Feature?)

2. bug or feature with expression columns

3. CType(), Bug or Feature??

4. Windows bug or feature?

5. Free online bug report / feature enhancement tracking

6. VB5 SP3 bug or feature?

7. RichTextBox BUG or feature?

8. Add-in problem -- bug or feature?

9. HE: DataGrid BUG OR FEATURE

10. Masked Edit Control (Bug or Feature)

11. Bug or Feature with ADO Command Object?

12. Bug or feature ?

 

 
Powered by phpBB® Forum Software