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

[AU3基础] 窗体切换问题(已解决)

  [复制链接]
发表于 2010-8-15 11:07:36 | 显示全部楼层 |阅读模式
本帖最后由 faceyao 于 2010-8-15 12:20 编辑

用koda建了2个窗体分别是Form1和Form2,在Form1上有个button确定按钮,

要求是点button确定按钮后,Form1就关闭,Form2就出现,请问代码该怎么写?

我用winclose(Form1,"")始终关闭不了Form1窗体。

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-8-15 11:19:59 | 显示全部楼层
搜索多窗口
 楼主| 发表于 2010-8-15 11:44:54 | 显示全部楼层
回复 2# afan

搜了,也仔细看了,帖子内容非常长,看不明白
发表于 2010-8-15 12:06:19 | 显示全部楼层
不知道是不是要这样:
#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

评分

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

查看全部评分

发表于 2010-8-15 12:17:34 | 显示全部楼层
事件模式、可返回主窗口
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

评分

参与人数 1金钱 +10 收起 理由
faceyao + 10 谢谢afan!

查看全部评分

 楼主| 发表于 2010-8-15 12:20:14 | 显示全部楼层
谢谢楼上2位,已解决!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-3 10:39 , Processed in 0.083475 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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