找回密码
 加入
搜索
查看: 3851|回复: 3

[系统综合] 请问怎么按关闭键跳出循环和关闭

[复制链接]
发表于 2014-1-17 16:06:08 | 显示全部楼层 |阅读模式
一个长循环执行时;按关闭键会无效果;必须等待循环结束才能关闭;例如以下:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 184, 168, 164, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
myfunc()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func myfunc()
        Local $i
        For $i = 0 To 10000000
                GUICtrlSetData($Label1,$i)
        Next
EndFunc

请问怎样按关闭按钮时 ExitLoop ;退出正在执行的循环关闭;谢。。。
 楼主| 发表于 2014-1-18 13:16:02 | 显示全部楼层
顶起。。。。。。。。。。。。。。。。。。。。。。。
发表于 2014-1-18 21:30:24 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 184, 168, 164, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Opt("GUIOnEventMode", 1);OnEvent模式
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
myfunc()

While 1

Sleep(100)
WEnd

Func myfunc()

Local $i

For $i = 0 To 10000000

GUICtrlSetData($Label1, $i)

Next
EndFunc   ;==>myfunc
Func _Exit()

Exit
EndFunc   ;==>_Exit
发表于 2014-1-19 16:06:29 | 显示全部楼层
zldfsz 大师不愧为大师!路过学习了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 09:25 , Processed in 0.076603 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表