找回密码
 加入
搜索
查看: 1398|回复: 8

如何关闭这个程式?

[复制链接]
发表于 2009-6-30 15:57:50 | 显示全部楼层 |阅读模式
本帖最后由 faceyao 于 2009-6-30 18:56 编辑

点了确定后,就开始循环了,但是再点右上角的X“关闭"按钮却无效,仍然继续运行,请问如何写代码才能让这个右上角的X有效,也就是点这个X循环就终止循环并关闭软件?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 157, 59, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 16, 16, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1

        $nMsg = GUIGetMsg()

        Switch $nMsg

                Case $GUI_EVENT_CLOSE

                        Exit

                Case $Button1
                        While 1
                        MsgBox (0,"","你点击了【确定】按钮")
                                                Sleep(4000)
                        WEnd

        EndSwitch

WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-6-30 17:45:04 | 显示全部楼层
MsgBox (0,"","你点击了【确定】按钮")
先说啊!我也是是新手,如果有说错的地方请多包含
我觉得可以将MsgBox (0,"","")改成MsgBox (1,"","")吧!
这样就有确定和取消,在赋予取消的命令应该就可以了。
只是思路具体看你自己啦
 楼主| 发表于 2009-6-30 18:14:23 | 显示全部楼层
MsgBox (0,"","你点击了【确定】按钮")
先说啊!我也是是新手,如果有说错的地方请多包含
我觉得可以将MsgBox (0,"","")改成MsgBox (1,"","")吧!
这样就有确定和取消,在赋予取消的命令应该就可以了。
只是思路 ...
水木子 发表于 2009-6-30 17:45

不是,必须要按下右上角X关闭按钮才做退出,和msgbox没关系,msgbox只是举例而已
发表于 2009-6-30 18:28:43 | 显示全部楼层
用热键 HotKeySet
发表于 2009-6-30 18:32:18 | 显示全部楼层
[co
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Dim $start = 0, $ostart
$Form1 = GUICreate("Form1", 157, 59, 192, 124)
$Button1 = GUICtrlCreateButton("确定", 16, 16, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "gui")
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetState(@SW_SHOW)


While 1
        If $start = 1 Then
                MsgBox(0, "", "你点击了【确定】按钮")
                Sleep(4000)
        EndIf
WEnd

Exit

Func gui()
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        $start = 0
                        Exit
                Case $Button1
                        $start = 1
        EndSwitch
EndFunc   ;==>gui
de][/code]
发表于 2009-6-30 18:33:26 | 显示全部楼层
本帖最后由 autoit3CN 于 2009-6-30 18:35 编辑
#include <GUIConstants.au3>
#include <Timers.au3>
$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
              Exit
    Case $Button1
  Dim $i=0
  $iTimeProgres4 = _Timer_SetTimer($Form ,4000,'fit')
  EndSwitch
WEnd

Func fit($hWnd, $iMsg, $iwParam, $ilParam)
MsgBox (1,"","你点击了【确定】按钮")
EndFunc
发表于 2009-6-30 18:47:04 | 显示全部楼层
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
                        MsgBox (0,"","你点击了【确定】按钮")
        EndSwitch
WEnd
发表于 2009-6-30 18:48:42 | 显示全部楼层
无限循环中套用无限循环行吗?

我不知.....
 楼主| 发表于 2009-6-30 18:55:28 | 显示全部楼层
谢谢5楼“即即 ”和6楼“autoit3CN ”,经尝试,你们的代码都解决了俺的问题,谢谢!!

也谢谢“131738 ”“afan”,“水木子 ”的热心帮助,TKS!

已解决!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-13 01:45 , Processed in 0.079200 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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