realcapone

Unchecking Radio/Check Buttons when selecting a tab

4 posts in this topic

Hi everyone. I just need a little help on how to set the state for the radio buttons or a checkbox to "Unchecked" whenever I select a different tab in the form. I run the functions from a single "Run" button as you can see from the codes below. Need your help please. Thanks.

GUICtrlSetState ( controlID, state ) ; I understand this but I'm not sure how to trigger it when a certain tab is selected

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Run
            If GUICtrlRead($JRT) = 1 Then ;Radio button in the Main Tab
                _JRT()
            ElseIf GUICtrlRead($CCleaner) = 1 Then ;Radio button in the Main Tab
                _Ccleaner()
            ElseIf GUICtrlRead($Msconfig) = 1 Then ;Checbox in the second tab
                _Msconfig()
            ElseIf GUICtrlRead($TaskSched) = 1 Then ;Checbox in the second tab
                _TaskScheduler()
            ElseIf GUICtrlRead($RestorePoint) = 1 Then ;Checbox in the second tab
                _CreateRestorePoint()
            EndIf

    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites



realcapone,

A couple of suggestions - which are a bit "belt and braces" as either should solve the problem:

- 1. Clear the controls when the tab control itself is actioned.

- 2. Check which tab is active and only check the relevant controls when you action the button.

Here is an example:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cTab = GUICtrlCreateTab(10, 10, 400, 200)

$cTab_0 = GUICtrlCreateTabItem("Tab 0")

$cCheck_0 = GUICtrlCreateCheckbox("Check 0", 50, 50, 100, 20)

$cTab_1 = GUICtrlCreateTabItem("Tab 1")

$cCheck_1 = GUICtrlCreateCheckbox("Check 1", 100, 100, 100, 20)

GUICtrlCreateTabItem("")

$cRun = GUICtrlCreateButton("Run", 10, 450, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cTab

            ; Clear all chekboxes

            _Clear_All()
        Case $cRun

            ; Which tab is selected?
            $iTabIndex = GUICtrlRead($cTab)
            ; Just check the controls on that tab
            Switch $iTabIndex

                Case 0
                    If GUICtrlRead($cCheck_0) = $GUI_CHECKED Then
                        ; Do something
                    EndIf

                Case 1
                    If GUICtrlRead($cCheck_1) = $GUI_CHECKED Then
                        ; Do something else
                    EndIf

            EndSwitch

    EndSwitch

WEnd



Func _Clear_All()
    ; Clear all controls 
    GUICtrlSetState($cCheck_0, $GUI_UNCHECKED)
    GUICtrlSetState($cCheck_1, $GUI_UNCHECKED)
EndFunc

Please ask if you have any questions.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi M23, ClearAll works perfect and I have also tried the second option by copy/pasting your code and it works great. I have yet to try it with my own code but I think it should work fine. I'll check back here once I'm at home to test it and post some questions if ever I have one. Thanks a lot. 

Share this post


Link to post
Share on other sites

realcapone,

Glad I could help and do not hesitate to come back if you do find a problem.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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