找回密码
 加入
搜索
查看: 2331|回复: 2

[GUI管理] 请教以下代码为什么在二级窗口退出时会卡死?(已解决)

[复制链接]
发表于 2010-11-20 15:36:02 | 显示全部楼层 |阅读模式
本帖最后由 dreamgg 于 2010-11-20 16:06 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt("TrayMenuMode",1)        ; 默认菜单项目 (脚本暂停中/退出)(Script Paused/Exit) 将不会显示. 

$settingsitem        = TrayCreateItem("设置...")
TrayCreateItem("")
$aboutitem                = TrayCreateItem("关于...")
TrayCreateItem("")
$exititem                = TrayCreateItem("退出...")

TraySetState()

While 1
        $msg = TrayGetMsg()
        Select
                Case $msg = 0
                        ContinueLoop
                Case $msg = $settingsitem
                        ;Msgbox(64,"提醒:","这是配置选项!")
                        Win1()
                Case $msg = $aboutitem
                        ;Msgbox(64,"提醒:","这是关于选项!")
                        Win2()
                Case $msg = $exititem
                        ;Msgbox(64,"提醒:","这是退出选项!")
                        ExitLoop
        EndSelect
WEnd

Func Win1()
    Local $gui1, $msg, $Group1, $Label1, $Label2, $Label3, $Input1, $Input2, $Input3, $Button_1, $Button_2
    
    $gui1 = GUICreate("服务器IP设置", 290, 242, Default, default, BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU))
                
        $Group1 = GUICtrlCreateGroup("设置服务器IP", 12, 12, 270, 182)
        
        $Label1 = GUICtrlCreateLabel("服务器IP:", 30, 52, 65, 12)
        $Label2 = GUICtrlCreateLabel("管理员账号:", 30, 97, 77, 12)
        $Label3 = GUICtrlCreateLabel("管理员密码:", 30, 142, 77, 12)
        
        $Input1 = GUICtrlCreateInput("", 112, 45, 150, 22)
        $Input2 = GUICtrlCreateInput("", 112, 90, 150, 22)
        $Input3 = GUICtrlCreateInput("", 112, 135, 150, 22)
        
        $Button_1 = GUICtrlCreateButton("确定", 52, 206, 77)
        $Button_2 = GUICtrlCreateButton("取消", 180, 206, 77)
        
    GUISetState(@SW_SHOW)
        
        While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $Button_1
                        Msgbox(0,"","输入的IP地址格式不正确!")
                Case $msg = $Button_2
                        Msgbox(0,"提醒:","你选择了退出!")
                        ExitLoop
        EndSelect
        WEnd

EndFunc

Func Win2()
    Local $gui2, $msg, $pic, $Button_3, $Label1, $Label2, $Label3
    
    $gui2 = GUICreate("网吧客户端", 404, 130, Default, default, BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU))
        
        $pic = GUICtrlCreatePic("win2.gif", 0, 0, 404, 130)
        
        GuiCtrlSetState(-1,$GUI_DISABLE)
        
        $Button_3 = GUICtrlCreateButton("确定", 310, 10, 77)
        GUICtrlSetBkColor(-1, 0xc0ffff)

        GUISetState(@SW_SHOW)
        
        While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $Button_3
                        Msgbox(0,"提醒:","你选择了退出!")
                        ExitLoop
        EndSelect
        WEnd

EndFunc

Exit
托盘菜单执行后的子窗口独立运行时可以正常退出,但放到主程序一起再选退出窗口的时候就不能正常退出了。

感谢帮忙的朋友,解决方法是在ExitLoop上面加一句GUIDelete()

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-11-20 15:55:15 | 显示全部楼层
试试guidelete 或 guicsetstate

评分

参与人数 1金钱 +15 收起 理由
afan + 15

查看全部评分

 楼主| 发表于 2010-11-20 16:05:37 | 显示全部楼层
感谢楼上的朋友,已解决。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 16:30 , Processed in 0.082075 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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