找回密码
 加入
搜索
查看: 5260|回复: 10

[系统综合] 如何通过Button实现页面切换

  [复制链接]
发表于 2010-12-11 15:14:16 | 显示全部楼层 |阅读模式
如代码
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 503, 387, 236, 129)
$Group1 = GUICtrlCreateGroup("Group1", 8, 8, 481, 281)
$Radio1 = GUICtrlCreateRadio("页面1内容", 136, 128, 145, 25)
$Radio2 = GUICtrlCreateRadio("页面2内容", 136, 192, 161, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("页面1", 48, 312, 97, 57)
$Button2 = GUICtrlCreateButton("页面2", 184, 312, 97, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        E

小弟想通过同一个窗口在按不同按钮时显示不同内容

如以上按Button1时显示$Radio1等内容 在按Button2时显示Radio2等

试过用
                        GUISetState(@SW_HIDE, $Form1)
                        GUISetState(@SW_SHOW, $Form1_1)
进行多窗口切换  不敢感觉效果不好  在切换时“闪动”厉害  感觉别扭

所以想请教下各位老师有没有其他更好的办法来实现   希望各位老师不吝赐教

小弟在线等候解决

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-12-11 15:37:57 | 显示全部楼层
学会搜索  向导窗口的演示
http://www.autoitx.com/forum.php ... hlight=%CF%F2%B5%BC
 楼主| 发表于 2010-12-11 15:46:05 | 显示全部楼层
学会搜索  向导窗口的演示
qq342252004 发表于 2010-12-11 15:37



    嗯嗯 谢谢楼上  我有搜索 不过可能对于某些关键字的不认识
所以有些东西没搜出来   谢谢
发表于 2010-12-11 16:17:37 | 显示全部楼层
本帖最后由 131738 于 2010-12-11 16:23 编辑
如代码

小弟想通过同一个窗口在按不同按钮时显示不同内容

如以上按Button1时显示$Radio1等内容 在按B ...
872777825 发表于 2010-12-11 15:14

自己分析参考修改。。。

点击 扫描文件类型 与 文件搜索预筛选
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <TabConstants.au3>
#include <StaticConstants.au3>
Global $button_tab_input_button[2]
Global $button_search_border[4],$button_search_background[4],$button_search_button[4]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 490, 643, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPSIBLINGS))
$button_tab_input_button[0] = GUICtrlCreateLabel("     扫描文件类型", 10, 354, 230, 28, BitOR($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE))
$button_tab_input_button[1] = GUICtrlCreateLabel("     文件搜索预筛选", 250, 354, 230, 28, BitOR($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE))
$button_search_border[0] = GUICtrlCreateLabel("", 16, 563, 142, 46)
GUICtrlSetBkColor(-1, 0xD2D2D2)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
$button_search_border[1] = GUICtrlCreateLabel("", 17, 564, 140, 44)

GUICtrlSetBkColor(-1, 0xF2F2F2)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
$button_search_background[0] = GUICtrlCreateLabel("", 18, 565, 138, 42)

GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
$button_search_button[0] = GUICtrlCreateLabel("取消搜索", 16, 563, 142, 46, BitOR($SS_NOTIFY, $SS_CENTER, $SS_CENTERIMAGE))

GUICtrlSetColor(-1, 0xD2D2D2)
;GUICtrlSetFont(-1, 8.5, 700, 0, $gui_font_name_1, $gui_font_quality)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; 透明标签



$c_Tab_Input = GUICtrlCreateTab(1, 1, 1, 1, $TCS_FOCUSNEVER)

$c_TabSheet_Input1 = GUICtrlCreateTabItem("扫描文件类型")

    $listview = GUICtrlCreateListView("列 1  |列 2|列 3  ", 50, 80, 200, 70);,$LVS_SORTDESCENDING)

    $item1 = GUICtrlCreateListViewItem("项目 2|子项 22|子项 23", $listview)

    $item2 = GUICtrlCreateListViewItem("项目 1|子项 12|子项 13", $listview)

    $item3 = GUICtrlCreateListViewItem("项目 3|子项 32|子项 33", $listview)
 
$c_button_search_returns_standard_all = GUICtrlCreateButton("全部", 135, 385, 75, 16)

$c_button_search_returns_standard_default = GUICtrlCreateButton("默认", 225, 385, 75, 16)


$c_TabSheet_Input2 = GUICtrlCreateTabItem("搜索预筛选")
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg

    $listview = GUICtrlCreateListView("列 1  |列 2|列 3  ", 10, 30, 200, 200);,$LVS_SORTDESCENDING)

    $item1 = GUICtrlCreateListViewItem("项目 2|子项 22|子项 23", $listview)
    $item2 = GUICtrlCreateListViewItem("项目 1|子项 12|子项 13", $listview)
    $item3 = GUICtrlCreateListViewItem("项目 3|子项 32|子项 33", $listview)


$c_Dummy_Check_Prefilters_First = GUICtrlCreateDummy();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 虚拟控件

$c_Input_FiletimeM_Time_H = GUICtrlCreateInput("23", 250, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeM_Time_M = GUICtrlCreateInput("59", 268, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeM_Time_S = GUICtrlCreateInput("59", 286, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeM_Time_H_After = GUICtrlCreateInput("23", 407, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeM_Time_M_After = GUICtrlCreateInput("59", 425, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeM_Time_S_After = GUICtrlCreateInput("59", 443, 407, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeC_Time_H = GUICtrlCreateInput("23", 250, 430, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeC_Time_M = GUICtrlCreateInput("59", 268, 430, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeC_Time_S = GUICtrlCreateInput("59", 286, 430, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeC_Time_H_After = GUICtrlCreateInput("23", 407, 430, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeC_Time_M_After = GUICtrlCreateInput("59", 425, 430, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeC_Time_S_After = GUICtrlCreateInput("59", 443, 430, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeA_Time_H = GUICtrlCreateInput("23", 250, 453, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeA_Time_M = GUICtrlCreateInput("59", 268, 453, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeA_Time_S = GUICtrlCreateInput("59", 286, 453, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeA_Time_H_After = GUICtrlCreateInput("23", 407, 453, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeA_Time_M_After = GUICtrlCreateInput("59", 425, 453, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeA_Time_S_After = GUICtrlCreateInput("59", 443, 453, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeF_Time_H = GUICtrlCreateInput("23", 250, 476, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeF_Time_M = GUICtrlCreateInput("59", 268, 476, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeF_Time_S = GUICtrlCreateInput("59", 286, 476, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeF_Time_H_After = GUICtrlCreateInput("23", 407, 476, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeF_Time_M_After = GUICtrlCreateInput("59", 425, 476, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeF_Time_S_After = GUICtrlCreateInput("59", 443, 476, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeL_Time_H = GUICtrlCreateInput("23", 250, 499, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeL_Time_M = GUICtrlCreateInput("59", 268, 499, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeL_Time_S = GUICtrlCreateInput("59", 286, 499, 18, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
GUICtrlSetBkColor(-1, 0xEBE9ED) ;背景颜色
$c_Input_FiletimeL_Time_H_After = GUICtrlCreateInput("23", 407, 499, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeL_Time_M_After = GUICtrlCreateInput("59", 425, 499, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Input_FiletimeL_Time_S_After = GUICtrlCreateInput("59", 443, 499, 18, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE) ;灰显;不可用
GUICtrlSetLimit(-1, 2)
$c_Dummy_Check_Prefilters_Last = GUICtrlCreateDummy();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 虚拟控件
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                Case $button_tab_input_button[0]; 点击 >>> "     扫描文件类型"
                                        ;$button_tab_input_button_active = 0;变换筛选项目显示的标志变量 = 0 ;默认=0
                                        GUICtrlSetState($c_TabSheet_Input1, $GUI_SHOW) ;显示 标签页1 包含的控件
                                        ;GUICtrlSetBkColor($button_tab_input_border[0], 0xF3583A);修改标签控件边框颜色
                                        ;GUICtrlSetBkColor($button_tab_input_border[1], 0xDDDDDD);修改标签控件边框颜色
                                Case $button_tab_input_button[1]; 点击 >>> "     文件搜索预筛选"
                                        ;$button_tab_input_button_active = 1;标志变量 = 1 ;默认=0
                                        GUICtrlSetState($c_TabSheet_Input2, $GUI_SHOW) ;显示 标签页2 包含的控件
                                        ;GUICtrlSetBkColor($button_tab_input_border[1], 0xF3583A);修改标签控件边框颜色
                                        ;GUICtrlSetBkColor($button_tab_input_border[0], 0xDDDDDD);修改标签控件边框颜色

        EndSwitch
WEnd
发表于 2010-12-11 20:20:57 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 625, 443, -1, -1)
$Button1 = GUICtrlCreateButton("窗口1", 528, 40, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("窗口2", 528, 88, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("窗口3", 528, 136, 75, 25, $WS_GROUP)

$Form2 = GUICreate("Choices Dialog", 345, 252, 30, 30, $WS_CHILD,"", $Form1)
$bListBox1 = GUICtrlCreateList("", 8, 8, 137, 201)
GUICtrlSetData(-1, "Item1|Item2|Item3|Item4|Item5")
$bButton1 = GUICtrlCreateButton(">", 156, 15, 30, 25, $WS_GROUP)
$bButton2 = GUICtrlCreateButton(">>", 156, 48, 31, 25, $WS_GROUP)
$bButton3 = GUICtrlCreateButton("<", 157, 81, 31, 25, $WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$bButton4 = GUICtrlCreateButton("<<", 157, 114, 32, 25, $WS_GROUP)
$bListBox2 = GUICtrlCreateList("", 200, 8, 137, 201)
$bButton5 = GUICtrlCreateButton("&OK", 104, 225, 75, 25, $WS_GROUP)
$bButton6 = GUICtrlCreateButton("&Cancel", 184, 225, 75, 25, $WS_GROUP)
$bButton7 = GUICtrlCreateButton("&Help", 264, 225, 75, 25, $WS_GROUP)

$Form3 = GUICreate("Tabbed Notebook Dialog", 420, 320, 30, 30, $WS_CHILD,"", $Form1)
$cPageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$cTabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$cTabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$cTabSheet3 = GUICtrlCreateTabItem("TabSheet3")
GUICtrlCreateTabItem("")
$cButton1 = GUICtrlCreateButton("&OK", 166, 272, 75, 25, $WS_GROUP)
$cButton2 = GUICtrlCreateButton("&Cancel", 246, 272, 75, 25, $WS_GROUP)
$cButton3 = GUICtrlCreateButton("&Help", 328, 272, 75, 25, $WS_GROUP)

$Form4 = GUICreate("About", 340, 253, 30, 30, $WS_CHILD,"", $Form1)
$dGroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
$dLabel1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
$dLabel2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
$dLabel4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
$dLabel3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$dButton1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25)

Local $Current = ""

GUISetState(@SW_SHOW, $Form1)


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        If $Current <> "" Then GUISetState(@SW_HIDE, $Current)
                        GUISetState(@SW_SHOW, $Form2)
                        $Current = $Form2
                Case $Button2
                        If $Current <> "" Then GUISetState(@SW_HIDE, $Current)
                        GUISetState(@SW_SHOW, $Form3)
                        $Current = $Form3                        
                Case $Button3
                        If $Current <> "" Then GUISetState(@SW_HIDE, $Current)
                        GUISetState(@SW_SHOW, $Form4)
                        $Current = $Form4                        
        EndSwitch
WEnd
发表于 2010-12-11 21:03:11 | 显示全部楼层
闪动厉害?在while循环里加个sleep(300)就应该不会闪了
发表于 2010-12-11 21:03:40 | 显示全部楼层
闪动厉害?在while循环里加个sleep(300)就应该不会闪了
发表于 2010-12-11 21:47:39 | 显示全部楼层
本帖最后由 KLU3K 于 2010-12-11 21:49 编辑

用TabSheet不行么?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Tabbed Notebook Dialog", 410, 273, 299, 218)
$PageControl1 = GUICtrlCreateTab(8, 8, 396, 256)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Radio1 = GUICtrlCreateRadio("Radio1", 32, 44, 113, 17)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Radio2 = GUICtrlCreateRadio("Radio2", 24, 48, 113, 17)
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Radio3 = GUICtrlCreateRadio("Radio3", 24, 44, 113, 17)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd
 楼主| 发表于 2010-12-14 15:09:48 | 显示全部楼层
闪动厉害?在while循环里加个sleep(300)就应该不会闪了
飘云 发表于 2010-12-11 21:03



    sleep(300)
加了好像没什么效果
 楼主| 发表于 2010-12-14 15:10:16 | 显示全部楼层
用TabSheet不行么?
KLU3K 发表于 2010-12-11 21:47



    不喜欢用分页标签 不美
 楼主| 发表于 2010-12-14 15:14:51 | 显示全部楼层
4楼的和2楼的  方式上好像不错   谢谢各位老师  谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-26 09:01 , Processed in 0.083295 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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