找回密码
 加入
搜索
查看: 5516|回复: 11

[GUI管理] [已解决]如何创建一个像对话框一样的子窗体

  [复制链接]
发表于 2010-8-21 15:37:37 | 显示全部楼层 |阅读模式
本帖最后由 itljl 于 2010-8-22 12:49 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 557, 381)
$Button1 = GUICtrlCreateButton("Button1", 5, 5, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,0,0,-1,$form1)
        EndSwitch
WEnd
上面的代码,当我们把msgbox的父窗口设置为$form1后,再点击$form1,窗体内所有控件不可用,并且,msgbox还会闪烁。

我已经试过所有样式,都不行。

有一种方法是,禁用$form1,但那样在点击父窗口的时候,子窗口不会闪烁。

评分

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

查看全部评分

 楼主| 发表于 2010-8-21 15:38:52 | 显示全部楼层
需要的效果和打开IE的,"intelnet 选项" 这个子窗口的效果一样。。
发表于 2010-8-21 16:51:58 | 显示全部楼层
貌似没这样式,自己写个吧
发表于 2010-8-21 17:19:23 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 800, 600)
$Button1 = GUICtrlCreateButton("子窗口", 360, 280, 80, 25)
GUISetState(@SW_SHOW,$Form1)

Opt("GUIOnEventMode", 1)
GUICtrlSetOnEvent($Button1, "Form2")
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")

$Form2 = GUICreate("Form2", 640, 480,-1,-1,-1,-1,$Form1)
$Button2 = GUICtrlCreateButton("退出子窗口", 270, 220, 100, 25)
GUICtrlSetOnEvent($Button2, "Form2")

While 1
sleep(10)
WEnd

func quit()
exit
endfunc

func Form2()
if WinGetState($Form2) < 7 then
GUISetState(@SW_DISABLE, $Form1)
GUISetState(@SW_SHOW,$Form2)
else
GUISetState(@SW_HIDE,$Form2)
GUISetState(@SW_ENABLE, $Form1)
endif
endfunc

评分

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

查看全部评分

 楼主| 发表于 2010-8-21 19:07:14 | 显示全部楼层
回复 4# xsjtxy


    谢谢啊,明白了,原来要用事件模式才有这样的效果,循环模式同样的写法,没有这样的效果!
发表于 2010-8-21 19:32:06 | 显示全部楼层
本帖最后由 republican 于 2010-8-21 19:44 编辑

回复 5# itljl

差别在于,你用了MSGbox,而4楼没有。

这个例子挺有趣的,说明了啥?

代码:

本帖子中包含更多资源

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

×
 楼主| 发表于 2010-8-21 20:12:03 | 显示全部楼层
回复 6# republican


    你想说明的是。。
发表于 2010-8-21 20:21:11 | 显示全部楼层
本帖最后由 republican 于 2010-8-21 20:24 编辑

回复 7# itljl


这个例子我自己的理解是:
1.AU3在一般情况下,一次只能做一件事.
2.没有经过特殊构造,MSGBOX后,界面将无响应。而原因是,消息无法直接传递。事实上,许多的阻塞,均来源于AU3自身。
3.后发消息优先级大于首发消息。
发表于 2010-8-21 21:31:36 | 显示全部楼层
回复 5# itljl


    问题好像出在谁是谁的子窗口。
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 800, 600)
$Button1 = GUICtrlCreateButton("子窗口", 360, 280, 80, 25)

GUISetState(@SW_SHOW,$Form1)


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



func Form2()
GUISetState(@SW_DISABLE, $Form1)
$Form2 = GUICreate("Form2", 640, 480,-1,-1,-1,-1,$Form1)
$Button2 = GUICtrlCreateButton("退出子窗口", 270, 220, 100, 25)
GUISetState(@SW_SHOW,$Form2)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $Button2
                        exitloop
        EndSwitch
WEnd
GUISetState(@SW_ENABLE, $Form1)
GUIDelete($Form2)
endfunc
发表于 2010-8-22 00:01:26 | 显示全部楼层
MSGBOX 后应该整个脚本都停了等待MSGBOX消息了吧
发表于 2010-8-22 00:13:54 | 显示全部楼层
使用 MSGBOX ,主脚本已暂停了,等待 MSGBOX 处理完毕,主脚本才会继续
发表于 2010-8-22 01:44:01 | 显示全部楼层
留脚印学习
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-3 01:31 , Processed in 0.085126 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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