C# – Compact Framework – Disable Mouse Events during loads

.net-2.0ccompact-frameworkwindows-mobile

Morning all,

I design a number of compact framework applications, and something that always eludes me is a way of preventing what we call yorkshire bank syndrome (ybs). YBS is named lovingly after the cash points at Yorkshire Bank due to the fact that their screen refresh is so slow, and one of my colleagues pressed the button twice thinking that he hadn't pressed the button and ended up drawing out £100 instead of the £20 he wanted (the "Cash Without Receipt" and "£100" buttons were assigned to the same button on the two different screens).

Basically, I load all my forms with a splash screen at the start of the application and every other form has a public event called Initialise(). To show a form I used Session.Instances.FormName.Initialise() then do a showdialog().

The Initialise() method normally calls some sort of form reset or data loading, so in turn the Cursor is set in that method as well. The problem arises when the user clicks a button to show a form, the form loads, but if they click the screen in the meantime, that screen click gets passed through to the form that is currently loading (but not shown).

For example, I click a button to show a form and then click the bottom left of the screen. In most of my CF apps, the button in the bottom right is the back button that sets DialogResult.Cancel. So once the load is finished, the form does not appear as the back button has been clicked, even though the form was never shown.

I have tried a number of things, including this.Enabled = false at the start of the Initialise(), but it seems that the click is stored in the background and then the click event fired onto the screen when the load has finished.

So, I'm now wondering if there's a way to disallow any mouse input during my loading and only enable it again just before my Form.ShowDialog()? OR does anyone have any better ideas of how to achieve this?

Best Answer

Chris Tacke created ApplicationEx as part of OpenNETCF. It allows getting every Windows message that your app receives.

There is an example of its use here.

Related Topic