昨晚搞到晚12点,没有搞出来,求大侠写哈(已解决)
本帖最后由 qsy666888 于 2018-3-17 15:37 编辑昨晚搞到晚12点,没有搞出来,求大侠写一下,想点击第一个按钮的时候显示第一个按钮标签1和2,点击第二个按钮的时候显示第二个按钮标签1和2,昨晚弄了会出现很多标签,没有搞成功。
默认第一个tab是显示状态,第二个为隐藏状态。按下第二个按钮的时候,第一个tab隐藏,第二个显示不是也可以吗~~ 回复 1# qsy666888 #include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Button1 = GUICtrlCreateButton("第一按钮", 512, 64, 75, 25)
$Button2 = GUICtrlCreateButton("第二按钮", 512, 120, 75, 25)
$Form2 = GUICreate("", 417, 305, 14, 28, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Tab1 = GUICtrlCreateTab(24, 48, 417, 305)
$TabSheet1 = GUICtrlCreateTabItem("第一个按钮标签1")
$Label1 = GUICtrlCreateLabel("Label1", 80, 96, 36, 17)
$Input1 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 48, 184, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date1 = GUICtrlCreateDate("2018/03/16 06:51:11", 48, 208, 186, 21)
$Group1 = GUICtrlCreateGroup("Group1", 216, 96, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Button3", 72, 248, 75, 25)
$TabSheet2 = GUICtrlCreateTabItem("第一按钮标签2")
GUICtrlSetState(-1,$GUI_SHOW)
$Label2 = GUICtrlCreateLabel("Label2", 96, 88, 36, 17)
$Group2 = GUICtrlCreateGroup("Group2", 208, 104, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input3 = GUICtrlCreateInput("Input3", 56, 152, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 56, 176, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 56, 200, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date2 = GUICtrlCreateDate("2018/03/16 06:52:54", 48, 224, 186, 21)
$Button4 = GUICtrlCreateButton("Button4", 80, 264, 75, 25)
GUICtrlCreateTabItem("")
$Form3 = GUICreate("", 417, 305, 14, 28, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Tab2 = GUICtrlCreateTab(24, 48, 417, 305)
$TabSheet3 = GUICtrlCreateTabItem("第二个按钮标签1")
$Label3 = GUICtrlCreateLabel("Label1", 80, 96, 36, 17)
$Input5 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input6 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
$Combo3 = GUICtrlCreateCombo("Combo1", 48, 184, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date3 = GUICtrlCreateDate("2018/03/16 06:51:11", 48, 208, 186, 21)
$Group3 = GUICtrlCreateGroup("Group1", 216, 96, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button5 = GUICtrlCreateButton("Button3", 72, 248, 75, 25)
$TabSheet4 = GUICtrlCreateTabItem("第二按钮标签2")
GUICtrlSetState(-1,$GUI_SHOW)
$Group2 = GUICtrlCreateGroup("Group2", 224, 80, 185, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button6 = GUICtrlCreateButton("Button4", 40, 88, 75, 25)
$Button7 = GUICtrlCreateButton("Button5", 120, 88, 75, 25)
$ListView1 = GUICtrlCreateListView("", 32, 128, 250, 150)
$TreeView1 = GUICtrlCreateTreeView(288, 128, 113, 209)
GUICtrlCreateTabItem("")
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $Form3)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_HIDE, $Form3)
Case $Button2
GUISetState(@SW_SHOW, $Form3)
GUISetState(@SW_HIDE, $Form2)
EndSwitch
WEnd
回复 1# qsy666888
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Button1 = GUICtrlCreateButton("菴珨偌聽", 512, 64, 75, 25)
$Button2 = GUICtrlCreateButton("菴媼偌聽", 512, 120, 75, 25)
$Tab1 = GUICtrlCreateTab(24, 48, 417, 305)
$TabSheet1 = GUICtrlCreateTabItem("Button1")
$Label1 = GUICtrlCreateLabel("Label1", 80, 96, 36, 17)
$Input1 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 48, 184, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date1 = GUICtrlCreateDate("2018/03/16 06:51:11", 48, 208, 186, 21)
$Group1 = GUICtrlCreateGroup("Group1", 216, 96, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Button3", 72, 248, 75, 25)
$TabSheet2 = GUICtrlCreateTabItem("button2")
GUICtrlSetState(-1,$GUI_SHOW)
$Label2 = GUICtrlCreateLabel("Label2", 96, 88, 36, 17)
$Group2 = GUICtrlCreateGroup("Group2", 208, 104, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input3 = GUICtrlCreateInput("Input3", 56, 152, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 56, 176, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 56, 200, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date2 = GUICtrlCreateDate("2018/03/16 06:52:54", 48, 224, 186, 21)
$Button4 = GUICtrlCreateButton("Button4", 80, 264, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
GUICtrlSendMsg($Tab1, 4912,0 , 0)
case $Button2
GUICtrlSendMsg($Tab1, 4912,1 , 0)
EndSwitch
WEnd
回复 3# austere
谢谢大侠谢谢大侠 本帖最后由 qsy666888 于 2018-3-16 09:27 编辑
回复 3# austere
发现标题成灰色了 回复 4# kk_lee69
不是你这样的,是点击按钮一的时候显示左边的两个标签页,点击按钮二的时候显示另外两个标签页,在同一窗口下 回复 7# qsy666888
发现标题成灰色了,如果这个对你要求很重要,就按照 2楼说的那样, 我是嫌一个一个隐藏你的控件太麻烦,所以才用的窗口~ 回复 8# austere
隐藏不了,你简单做一个看看,可以吗 本帖最后由 xzf680 于 2018-3-16 11:13 编辑
看看是不是你想要的效果
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <ComboConstants.au3>
$Form1 = GUICreate("Form1", 615, 438, -1, -1)
;左边按钮
$Button1 = GUICtrlCreateButton("第一按钮", 512, 64, 75, 25)
$Button2 = GUICtrlCreateButton("第二按钮", 512, 120, 75, 25)
;左边背景色
GUICtrlCreateGraphic(445,0,170,438)
GUICtrlSetBkColor(-1, 0x304040)
;右边背景色
GUICtrlCreateGraphic(0, 0, 445, 438)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetState(-1,128)
;选项卡
$Tab1 = GUICtrlCreateTab(0, -4, 448, 444,$TCS_FIXEDWIDTH)
_GUICtrlTab_SetItemSize(-1, 1, 1)
$TabSheet1 = GUICtrlCreateTabItem("说明")
$Label1 = GUICtrlCreateLabel("Label1", 80, 96, 36, 17)
$Input1 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 48, 184, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date1 = GUICtrlCreateDate("2018/03/16 06:51:11", 48, 208, 186, 21)
$Group1 = GUICtrlCreateGroup("Group1", 216, 96, 185, 105)
$Button3 = GUICtrlCreateButton("Button3", 72, 248, 75, 25)
GUICtrlCreateTabItem("")
;--------------------------------------------------------
$TabSheet2 = GUICtrlCreateTabItem("VERTICAL")
$Label2 = GUICtrlCreateLabel("Label2", 96, 88, 36, 17)
$Group2 = GUICtrlCreateGroup("Group2", 208, 104, 185, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input3 = GUICtrlCreateInput("Input3", 56, 152, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 56, 176, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 56, 200, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date2 = GUICtrlCreateDate("2018/03/16 06:52:54", 48, 224, 186, 21)
$Button4 = GUICtrlCreateButton("Button4", 80, 264, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_GUICtrlTab_SetCurFocus ($Tab1,0); 如果标签控件没有 $TCS_BUTTONS 样式, 改变焦点也同时改变选定的标签.
Case $Button2
_GUICtrlTab_SetCurFocus ($Tab1,1)
EndSwitch
WEnd
留個腳印MacGyver 本帖最后由 qsy666888 于 2018-3-16 12:49 编辑
回复 10# xzf680
不是你这种,要像三楼那种,三楼大侠那个还有点美中不足的是标题是灰色,还有就是如果窗口最大化,会影响界面,看起不美观,就是不知道隐藏TabItem标签是哪个代码 回复 12# qsy666888 #include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GuiTab.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, -1, -1)
$Button1 = GUICtrlCreateButton("第一按钮", 512, 64, 75, 25)
$Button2 = GUICtrlCreateButton("第二按钮", 512, 120, 75, 25)
$Tab1 = _GUICtrlTab_Create($Form1, 24, 48, 417, 350)
$TabSheet1 = _GUICtrlTab_InsertItem($Tab1,0, "第一个按钮标签1")
$TabSheet2 = _GUICtrlTab_InsertItem($Tab1, 1 , "第一按钮标签2")
$Tab2 = _GUICtrlTab_Create($Form1, 24, 48, 417, 350)
$TabSheet3 = _GUICtrlTab_InsertItem($Tab2,0, "第二个按钮标签1")
$TabSheet4 = _GUICtrlTab_InsertItem($Tab2,1, "第二按钮标签2")
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
ControlHide($Form1, '', $Tab2)
ControlShow($Form1, '', $Tab1)
Case $Button2
ControlHide($Form1, '', $Tab1)
ControlShow($Form1, '', $Tab2)
EndSwitch
WEnd 回复 13# austere [
你这个效果是达到了,往里面加控件,可四个标签框里都有那个控件,不知是不是AU3写不出来了,还是没有找到方法? 本帖最后由 austere 于 2018-3-16 15:55 编辑
回复 14# qsy666888
....... 这个UDF里的我也没用过,那就再换回去,用窗口操作~代码给你~窗口移动问题自己解决.....
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GuiTab.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, -1, -1)
GUICtrlCreateButton("第一按钮", 512, 64, 75, 25)
$Button2 = GUICtrlCreateButton("第二按钮", 512, 120, 75, 25)
$Tab1 = GUICtrlCreateTab(24, 48, 417, 350)
$TabSheet1 = GUICtrlCreateTabItem( "第一个按钮标签1")
$Label1 = GUICtrlCreateLabel("Label1", 80, 96, 36, 17)
$Input1 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
GUICtrlCreateTabItem("")
$TabSheet2 = GUICtrlCreateTabItem("第一按钮标签2")
$Combo2 = GUICtrlCreateCombo("Combo2", 56, 200, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Date2 = GUICtrlCreateDate("2018/03/16 06:52:54", 48, 224, 186, 21)
$Form2 = GUICreate("Form1", 615, 437, -1, -1)
$Button1 = GUICtrlCreateButton("第一按钮", 512, 64, 75, 25)
GUICtrlCreateButton("第二按钮", 512, 120, 75, 25)
$Tab2 =GUICtrlCreateTab(24, 48, 417, 350)
$TabSheet3 = GUICtrlCreateTabItem("第二个按钮标签1")
$Input5 = GUICtrlCreateInput("Input1", 48, 128, 121, 21)
$Input6 = GUICtrlCreateInput("Input2", 48, 152, 121, 21)
$TabSheet4 = GUICtrlCreateTabItem("第二按钮标签2")
$Group2 = GUICtrlCreateGroup("Group2", 224, 80, 185, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_HIDE, $Form2)
Case $Button2
GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_HIDE, $Form1)
EndSwitch
WEnd
页:
[1]
2