Sign in to follow this  
Followers 0
BryonR

If Radio checked then label & input

5 posts in this topic

I have the following code

If BitAND(GUICtrlRead($ittab_radio_difcomp), $GUI_CHECKED) = $GUI_CHECKED Then 
$ittab_lbl_computername = GUICtrlCreateLabel("Computer Name:" ,100,208,193,17)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
$ittab_input_computername = GUICtrlCreateInput("", 100,300,193,17)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
EndIf

However when I check on the radio its not displaying the input or label.

Thanks!

Bryon

Share this post


Link to post
Share on other sites



It's working for me so make sure that you are not re-using a variable name and that your control positioning is correct.

I would also suggest that it's a better idea to create the controls when you create the GUI and then set their stae to hidden. All you have to do then is change the states when the radio is clicked. Or at the very least declare the label and input control names at the top of the script

Global $ittab_lbl_computername, $ittab_input_computername

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I'm still having the same problem, here is the code.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 112, 88, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 120, 112, 113, 17)
If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then
$Label1 = GUICtrlCreateLabel("Label1", 336, 120, 36, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
EndIf

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

BryonR,

You need to put your If BitAND(GUICtrlRead($Radio2) section inside the While...WEnd loop. At the moment it is only being looked at as the code creates the GUI - and so obviously the radio is not set. Look at this code - I have included GEOSoft's advice to create the label at the beginning and then use "show/hide" to react to the radio:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 112, 88, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 120, 112, 113, 17)
$Label1 = GUICtrlCreateLabel("Label1", 336, 120, 36, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
; This is the part you needed
    If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($Label1, $GUI_SHOW)
    Else
        GUICtrlSetState($Label1, $GUI_HIDE)
    EndIf
WEnd

You will see that the label flickers when it is visble and you move the mouse - that is because every time there is a message from the GUI, the loop finds that the radio is checked and the GUISetState is actioned. A good way to cure this is to use a flag to show the state of the label and then only action the GUISetState when the radio and state do not match:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 112, 88, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 120, 112, 113, 17)
$Label1 = GUICtrlCreateLabel("Label1", 336, 120, 36, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Radio_Checked = False

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
; This is the part you needed
    If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) <> $Radio_Checked Then
        $Radio_Checked = Not $Radio_Checked
        If $Radio_Checked = True Then 
            GUICtrlSetState($Label1, $GUI_SHOW)
        Else
            GUICtrlSetState($Label1, $GUI_HIDE)
        EndIf
    EndIf
WEnd

I hope this is clear - ask if you do not understand.

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

Better yet.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 112, 88, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 120, 112, 113, 17)
$Label1 = GUICtrlCreateLabel("Label1", 336, 120, 36, 17)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetFont(-1, 12, 400, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$Radio_Checked = False

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio2
            If BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) Then
                If GUICtrlGetState($Label1) > $GUI_SHOW Then GUICtrlSetState($Label1, $GUI_SHOW)
            Else
                If GUICtrlGetState($Label1) < $GUI_HIDE Then GUICtrlSetState($Label1, $GUI_HIDE)
            EndIf
        Case Else
    EndSwitch
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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
Sign in to follow this  
Followers 0