Jump to content

Recommended Posts

Opt("MustDeclareVars", 1)
Global $aRadio[61] = [10]

GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

GUICtrlCreateTabItem("One")
GUIStartGroup()
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)
GUIStartGroup()

GUICtrlCreateTabItem("Two")
GUIStartGroup()
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)
GUIStartGroup()

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
        Case $msg = $go
            For $i = 1 To 60
                If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0,"",ControlGetText("Title", "", $aRadio[$i]))
            Next
    EndSelect
WEnd

Edit: Forgot the code tags ... AGAIN!

Edited by GEOSoft

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!"

Link to comment
Share on other sites

  • Moderators

Thanubis,

Take a look at this:

Opt("MustDeclareVars", 1)
Global $aRadio[11] = [11]

GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

GUICtrlCreateTabItem("One")
GUIStartGroup()
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)
GUIStartGroup()

GUICtrlCreateTabItem("Two")
GUIStartGroup()
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)
GUIStartGroup()

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
    EndSelect

    For $i = 1 To 10
        If $msg = $aRadio[$i] And GUICtrlRead($aRadio[$i]) = 1 Then
            For $j = 1 To 10
                GUICtrlSetState($aRadio[$j], 4)
            Next
            GUICtrlSetState($aRadio[$i], 1)
        EndIf
    Next
WEnd

You can see the radio being reset when you change tabs, but at least it changes!

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

The tabs automatically put them in separate groups, so one button is selectable from each tab, and GUIStartGroup isn't needed.

Try this instead to reset the rest when one is selected.

Opt("MustDeclareVars", 1)
Global $aRadio[61] = [10]

GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

GUICtrlCreateTabItem("One")
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)

GUICtrlCreateTabItem("Two")
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    
    For $iX = 1 To 10
        If $msg = $aRadio[$iX] Then
            For $iY = 1 To 10
                If $iX <> $iY Then GUICtrlSetState($aRadio[$iY], $GUI_UNCHECKED)
            Next
        EndIf
    Next
    
    Select
        Case $msg = -3
            Exit
        Case $msg = $go
            For $i = 1 To 60
                If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0, "", ControlGetText("Title", "", $aRadio[$i]))
            Next
    EndSelect
WEnd

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Excellent, thanks for the help, guys.

That's exactly what I'm looking for. It works perfectly without slowing anything down. I think the only thing better would be to reset all of the radios when the tab changes, but then I'd have to figure out how to tell when the tab actually changes.

The current, and most likely final, code.

Opt("MustDeclareVars", 1)
 Global $aRadio[11] = [10]
 
 GUICreate("Title", 200, 200)
 Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
 Local $tab = GUICtrlCreateTab(0, 0, 200, 150)
 
 GUICtrlCreateTabItem("One")
 $aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
 $aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
 $aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
 $aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
 $aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)
 
 GUICtrlCreateTabItem("Two")
 $aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
 $aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
 $aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
 $aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
 $aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)
 
 GUICtrlCreateTabItem("")
 GUISetState(@SW_SHOW)
 
 While 1
     Local $msg = GUIGetMsg()
     Select
         Case $msg = -3
             Exit
         Case $msg = $go
             Go()
     EndSelect
     For $i1 = 1 To 10
         If $msg = $aRadio[$i1] Then
             For $i2 = 1 To 10
                 If $i1 <> $i2 Then GUICtrlSetState($aRadio[$i2], 4)
             Next
         EndIf
     Next
 WEnd
 
 Func Go()
     For $i = 1 To 10
         If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0,"",ControlGetText("Title", "", $aRadio[$i]))
     Next
 EndFunc
Here's another variation

Opt("MustDeclareVars", 1)
Global $aRadio[11] = [10],$Radio,$Tab2

GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

GUICtrlCreateTabItem("One")
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)

$Tab2 = GUICtrlCreateTabItem("Two")
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)
$Radio = 0
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
        Case $msg = $go
            Go()
        Case $msg >=$aRadio[1] and $msg <= $aRadio[10] and $msg <> $Tab2
            GUICtrlSetState($Radio, 4)
            GUICtrlSetState($msg, 5);$GUI_CHECKED)
            $Radio = $msg
    EndSelect
    
WEnd

Func Go()
    For $i = 1 To 10
        If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0,"",ControlGetText("Title", "", $aRadio[$i]))
    Next
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

This is my solution with OnEventMode :D

#include<GUIConstantsEx.au3>
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $aRadio[11] = [10] , $giSelectedRadioID = -1

GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
GUICtrlSetOnEvent($go, "GO")
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

GUICtrlCreateTabItem("One")
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)

GUICtrlCreateTabItem("Two")
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)

GUICtrlCreateTabItem("")

For $i = 1 To $aRadio[0]
    GUICtrlSetOnEvent($aRadio[$i], "_RadioAction")
Next
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Close()
    Exit
EndFunc

Func _RadioAction()
    If $giSelectedRadioID > -1 And $giSelectedRadioID <> @GUI_CtrlId Then GUICtrlSetState($giSelectedRadioID, $GUI_UNCHECKED)
    $giSelectedRadioID = @GUI_CtrlId
EndFunc

Func Go()
    For $i = 1 To $aRadio[0]
        If $aRadio[$i] = $giSelectedRadioID Then MsgBox(0,"", "RadioIndex: " & $i & @CRLF & "RadioCtrlID: " & $giSelectedRadioID)
    Next
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Well, I think I understand what you were trying to do, but your code doesn't work. Regardless of whether or not it works, that method would really be a pain to add to my full script.

Not only "trying" but succeeding for me. :D But if it's a pain to use for you then that's a different point.

If using OnEvent mode as in Prog@ndy's suggestion is also a problem then maybe this version of my suggestion removes some problems for you, but I'm guessing since I don't know what those problems are.

Opt("MustDeclareVars", 1)
Global $aRadio[11] = [10],$Radio,$Gui,$Tab1, $Tab2

$Gui = GUICreate("Title", 200, 200)
Local $go = GUICtrlCreateButton("Go", 0, 150, 200, 50, 0x0F00)
Local $tab = GUICtrlCreateTab(0, 0, 200, 150)

$Tab1 = GUICtrlCreateTabItem("One")
$Tab2 = GUICtrlCreateTabItem("Two")
GUICtrlCreateTabItem("")
GUISwitch($Gui,$tab1)
$aRadio[01] = GUICtrlCreateRadio("01", 9, 33, 180, 20)
$aRadio[02] = GUICtrlCreateRadio("02", 9, 53, 180, 20)
$aRadio[03] = GUICtrlCreateRadio("03", 9, 73, 180, 20)
$aRadio[04] = GUICtrlCreateRadio("04", 9, 93, 180, 20)
$aRadio[05] = GUICtrlCreateRadio("05", 9, 113, 180, 20)

GUISwitch($Gui,$tab2)
$aRadio[06] = GUICtrlCreateRadio("06", 9, 33, 180, 20)
$aRadio[07] = GUICtrlCreateRadio("07", 9, 53, 180, 20)
$aRadio[08] = GUICtrlCreateRadio("08", 9, 73, 180, 20)
$aRadio[09] = GUICtrlCreateRadio("09", 9, 93, 180, 20)
$aRadio[10] = GUICtrlCreateRadio("10", 9, 113, 180, 20)
$Radio = 0

GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
        Case $msg = $go
            Go()
        Case $msg >=$aRadio[1] and $msg <= $aRadio[10]
            GUICtrlSetState($Radio, 4)
            GUICtrlSetState($msg, 5);$GUI_CHECKED)
            $Radio = $msg
    EndSelect
    
WEnd

Func Go()
    For $i = 1 To 10
        If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0,"",ControlGetText("Title", "", $aRadio[$i]))
    Next
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...