本帖最后由 xiehuahere 于 2012-8-8 16:39 编辑
回复 1# au3retry
没看到隐藏的方法,好像只能删除,需要的时候重建。
下面是在官网的一个例子上稍作修改(原代码有点问题#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <Array.au3>
$Form1 = GUICreate("Use Ctrl+T and CTRL+W to add/remove tabs", 625, 443, 192, 124)
$Tab1 = GUICtrlCreateTab(5, 30, 616, 406)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
$Add = GUICtrlCreateButton("Add", 5, 5, 75, 25, $WS_GROUP)
$Remove = GUICtrlCreateButton("Remove", 85, 5, 75, 25, $WS_GROUP)
Dim $Form1_AccelTable[2][2] = [["^t", $Add],["^w", $Remove]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
; Log both tabitems AND edits
Global $TABS, $EDITS
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Add
; Log both the tab AND the edit ControlID
If Not IsArray($TABS) Then
Dim $TABS[1], $EDITS[1]
Else
; ReDim BOTH arrays
ReDim $TABS[UBound($TABS)+1]
ReDim $EDITS[UBound($EDITS)+1]
EndIf
$TABS[UBound($TABS)-1] = GUICtrlCreateTabItem("TabSheet " & UBound($TABS))
$EDITS[UBound($EDITS)-1] = GUICtrlCreateEdit(UBound($EDITS), 7, 55, 610, 370)
GUICtrlCreateTabItem("")
Case $Remove
If Not IsArray($TABS) Then ContinueLoop
; Read the tab index
$iTab = GUICtrlRead($Tab1)
; Remove the tab
GUICtrlDelete($TABS[$iTab])
; Remove the tab AND the edit from the arrays
_ArrayDelete($TABS, $iTab)
_ArrayDelete($EDITS, $iTab)
EndSwitch
WEnd
|