Jump to content

Embeding TabControl in TabControlItem


 Share

Recommended Posts

Hi,

I am having a problem to embed Tab control withing a tab control item. e.g. I want to make a nested tabs.

I have tried to develop it in Koda(formDesigner) but it hang the SciTE editor.

Does it possible in AutoIt? Any input or code if someone already developed it?

THX!

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Hi lsakizada

As far as I know we can have only one TAB ctrl per GUI.

For embedding more TABs in the same window or a TAB in TAB we have to use child GUIs.

To get the idea try the following

TabInTab.au3

; Example of TAB in TAB ctrl
#include <GUIConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

; This window has 2 ok/cancel-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

; 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(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")

GUISetState()

; 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",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
            
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
            
                Case 1
                 GUISetState(@SW_HIDE,$child1)
                  GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd

and

MultiTAB.au3

; Example of multiple tabs in the same GUI
#include <GUIConstants.au3>

DIM $main_GUI,$ok_button,$cancel_button

; The main GUI window has the 2 ok/cancel-buttons and two child GUIs
$main_GUI        = GUICreate("Multiple TABs",520,250,-1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS))
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

GUISetState()

; Creates the first child GUI window as a child of main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab       = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")


GUISetState()

; Creates the second gui window as a child of main GUI
$child2         = GUICreate("",230,170,250,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)

; Create second TAB control and its the tabs
$main_tab        = GUICtrlCreateTab(10,10,220,150)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")
GUICtrlSetState($child1tab,$GUI_SHOW)
GUISetState()

GUISwitch($main_GUI)

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
            
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
            
                Case 1
                
            EndSwitch
    EndSwitch
WEnd
Link to comment
Share on other sites

Hi lsakizada

As far as I know we can have only one TAB ctrl per GUI.

For embedding more TABs in the same window or a TAB in TAB we have to use child GUIs.

To get the idea try the following

TabInTab.au3

; Example of TAB in TAB ctrl
#include <GUIConstants.au3>

Global $main_GUI,$ok_button,$cancel_button

; This window has 2 ok/cancel-buttons
$main_GUI       = GUICreate("TAB in TAB",260,250,-1,-1)
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

; 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(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")

GUISetState()

; 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",10,10,210,150,-1,$WS_EX_CLIENTEDGE)
GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,240,200)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
            
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
                  GUISetState(@SW_HIDE,$child2)
                  GUISetState(@SW_SHOW,$child1)
            
                Case 1
                 GUISetState(@SW_HIDE,$child1)
                  GUISetState(@SW_SHOW,$child2)
            EndSwitch
    EndSwitch
WEnd

and

MultiTAB.au3

; Example of multiple tabs in the same GUI
#include <GUIConstants.au3>

DIM $main_GUI,$ok_button,$cancel_button

; The main GUI window has the 2 ok/cancel-buttons and two child GUIs
$main_GUI        = GUICreate("Multiple TABs",520,250,-1,-1,BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS))
$ok_button      = GUICtrlCreateButton("OK",40,220,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,220,70,20)

GUISetState()

; Creates the first child GUI window as a child of main GUI
$child1         = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)
$child_tab       = GUICtrlCreateTab(10,10,210,150)
$child11tab     = GUICtrlCreateTabItem("1")
$child12tab     = GUICtrlCreateTabItem("2")
GUICtrlCreateTabItem("")
GUISetState()

; Creates the second gui window as a child of main GUI
$child2         = GUICreate("",230,170,250,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)

; Create second TAB control and its the tabs
$main_tab        = GUICtrlCreateTab(10,10,220,150)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")
GUICtrlSetState($child1tab,$GUI_SHOW)
GUISetState()

GUISwitch($main_GUI)

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
            
        Case $main_tab
            Switch GUICtrlRead($main_tab)
                Case 0
            
                Case 1
                
            EndSwitch
    EndSwitch
WEnd

Great example two is exactly what I need!!!! :shocked:

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

  • 4 years later...

Hi, i test this script and inside it have a link this topic...

The original SubTab is located in the main TAB 2.

I try put another SubTab in TAB 3, for example, but I cant.

Some one can help-me please?

That is the code

;Original im MsgLoop-Modus gefunden (dank Progandy) auf http://www.autoitscript.com/forum/index.php?showtopic=44083&view=findpost&p=328240
#Region
#AutoIt3Wrapper_Add_Constants=n
#EndRegion
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)

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

Func _main()
    $main_GUI = GUICreate("Teste TAB (in) TAB", 700, 450, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
    GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUICtrlSetOnEvent(-1, '_End')
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
    GUICtrlSetOnEvent(-1, '_End')

    ; Create the first child window that is implemented into the main GUI
    $child1 = GUICreate("", 680, 370, 15, 35, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
    $child_tab = GUICtrlCreateTab(2, 5, 675, 365)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    $child11tab = GUICtrlCreateTabItem(" SubMenu01 ")
    GUICtrlCreateButton("um", 40, 200, 70, 20)
    $child12tab = GUICtrlCreateTabItem(" SubMenu02 ")
    GUICtrlCreateButton("dois", 40, 200, 70, 20)
    $child13tab = GUICtrlCreateTabItem(" SubMenu03 ")
    GUICtrlCreateButton("tres", 40, 200, 70, 20)
    $child14tab = GUICtrlCreateTabItem(" SubMenu04 ")
    GUICtrlCreateButton("quatro", 40, 200, 70, 20)
    $child15tab = GUICtrlCreateTabItem(" SubMenu05 ")
    GUICtrlCreateButton("cinco", 40, 200, 70, 20)
    $child16tab = GUICtrlCreateTabItem(" SubMenu06 ")
    GUICtrlCreateButton("seis", 40, 200, 70, 20)
    
    ;GUICtrlCreateTabItem("tttt")

    ; 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)
    GUISetState()

    ; Switch back the main GUI and create the tabs
    GUISwitch($main_GUI)
    $main_tab = GUICtrlCreateTab(10, 10, 679, 384)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    GUICtrlSetOnEvent(-1, '_MainTab')
    
    $child1tab = GUICtrlCreateTabItem("Menu 01")
        ;GUICtrlCreateButton("Lab", 40, 200, 70, 20)
        GUICtrlCreateIcon("shell32.dll", 10, 20, 40)
    $child2tab = GUICtrlCreateTabItem("Menu 02")
    $child3tab = GUICtrlCreateTabItem("Menu 03")
        GUICtrlCreateButton("Tools", 40, 200, 70, 20)
    $child4tab = GUICtrlCreateTabItem("Menu 04")
    GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
        GUICtrlCreateButton("Form", 40, 200, 70, 20)
        
    GUISetState()

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

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

Func _MainTab()
    Switch GUICtrlRead($main_tab)
        Case 0
            GUISetState(@SW_HIDE, $child1)
            GUISetState(@SW_SHOW, $child2)
        Case 1
            GUISetState(@SW_HIDE, $child2)
            GUISetState(@SW_SHOW, $child1)
        Case Else
            GUISetState(@SW_HIDE, $child1)
            GUISetState(@SW_HIDE, $child2)
    EndSwitch
EndFunc   ;==>_MainTab

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
Edited by detefon

Visit my repository

Link to comment
Share on other sites

You can read through this thread and you should be able to figure it out

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...