tlman12 Posted July 28, 2010 Share Posted July 28, 2010 i'm trying to use the GUICtrlTab UDF but i can't figure out how to add data to the tabs. i know with the built in guictrlcreatetabitem() all i have to do is add the data after that but it dosn't work that way with the UDF or i'm just doing something stupid what my over all goal is, is to take advantage of the $TCS_MULTILINE style in the UDF. i can't seem to find an answer to this anywhere in the autoit help and i did a few searches here that didn't turn up what i wanted either. Thanks for your help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 28, 2010 Moderators Share Posted July 28, 2010 tlman12,Unlike the built-in GUICtrlCreateTab, you have to hide/show the controls yourself when you use the GUICtrlTab UDF. Here is a short example - note how the 3 buttons are created in the same place and we have to determine which should be shown depending on the active tab:expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> ; Create GUI $hGUI = GUICreate("Test", 400, 300) $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296) GUISetState() ; Add tabs _GUICtrlTab_InsertItem($hTab, 0, "Tab 1") _GUICtrlTab_InsertItem($hTab, 1, "Tab 2") _GUICtrlTab_InsertItem($hTab, 2, "Tab 3") ; Add controls and only show those on the active tab $hButton_1 = GUICtrlCreateButton("Test 1", 10, 30, 80, 30) $hButton_2 = GUICtrlCreateButton("Test 2", 10, 30, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) $hButton_3 = GUICtrlCreateButton("Test 3", 10, 30, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) ; This is the current active tab $iLastTab = 0 ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 MsgBox(0, "Button", "You pressed the button on Tab 1") Case $hButton_2 MsgBox(0, "Button", "You pressed the button on Tab 2") Case $hButton_3 MsgBox(0, "Button", "You pressed the button on Tab 3") EndSwitch ; Check which tab is active $iCurrTab = _GUICtrlTab_GetCurFocus($hTab) ; If the tab has changed If $iCurrTab <> $iLastTab Then ; Store the value for future comparisons $iLastTab = $iCurrTab ; Show/Hide controls as required Switch $iCurrTab Case 0 GUICtrlSetState($hButton_1, $GUI_SHOW) GUICtrlSetState($hButton_2, $GUI_HIDE) GUICtrlSetState($hButton_3, $GUI_HIDE) Case 1 GUICtrlSetState($hButton_1, $GUI_HIDE) GUICtrlSetState($hButton_2, $GUI_SHOW) GUICtrlSetState($hButton_3, $GUI_HIDE) Case 2 GUICtrlSetState($hButton_1, $GUI_HIDE) GUICtrlSetState($hButton_2, $GUI_HIDE) GUICtrlSetState($hButton_3, $GUI_SHOW) EndSwitch EndIf WEndPlease ask if anything is unclear. 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...
tlman12 Posted July 28, 2010 Author Share Posted July 28, 2010 tlman12, Unlike the built-in GUICtrlCreateTab, you have to hide/show the controls yourself when you use the GUICtrlTab UDF. Here is a short example - note how the 3 buttons are created in the same place and we have to determine which should be shown depending on the active tab: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> ; Create GUI $hGUI = GUICreate("Test", 400, 300) $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296) GUISetState() ; Add tabs _GUICtrlTab_InsertItem($hTab, 0, "Tab 1") _GUICtrlTab_InsertItem($hTab, 1, "Tab 2") _GUICtrlTab_InsertItem($hTab, 2, "Tab 3") ; Add controls and only show those on the active tab $hButton_1 = GUICtrlCreateButton("Test 1", 10, 30, 80, 30) $hButton_2 = GUICtrlCreateButton("Test 2", 10, 30, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) $hButton_3 = GUICtrlCreateButton("Test 3", 10, 30, 80, 30) GUICtrlSetState(-1, $GUI_HIDE) ; This is the current active tab $iLastTab = 0 ; Loop until user exits While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 MsgBox(0, "Button", "You pressed the button on Tab 1") Case $hButton_2 MsgBox(0, "Button", "You pressed the button on Tab 2") Case $hButton_3 MsgBox(0, "Button", "You pressed the button on Tab 3") EndSwitch ; Check which tab is active $iCurrTab = _GUICtrlTab_GetCurFocus($hTab) ; If the tab has changed If $iCurrTab <> $iLastTab Then ; Store the value for future comparisons $iLastTab = $iCurrTab ; Show/Hide controls as required Switch $iCurrTab Case 0 GUICtrlSetState($hButton_1, $GUI_SHOW) GUICtrlSetState($hButton_2, $GUI_HIDE) GUICtrlSetState($hButton_3, $GUI_HIDE) Case 1 GUICtrlSetState($hButton_1, $GUI_HIDE) GUICtrlSetState($hButton_2, $GUI_SHOW) GUICtrlSetState($hButton_3, $GUI_HIDE) Case 2 GUICtrlSetState($hButton_1, $GUI_HIDE) GUICtrlSetState($hButton_2, $GUI_HIDE) GUICtrlSetState($hButton_3, $GUI_SHOW) EndSwitch EndIf WEnd Please ask if anything is unclear. M23 that seems like a big pain in the but if you have a lot of controls (which i do) theres nothing easier? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 28, 2010 Moderators Share Posted July 28, 2010 tlman12 , theres nothing easier?If you want to use the UDF, you must accept the limitations of the UDF as well. But why do you want to use the UDF anyway? The built-in GUICtrlCreateTab function can use the $TCS_MULTILINE style and AutoIt looks after all the controls for you: #include <GUIConstantsEx.au3> #include <TabConstants.au3> $hGUI = GUICreate("Tab Row Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480, BitOR($GUI_SS_DEFAULT_TAB, $TCS_MULTILINE, $TCS_RIGHTJUSTIFY)) ; Create tabitems For $i = 1 To 15 GUICtrlCreateTabItem($i) GUICtrlCreateButton("Button " & $i, 20, 100, 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Your choice! M23 P.S. And when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
tlman12 Posted July 29, 2010 Author Share Posted July 29, 2010 doh.. i didn't even see that lol thank you for pointing that out 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