Search code examples
c#.netwinforms.net-3.5

Delaying or briefly pausing windows messages


I have a Winforms DataGridView in my application. When the user selects a row and hits enter, I load a new form with details related to that row. It takes about a second to get the data and show the screen. Some of the users are pretty fast and they start entering keystrokes relevant to the form e.g Pg Down/Pg Up, even before it loads and complain that the grid scrolls down instead of seeing the intended effect on the loaded Form.

I need a way to pause the keystroke messages from being processed until the form is loaded. Any ideas highly appreciated.


Solution

  • You could capture the WM_KEYDOWN message and ignore it if the form is loading (perhaps setting a flag) or you could post the messages to the currently loading form.

    Have a look at IMessageFilter