JakeJohnson74 Posted February 4, 2015 Share Posted February 4, 2015 (edited) Hello! I am trying to figure out how to nest a tab control within another tab control. The help file says that one GUI can not have more than one Tab control and they show this example: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) GUISetState() ; Create child GUIs to hold tabs $hTab_Win0 = GUICreate("", 400, 200, 50, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_0 = GUICtrlCreateTab(10, 10, 380, 180) $hTab_00 = GUICtrlCreateTabitem("00") GUICtrlCreateButton("00", 160, 90, 80, 30) $hTab_01 = GUICtrlCreateTabitem("01") GUICtrlCreateButton("01", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() $hTab_Win1 = GUICreate("", 400, 200, 50, 250, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_1 = GUICtrlCreateTab(10, 10, 380, 180) $hTab_10 = GUICtrlCreateTabitem("10") GUICtrlCreateButton("10", 160, 90, 80, 30) $hTab_11 = GUICtrlCreateTabitem("11") GUICtrlCreateButton("11", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd They are creating 2 Gui's and each one has its own Tab control, it follows the rules and works as expected! Now, my question is - Can I create a GUI on one of the Tab Items and put a tab control onto that GUI with its own tab items? I have tried changing the parent to $hTab_Win0, I also tried $hTab_0 as a parent and neither one of those options gives me what I want. Edited February 4, 2015 by JakeKenmode Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 4, 2015 Moderators Share Posted February 4, 2015 JakeKenmode,You need yet more child GUIs - and you need to manage which appears when the tab is changed: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Main GUI $hGUI = GUICreate("Test", 500, 500) GUISetState() ; Create top child GUI to hold tabs $hTab_Win0 = GUICreate("", 400, 200, 50, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $cTab_0 = GUICtrlCreateTab(10, 10, 380, 180) $cTab_00 = GUICtrlCreateTabItem("00") $cTab_01 = GUICtrlCreateTabItem("01") GUICtrlCreateTabItem("") GUISetState() ; Create bottom child GUI to hold tabs $hTab_Win1 = GUICreate("", 400, 200, 50, 250, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $cTab_1 = GUICtrlCreateTab(10, 10, 380, 180) $cTab_10 = GUICtrlCreateTabItem("10") GUICtrlCreateButton("10", 160, 90, 80, 30) $cTab_11 = GUICtrlCreateTabItem("11") GUICtrlCreateButton("11", 160, 90, 80, 30) GUICtrlCreateTabItem("") GUISetState() ; Create child GUI to hold internal tab for first tab of top child $hTabWin0_Child0 = GUICreate("", 330, 120, 40, 50, $WS_POPUP, $WS_EX_MDICHILD, $hTab_Win0) GUISetBkColor(0xFF0000) $cTab_0_ChildTab_0 = GUICtrlCreateTab(10, 10, 310, 100) $cTab_0000 = GUICtrlCreateTabItem("000") GUICtrlCreateButton("0000", 50, 50, 80, 30) $cTab_0001 = GUICtrlCreateTabItem("001") GUICtrlCreateButton("0001", 50, 50, 80, 30) GUICtrlCreateTabItem("") GUISetState() ; Create child GUI to hold internal tab for second tab of top child $hTabWin0_Child1 = GUICreate("", 330, 120, 40, 50, $WS_POPUP, $WS_EX_MDICHILD, $hTab_Win0) GUISetBkColor(0x00FF00) $cTab_0_ChildTab_1 = GUICtrlCreateTab(10, 10, 310, 100) $cTab_0110 = GUICtrlCreateTabItem("000") GUICtrlCreateButton("0110", 50, 50, 80, 30) $cTab_0111 = GUICtrlCreateTabItem("001") GUICtrlCreateButton("0111", 50, 50, 80, 30) GUICtrlCreateTabItem("") GUISetState(@SW_HIDE) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cTab_0 ; Which tab has been selected? Switch GUICtrlRead($cTab_0) Case 0 ; Adjust child GUIs accordingly GUISetState(@SW_HIDE, $hTabWin0_Child1) GUISetState(@SW_SHOW, $hTabWin0_Child0) Case 1 GUISetState(@SW_HIDE, $hTabWin0_Child0) GUISetState(@SW_SHOW, $hTabWin0_Child1) EndSwitch EndSwitch WEndI hope that the code is clear enough - but you will have to wait until tomorrow if you want a more detailed explanation as it has been a tiring day. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted February 5, 2015 Author Share Posted February 5, 2015 Thanks agian Melba!, The hiding and showing of the GUI's was the part I was missing. Uhg! This might get messy though! I will have 2 Main tabs and on each of those main tabs there will be various other tabs. For starters it will be like this. Tab1 - Tab a Tab b Tab2 - Tab a Tab b Tab c Tab d Tab e That's a good amount of hide/show management haha! I also need to have all of this resize itself correctly! Below is where I am currently. The second list view will turn into the Tab control and each tab will house the listview. My question now is on the GUICtlrsetResize() Function. I am assuming this only works for controls. If I have GUI's on each tab, when I resize, I'm thinking my controls will resize as expected, but I will have to do something else to "dock" and resize all of my GUI's. I'll experiment a little and come back in a bit! expandcollapse popup#Region Includes #include "winapi.au3" #include "GuiToolbar.au3" #include "GuiImageList.au3" #include "GuiConstantsEx.au3" #include <WindowsConstants.au3> #include "GUITab.au3" #EndRegion AutoItSetOption('MouseCoordMode', 2) #Region URL ref ;This is a site I used to trial and error finding the Id's for the Icons I wanted. ;http://diymediahome.org/windows-icons-reference-list-with-details-locations-images/ #EndRegion #Region Vars ;Only Tested on Win7 64 machine Local $fIconsLoc1 = "imageres.dll" Local $fIconsLoc2 = "Resources\Icons\Undo.ico" Global $aStrings[12] Local $iNew,$iBrowse,$iEdit,$iDelete,$iSave,$iPrint Global Enum $e_new =0, $e_edit, $e_delete, $e_save, $e_print, $e_undo ; Icon Index from DLL $iNew = 2 ;$iBrowse = 202 $iEdit = 111 $iDelete = 84 $iSave = 23 $iPrint = 46 $DividerOffset = 250 $BkColor = 0xf0f0f0 ;Create Form, Toobar and ImageList $hGui = GUICreate("Test",660, 320, 192, 125, BitOR($WS_OVERLAPPEDWINDOW, $WS_POPUP)) $hToolbar1 = _GUICtrlToolbar_Create($hGui) $imgs = _GUIImageList_Create(32,32,5) ; change first 2 params to Size the icons accordingly. #EndRegion Vars #Region Toolbar ;Populate Image List _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iNew,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iEdit,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iDelete,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iSave,True) _GUIImageList_AddIcon($imgs, $fIconsLoc1,$iPrint,True) _GUIImageList_AddIcon($imgs, $fIconsLoc2,0,True) ;Add Text to Buttons in Toolbar $aStrings[$e_new] = _GUICtrlToolbar_AddString($hToolbar1, "&New") $aStrings[$e_edit] = _GUICtrlToolbar_AddString($hToolbar1, "&Edit") $aStrings[$e_delete] = _GUICtrlToolbar_AddString($hToolbar1, "&Delete") $aStrings[$e_save] = _GUICtrlToolbar_AddString($hToolbar1, "&Save") $aStrings[$e_print] = _GUICtrlToolbar_AddString($hToolbar1, "&Print") $aStrings[$e_undo] = _GUICtrlToolbar_AddString($hToolbar1, "&Undo") ;Set Imagelist of Toolbar to my ImageList $t = _GUICtrlToolbar_SetImageList($hToolbar1, $imgs) ;Add buttons to toolbar _GUICtrlToolbar_AddButton($hToolbar1, 1000, $e_new,$aStrings[$e_new]) _GUICtrlToolbar_AddButton($hToolbar1, 1001, $e_edit,$aStrings[$e_edit]) _GUICtrlToolbar_AddButton($hToolbar1, 1002, $e_delete,$aStrings[$e_delete]) _GUICtrlToolbar_AddButton($hToolbar1, 1003, $e_save,$aStrings[$e_save]) _GUICtrlToolbar_AddButton($hToolbar1, 1004, $e_print,$aStrings[$e_print]) _GUICtrlToolbar_AddButton($hToolbar1, 1005, $e_undo,$aStrings[$e_undo]) #EndRegion Toolbar GUISetState() #Region Create Tabs $hTab = GUICtrlCreateTab(-1,60,665,265) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH,$GUI_DOCKRIGHT)) ; Create Tab Items GUICtrlCreateTabItem("Tab1") GUICtrlCreateLabel("",-1,82,665,265) GUICtrlSetBkColor(-1, $BkColor) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH,$GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DISABLE) $ListView1 = GUICtrlCreateListView("col1|col2|col3", 5, 85, $DividerOffset - 5, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH)) $ListView2 = GUICtrlCreateListView("col1|col2|col3", $DividerOffset + 5, 85, 660 - $DividerOffset - 10, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKRIGHT)) $Divider1 = GUICtrlCreateLabel('', $DividerOffset, 85, 5, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUICtrlSetCursor(-1, 13) GUICtrlCreateTabItem("Tab2") GUICtrlCreateLabel("",0,82,665,265) GUICtrlSetBkColor(-1, $BkColor) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH,$GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DISABLE) $ListView3 = GUICtrlCreateListView("col1|col2|col3", 5, 85, $DividerOffset - 5, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKWIDTH)) $ListView4 = GUICtrlCreateListView("col1|col2|col3", $DividerOffset + 5, 85, 660 - $DividerOffset - 10, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM, $GUI_DOCKRIGHT)) $Divider2 = GUICtrlCreateLabel('', $DividerOffset, 85, 5, 232) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUICtrlSetCursor(-1, 13) ; Finished Creating Tabs GUICtrlCreateTabItem("") GUISetState() #EndRegion End tabs #Region GUI Message Loop While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE Exit Case $Divider1 Resize() Case $Divider2 Resize() EndSwitch WEnd #EndRegion GUI Message Loop #Region Functions Func Resize() GUISetCursor(13, 1, $hGui) $siz = WinGetClientSize($hGui) Do $arr = GUIGetCursorInfo($hGui) $pos = MouseGetPos(0) Select Case $pos < 100 $pos = 100 Case $pos > $siz[0] - 100 $pos = $siz[0] - 100 EndSelect If $pos <> $DividerOffset Then $DividerOffset = $pos GUICtrlSetPos($ListView1, -1, -1, $DividerOffset - 5) GUICtrlSetPos($ListView2, $DividerOffset + 5, -1, $siz[0] - $DividerOffset - 10) GUICtrlSetPos($ListView3, -1, -1, $DividerOffset - 5) GUICtrlSetPos($ListView4, $DividerOffset + 5, -1, $siz[0] - $DividerOffset - 10) EndIf Until Not $arr[2] GUICtrlSetPos($Divider1, $DividerOffset) GUICtrlSetPos($Divider2, $DividerOffset) GUISetCursor(-1, 0, $hGui) EndFunc #EndRegion functions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2015 Moderators Share Posted February 5, 2015 JakeKenmode,When I need to resize non-native controls (which is what child GUIs essentially are) I often create a native label which can automatically resize and then resize the control to match the label once the resizing is finished - this thread shows an example with ListViews. M23 MikahS 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JakeJohnson74 Posted February 5, 2015 Author Share Posted February 5, 2015 (edited) Ah very cool - Nice I will get that up and running! Labels are AutoIT's secret little weapon, haha I see labels being used often in little tricky spots. Edit* Gotcha - WinMove() to move non-standard controls. Edited February 5, 2015 by JakeKenmode Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now