Jump to content

Variable Sized Form and Radio buttons


c.haslam
 Share

Recommended Posts

Consider the following code:

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

Local $cities[3] = ["","Montreal","San Francisco"]
$val = Choose($cities)
If $val=False Then
    MsgBox(0,"","Cancelled")
Else
    MsgBox(0,"", "Chose "&$val)
EndIf

Func Choose($citiesVec)
    Local $radVec[UBound($citiesVec)+1]
    $Form2 = GUICreate("Form2", 413, 134, 303, 219)
    $Label1 = GUICtrlCreateLabel("Choose a city:", 8, 8, 71, 17)
    For $i = 1 To UBound($citiesVec)-1
        $radVec[$i] = GUICtrlCreateRadio($citiesVec[$i], 24, 8+$i*24, 200, 17)
    Next
    $btnOK = GUICtrlCreateButton("OK", 352, 96, 33, 25, 0)
    $btnCancel = GUICtrlCreateButton("Cancel", 280, 96, 49, 25, 0)
    GUICtrlSetState($radVec[1],$GUI_CHECKED)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE,$btnCancel
                $ret = False
                ExitLoop
            Case $btnOK
                $ret = True
                ExitLoop
        EndSwitch
    WEnd
    If $ret Then
        For $i = 1 To UBound($radVec)-1
            If BitAND(GUICtrlRead($radVec[$i]), $GUI_CHECKED) = $GUI_CHECKED Then
                $ret = $citiesVec[$i]
                ExitLoop
            EndIf
        Next
    EndIf
    GUIDelete()
    Return $ret
EndFunc

Here $cities is pre-defined (constant), but what if the cites can be any in the world, i.e. variable?

Here the widths of the Radio controls are constants, but how can I calculate the widths for any cities? Is there a function that will return the length (in pixels) of any word or phrase?

I expect that I will need to calculate the width of the form from the length of the radio controls.

...chris

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

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