Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Eric den Doop
  Where is Eric den Doop?
 Houten
 Netherlands
 Eric den Doop
 To: Russell Hill
  Where is Russell Hill?
 Sydney
 Australia
 Russell Hill
 Tags
Subject: RE: Stopping a program
Thread ID: 22605 Message ID: 22609 # Views: 32 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Wednesday, April 23, 2003 6:37:24 AM         
   


>
> Hi everyone.
>
> I would like to know how to create a button similar to 'Stop Search' in Windows 2000 under Start ... Search ... For Files or Folders ...
>
> At the moment when I run some batch program which skips through large tables processing information the only way I can stop it is to hit ESC.
>
> This is obviously not ideal as sometimes information is either not saved or corrupted in some way.
>
> I would like a 'Stop Processing' button which is enabled when the batch program begins and which would stop the batch program processing when it is clicked.
>
> Thanks in advance.
>
> Russell.
>

You're looking for DOEVENTS. This sample code code should get you started.
loForm = CREATEOBJECT("frmBusy")
loForm.show()
loForm.BeVeryBusy()
 
DEFINE CLASS frmBusy AS Form
 
 width = 200
 height = 90
 autocenter = .t.
 caption = "Very busy form"
 l_proceed = .T.
 n_count = 0
 
 ADD OBJECT "Label1" as Label WITH ;
  caption = "", ;
  left = 10, ;
  top = 20, ;
  width = 130 ;
 
 ADD OBJECT "Button1" as CommandButton WITH ;
  caption = "\<Cancel", ;
  cancel = .T., ;
  left = 10, ;
  autosize = .T., ;
  top = 40
 
 PROCEDURE BeVeryBusy
  DO WHILE this.l_proceed
   this.n_count = this.n_count + 1
   this.label1.caption = "Counting...: " + TRANSFORM(this.n_count)
   DOEVENTS
  ENDDO
 ENDPROC
 
 PROCEDURE Button1.Click
  IF MESSAGEBOX("Cancel this process?", 36, _screen.Caption) = 6
   thisform.l_proceed = .F.
  ENDIF
 ENDPROC
 
ENDDEFINE


Now, you might want to give this a read too:
FIX: DOEVENTS Command Runs Slowly
http://support.microsoft.com/default.aspx?scid=kb;en-us;268771
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts

COMPLETE THREAD

Stopping a program Posted by Russell Hill @ 4/23/2003 5:33:51 AM
RE: Stopping a program Posted by Eric den Doop @ 4/23/2003 6:37:24 AM
RE: Stopping a program Posted by Russell Hill @ 4/23/2003 10:02:01 AM