Jump to content

A simple predefined dialog function


Achilles
 Share

Recommended Posts

;===============================================================================
;
; Description:      Returns a value based on which of radio buttons is selected
; Syntax:           _RadioOptionBox($title, $message, $width = 300, $guiOnEvent = False,  $rad_0, $rad_1, $rad_2 = '', ..., $rad_10 = '')
; Parameter(s):     $title: the title of the window
;                   $message: the message shown inside the window
;                   $guiOnEvent: if GuiOnEventMode is active set this to True in order to restore GuiEventMode (Has to be declared)
;                   $rad0: the text to be shown for the first radio button
;                   $rad1: the text to be shown for the second radio button
;                   ...
;                   $rad10: the text to be shown for the eleventh radio button
; Requirement(s):   #include <GUIConstants.au3>
; Return Value(s):  Returns -1 if any of the required parameters is left blank
;                   Returns 0 if Exit or Cancel was clicked
;                   Returns 0 if the first radio button is selected
;                   Returns 1 if the second radio button is selected
;                   ...
;                   10 if the eleventh radio button is selected
; Author(s):        Piano_Man
; Note(s):          Rad one is the default
;
;===============================================================================

Func _RadioOptionBox($title, $message, $rad_0, $rad_1, $rad_2 = '', $rad_3 = '', $rad_4 = '', $rad_5 = '', $rad_6 = '', $rad_7 = '', $rad_8 = '', $rad_9 = '', $rad_10 = '')
    Local $width = 300
    Local $i_UBound = @NumParams - 3
    Local $rad[$i_UBound]
    If $title = '' then Return -2
    If $message = '' then Return -2
    If $rad_0 = '' then Return -2
    If $rad_1 = '' then Return -2
        
    $guiOnEvent = Opt('GUIOnEventMode', 0)
    
    $optionGui = GuiCreate($title, $width, 100 + (@NumParams - 3) * 25, -1, -1, $DS_SETFOREGROUND)
    GuiSetFont(13, 400, '', 'Timer New Roman')
    
    GuiCtrlCreateLabel($message, 5, 5, $width - 10, 25, $SS_CENTER)
    
    For $i_Index = 0 To $i_UBound - 1
        $rad[$i_Index] = GuiCtrlCreateRadio(Eval("rad_" & String($i_Index)), 15, $i_Index * 25 + 30, 270, 25)
    Next
    
    $cancel = GuiCtrlCreateButton('Cancel', $width / 2 - 90, ($i_UBound) * 25 + 40, 80, 25)
    $ok = GuiCtrlCreateButton('Ok', $width / 2 + 10, ($i_UBound) * 25 + 40, 80, 25)
    
    GuiSetState()
    
    While 1 
        Switch GuiGetMsg() 
            Case $GUI_EVENT_CLOSE 
                $return = -1
                ExitLoop
            Case $cancel 
                $return = -1
                ExitLoop
            Case $ok
                For $a = 0 to $i_UBound
                    If GuiCtrlRead($rad[$a]) = $GUI_CHECKED then
                        $return = $a 
                        ExitLoop 2
                    EndIf 
                Next 
        EndSwitch 
    WEnd
    
    GuiDelete()
    If $guiOnEvent then ConsoleWrite(Opt('GUIOnEventMode', 1))
    
    Return $return
EndFuncoÝ÷ Ø·­é'£!jܨºØbB-ßÛjÇ¡ûax
ëk «y«^¬§^o Úâ¥i«nN&¦Ê'²ajy,¶b}Äv+Gz··öƧ{¦¦WºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ë]LÉÝÂÌÍÜÜÈHÔY[ÓÜ[ÛÞ
    ÌÎNÑÚÝÜ   ÌÎNË ÌÎNÕÚ]ÛÝ[[ÝHZÙHÈÛÚÈÜÉÌÎNËYK    ÌÎNÕ[YIÌÎNË   ÌÎNÕÉÌÎNË    ÌÎNÔÙYIÌÎNË  ÌÎNÒÝÉÌÎNË  ÌÎNÕÉÌÎNË    ÌÎNÕÛÜÜÉÌÎNË  ÌÎNÉÌÌÎÉÌÌÎÉÌÌÎÉÌÎNÊBÙØÞ
    ÌÎNÕHÝ[ ÌÎNË ÌÍÜÜÊ

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

you use this

Opt('GUIOnEventMode', 0)

then this

If $guiOnEvent then Opt('GUIOnEventMode', 1)

that won't work... but this might

$guiOnEvent = Opt('GUIOnEventMode', 0)

then

If $guiOnEvent then Opt('GUIOnEventMode', 1)

8)

The "Opt('GUIOnEventMode', 0)" just makes sure that GuiEventMode is off, that doesn't matter if it's on or off already...

The later "If $optGuiEvent..." just turns GuiEVentMode back on if the user specifies that GuiEventMode is true (that's done in the parameters)

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...