• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

.Net click through forms

xoggoth

More fingers than teeth
Thanks received
1,183
Have a button on a child form that opens another child form with a button in much the same place. If somebody double clicks on the first form, it clicks the button on the second form. Tried sticking flags and checks in various events but nothing works.

Someone has suggested using a timer and only showing the second form or enabling its button after a delay. That does work but it seems a messy sort of solution to me. Anyone know of a neater one?

Cheers for ideas.
 
Have a button on a child form that opens another child form with a button in much the same place. If somebody double clicks on the first form, it clicks the button on the second form. Tried sticking flags and checks in various events but nothing works.

Someone has suggested using a timer and only showing the second form or enabling its button after a delay. That does work but it seems a messy sort of solution to me. Anyone know of a neater one?

Cheers for ideas.

The obvious one is don't have the button in the same place as the one underneath.
 
Ta but not possible, there are a whole load of buttons on both forms.

Tell the users not to double click buttons? Do they press BBC1 twice when they change channel on the TV?

What about ignoring the click of the child button for the first 500ms (rather than disabling it?

create a global System.Diagnostics.Stopwatch, start it in the form init code.
In the click handler, wrap the code in an if .ElapsedMilliseconds > 500
 
It's for kids so they probably don't just double click, they go clcik cklickety clicketyclicktey clcick clcikchchhk...
 
Is the Double click event being triggered?

Or is it 2 slow single clicks?

Does sound like a user education issue though.
 
Last edited: 16:33
Does sound like a user education issue though.

Not really, if you need to educate users to use your interface, generally your interface design is flawed, not the users so i'm guessing re-education is not the answer he's looking for.

Can you not just alter the part of the screen it appears on? Or is this a full screen thing. Hard to say without seeing it but i'd look to re-do the layout of the child form before fudging with timers/fade-ins etc.
 
Xog,

Firstly I don't think it's a double click, otherwise the doubleclick event of the button should fire. So it's two single clicks not quick enough. The second click message is not dispatched until the click handler completes. However at this point this is just a message up the spout and the target is unknown. After the click event completes the message causes a click even on the second form because this is what is valid at that screen location at the time of dispatch.

The basic problem you have is that you don't want to respond to the second click until you are in a known state and that is after all message pumping.

If you make sure buttons on the form as disabled at load time and then enable them in the show event the second form is fine. Unfortunately this means the click will go to the first form which may be unhelpful........

TheBigYinJames solution is probably the pragmatic one.

However you could use a custom windows message and override the message queue - but this seems like a lot of faffing about.
 
Or to save using a timer, store the system time at form load and if the new form's button is clicked less than 200ms or so after form load, ignore it. 3 lines of code I expect.
 

Advertisers

Back
Top