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

求解一个问题

[复制链接]
发表于 2009-7-22 17:58:42 | 显示全部楼层 |阅读模式
如题:

#include <GuiConstantsEx.au3>


Global $mune1, $mune2, $mune3,$mune4,$mune5,$BS_FLAT, $BS_CENTER



;GUI
$Win=GUICreate("my test ",400,400,700,350)
GUISetIcon(@SystemDir &"",0)
$mune1 = GUICtrlCreateMenu("文件[&F]")
$next_mune1= GUICtrlCreateMenuItem("退出程序[&X]",$mune1)
$Button_tab0=GUICtrlCreateButton("Network Settings",260,290,Default,Default,$BS_FLAT & $BS_CENTER)
GUICtrlSetTip(-1,"进入目标设备配置")
$Button_color=GUICtrlSetColor($Button_tab0,0x000080)
$win_Childw = GUICreate("network settings Top mesh",400,200,700,450)
GUISwitch($Win)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ###Win========================================

While 1
        $nmsg = GUIGetMsg()

        Select
                Case $nmsg= $GUI_EVENT_CLOSE
                        If MsgBox(1,"警告","你真的要退出吗?")=1 Then ;当选为1时msgbox反回控件信息
                        ExitLoop
                        EndIf       
                Case $nmsg= $next_mune1
                        ExitLoop
                Case $nmsg=$Button_tab0
                        GUISwitch($win_Childw)
                        GUISetState(@SW_SHOW)
                        ;GUISetState(@SW_DISABLE,$win)         禁止访问主窗口

                       
        EndSelect
WEnd
-----------------------------------------------------------------

上面的例子为什么在弹出副窗口时,点右上角的差、会连主窗口一起关闭

怎样在关闭副窗口时返回主窗口

求教
发表于 2009-7-22 18:27:08 | 显示全部楼层
 #include <GuiConstantsEx.au3>
Opt("GUIOnEventMode", 1); 切换为 OnEvent 模式
Global $mune1, $mune2, $mune3,$mune4,$mune5,$BS_FLAT, $BS_CENTER
$Win=GUICreate("my test ",400,400,700,350)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; 设置窗口关闭事件
$mune1 = GUICtrlCreateMenu("文件[&F]")
$next_mune1= GUICtrlCreateMenuItem("退出程序[&X]",$mune1)
GUICtrlSetOnEvent($next_mune1, "CLOSEClicked") ; 设置窗口关闭事件
$Button_tab0=GUICtrlCreateButton("Network Settings",260,290,Default,Default,$BS_FLAT & $BS_CENTER)
$Button_color=GUICtrlSetColor($Button_tab0,0x000080)
GUICtrlSetOnEvent($Button_tab0, "OKButton");当某个控件被点击发送控件事件
GUICtrlSetTip(-1,"进入目标设备配置")
$win_Childw = GUICreate("network settings Top mesh",400,200,700,450)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked2") ; 设置窗口关闭事件
GUISwitch($Win)
GUISetState(@SW_SHOW)
While 1
        Sleep(100) 
WEnd

Func OKButton()
GUISwitch($win_Childw)
GUISetState(@SW_SHOW)
EndFunc
Func CLOSEClicked()
If MsgBox(1,"警告","你真的要退出吗?")=1 Then   Exit
EndFunc
Func CLOSEClicked2()
GUISwitch($win)
GUISetState(@SW_HIDE,$win_Childw)
EndFunc
发表于 2009-7-22 18:28:56 | 显示全部楼层
详见帮助文件 - GUI 相关 - OnEvent 模式
发表于 2009-7-22 18:31:59 | 显示全部楼层
借前辈的例子回答你的问题,你这样肯定是不行的。
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
Opt("GUIOnEventMode", 1)

$Main_GUI = GUICreate("父窗口", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiMsg")
GUISetBkColor(0x008040, $Main_GUI)
$Btn_Show = GUICtrlCreateButton("子窗口", 50, 70, 100, 30)
GUISetState(@SW_SHOW, $Main_GUI)
$Child1_GUI = GUICreate("子窗口", 200, 100, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiMsg")
$Btn_Test1 = GUICtrlCreateButton("显示", 50, 20, 100, 30)
GUICtrlSetOnEvent($Btn_Show, "_GuiMsg")
GUICtrlSetOnEvent($Btn_Test1, "_GuiMsg")

While 1
Sleep(250)
WEnd

Func _GuiMsg()
Switch @GUI_CTRLID 
Case $GUI_EVENT_CLOSE
Switch @GUI_WinHandle
Case $Main_GUI
Exit
Case $Child1_GUI 
GUISetState(@SW_HIDE,$Child1_GUI )
GUISetState(@SW_ENABLE ,$Main_GUI ) 
EndSwitch 
Case $Btn_Show 
GUISetState(@SW_SHOW,$Child1_GUI ) 
GUISetState(@SW_DISABLE ,$Main_GUI ) 
Case $Btn_Test1
MsgBox(64,"测试","我是子窗口")
EndSwitch
EndFunc
 楼主| 发表于 2009-7-22 19:14:23 | 显示全部楼层
谢谢lynfr8的答案。。学习
虽然4楼不是我想要的答案,,感谢幸苦路过
发表于 2009-7-23 04:44:14 | 显示全部楼层
先把句柄交回主窗体,然后指定子窗体并关闭
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-27 11:04 , Processed in 0.101873 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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