Solved

Trap all key strokes

Posted on 2006-11-08
5
235 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:K V
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:
K V 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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