Jump to content

Set radio button as selected by default


Go to solution Solved by saudumm,

Recommended Posts

Hey everyone.

looking for some quick answer to this--

I'm using couple of radio buttons created via GUICtrlCreateRadio function.

My intent is to have one of those selected by default upon program launch, can this be achieved & if yes, how.

thanks in advance..

Link to comment
Share on other sites

Thanks Saudumm.

this works fine however I'm importing the radio button selection as a variable in a .vbs script that executes after my program finishes.

Now, the program has radio button#2 selected as default however when I directly finish the program, it doesn't show me the value of radio button#2 in the .vbs script.

If I select radio button#1 then it works as expected.

Link to comment
Share on other sites

Koda Section--

 
$OS = GUICtrlCreateRadio("Select OS Only", 110, 312, 129, 25)
GUICtrlSetFont(-1, 10, 800, 0, $GUIFont)
$OSPlusApps = GUICtrlCreateRadio("Select OS & Apps", 280, 312, 129, 25)
GUICtrlSetFont(-1, 10, 800, 0, $GUIFont)
GUICtrlSetState($OSPlusApps, $gui_checked)
 
 
 
 
From the function--
 
        $msg  = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
Case $msg = $OS
                $strOS = True
$strOSPlusApps = False
            Case $msg = $OSPlusApps
                $strOSPlusApps = True
   $strOS = False
 
 
 
Vbs filewrite-- 
 
IF $strOS Then FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSOnly" & Chr(34) & ") = " & Chr(34) & $strOS & Chr(34))
    IF $strOS Then FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSWithApps" & Chr(34) & ") = " & Chr(34) & $strOSPlusApps & Chr(34))
    IF $strOSPlusApps Then FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSWithApps" & Chr(34) & ") = " & Chr(34) & $strOSPlusApps & Chr(34))
    IF $strOSPlusApps Then FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSOnly" & Chr(34) & ") = " & Chr(34) & $strOS & Chr(34))
Link to comment
Share on other sites

Please try this Vbs Filewrite. It checks the State of your Radio Buttons, sets the variables and writes to your vbs-file.

Switch $GUI_CHECKED
    Case GUICtrlRead($OS)
        $strOS = True
        $strOSPlusApps = False
    Case GUICtrlRead($OSPlusApps)
        $strOS = False
        $strOSPlusApps = True
EndSwitch

FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSOnly" & Chr(34) & ") = " & Chr(34) & $strOS & Chr(34))
FileWriteLine($OutFile, "TSEnv(" & Chr(34) & "OSWithApps" & Chr(34) & ") = " & Chr(34) & $strOSPlusApps & Chr(34))
Link to comment
Share on other sites

$msg  = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Switch $GUI_CHECKED
                Case GUICtrlRead($OS)
                    $strOS = True
                    $strOSPlusApps = False
                Case GUICtrlRead($OSPlusApps)
                    $strOS = False
                    $strOSPlusApps = True
            EndSwitch
             ;Case $msg = $OS
                         ;$strOS = True
             ;$strOSPlusApps = False
                         ;Case $msg = $OSPlusApps
                         ;$strOSPlusApps = True
             ; $strOS = False
             
              Case $msg = $Finish

It didn't enumerate the results in the .vbs output--

TSEnv("OSOnly") = ""
TSEnv("OSWithApps") = ""
Link to comment
Share on other sites

  • Solution

You have to put my Switch-Statement outside of your Select-Statement just before your Filewriteline. Something like this:

$msg  = GUIGetMsg()
Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Finish
        ;Something else
EndSelect


Switch $GUI_CHECKED
    Case GUICtrlRead($OS)
        $strOS = True
        $strOSPlusApps = False
    Case GUICtrlRead($OSPlusApps)
        $strOS = False
        $strOSPlusApps = True
EndSwitch

Could you please post more of your code or pm it to me, if you don't want it to be made public?

Edited by saudumm
Link to comment
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
 Share

×
×
  • Create New...