Jump to content

[SOLVED]Problem with radio buttons


airrs
 Share

Recommended Posts

Hi there,

i've got a problem with the radio buttons.

i have a gui with 3 radio buttons and a normal button. if you select radio button 1 an click on the button, the main window should close and window 1 should open (radio utton 2 window 2 and so on)

another problem: the program open and close in less than a sec. Sleep, doesn't work out

here my source code

#include

$mainWin = ""
$test1 = ""
$test2 = ""
$test3 = ""
$rbN = ""

;Hauptfenster

$mainWin = GUICreate("Neuer Account",190,150)
GUICtrlCreateGroup("Auswahl",20,10,150,95)
GUIStartGroup()
$rb1 = GUICtrlCreateRadio("Station",40,25)
$rb2 = GUICtrlCreateRadio("Agent",40,50)
$rb3 = GUICtrlCreateRadio("Search and Replay",40,75)
$rb4 = GUICtrlCreateGroup("", -99, -99, 1, 1) ;gruppe schließen
$btn = GUICtrlCreateButton("Weiter",80,115)

;FENSTER 1

$test1 = GUICreate("testfenster",190,150)
GUICtrlCreateGroup("11",20,10,150,95)
GUIStartGroup()
$rb = GUICtrlCreateRadio("12",40,25)
$rb = GUICtrlCreateRadio("13",40,50)
$rb = GUICtrlCreateRadio("14",40,75)
$rb = GUICtrlCreateGroup("", -99, -99, 1, 1) ;gruppe schließen
$btn2 = GUICtrlCreateButton("Zurück",80,115)

...
...
...

GUISetState(@SW_SHOW,$mainWin)

While 1
$msg = GUIGetMsg(1)
GuiCtrlRead($rb1, $GUI_CHECKED)
GuiCtrlRead($rb2, $GUI_CHECKED)


Switch $msg[1]
Case $mainWin
Switch $msg[0]
Case $GUI_EVENT_CLOSE
Exit
Case $btn
If $msg = $rb1 And BitAND(GUICtrlRead($rb1), $GUI_CHECKED) = $GUI_CHECKED Then
GUISetState(@SW_HIDE,$mainWin)
GUISetState(@SW_Show,$test1)
ElseIf $msg = $rb2 And BitAND(GUICtrlRead($rb2), $GUI_CHECKED) = $GUI_CHECKED Then
GUISetState(@SW_HIDE,$mainWin)
GUISetState(@SW_Show,$test2)
EndIf
EndSwitch
Case $test1
Switch $msg[0]
Case $btn2
GUISetState(@SW_Show,$mainWin)
GUISetState(@SW_HIDE,$test1)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndSwitch
WEnd

I hope you're able to help me.

Edited by airrs
Link to comment
Share on other sites

  • Moderators

airrs,

Welcome to the AutoIt forum. :)

You were making the conditions too strict for the action to occur - try something like this: ;)

#include <GUIConstantsEx.au3>

$mainWin = ""
$test1 = ""
$test2 = ""
$test3 = ""
$rbN = ""

;Hauptfenster

$mainWin = GUICreate("Neuer Account", 190, 150)
GUICtrlCreateGroup("Auswahl", 20, 10, 150, 95)
GUIStartGroup()
$rb1 = GUICtrlCreateRadio("Station", 40, 25)
$rb2 = GUICtrlCreateRadio("Agent", 40, 50)
$rb3 = GUICtrlCreateRadio("Search and Replay", 40, 75)
$rb4 = GUICtrlCreateGroup("", -99, -99, 1, 1) ;gruppe schließen
$btn = GUICtrlCreateButton("Weiter", 80, 115)

GUISetState(@SW_SHOW, $mainWin)

;FENSTER 1

$test1 = GUICreate("testfenster1", 190, 150)
$btn1 = GUICtrlCreateButton("Zurück", 80, 115)

GUISetState(@SW_HIDE)

;FENSTER 2

$test2 = GUICreate("testfenster2", 190, 150)
$btn2 = GUICtrlCreateButton("Zurück", 80, 115)

GUISetState(@SW_HIDE)


While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $mainWin
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $btn
                    If GUICtrlRead($rb1) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        GUISetState(@SW_HIDE, $mainWin)
                        GUISetState(@SW_SHOW, $test1)
                    Else
                        GUISetState(@SW_HIDE, $mainWin)
                        GUISetState(@SW_SHOW, $test2)
                    EndIf
            EndSwitch
        Case $test1
            Switch $msg[0]
                Case $btn1
                    GUISetState(@SW_SHOW, $mainWin)
                    GUISetState(@SW_HIDE, $test1)
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch
        Case $test2
            Switch $msg[0]
                Case $btn2
                    GUISetState(@SW_SHOW, $mainWin)
                    GUISetState(@SW_HIDE, $test2)
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch
    EndSwitch
WEnd

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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