是否可以在VB6.0中取消长时间运行的进程,而不使用DoEvent?
例如:
for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end if next Sub btnCancel_Click() cancel = true End Sub
不,你说得对,你肯定想要你的循环中的DoEvents。
如果将DoEvents放在主循环中,发现处理速度太慢,请尝试调用Windows API函数GetQueueStatus(这比DoEvents快得多)来快速确定是否有必要调用DoEvents。 GetQueueStatus告诉你是否有任何事件要处理。
' at the top: Declare Function GetQueueStatus Lib "user32" (ByVal qsFlags As Long) As Long ' then call this instead of DoEvents: Sub DoEventsIfNecessary() If GetQueueStatus(255) <> 0 Then DoEvents End Sub
原文地址:https://www.jb51.cc/vb/256105.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。