Solved

Trap all key strokes

Posted on 2006-11-08
5
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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