Ignoring all key events in whole application

G

Guest

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
 
L

Lee

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

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.
 
G

Guest

Lee said:
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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top