Jump to content

Radio + Radio2 = Radio7 (HELP!)


Swift
 Share

Recommended Posts

basically if i have a gui window... and it has to radios on it...

Radio 1

Radio 2

|Next| <----button

next creates a new gui with radio:

Radio 3

Radio 4

|Done| <---- button

and when you press Done...it checks what you pressed...either Radio 1 or Radio 2...

i was thinking:

If $Radio1 = $GUI_CHECKED and $Radio3 = $GUI_CHECKED then Msgbox(0, "", "you choose radio's one and 3")

If $Radio2 = $GUI_CHECKED and $Radio4 = $GUI_CHECKED then msgbox(0, "", "you chose radios 4 and 2")

If $Radio1 = $GUI_CHECKED and $Radio3 = $GUI_CHECKED then msgbox(0, "", "you chose radio 1 and 3")

ETC...how would this become possible....the helpfile hasnt contained any knowledge about this...thanks...

Link to comment
Share on other sites

heh...thats the problem...havnt made a code yet...i figured it would be easier if i knew how to make the end reseult...ill work on one now i guess...

First change to second..

Edited by Swift
Link to comment
Share on other sites

I'd use one gui then. Using the code similar to the help file for guicreate. Then create your radios, but only show two. Then use a guictrlsetstate to change which radio's are showing. Then when pressing done, have it read the radio's via guictrlread.

Link to comment
Share on other sites

Ehh....this isnt working...this is sorta the way i want it...

#include <GUIConstants.au3>
GUICreate("Test", 200, 200)
GUICtrlCreateRadio("Radio1", 10, 20)
GUICtrlCreateRadio("Radio2", 10, 40)
GUICtrlCreateButton("Next", 10, 80)
GUISetState()
While 1
    Select
    Case $GUI_EVENT_CLOSE
        Exit
    Case $next
        GUISetState(@SW_HIDE)
        new()
    EndSelect
WEnd
    
    Func new()
        GUICreate("next", 200, 200)
        GUICtrlCreateRadio("Radio1", 10, 20)
GUICtrlCreateRadio("Radio2", 10, 40)
GUICtrlCreateButton("Results", 10, 80)
GUISetState()
While 1
    WEnd
EndFunc

the window closes after it opens...grr? why?

This sorta works...

#include <GUIConstants.au3>

GUICreate("My GUI"); will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)   ; will display an empty dialog box
GUICtrlCreateRadio("Radio1", 10, 20)
GUICtrlCreateRadio("Radio2", 10, 40)
$next = GUICtrlCreateButton("Next", 10, 80)

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    
    If $msg = $next Then
        newwindow()
EndIf
Wend
    
    Func newwindow()
        GUISetState(@SW_HIDE)
GUICreate("My GUI"); will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)   ; will display an empty dialog box
GUICtrlCreateRadio("Radio3", 10, 20)
GUICtrlCreateRadio("Radio4", 10, 40)
$done = GUICtrlCreateButton("Done", 10, 80)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE then ExitLoop
        
        If $msg = $done Then
            GUISetState(@SW_HIDE)
            Exit
    EndIf
WEnd
EndFunc

Now...i need to read which Radio the user chooses..

Edited by Swift
Link to comment
Share on other sites

How about this...

#include <GuiConstants.au3>

Dim $show = 0, $Child_[6], $children = 5, $Radio[11]

$Main = GUICreate("MyGUI", 516, 323, (@DesktopWidth - 516) / 2, (@DesktopHeight - 323) / 2)

$Button_1 = GUICtrlCreateButton("&Next >", 335, 290, 80, 25)
$Button_2 = GUICtrlCreateButton("< &Back", 250, 290, 80, 25)
$Button_3 = GUICtrlCreateButton("&Exit", 420, 290, 80, 25)
$Button_4 = GUICtrlCreateButton("&Done", 165, 290, 80, 25)
$Button_6 = GUICtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE)

GUISetState()

$Child_[1] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 1.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[1] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[2] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState()

$Child_[2] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 2.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[3] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[4] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[3] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 3.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[5] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[6] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[4] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[7] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[8] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)

$Child_[5] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
$Label_1 = GuiCtrlCreateLabel("Child 5.", 40, 140, 290, 30)
GUICtrlSetFont(-1, 10, 650)
$radio[9] = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio[10] = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUISetState(@SW_HIDE)


While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3
            ExitLoop
        Case $msg = $Button_1
            Set_Next()
        Case $msg = $Button_2
            Set_Back()
        Case $msg = $Button_4
            Set_Done()
            ;;;
    EndSelect
WEnd


;--------- Functions -------------------

Func Set_Done()
for $x = 1 to UBound($radio) -1
    If _IsChecked($radio[$x]) Then MsgBox(0x0,"#" & $x, "You selected Radio " & $x, 2)
    Next
EndFunc

Func Set_Next()

    For $x = 1 To $children - 1
        $Nwin = WinGetState($Child_[$x])
        If $Nwin > 5 Then
            GUISetState(@SW_HIDE, $Child_[$x])
            GUISetState(@SW_SHOW, $Child_[$x + 1])
            Return
        EndIf
    Next

EndFunc   ;==>Set_Next

Func Set_Back()

    For $x = $children To 1 Step - 1
        $Nwin = WinGetState($Child_[$x])
        If $Nwin > 5 Then
            GUISetState(@SW_HIDE, $Child_[$x])
            GUISetState(@SW_SHOW, $Child_[$x - 1])
            Return
        EndIf
    Next

EndFunc   ;==>Set_Back

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

NEWHeader1.png

Link to comment
Share on other sites

To do it with the one gui I'd do it like this:

#include <GUIConstants.au3>

GUICreate("Test", 200, 200)
$radio1 = GUICtrlCreateRadio("Radio1", 10, 20,70)
$radio2 = GUICtrlCreateRadio("Radio2", 10, 40,70)

$radio3 = GUICtrlCreateRadio("Radio3", 10, 20,70)
GUICtrlSetState(-1,$GUI_HIDE)
$radio4 = GUICtrlCreateRadio("Radio4", 10, 40,70)
GUICtrlSetState(-1,$GUI_HIDE)

$btn = GUICtrlCreateButton("Next", 10, 80,50)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $btn And GUICtrlRead($btn) = 'Next'
        GUICtrlSetState($radio1,$GUI_HIDE)
        GUICtrlSetState($radio2,$GUI_HIDE)
        GUICtrlSetState($radio3,$GUI_SHOW)
        GUICtrlSetState($radio4,$GUI_SHOW)
        GUICtrlSetData($btn,'Done')
    Case $msg = $btn And GUICtrlRead($btn) = 'Done'
        If BitAnd(GUICtrlRead($radio1),$GUI_CHECKED) Then
            $res1='ONE'
        ElseIf BitAnd(GUICtrlRead($radio2),$GUI_CHECKED) Then
            $res1 = 'TWO'
        Else
            $res1 = 'NONE'
        EndIf
        
        If BitAnd(GUICtrlRead($radio3),$GUI_CHECKED) Then
            $res2='THREE'
        ElseIf BitAnd(GUICtrlRead($radio4),$GUI_CHECKED) Then
            $res2 = 'FOUR'
        Else
            $res2 = 'NONE'
        EndIf
        
        Msgbox(0, "", "you choose radio's "&$res1&" and "&$res2)
    
        Exit
    EndSelect
WEnd
Link to comment
Share on other sites

maybe your not getting what im asking...like stampys...instead of a msgbox...i want IF $RADIO1 and $RADIO3 are checked...then GUICreate('g', 200, 200)

and put a picture...from the internet...but if you choose

$RADIO1 and $RADIO4...a different picture...and so on...

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...