PDA

Click to See Complete Forum and Search --> : How to have a command button to cancel a long process?


ganraj
Jan 10th, 2000, 10:21 PM
Hello!


I am using vb5. I want to have a command button to cancel a long process. If I place a timer control and look for the command button click, it never happens.

When the process starts, the screen freezes and only a listview is updated. But the buttons doesn't get focus. How do I do it?


Thanks,




------------------
ganraj.

MartinLiss
Jan 10th, 2000, 10:29 PM
Put a DoEvents statement in the loop.

------------------
Marty

Jan 10th, 2000, 10:30 PM
Scatter a few "DoEvents" statements in your code to give Windows a chance to do other things while your program is running...if your process if a loop then just put "DoEvents" in once inside the loop. This will give the user chance to click the Cancel button.

Now make a public variable eg "Dim bCancel As Boolean" and when the Cancel button is pressed set this vairble to true.

Then make your process regularly check the contents of this variable and about if it becomes true. I personally would make this check after each "DoEvents" statement.

------------------
Matthew Ralston
E-Mail: m.ralston@mediavault.co.uk
ICQ:31422892 (http://www.thebluelink.cjb.net/icq.html)
Web Sites:The Blue Link (http://www.thebluelink.cjb.net) My Home Page (http://mralston.cjb.net) (Not up at the moment!)

ganraj
Jan 10th, 2000, 10:32 PM
Hello Marty!


Thanks... It works...




------------------
ganraj.

ganraj
Jan 10th, 2000, 10:35 PM
Hello Mathew!


Thanks to you also...




------------------
ganraj.