Jump to content

[Solved] GUI Radio buttons + Iniwrite Function need help


Recommended Posts

Here is my code to begin with

$Normal = GUICtrlCreateRadio("Normal", 448, 200, 113, 17)
$Nightmare = GUICtrlCreateRadio("Nightmare", 448, 224, 113, 17)
$Hell = GUICtrlCreateRadio("Hel", 448, 248, 113, 17)


and 


Iniwrite("Configuration.ini", "Personal Information", "Difficuluty", Im stuck here....")

Now my question.

Heres what my GuI looks like Posted Image

Now i want my script to write what the user chooses

So if he clicks Nightmare, i want it to

Iniwrite("Configuration.ini", "Personal Information", "Difficulty", $Nightmare)

How can i do about doing this.

------------------------------------------------

I solved by adding this to INIWRITE

$Normal = GUICtrlCreateRadio("Normal", 448, 200, 113, 17)
$Nightmare = GUICtrlCreateRadio("Nightmare", 448, 224, 113, 17)
$Hell = GUICtrlCreateRadio("Hel", 448, 248, 113, 17)


and 


Iniwrite("Configuration.ini", "Personal Information", "Difficuluty", $Normal Or $Nightmare or $Hell")

Hope im helpful!

Edited by ecstatic
Link to comment
Share on other sites

How are you getting messages from your GUI? The following will poll the GUI ...

While 1
$msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Normal And BitAND(GUICtrlRead($Normal), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Normal radio and it is Checked.')
            Case $msg = $Nightmare And BitAND(GUICtrlRead($Nightmare), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Nightmare radio and it is Checked.')
                                                Case $msg = $Hell And BitAND(GUICtrlRead($Hell), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Hell radio and it is Checked.')

        EndSelect
    WEnd

Replace the msgbox with your INIWrite...

This is all from help file so I'm not sure if it will work, but hopefully help you out at least a little...

Link to comment
Share on other sites

How are you getting messages from your GUI? The following will poll the GUI ...

While 1
$msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $Normal And BitAND(GUICtrlRead($Normal), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Normal radio and it is Checked.')
            Case $msg = $Nightmare And BitAND(GUICtrlRead($Nightmare), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Nightmare radio and it is Checked.')
                                                Case $msg = $Hell And BitAND(GUICtrlRead($Hell), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'You clicked the Hell radio and it is Checked.')

        EndSelect
    WEnd

Replace the msgbox with your INIWrite...

This is all from help file so I'm not sure if it will work, but hopefully help you out at least a little...

:S Didnt understand most of that haha but ill try it out i guess?
Link to comment
Share on other sites

:S Didnt understand most of that haha but ill try it out i guess?

Read the part of the help file that deals with introduction to GUI concepts...or all introductions for that matter. Then read about how to get messages from GUI. There are different ways to get messages from the GUI. A message is when something happens like click a radio button, click a regular button, close the GUI... stuff like that. That example I posted was straight out of the help file with a few changes to use your variables.

Edit: Yea there are other ways to deal with this depending on what you need. Now that I see how you are using it there's an easier way to get this done.

Edited by MrMitchell
Link to comment
Share on other sites

You might want to look into GUICtrlCreateGroup as well.

It will limit the user to selecting only one of the radios at a time.

It also parks a title above and a box around the group.

try the little demo below...

Global $Diff, $DiffText[3] = ["Normal","Nightmare","Hell"], $DiffButton[3]
GUICreate("test",600,600)
GUICtrlCreateGroup("DIFFICULTY", 435, 182, 90, 90)
For $x = 0 to 2
    $DiffButton[$x] = GUICtrlCreateRadio($DiffText[$x], 448, 200 + $x * 24)
Next
GUICtrlCreateGroup("", -1,-1, 0, 0)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $DiffButton[0], $DiffButton[1], $DiffButton[2]
            $Diff = $msg - $DiffButton[0] 
            MsgBox(1, "", "Current level: " & $Diff & " - " & $DiffText[$Diff])
        Case -3;$GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by Spiff59
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...