PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms User controlled exit from processing loop

Reply

User controlled exit from processing loop

 
Thread Tools Rate Thread
Old 01-06-2005, 12:03 PM   #1
JezB
Guest
 
Posts: n/a
Default User controlled exit from processing loop


In my windows forms application, I have a process which takes some time to
complete. I have a nice progress bar showing how far through the process is,
but I want to enhance this with a "Press ESC to abort" statusbar message.
But how can I actually implement this hotkey-escape-from-loop functionality
?


  Reply With Quote
Old 01-06-2005, 12:29 PM   #2
JezB
Guest
 
Posts: n/a
Default Re: User controlled exit from processing loop

Tried subscribing to KeyDown event on my form, and in there setting a
private bool variable "escaped" to true, testing this in my loop. This works
"sometimes" - only when I focus on my form by clicking on it's taskbar entry
(when I just focus by clicking on the window KeyDown is not fired!).

"JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
news:%23Mv9ekpZFHA.1456@TK2MSFTNGP15.phx.gbl...
> In my windows forms application, I have a process which takes some time to
> complete. I have a nice progress bar showing how far through the process
> is, but I want to enhance this with a "Press ESC to abort" statusbar
> message. But how can I actually implement this hotkey-escape-from-loop
> functionality ?
>



  Reply With Quote
Old 01-06-2005, 01:04 PM   #3
JezB
Guest
 
Posts: n/a
Default Re: User controlled exit from processing loop

I may just be talking to myself here but ....

The KeyDown approach seems to be more reliable when I set the KeyPreview
property of the form to True.

"JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
news:OQeWKzpZFHA.1092@tk2msftngp13.phx.gbl...
> Tried subscribing to KeyDown event on my form, and in there setting a
> private bool variable "escaped" to true, testing this in my loop. This
> works "sometimes" - only when I focus on my form by clicking on it's
> taskbar entry (when I just focus by clicking on the window KeyDown is not
> fired!).
>
> "JezB" <jezbroadsword@blueyonder.co.uk> wrote in message
> news:%23Mv9ekpZFHA.1456@TK2MSFTNGP15.phx.gbl...
>> In my windows forms application, I have a process which takes some time
>> to complete. I have a nice progress bar showing how far through the
>> process is, but I want to enhance this with a "Press ESC to abort"
>> statusbar message. But how can I actually implement this
>> hotkey-escape-from-loop functionality ?
>>

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off