Sign in to follow this  
Followers 0
DigDeep

Select Radio Button and enter text in GUICtrlCreateInput

5 posts in this topic

#1 ·  Posted (edited)

Hi,

I am little stuck here. What I want is if I am selecting the Radio Button, then the text in the Radio button should appear in the TextBox below which is for GUICtrlCreateInput.

I might be silly for the solution might be very simple one but I am not able to figure it out.

Can someone please help.

 

#Region ###
$Form1 = GUICreate("Example", 355, 253, -1, -1, $GUI_SS_DEFAULT_GUI)
$Input = GUICtrlCreateInput("", 96, 168, 161, 24)
$Test = GUICtrlCreateRadio("    Test", 32, 24, 113, 17)
$Submit = GUICtrlCreateButton("Submit", 144, 208, 75, 25)
GUICtrlSetState(0, $GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ###



While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Submit
            Select
                Case GUICtrlRead($Test) = 1
; It should show the Text "Test" in the box.
;And if I click on Submit button then it will carry on with rest of the code.
            EndSelect
    EndSwitch
WEnd

 

Edited by sunshinesmile84

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Do you mean like this?

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

$Form1 = GUICreate("Example", 355, 253, -1, -1, $GUI_SS_DEFAULT_GUI)
$Input = GUICtrlCreateInput("", 96, 168, 161, 24)
$Test = GUICtrlCreateRadio("    Test", 32, 24, 113, 17)
$Submit = GUICtrlCreateButton("Submit", 144, 208, 75, 25)
GUICtrlSetState(0, $GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ###



While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Submit
            Select
                Case GUICtrlRead($Test) = 1
                    GUICtrlSetData($Input, "Test")
            EndSelect
    EndSwitch
WEnd

Or are you saying that, whatever text you put into the RadioButton control, you want it to automatically insert into the Input field?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@ JLogan3o13

This is somewhat close by. But the text appears only when I click on Submit Button.

I would like, if I just select the Radio button, the Text Box should show the Text. Shouldn't be waiting for me to click on Submit button.

 

to your below statement: whatever text you put into the RadioButton control, you want it to automatically insert into the Input field?

Now, I have more Rsdio buttons too. So, the Text should only appear when I select the radio buttons.

Edited by sunshinesmile84

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So something more like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Example", 355, 253, -1, -1, $GUI_SS_DEFAULT_GUI)
$Input = GUICtrlCreateInput("", 96, 168, 161, 24)
$Test = GUICtrlCreateRadio("    Test", 32, 24, 113, 17)
    GUICtrlSetOnEvent(-1, "MyControl")
$Submit = GUICtrlCreateButton("Submit", 144, 208, 75, 25)
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
WEnd

Func MyControl()
    GUICtrlSetData($Input, "Test")
EndFunc

And before you respond with "Now my GUI doesn't close with the X!", you are correct I left that piece out. This is to get you started; look in the help file under OnEvent Mode to get a clearer understanding of how to structure your GUI using this feature.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for getting this done. I was able to get the GUI Closed. :)

But I think something got messed up.

1. After making the above additions, everything is working good with the new options too, except nothing runs when selecting the Submit button.. And I think I should have provided other radio buttons earlier. I had provided only 1 button thinking there might be one part for all of them.

2. I am able to add the functions for Step 1 button to show Step 1 Text and so on.... but do I have to create different functions for each Radio buttons? I am asking here coz I have 10 Radio buttons in my actual code.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Dim $Close1

$Form1 = GUICreate("Example", 356, 254, -1, -1, $GUI_SS_DEFAULT_GUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton")
$Step_1 = GUICtrlCreateRadio("  Step 1", 32, 24, 169, 25)
    GUICtrlSetOnEvent(1, "MyControl1")
$Step_2 = GUICtrlCreateRadio("  Step 2", 32, 80, 177, 25)
    GUICtrlSetOnEvent(1, "MyControl2")
$Step_3 = GUICtrlCreateRadio("  Step 3", 32, 128, 201, 25)
    GUICtrlSetOnEvent(1, "MyControl3")
$Input = GUICtrlCreateInput("", 96, 168, 161, 24)
$Submit = GUICtrlCreateButton("Submit", 144, 208, 75, 25)
GUISetState(@SW_SHOW)


While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE

        Case $Submit
            Select
                Case GUICtrlRead($Step_1) = 1
                    ; Hide the main GUI to centre the message box on screen
                    GUISetState(@SW_HIDE, $Form1)

                MsgBox(0, "", "Step 1 running")

                    GUISetState(@SW_SHOW, $Form1)
            EndSelect
        EndSwitch
        Sleep(100)
WEnd

Func MyControl1()
    GUICtrlSetData($Input, "Step 1")
EndFunc

Func MyControl2()
    GUICtrlSetData($Input, "Step 2")
EndFunc

Func MyControl3()
    GUICtrlSetData($Input, "Step 3")
EndFunc

Func CLOSEButton()
Exit
EndFunc   ;==>CLOSEButton

 

Edited by sunshinesmile84

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