Solved

Trap all key strokes

Posted on 2006-11-08
5
198 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
Comment Utility
One additional note:  I still want to be able to tab out of the field
0
 
LVL 21

Expert Comment

by:theGhost_k8
Comment Utility
   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
Comment Utility
or
 just set e=nothing on forms keypress event
0
 
LVL 2

Author Comment

by:Moed
Comment Utility
Thanks.  Worked perfect.
0
 
LVL 2

Author Comment

by:Moed
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now