How do I disable the default function key behaviour?

P

Peeter Ilumäe

Hi!

I have a form. It contains various controls and among other things a
standard main menu.

By default F10 acts like ALT pressed alone - it activates the menu selection
bar. I however have different needs for that key, and I've already written a
keydown event handler that modifies data on other controls when F10 is
pressed.

But, while doing what it has to, the F10 function key also does what it is
not supposed to - activating the main menu selection. So my question is -
how do I disable that? I've tried overriding the forms default
KeyUp-down-pressed events but either I did something wrong, or the reason
isn't there.

Any ideas for a solution?


Best regards,
Peeter Ilumäe
Codewiser.com
 
C

Claes Bergefall

It works fine for me. I don't get the default behaviour of F10
if I handle it in KeyDown. Did you remember to set e.Handled
to true in your event handler? Here is my code:

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F10 Then
MessageBox.Show("F10", "")
e.Handled = True
End If
End Sub

It shows the message box and nothing more

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top