窗体切换问题(已解决)
本帖最后由 faceyao 于 2010-8-15 12:20 编辑用koda建了2个窗体分别是Form1和Form2,在Form1上有个button确定按钮,
要求是点button确定按钮后,Form1就关闭,Form2就出现,请问代码该怎么写?
我用winclose(Form1,"")始终关闭不了Form1窗体。 搜索多窗口 回复 2# afan
搜了,也仔细看了,帖子内容非常长,看不明白 不知道是不是要这样:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 419, 261, 374, 160)
$Button1 = GUICtrlCreateButton("OK", 160, 208, 129, 41)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUIDelete ( $Form1 )
ExitLoop
EndSwitch
WEnd
$Form2 = GUICreate("Form2", 419, 261, 374, 160)
$Button2 = GUICtrlCreateButton("OK", 160, 208, 129, 41)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
Exit
EndSwitch
WEnd
事件模式、可返回主窗口Opt('GUIOnEventMode', 1)
$Form1 = GUICreate('Form1 <-> Form2 - Afan')
GUISetOnEvent(-3, '_exit')
$Button1 = GUICtrlCreateButton('切换至Form2', 50, 290, 100, 20)
GUICtrlSetOnEvent(-1, 'Form1')
$Form2 = GUICreate('Form2', 300, 200)
GUISetOnEvent(-3, 'Form2')
$Button2 = GUICtrlCreateButton('返回Form1', 180, 150, 100, 20)
GUICtrlSetOnEvent(-1, 'Form2')
$Button3 = GUICtrlCreateButton('退出程序', 50, 150, 100, 20)
GUICtrlSetOnEvent(-1, 'Form2')
GUISetState(@SW_SHOW, $Form1)
While 1
Sleep(1000)
WEnd
Func Form1()
GUISetState(@SW_HIDE, $Form1)
GUISwitch($Form2)
GUISetState()
EndFunc ;==>Form1
Func Form2()
Switch @GUI_CtrlId
Case $Button2, -3
GUISetState(@SW_HIDE, $Form2)
GUISwitch($Form1)
GUISetState()
Case $Button3
Exit
EndSwitch
EndFunc ;==>Form2
Func _exit()
Exit
EndFunc ;==>_exit
谢谢楼上2位,已解决!
页:
[1]