找回密码
 加入
搜索
查看: 2351|回复: 1

[GUI管理] 如何避免出现多个窗口?[已解决]

[复制链接]
发表于 2010-8-29 09:32:50 | 显示全部楼层 |阅读模式
本帖最后由 仙乃日 于 2010-8-29 09:49 编辑
#include <GuiConstants.au3>
Global $Form1, $Label1, $Label2, $Label3, $Button1, $Button2, $Button3, $Button4, $Input1, $Input2, $Radio1, $sRadio1, $Radio2, $sRadio2, $Checkbox1, $sCheckbox1, $Checkbox2, $sCheckbox2, $Checkbox3, $sCheckbox3,$x
Opt("GUIOnEventMode", 1)
$x=1
Step_gui($x)
While 1
        Sleep(20)
        WEnd
Func Step_gui($x)
        Select
                Case $x = 1
                        $Form1 = GUICreate("离线驱动注入工具  By 仙乃日", 450, 220, -1, -1)
                        $Button1 = GUICtrlCreateButton("< 上一步[&B]", 200, 185, 89, 25, 0)
                        GUICtrlSetState($Button1, $gui_disable)
                        $Button2 = GUICtrlCreateButton("下一步[&N] >", 325, 185, 89, 25, 0)
                        $Label1 = GUICtrlCreateLabel("请选择所要进行的操作!", 25, 16, 400, 30);在GUI上创建一个静态标签(Label)控件 GUICtrlCreateLabel ( "文本", 左侧, 顶部 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]]
                        GUICtrlSetFont($Label1, 12, 650, 2)
                        $Radio1 = GUICtrlCreateRadio("清除目标系统中所有的大容量存储控制器驱动!", 35, 45, 400, 20)
                        $Radio2 = GUICtrlCreateRadio("清除目标系统中的大容量存储控制器驱动,但保留适合本机的驱动!", 35, 70)
                        $Checkbox1 = GUICtrlCreateCheckbox("从PE中注入适合本机的大容量存储控制器驱动!", 35, 95)
                        $Checkbox2 = GUICtrlCreateCheckbox("注入适合本机的第3方厂商大容量存储控制器驱动!", 35, 120)
                        GUICtrlSetState($Checkbox2, $gui_disable)
                        $Checkbox3 = GUICtrlCreateCheckbox("自动更改目标系统的电源模式,使其适合本机!", 35, 145)
                        GUICtrlSetState($Checkbox3, $gui_disable)
                        GUISetState()
                        
                        GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button1,"GUI_CTRL")
                        GUICtrlSetOnEvent($Button2,"GUI_CTRL")
                Case $x = 2
                        GUICtrlSetState($Button1, $gui_enable)
                        If GUICtrlRead($Radio1) = $GUI_CHECKED Then $sRadio1 = 1
                        GUICtrlSetState($Radio1, $gui_hide)
                        If GUICtrlRead($Radio2) = $GUI_CHECKED Then $sRadio2 = 1
                        GUICtrlSetState($Radio2, $gui_hide)
                        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sCheckbox1 = 1
                        GUICtrlSetState($Checkbox1, $gui_hide)
                        If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $sCheckbox2 = 1
                        GUICtrlSetState($Checkbox2, $gui_hide)
                        If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $sCheckbox3 = 1
                        GUICtrlSetState($Checkbox3, $gui_hide)
                        GUICtrlSetState($Button2, $gui_disable)

                        GUICtrlSetData($Label1, "请选择目标系统所在的目录和第3方厂商驱动所在的目录!")
                        GUICtrlSetFont($Label1, 11, 580, 0)
                        $Label2 = GUICtrlCreateLabel("系统路径:", 25, 68, 80, 25)
                        GUICtrlSetFont($Label2, 12, 550, 0)
                        $Button3 = GUICtrlCreateButton("打开", 310, 65, 45, 25)
                        $Input1 = GUICtrlCreateInput("", 105, 65, 200, 25)
                        $Label3 = GUICtrlCreateLabel("驱动路径:", 25, 113, 80, 25)
                        GUICtrlSetFont($Label3, 12, 550, 0)
                        $Input2 = GUICtrlCreateInput("", 105, 110, 200, 25)
                        $Button4 = GUICtrlCreateButton("打开", 310, 110, 45, 25)
        EndSelect
EndFunc   ;==>Step_gui


Func GUI_CTRL()
        
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $x -=1
                        Step_gui($x)
                Case $Button2
                                If GUICtrlRead($Button2) = "完成[&F]" Then Exit
                                $x +=1
                                Step_gui($x)
                                
        EndSwitch

EndFunc   ;==>_GUI_CTRL
自己初学GUI很多基本的知识都不懂。这个界面在多次按“上一步”“下一步”后就会出现多个窗口,如何避免呢?

评分

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

查看全部评分

 楼主| 发表于 2010-8-29 09:49:25 | 显示全部楼层
谢谢 水木子 帮忙!
#include <GuiConstants.au3>
Global $Form1, $Label1, $Label2, $Label3, $Button1, $Button2, $Button3, $Button4, $Input1, $Input2, $Radio1, $sRadio1, $Radio2, $sRadio2, $Checkbox1, $sCheckbox1, $Checkbox2, $sCheckbox2, $Checkbox3, $sCheckbox3, $x
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("离线驱动注入工具  By 仙乃日", 450, 220, -1, -1)
$Button1 = GUICtrlCreateButton("< 上一步[&B]", 200, 185, 89, 25, 0)
GUICtrlSetState($Button1, $gui_disable)
$Button2 = GUICtrlCreateButton("下一步[&N] >", 325, 185, 89, 25, 0)
$x = 1
Step_gui($x)
While 1
        Sleep(20)
WEnd
Func Step_gui($x)
        Select
                Case $x = 1

                        $Label1 = GUICtrlCreateLabel("请选择所要进行的操作!", 25, 16, 400, 30);在GUI上创建一个静态标签(Label)控件 GUICtrlCreateLabel ( "文本", 左侧, 顶部 [, 宽度 [, 高度 [, 样式 [, 扩展样式]]]]
                        GUICtrlSetFont($Label1, 12, 650, 2)
                        $Radio1 = GUICtrlCreateRadio("清除目标系统中所有的大容量存储控制器驱动!", 35, 45, 400, 20)
                        $Radio2 = GUICtrlCreateRadio("清除目标系统中的大容量存储控制器驱动,但保留适合本机的驱动!", 35, 70)
                        $Checkbox1 = GUICtrlCreateCheckbox("从PE中注入适合本机的大容量存储控制器驱动!", 35, 95)
                        $Checkbox2 = GUICtrlCreateCheckbox("注入适合本机的第3方厂商大容量存储控制器驱动!", 35, 120)
                        GUICtrlSetState($Checkbox2, $gui_disable)
                        $Checkbox3 = GUICtrlCreateCheckbox("自动更改目标系统的电源模式,使其适合本机!", 35, 145)
                        GUICtrlSetState($Checkbox3, $gui_disable)
                        GUISetState()

                        GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button1, "GUI_CTRL")
                        GUICtrlSetOnEvent($Button2, "GUI_CTRL")
                        ;控件切换 
                        GUICtrlSetState($Button1, $gui_disable)
                        GUICtrlSetState($Button2, $gui_enable)
                        GUICtrlSetState($Label2, $gui_hide)
                        GUICtrlSetState($Button3, $gui_hide)
                        GUICtrlSetState($Input1, $gui_hide)
                        GUICtrlSetState($Label3, $gui_hide)
                        GUICtrlSetState($Input2, $gui_hide)
                        GUICtrlSetState($Button4, $gui_hide)
                Case $x = 2
                        GUICtrlSetState($Button1, $gui_enable)
                        If GUICtrlRead($Radio1) = $GUI_CHECKED Then $sRadio1 = 1
                        GUICtrlSetState($Radio1, $gui_hide)
                        If GUICtrlRead($Radio2) = $GUI_CHECKED Then $sRadio2 = 1
                        GUICtrlSetState($Radio2, $gui_hide)
                        If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sCheckbox1 = 1
                        GUICtrlSetState($Checkbox1, $gui_hide)
                        If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $sCheckbox2 = 1
                        GUICtrlSetState($Checkbox2, $gui_hide)
                        If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then $sCheckbox3 = 1
                        GUICtrlSetState($Checkbox3, $gui_hide)
                        GUICtrlSetState($Button2, $gui_disable)

                        GUICtrlSetData($Label1, "请选择目标系统所在的目录和第3方厂商驱动所在的目录!")
                        GUICtrlSetFont($Label1, 11, 580, 0)
                        $Label2 = GUICtrlCreateLabel("系统路径:", 25, 68, 80, 25)
                        GUICtrlSetFont($Label2, 12, 550, 0)
                        $Button3 = GUICtrlCreateButton("打开", 310, 65, 45, 25)
                        $Input1 = GUICtrlCreateInput("", 105, 65, 200, 25)
                        $Label3 = GUICtrlCreateLabel("驱动路径:", 25, 113, 80, 25)
                        GUICtrlSetFont($Label3, 12, 550, 0)
                        $Input2 = GUICtrlCreateInput("", 105, 110, 200, 25)
                        $Button4 = GUICtrlCreateButton("打开", 310, 110, 45, 25)
        EndSelect
EndFunc   ;==>Step_gui


Func GUI_CTRL()

        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $x -= 1
                        Step_gui($x)
                Case $Button2
                        If GUICtrlRead($Button2) = "完成[&F]" Then Exit
                        $x += 1
                        Step_gui($x)

        EndSwitch

EndFunc   ;==>GUI_CTRL
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 17:32 , Processed in 0.079416 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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