Tab in Tab

  • Hi!

    Ist es etwa nicht möglich, ein Tabcontrol in einem Tabcontrol zu platzieren? Also folgendermaßen:

    Tab 1 | Tab 2 | Tab 3 |
    ===================
    Inhalt von Tab 1
    Weitere Tabs
    ===================

    Ich hoffe mal ihr wisst was ich meine^^

    fabs

  • Moin,

    so in etwa ???

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
    #include <GuiConstantsEx.au3>
    #include <GuiTab.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    $Debug_TAB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

    [/autoit] [autoit][/autoit] [autoit]

    Global $hTab
    Global $hTab2

    [/autoit] [autoit][/autoit] [autoit]

    _Main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _Main()
    Local $hGUI

    [/autoit] [autoit][/autoit] [autoit]

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Tab Control Create", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 22)
    $hTab2 = _GUICtrlTab_Create($hGUI, 4, 25, 390, 246)
    ControlHide ($hGUI, 0, GetDlgCtrlID ($hTab2))
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

    [/autoit] [autoit][/autoit] [autoit]

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab2, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab2, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab2, 2, "Tab 3")
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $hWndTab2
    $hWndTab = $hTab
    If Not IsHWnd($hTab) Then $hWndTab = GUICtrlGetHandle($hTab)
    $hWndTab2 = $hTab2
    If Not IsHWnd($hTab2) Then $hWndTab2 = GUICtrlGetHandle($hTab2)

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch ($hWndFrom)
    Case $hWndTab
    Switch ($iCode)
    Case $TCN_SELCHANGE
    Switch (_GUICtrlTab_GetCurSel ($hWndTab))
    Case 0
    ControlHide ($hWnd, 0, GetDlgCtrlID ($hWndTab2))
    Case 1
    ControlShow ($hWnd, 0, GetDlgCtrlID ($hWndTab2))
    Case 2
    ControlHide ($hWnd, 0, GetDlgCtrlID ($hWndTab2))
    EndSwitch
    EndSwitch

    Case $hWndTab2
    Switch $iCode
    Case $NM_CLICK ; The user has clicked the left mouse button within the control
    _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)

    ; The return value is ignored by the tab control
    Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
    _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ;~ Return 1 ; nonzero to not allow the default processing
    Return 0 ; zero to allow the default processing
    Case $NM_RCLICK ; The user has clicked the right mouse button within the control
    _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ;~ Return 1 ; nonzero to not allow the default processing
    Return 0 ; zero to allow the default processing
    Case $NM_RDBLCLK ; The user has clicked the right mouse button within the control
    _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ;~ Return 1 ; nonzero to not allow the default processing
    Return 0 ; zero to allow the default processing
    Case $NM_RELEASEDCAPTURE ; control is releasing mouse capture
    _DebugPrint("$NM_RELEASEDCAPTURE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    ; No return value
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit] [autoit][/autoit] [autoit]

    Func GetDlgCtrlID ($hwndCtl)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ("user32.dll", 'int', 'GetDlgCtrlID', _
    'hwnd', $hwndCtl)
    Return $aRes[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    ConsoleWrite( _
    "!===========================================================" & @LF & _
    "+======================================================" & @LF & _
    "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
    "+======================================================" & @LF)
    EndFunc ;==>_DebugPrint

    [/autoit]


    Gruß
    Greenhorn


  • Hallo fabs,

    noch eine 2. Möglichkeit

    Spoiler anzeigen
    [autoit]

    ;Original im MsgLoop-Modus gefunden (dank Progandy) auf http://www.autoitscript.com/forum/index.ph…ndpost&p=328240
    ;umgeschrieben auf OnEvent-Modus und Rseizing eingebaut (Auto)Bert
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Add_Constants=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    ; Example of TAB in TAB ctrl
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('GUIOnEventMode', 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $main_GUI, $child1, $child2, $main_tab, $ok_button, $cancel_button
    _main()

    [/autoit] [autoit][/autoit] [autoit]

    Func _main()
    ; This window has 2 ok/cancel-buttons
    $main_GUI = GUICreate("TAB in TAB", 260, 250, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
    GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
    $ok_button = GUICtrlCreateButton("OK", 40, 200, 70, 20)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUICtrlSetOnEvent(-1, '_End')
    $cancel_button = GUICtrlCreateButton("Cancel", 150, 200, 70, 20)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUICtrlSetOnEvent(-1, '_End')

    [/autoit] [autoit][/autoit] [autoit]

    ; Create the first child window that is implemented into the main GUI
    $child1 = GUICreate("", 230, 170, 15, 35, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
    $child_tab = GUICtrlCreateTab(2, 5, 225, 165)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    $child11tab = GUICtrlCreateTabItem("1")
    $child12tab = GUICtrlCreateTabItem("2")
    GUICtrlCreateTabItem("")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Create the second child window that is implemented into the main GUI
    $child2 = GUICreate("", 230, 170, 15, 35, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
    $listview2 = GUICtrlCreateListView("Col1|Col2", 2, 5, 225, 165, -1, $WS_EX_CLIENTEDGE)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
    GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; Switch back the main GUI and create the tabs
    GUISwitch($main_GUI)
    $main_tab = GUICtrlCreateTab(10, 10, 240, 180)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    GUICtrlSetOnEvent(-1, '_MainTab')
    $child1tab = GUICtrlCreateTabItem("Child1")
    $child2tab = GUICtrlCreateTabItem("Child2")
    $child3tab = GUICtrlCreateTabItem("Child3")
    $listview3 = GUICtrlCreateListView("Noch|eine|LV", 17, 39, 223, 138, -1, $WS_EX_CLIENTEDGE)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    GUICtrlCreateListViewItem("Spalte1.1|Spalte1.2|Spalte1.3", $listview3)
    GUICtrlCreateListViewItem("Spalte2.1|Spalte2.2|Spalte2.3", $listview3)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateTabItem("")

    GUIRegisterMsg($WM_SIZE, 'WM_SIZE')

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    While 1
    Sleep(125)
    WEnd
    EndFunc ;==>_main

    [/autoit] [autoit][/autoit] [autoit]

    Func _End()
    GUIDelete($child1)
    GUIDelete($child2)
    GUIDelete($main_GUI)
    Exit
    EndFunc ;==>_End

    [/autoit] [autoit][/autoit] [autoit]

    Func _MainTab()
    Switch GUICtrlRead($main_tab)
    Case 0
    GUISetState(@SW_HIDE, $child1)
    GUISetState(@SW_SHOW, $child2)

    [/autoit] [autoit][/autoit] [autoit]

    Case 1
    GUISetState(@SW_HIDE, $child2)
    GUISetState(@SW_SHOW, $child1)
    Case Else
    GUISetState(@SW_HIDE, $child1)
    GUISetState(@SW_HIDE, $child2)
    EndSwitch
    EndFunc ;==>_MainTab

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_SIZE($hWnd, $iMsg, $iWParam, $iLParam)
    $aMGPos = WinGetClientSize ($main_GUI)
    Winmove($child1,"",15,35,+$aMGPos[0]-30,+$aMGPos[1]-80)
    Winmove($child2,"",15,35,+$aMGPos[0]-30,+$aMGPos[1]-80)
    EndFunc

    [/autoit]

    mfg (Auto)Bert

  • Genau so stelle ich mir das vor. Danke euch beiden!

    edit:
    Also zur Möglichkeit von Greenhorn: Wie kann ich festlegen, in welchem Tab die Untertabs liegen sollen? Also im Beispiel sollen die Untertabs dann im ersten Übertab liegen.

    Einmal editiert, zuletzt von fabs (6. September 2009 um 01:40)

  • Hier wird das zweite Tab-Control gleich nach dem Erstellen versteckt (wenn es nicht im ersten Register des ersten Tab-Controls sichtbar sein soll)

    Spoiler anzeigen
    [autoit]

    $hTab2 = _GUICtrlTab_Create($hGUI, 4, 25, 390, 246)
    ControlHide ($hGUI, 0, GetDlgCtrlID ($hTab2))

    [/autoit]

    In diesem Teil legst du fest, wann das zweite Tab-Control sichtbar ist.

    Spoiler anzeigen
    [autoit]

    Switch (_GUICtrlTab_GetCurSel($hWndTab))
    Case 0
    ControlHide($hWnd, 0, GetDlgCtrlID($hWndTab2))
    Case 1
    ControlShow($hWnd, 0, GetDlgCtrlID($hWndTab2))
    Case 2
    ControlHide($hWnd, 0, GetDlgCtrlID($hWndTab2))
    EndSwitch

    [/autoit]
  • Okay, das klappt jetzt auch. Aber wie kann ich jetzt den spezifischen Inhalt (Lables, Controls etc.) pro Tab/Untertab festlegen? Das ist ja auch nicht im Beispiel der Hilfe drin