2

我运行这段代码:

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 事件中的 THISFORM.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 循环中单击了暂停按钮?

4

1 回答 1

3

尝试这个:

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
于 2013-08-19T19:32:47.470 回答