找回密码
 加入
搜索
查看: 1999|回复: 5

[AU3基础] [已解决]如何使2个窗口成为父子关系

[复制链接]
发表于 2020-4-9 15:49:27 | 显示全部楼层 |阅读模式
本帖最后由 phimiler 于 2020-4-13 10:11 编辑

A窗口为父窗口,B窗口为子窗口,如何做到当B窗口存在的时候,无法操作A窗口上的控件。我在创建B窗口的GUICreate函数的最后一个参数设定了A窗口的句柄,照理说这两个窗口已经成为父子关系,但B窗口存在的时候还是能操作A窗口上的控件。

请问:是我的操作有误,还是A和B窗口已经成为父子关系,只不过想实现我的功能不仅仅要求两个窗口成为父子关系,还需要别的什么约束。
发表于 2020-4-9 15:58:35 | 显示全部楼层
是父子,但仅在Z序显示上子于父上。要约束,在操作子窗时加上 GUISetState(@SW_DISABLE, $hParentWin),完事后 GUISetState(@SW_ENABLE, $hParentWin)
 楼主| 发表于 2020-4-9 16:30:14 | 显示全部楼层
afan 发表于 2020-4-9 15:58
是父子,但仅在Z序显示上子于父上。要约束,在操作子窗时加上 GUISetState(@SW_DISABLE, $hParentWin),完 ...

谢谢,我明白你的意思了。按你的说法我写了如下代码验证,可以实现功能,但又有一个问题:关闭父窗口程序后程序还是在运行中,好像是还处在子窗口的消息循环中,Exit不是可以直接退出脚本的么,代码如下:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$hParentWin = GUICreate("ParentWindow", 615, 437, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 192, 96, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 248, 216, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        GUISetState(@SW_DISABLE)
                        GiveMeChild()

        EndSwitch
WEnd


Func GiveMeChild()
        #Region ### START Koda GUI section ### Form=
        $hChildWin = GUICreate("ChildWindow", 405, 293, 302, 218)
        GUISetState(@SW_SHOW)
        #EndRegion ### END Koda GUI section ###
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                GUISetState(@SW_HIDE)
                                GUISetState(@SW_ENABLE, $Form1)
                EndSwitch
        WEnd
EndFunc   ;==>GiveMeChild
发表于 2020-4-9 16:45:32 | 显示全部楼层
phimiler 发表于 2020-4-9 16:30
谢谢,我明白你的意思了。按你的说法我写了如下代码验证,可以实现功能,但又有一个问题:关闭父窗口程序 ...

要退出循环,第35行(后面的句柄错的,)其下插入一行 ExitLoop
发表于 2020-4-9 16:50:52 | 显示全部楼层
Global $hParentWin = GUICreate("ParentWindow", 615, 437)
GUICtrlCreateCheckbox("Checkbox1", 192, 96, 97, 17)
Local $Button1 = GUICtrlCreateButton("Button1", 248, 216, 75, 25)
GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Button1
                        _GiveMeChild()
        EndSwitch
WEnd

Func _GiveMeChild()
        GUISetState(@SW_DISABLE, $hParentWin)
        Local $hChildWin = GUICreate("ChildWindow", 405, 293, -1, -1, -1, -1, $hParentWin)
        GUISetState()
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case -3
                                GUISetState(@SW_ENABLE, $hParentWin)
                                GUIDelete($hChildWin)
                                ExitLoop
                EndSwitch
        WEnd
EndFunc   ;==>_GiveMeChild
 楼主| 发表于 2020-4-9 17:24:10 | 显示全部楼层
afan 发表于 2020-4-9 16:45
要退出循环,第35行(后面的句柄错的,)其下插入一行 ExitLoop

谢谢大侠。。。。。。。。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-3-29 04:49 , Processed in 0.071610 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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