Realm Posted May 5, 2010 Share Posted May 5, 2010 (edited) How do I activate or hide particular tabs with radio buttons? What I'd like to do is if Radio1 is pressed than only tabsheet1 will show if Radio2 then only tabsheet 2 if Radio3 then both tabsheet 1 and tabsheet 2 if Radio4 then tabsheet 3 #include <GUIConstantsEx.au3> $gui = GUICreate("test",450, 300) $Radio1 = GUICtrlCreateRadio("Radio1", 32, 250, 60, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 32, 274, 57, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 112, 250, 113, 17) $Radio4 = GUICtrlCreateRadio("Radio4", 112, 274, 97, 17) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $TabSheet2 = GUICtrlCreateTabItem("Tabsheet 2") $TabSheet3 = GUICtrlCreateTabItem("Tabsheet 3") GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Thanks in advance Edited May 5, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 5, 2010 Moderators Share Posted May 5, 2010 (edited) Realm,I do not believe you can disable (or hide) tabs. But you can prevent them from being selected like this: expandcollapse popup#include <GUIConstantsEx.au3> ; Array to hold tab allowed state Global $afTabSheets[3] = [True, False, False] $gui = GUICreate("test",450, 300) GUIStartGroup() $Radio1 = GUICtrlCreateRadio("Radio1", 32, 250, 100, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio("Radio2", 32, 274, 100, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 152, 250, 100, 17) $Radio4 = GUICtrlCreateRadio("Radio4", 152, 274, 100, 17) GUIStartGroup() $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() $iCurrRadio = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Tab1 ; If tab clicked, check if tab valid $iTabSel = GUICtrlRead($Tab1) ; Ensure valid tab displayed If $afTabSheets[$iTabSel] = False Then _Sel_Tab() EndIf EndSwitch ; Check if radios altered For $i = 0 To 4 If GUICtrlRead($Radio1 + $i) = 1 Then ExitLoop Next If $i <> $iCurrRadio Then ; Change reference value $iCurrRadio = $i ; Set tab state array as required Switch $i Case 0 ; Radio 1 $afTabSheets[0] = True GUICtrlSetData($TabSheet1, "Tabsheet 1") $afTabSheets[1] = False GUICtrlSetData($TabSheet2, " ") $afTabSheets[2] = False GUICtrlSetData($TabSheet3, " ") Case 1 ; Radio 2 $afTabSheets[0] = False GUICtrlSetData($TabSheet1, " ") $afTabSheets[1] = True GUICtrlSetData($TabSheet2, "Tabsheet 2") $afTabSheets[2] = False GUICtrlSetData($TabSheet3, " ") Case 2 ; Radio 3 $afTabSheets[0] = True GUICtrlSetData($TabSheet1, "Tabsheet 1") $afTabSheets[1] = True GUICtrlSetData($TabSheet2, "Tabsheet 2") $afTabSheets[2] = False GUICtrlSetData($TabSheet3, " ") Case 3 ; Radio 4 $afTabSheets[0] = False GUICtrlSetData($TabSheet1, " ") $afTabSheets[1] = False GUICtrlSetData($TabSheet2, " ") $afTabSheets[2] = True GUICtrlSetData($TabSheet3, "Tabsheet 3") EndSwitch ; Ensure valid tab displayed _Sel_Tab() EndIf WEnd Func _Sel_Tab() ; Show first valid tab For $i = 0 To 3 If $afTabSheets[$i] = True Then GUICtrlSetState($TabSheet1 + $i, $GUI_SHOW) Return EndIf Next EndFuncI hope that helps. M23Edit: Found Funkey's OwnTab UDF which might help as apparently it can disable the tabs it creates. Edited May 5, 2010 by Melba23 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...
Realm Posted May 5, 2010 Author Share Posted May 5, 2010 Edit: Found Funkey's OwnTab UDF which might help as apparently it can disable the tabs it creates. Just Fabulous, a perfect solution, thanks for pointing it out, I also left a comment on his thread as well! My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 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