Solved

Trap all key strokes

Posted on 2006-11-08
5
216 Views
Last Modified: 2010-04-23
If my form is not in edit mode I want to cancel all keystrokes.  How do I do that?

Thanks
0
Comment
Question by:Moed
  • 3
  • 2
5 Comments
 
LVL 2

Author Comment

by:Moed
ID: 17897216
One additional note:  I still want to be able to tab out of the field
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 17897334
   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Try
            Select Case m.Msg
                Case WM_KEYDOWN
                    Exit Sub
                Case WM_KEYUP
                    Exit Sub
            End Select
            MyBase.WndProc(m)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        MyBase.WndProc(m)
    End Sub
0
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 50 total points
ID: 17897336
or
 just set e=nothing on forms keypress event
0
 
LVL 2

Author Comment

by:Moed
ID: 17900443
Thanks.  Worked perfect.
0
 
LVL 2

Author Comment

by:Moed
ID: 17900473
Just for clarification if e = nothing or e.handled is used this line

MyBase.KeyPreview = True

needs added to the form load event.  
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question