Foxpro中的计时器(如何暂停和控制时间)



我运行以下代码:

1.THIS.ENABLED = .F.     && suspend timer
2.
3.lnTotFiles = ADIR(laFiles, "*.ERA")
4.FOR lnCntFiles = 1 TO lnTotFiles
5.     DO myprocess WITH laFiles[lnCntFiles,1]
6.     IF THISFORM.cmdPause.CLICK()
7.          MESSAGEBOX("Click OK to resume processing")
8.     ENDIF
9.NEXT lnCntFiles
10.
11.THIS.ENABLED = .T.   && reactivate timer

问题是,无论我是否单击"暂停"命令按钮,Timer事件中的THISORM.cmdPause.CLICK()总是返回.T。

cmdPause.CLICK()包含以下内容:

1.IF THISFORM.cmdPause.CAPTION = "Pause"
2. THISFORM.cmdPause.CAPTION = "Resume"
3. THISFORM.tmrChkDir.ENABLED = .F. 
4.ELSE 5. THISFORM.cmdPause.CAPTION = "Pause" 
6. THISFORM.tmrChkDir.ENABLED = .T. 
7.ENDIF 

那么,我应该如何测试在Timer事件的FOR-NEXT循环中是否单击了Pause按钮呢?

试试这个:

THIS.ENABLED = .F.     && suspend timer
lnTotFiles = ADIR(laFiles, "*.ERA")
FOR lnCntFiles = 1 TO lnTotFiles
DO myprocess WITH laFiles[lnCntFiles,1]
DOEVENTS     
DO WHILE .T.
IF THISFORM.cmdPause.ENABLED
EXIT
ENDIF
DOEVENTS
ENDDO
NEXT lnCntFiles
THIS.ENABLED = .T.   && reactivate timer

相关内容

  • 没有找到相关文章

最新更新