怎么使子窗口出现在最前面 无法操作父窗口
#include <ButtonConstants.au3>#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 269, 141, 372, 253)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 136, 56, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
manager()
EndSwitch
WEnd
Func manager()
$Form2 = GUICreate("Form2", 239, 100, 372, 253)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 136, 56, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form2)
WinActivate("Form2")
GUISetState(@SW_ENABLE, $Form1)
ExitLoop
EndSwitch
WEnd
EndFunc
简单点说就是在父窗口上点出子窗口来
然后子窗口在最顶层 而且不能操作父窗口 必须把子窗口关掉才能操作父窗口
怎么实现?因为做的软件需要这个功能请大家帮忙
[ 本帖最后由 kryiran 于 2008-8-21 21:31 编辑 ] 试试
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 269, 141, 372, 253)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 136, 56, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_DISABLE,$Form1)
manager()
GUISetState(@SW_ENABLE,$Form1)
EndSwitch
WEnd
Func manager()
$Form2 = GUICreate("Form2", 239, 100, -1,-1)
$Button1 = GUICtrlCreateButton("Button1", 40, 56, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 136, 56, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form2)
WinActivate("Form2")
GUISetState(@SW_ENABLE, $Form1)
ExitLoop
EndSwitch
WEnd
EndFunc
成功到是成功了
但是子窗口退出后 父窗口为什么会最小化呢?很郁闷 不建议使用多重循环嵌套.先写出gui,在需要的时候GUISetState(@SW_SHOW,hwnd),用完了再关闭. 父子窗口建议用GUIOnEventMode模式。
为什么不建议使用多重循环嵌套?
#include <GUIConstantsex.au3>$mainwindow = GUICreate('$strmaintitle', 371, 354)
$Button3 = GUICtrlCreateButton("新建...", 101, 272, 75, 25, 0)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
GUISetState(@SW_DISABLE,$mainwindow)
$newindow = GUICreate('$strnewtitle', 300, 200)
$newindowCancel = GUICtrlCreateButton("cancel", 156, 112, 75, 25, 0)
GUISetState()
While 1
Switch guigetmsg()
Case $GUI_EVENT_CLOSE
GUISetState(@SW_ENABLE,$mainwindow)
GUIDelete($newindow)
ExitLoop
Case $newindowCancel
GUISetState(@SW_ENABLE,$mainwindow)
GUIDelete($newindow)
ExitLoop
EndSwitch
WEnd
EndSwitch
WEnd
这样应该是多重循环嵌套吧?我经常这样用 在多窗口的时候GUIOnEventMode模式比多重循环要好。
建议阅读一下zcbenz的大作。并自己实际测试一下,就会知道了。 原帖由 kakinkgb 于 2008-8-15 13:26 发表 http://www.autoitx.com/images/common/back.gif
#include
$mainwindow = GUICreate('$strmaintitle', 371, 354)
$Button3 = GUICtrlCreateButton("新建...", 101, 272, 75, 25, 0)
GUISetState()
While 1
Switch GUIGetMsg()
Case $ ...
占用cpu/容易出错/不便于阅读/不便于修改...... 学习了,谢谢 认真学习 顶 正在研究父子窗口问题`~搜索下就找到了这个帖子,谢谢各位高手指教`~ 受教呀,非常感谢 以前的例子
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $B1, $F1, $F2
Opt("GUIOnEventMode", 1)
father()
Func father()
$F1 = GUICreate("father", 608, 456, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetBkColor(0x335EA8)
$B1 = GUICtrlCreateButton("son", 472, 384, 105, 41)
GUICtrlSetOnEvent($B1, "gui")
GUISetState(@SW_SHOW)
EndFunc ;==>father
Func son()
$F2 = GUICreate("son", 413, 298, 193, 123)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetBkColor(0x800080)
GUISetState(@SW_SHOW)
EndFunc ;==>son
While 1
;
WEnd
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Switch @GUI_WinHandle
Case $F1
Exit
Case $F2
GUISetState(@SW_HIDE, $F2)
GUISetState(@SW_ENABLE, $F1)
WinActivate("father")
EndSwitch
Case $B1
GUISetState(@SW_DISABLE, $F1)
son()
EndSwitch
EndFunc ;==>gui
研究下,子窗口 剛剛才玩父、子窗口,有源碼參考,做出了自己想要的窗口...
页:
[1]
2