How to pause timer control in visual Foxpro?

Please support our Legacy and Other Languages advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2007
Posts: 6
Reputation: icsantos is an unknown quantity at this point 
Solved Threads: 0
icsantos's Avatar
icsantos icsantos is offline Offline
Newbie Poster

How to pause timer control in visual Foxpro?

 
0
  #1
Aug 27th, 2007
I created a form containing a timer control named tmrChkDir and a command button named cmdPause. What I need help on is how to check if the user clicked on the cmdPause button while the Timer event of tmrChkDir is in progress, and pause execution until another mouse click occurs.

For example, within the Timer event of tmrChkDir, I have this code:
THIS.ENABLED = .F.     && suspend timer

lnTotFiles = ADIR(laFiles, "*.ERA")
FOR lnCntFiles = 1 TO lnTotFiles
     DO myprocess WITH laFiles[lnCntFiles,1]
     IF THISFORM.cmdPause.CLICK()
          MESSAGEBOX("Click OK to resume processing")
     ENDIF
NEXT lnCntFiles

THIS.ENABLED = .T.   && reactivate timer

cmdPause.click() contains this code:
IF THISFORM.cmdPause.CAPTION = "Pause"
    THISFORM.cmdPause.CAPTION = "Resume"
    THISFORM.tmrChkDir.ENABLED = .F.
ELSE
    THISFORM.cmdPause.CAPTION = "Pause"
    THISFORM.tmrChkDir.ENABLED = .T.
ENDIF

The problem is, THISFORM.cmdPause.CLICK() in the Timer event always returns .T. whether or not I click on the Pause command button.

So how should I test if the Pause button was clicked within the FOR-NEXT loop in the Timer event?

Any help would be greatly appreciated. Thanks!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 6
Reputation: icsantos is an unknown quantity at this point 
Solved Threads: 0
icsantos's Avatar
icsantos icsantos is offline Offline
Newbie Poster

Re: How to pause timer control in visual Foxpro?

 
0
  #2
Aug 28th, 2007
Never mind, I figured it out. I replaced
     IF THISFORM.cmdPause.CLICK()
          MESSAGEBOX("Click OK to resume processing")
     ENDIF
with
     DOEVENTS
     DO WHILE .T.
          IF THISFORM.cmdPause.ENABLED
               EXIT
          ENDIF
          DOEVENTS
     ENDDO
And instead of a single command button that toggled between "Pause" and "Resume", I created a Pause command button and a Resume command button.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Legacy and Other Languages Forum
Thread Tools Search this Thread



Tag cloud for Legacy and Other Languages
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC