We help IT Professionals succeed at work.

User abort of program flow

chrishart
chrishart asked
on
Medium Priority
225 Views
Last Modified: 2010-04-04
I want to be able to abort some calculations if the user presses a key or clicks the mouse.

I'd like to be able to do this without the hassle of setting up a 2ndthread.

Any ideas?

Cheers Chris
Comment
Watch Question

Commented:
An idea could be, that in the OnClick of the button, you set a variable to true. Before you start your calculation, set the same variable to False.

In your calculation have the following lines:

[...]
Application.ProcessMessages;
If <Your_VariableName> then exit;
[...]

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks, 98113772, that's the sort of answer I was looking for :-)

Didn't know about the process messages command.

Cheers chris

PS 20 bonus points for mega fast response!

Commented:
Thanks for the bonus
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.