luis713 Posted August 30, 2018 Posted August 30, 2018 (edited) I took part of the code used to create a tab inside another tab, I tried to understand how it works, I know first we have to create the main gui which will contain the main tab and create secondary tabs and guis. I have created successful 2 main tabs with their secondary tab but I need to create more, could you help me? and I will glad to know gui child's syntax. expandcollapse popup#include <ColorConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global $fInterrupt = 0 ;Interrupts a function Global $hLeftClick = False ;To interrupt a function Global $Label, $hDll, $running = False Opt("MustDeclareVars", 1) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) Global $hGui,$ok_button,$cancel_button, $cLabel, $Label2, $Label3 ;================================================================================================================================================================================== ; This window has 2 ok/cancel-buttons Global $GuiText = "Gui's name" Global $hGui = GUICreate($GuiText) WinSetState($hGUI, "", @SW_MAXIMIZE) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") ;================================================================================================================================================================================== ;Shooting ; Create the first child window that is implemented into the main GUI Global $SoundChild = GUICreate("",@DesktopWidth,@DesktopHeight * .9,0,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$hGui) Global $child_tab = GUICtrlCreateTab(0,0,@DesktopWidth,@DesktopHeight) GUICtrlSetOnEvent(-1, "SpecialEvents") ;Game tab Global $SubTabSound = GUICtrlCreateTabItem("SubTab 1") Global $ok_button = GUICtrlCreateButton("OK",40,220,70,20) GUICtrlSetOnEvent(-1, "SpecialEvents") Global $cancel_button = GUICtrlCreateButton("Cancel",150,220,70,20) GUICtrlSetOnEvent(-1, "SpecialEvents") ;Options tab Global $SubTabSound2 = GUICtrlCreateTabItem("SubTab 2") GUICtrlCreateTabItem("") GUISetState() ;================================================================================================================================================================================== ; Create the second child window that is implemented into the main GUI Global $MainTabChild = GUICreate("",@DesktopWidth,@DesktopHeight,0,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$hGUI) ;create controls for this tab ; Switch back the main GUI and create the tabs GUISwitch($hGui) Global $main_tab = GUICtrlCreateTab(0,10,@DesktopWidth,@DesktopHeight * .9) GUICtrlSetOnEvent(-1, "SpecialEvents") Global $SoundChildtab = GUICtrlCreateTabItem("Sound") Global $VideoChildtab = GUICtrlCreateTabItem("Video") Global $PictureTab = GUICtrlCreateTabItem("Picture") GUICtrlCreateTabItem("") GUISetState() ;================================================================================================================================================================================== ;Drag and Drop ; Create the first child window that is implemented into the main GUI Global $VideoChild = GUICreate("",@DesktopWidth,@DesktopHeight * .9,0,0,BitOr($WS_CHILD,$WS_TABSTOP),-1,$MainTabChild) Global $DragAndDropTabs = GUICtrlCreateTab(0,0,@DesktopWidth, @DesktopHeight) GUICtrlSetOnEvent(-1, "SpecialEvents") ;video tab Global $VideoTab = GUICtrlCreateTabItem("SubTab 1") Global $VideoButton = GUICtrlCreateButton("Button 1", @DesktopWidth * 0.43, @DesktopHeight * 0.86, @DesktopWidth * 0.07, @DesktopHeight * 0.025) GUICtrlSetOnEvent(-1, "SpecialEvents") Global $VideoButton2 = GUICtrlCreateButton("Button 2", @DesktopWidth * 0.5, @DesktopHeight * 0.86, @DesktopWidth * 0.07, @DesktopHeight * 0.025) GUICtrlSetOnEvent(-1, "SpecialEvents") GUICtrlSetState(-1, $GUI_DISABLE) Global $Check = GUICtrlCreateButton("Check", @DesktopWidth * 0.57, @DesktopHeight * 0.86, @DesktopWidth * 0.07, @DesktopHeight * 0.025) GUICtrlSetOnEvent(-1, "SpecialEvents") GUICtrlSetState(-1, $GUI_DISABLE) Global $Combo = GUICtrlCreateCombo("", @DesktopWidth * 0.2, @DesktopHeight * 0.86, @DesktopWidth * 0.2, @DesktopHeight * 0.02, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "SpecialEvents") ;Options tab Global $VideoOptionsTab = GUICtrlCreateTabItem("SubTab 2") ;Add tab Global $VideoTab2 = GUICtrlCreateTabItem("SubTab 3") GUICtrlCreateLabel("Choose or type the topic", @DesktopWidth * 0.01, @DesktopHeight * 0.04, @DesktopWidth * 0.15, @DesktopHeight * 0.025) GUICtrlSetFont(-1, 12) Global $VideoTopic = GUICtrlCreateCombo("New topic", @DesktopWidth * 0.16, @DesktopHeight * 0.04, @DesktopWidth * 0.25, @DesktopHeight * 0.025, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "SpecialEvents") Global $VideoInput = GUICtrlCreateInput("", @DesktopWidth * 0.41, @DesktopHeight * 0.04, @DesktopWidth * 0.5, @DesktopHeight * 0.025) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Choose or type the category", @DesktopWidth * 0.01, @DesktopHeight * 0.07, @DesktopWidth * 0.15, @DesktopHeight * 0.025) GUICtrlSetFont(-1, 12) Global $VideoCombo= GUICtrlCreateCombo("New category", @DesktopWidth * 0.16, @DesktopHeight * 0.07, @DesktopWidth * 0.25, @DesktopHeight * 0.025, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "SpecialEvents") Global $CategoryInput = GUICtrlCreateInput("", @DesktopWidth * 0.41, @DesktopHeight * 0.07, @DesktopWidth * 0.5, @DesktopHeight * 0.025) GUICtrlSetState(-1, $GUI_DISABLE) Global $Add = GUICtrlCreateButton("Add", @DesktopWidth * 0.43, @DesktopHeight * 0.83, @DesktopWidth * 0.07, @DesktopHeight * 0.025) GUICtrlSetOnEvent(-1, "SpecialEvents") GUICtrlCreateTabItem("") GUISetState() ; Intercept Windows command messages with out own handler GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUIRegisterMsg($WM_LBUTTONUP, "_WM_LBUTTONUP") GUIRegisterMsg($WM_SYSCOMMAND,"WM_SYSCOMMAND") ;to exit from a running function ;================================================================================================================================================================================== ; Create the first child window that is implemented into the main GUI ; Create the first child window that is implemented into the main GUI Global $NewGui = GUICreate("",@DesktopWidth,@DesktopHeight * .9,0,35,BitOr($WS_CHILD,$WS_TABSTOP),$MainTabChild,$MainTabChild) GUISetState() ;================================================================================================================================================================================== While 1 WEnd Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit Case @GUI_CtrlId = $main_tab Switch GUICtrlRead($main_tab) ;Shooting tab Case 0 GUISetState(@SW_HIDE,$MainTabChild) GUISetState(@SW_HIDE,$NewGui) GUISetState(@SW_SHOW,$SoundChild) GUISetState(@SW_HIDE, $VideoChild) ;Drag and drop Case 1 GUISetState(@SW_HIDE,$SoundChild) GUISetState(@SW_SHOW, $VideoChild) GUISetState(@SW_SHOW,$MainTabChild) ;Lyrics creator Case 2 GUISetState(@SW_HIDE,$SoundChild) GUISetState(@SW_HIDE,$MainTabChild) GUISetState(@SW_HIDE, $VideoChild) GUISetState(@SW_SHOW,$NewGui) EndSwitch EndSelect EndFunc Edited August 30, 2018 by luis713
Moderators Melba23 Posted August 30, 2018 Moderators Posted August 30, 2018 (edited) Luis713, Does this example with coloured child GUIs make it any clearer? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Create main GUI $hGUI = GUICreate("Main", 1000, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Events") ; Create tab in main GUI $cMain_Tab = GUICtrlCreateTab(10, 10, 980, 400) GUICtrlSetOnEvent($cMain_Tab, "_Events") $cSound_Tab = GUICtrlCreateTabItem("Sound") $cVideo_Tab = GUICtrlCreateTabItem("Video") $cPicture_Tab = GUICtrlCreateTabItem("Picture") GUICtrlCreateTabItem("") ; Hide main GUI GUISetState(@SW_HIDE, $hGUI) $aPos = WinGetPos($hGUI) ConsoleWrite($aPos[0] & " - " & $aPos[1] & @CRLF) ; Create child GUIs which will appear on tabs $hChild_Sound = GUICreate("", 960, 350, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFCCCC, $hChild_Sound) ; Using colours just for example GUISetState(@SW_HIDE, $hChild_Sound) $hChild_Video = GUICreate("", 960, 350, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xCCFFCC, $hChild_Video) GUISetState(@SW_HIDE, $hChild_Video) $hChild_Picture = GUICreate("", 960, 350, 20, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xCCCCFF, $hChild_Picture) GUISetState(@SW_HIDE, $hChild_Picture) ; Now add tabs to the child GUIs GUISwitch($hChild_Sound) $cSound_Sub_Tab = GUICtrlCreateTab(10, 10, 940, 320) $cSound_Sub_Tab_1 = GUICtrlCreateTabItem("Sound_Sub_1") $cSound_Sub_Tab_2 = GUICtrlCreateTabItem("Sound_Sub_2") GUICtrlCreateTabItem("") GUISwitch($hChild_Video) $cVideo_Sub_Tab = GUICtrlCreateTab(10, 10, 940, 320) $cVideo_Sub_Tab_1 = GUICtrlCreateTabItem("Video_Sub_1") $cVideo_Sub_Tab_2 = GUICtrlCreateTabItem("Video_Sub_2") $cVideo_Sub_Tab_3 = GUICtrlCreateTabItem("Video_Sub_3") GUICtrlCreateTabItem("") GUISwitch($hGUI) ; Show Main and initial child GUIs GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hChild_Sound) While 1 Sleep(10) WEnd Func _Events() ConsoleWrite(@GUI_CtrlId & @CRLF) Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $cMain_Tab ; Hide/show child GUIs as required Switch GUICtrlRead($cMain_Tab) Case 0 GUISetState(@SW_SHOW, $hChild_Sound) GUISetState(@SW_HIDE, $hChild_Video) GUISetState(@SW_HIDE, $hChild_Picture) Case 1 GUISetState(@SW_HIDE, $hChild_Sound) GUISetState(@SW_SHOW, $hChild_Video) GUISetState(@SW_HIDE, $hChild_Picture) Case 2 GUISetState(@SW_HIDE, $hChild_Sound) GUISetState(@SW_HIDE, $hChild_Video) GUISetState(@SW_SHOW, $hChild_Picture) EndSwitch EndSwitch EndFunc Please ask if you have any questions. M23 Edited August 30, 2018 by Melba23 Typo 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
luis713 Posted August 30, 2018 Author Posted August 30, 2018 Hi Melba23, I havent tested the code yet but I could understand better the code with your example, I'll give it a try and let you know the results when I run it. Thank you so much
luis713 Posted August 31, 2018 Author Posted August 31, 2018 Hi Melba that is what I was looking for and much easier to read your code. Thanks a lot
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