Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2007

Tip: Looking for answers? Try searching our database.

Ignoring all key events in whole application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robintw - 19 Jul 2007 16:18 GMT
Hi all,

I've been struggling with this problem for quite a while, and have searched
the internet many times, and tried many of the ideas which that turned up -
but haven't managed to get this to work!

Basically, my application receives serial messages from another system. If a
certain field is set to true in the status message then the application must
not let the user do anything using the keyboard. As in the application must
ignore all key events in all possible ways - none of the code in any KeyUp,
KeyDown or KeyPress events should execute, and all controls should ignore
keys (ie. if the focus is on a text box, then the text box must not allow the
user to add any text, and the same for any other controls). When the field is
changes back to false then the application should return to normal.

Basically, what I am looking for is a way to stop the application getting
any key events whatsoever. Is this possible? If so, what is the best (or
only?) way to do it?

I have struggled with such things as e->SupressKeyPress (which didn't seem
to work at all), PreFilterMessage, PreProcessMessage and haven't managed to
get anything to work!

If anyone has any ideas at all, I would be very grateful to hear them!

Cheers,

Robin
Lee - 20 Jul 2007 12:34 GMT
On Jul 19, 11:18 am, robintw <robi...@discussions.microsoft.com>
wrote:
> Hi all,
>
[quoted text clipped - 24 lines]
>
> Robin

1) Instead of disabling all Key-events, how about displaying a modal
form when the users cannot interact with the form and closing the
modal form when they can interact again. An additional benefit is that
you can give some feed-back to the user on the modal form.

2) Alternately, I think if you 'disable' the form, then the users will
not be able to interact with it.
robintw - 20 Jul 2007 13:38 GMT
> 1) Instead of disabling all Key-events, how about displaying a modal
> form when the users cannot interact with the form and closing the
[quoted text clipped - 3 lines]
> 2) Alternately, I think if you 'disable' the form, then the users will
> not be able to interact with it.

Thank you for your help Lee. The modal form sounds like a good idea -
although it will mean that the user interface is different to the legacy
system we are replacing. However as this difference is in a 'helpful' way it
shouldn't matter too much. I have also just tried 'disabling' the form - and
that seems to work too.

However, I have realised that I did not explain the other part of the
problem in my first message. There is one situation in which we would like to
disable the application completely (in which case either of the two methods
you suggested would work fine), but there is also another situation in which
we would like to ignore all key events apart from Alt-S. This is because
there is a hardware switch which has to be set to allow data to be saved to
the remote system. When the switch is set all input apart from Alt-S (the
shortcut to save) must be ignored.

Do you know of any way to do this? I was hoping that if I found a solution
to the first problem using some kind of message filter, it would be
relatively easy to modify to ignore everything except Alt-S. Is this possible
do you think?

Sorry to not explain the other half of the problem (or the other problem -
as in many ways it is a slightly different problem) the first time.

Cheers,

Robin
AlexS - 20 Jul 2007 13:47 GMT
You can put button or another control reacting on Alt-S on modal form
(dialog).

>> 1) Instead of disabling all Key-events, how about displaying a modal
>> form when the users cannot interact with the form and closing the
[quoted text clipped - 37 lines]
>
> Robin

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.