My program takes a key input to switch between states:
Ex:
- private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
- {
- switch (e.Key)
- {
- case System.Windows.Input.Key.PageUp:
- MoveBackward();
- break;
- case System.Windows.Input.Key.Next:
- // MessageBox.Show(currentState.ToString());
- MoveForward();
- break;
- case System.Windows.Input.Key.Escape:
- Application.Current.Shutdown();
- break;
- default:
- break;
- }
- }
But, there are times when I'm playing a file in which I would like to temporarily suspend any input mouse/keyboard. Does anyone have any idea on how to accomplish that?
Thanks
Jaish MathewsPosted Aug 2, 2010, 11:59 AM
For key entering block do following
1. Make KeyPreview roerty of the Form as "true"
2. Enter an event handler for key_press like below
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}