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

[GUI管理] 关闭窗体2不影响窗体1的运行(已解决)

[复制链接]
发表于 2010-8-23 11:47:51 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2010-8-23 12:41 编辑

比如下面这段代码  效果 关闭2后 直接结束运行 如何关闭窗体2 返回1 而且不影响1的关闭
#include <GUIConstantsEx.au3>
$form1=GUICreate("测试1",200,150,-1,-1)
$button1=GUICtrlCreateButton("窗体2",75,100,50,25)
$form2=GUICreate("测试2",200,150,-1,-1)
$button2=GUICtrlCreateButton("待定",75,100,50,25)
GUISwitch($form1)
GUISetState()
While 1
        $nMsg=GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $button1
                        GUISetState(@SW_SHOW,$form2)
                        GUISetState(@SW_HIDE,$form1)
                        Switch $nMsg
                                Case $GUI_EVENT_CLOSE
                                        GUISetState(@SW_HIDE,$form2)
                                        GUISetState(@SW_SHOW,$form1)
                                Case $button2
                        EndSwitch
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
pusofalse + 10 感谢主动给标题加“已解决”字样。

查看全部评分

发表于 2010-8-23 12:09:25 | 显示全部楼层
#include <GUIConstantsEx.au3>

$form1=GUICreate("测试1",200,150,-1,-1)
$button1=GUICtrlCreateButton("窗体2",75,100,50,25)
GUISetState(@SW_SHOW)

While 1

        $nMsg=GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $button1
                        form2()
        EndSwitch

WEnd

func form2()
$form2=GUICreate("测试2",200,150,-1,-1)
$button2=GUICtrlCreateButton("待定",75,100,50,25)
GUISetState(@SW_SHOW,$form2)
GUISetState(@SW_HIDE,$form1)
While 1
        $nMsg=GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        exitloop
                Case $button2
        EndSwitch
WEnd
GUIDelete($form2)
GUISetState(@SW_SHOW,$form1)
endfunc

评分

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

查看全部评分

发表于 2010-8-23 12:12:42 | 显示全部楼层
本帖最后由 lixiaolong 于 2010-8-23 12:27 编辑

回复 1# shenrenba
#include <GUIConstantsEx.au3>

$form1=GUICreate("测试1",200,150,-1,-1
$button1=GUICtrlCreateButton("窗体2",75,100,50,25)
$form2=GUICreate("测试2",200,150,-1,-1)
$button2=GUICtrlCreateButton("待定",75,100,50,25)

GUISwitch($form1)
GUISetState()

While 1

        $nMsg=GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                 If WinActive("测试1")Then
                  Exit
        ElseIf WinActive("测试2")Then
                 GUISetState(@SW_HIDE,$form2)
         GUISetState(@SW_SHOW,$form1)
         ContinueLoop
                  EndIf
                Case $button1
                  GUISetState(@SW_SHOW,$form2)
                  GUISetState(@SW_HIDE,$form1)
        EndSwitch

WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-9 07:26 , Processed in 0.098143 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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