views:

722

answers:

2

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?

+2  A: 

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.

Mitch Wheat
And another example here:http://blog.opennetcf.com/ctacke/2007/05/07/SDFSampleGettingMouseUpAndMouseDownForControlsWithoutThoseEvents.aspx
ctacke
A: 

A crude method I deployed in my younger years was to set a timer to hook up the events to ui elements on a form after the load. That did the job in that case.

These days I haven't had so much of a problem, especially if I preload the forms. Perhaps the issue lies with performing some form of longish data operation on the UI thread when showing the form?

If you want to get into "hack" territory you could always try kicking off an Application.DoEvents() somewhere in a poor attempt to clear the buffer.

Quibblesome