Jump to content



Photo

_GUICtrlCreateRadioCBox() UDF


  • Please log in to reply
3 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 06 December 2007 - 05:07 PM

Hi all,

This is a simple UDF that allows to create radio button or checkbox with text align to different sides:

AutoIt         
;Example #include <GuiConstants.au3> $Gui = GuiCreate("_GUICtrlCreateRadioCBox Demo") $Radio_1 = _GUICtrlCreateRadioCBox("My Custom Radio at the Right", "Right", 0, 20, 30) $Radio_2 = _GUICtrlCreateRadioCBox("My Custom Radio at the Bottom", "Bottom", 0, 20, 80) $Radio_3 = _GUICtrlCreateRadioCBox("My Custom Radio at the Left", "Left", 0, 20, 150, 150) $Radio_4 = _GUICtrlCreateRadioCBox("My Custom Radio at the top", "Top", 0, 20, 200) $CheckBox = _GUICtrlCreateRadioCBox("My Custom CheckBox with text at the Left", "Left", 1, 20, 290, 215) GUISetState() While 1     $Msg = GUIGetMsg()     Switch $Msg         Case $GUI_EVENT_CLOSE             Exit         Case $Radio_1[1]             ControlClick($Gui, "", $Radio_1[0])         Case $Radio_2[1]             ControlClick($Gui, "", $Radio_2[0])         Case $Radio_3[1]             ControlClick($Gui, "", $Radio_3[0])         Case $Radio_4[1]             ControlClick($Gui, "", $Radio_4[0])         Case $CheckBox[1]             ControlClick($Gui, "", $CheckBox[0])     EndSwitch WEnd ;The UDF ;=============================================================================== ; Function Name:    _GUICtrlCreateRadioCBox() ; Description:     Create a radio/checkbox control, with ability to set text from different directions. ; Syntax:          _GUICtrlCreateRadioCBox($sText, $sDirection, $iMode [,$Left [,$Top [,$Width [,$Height [,$Style [,$exStyle ]]]]]]) ; ; Parameter(s):    $sText      - The text of the control. ;                  $sDirection - a string that indicate the text align direction (Right, Left, Top, Bottom). ;                  $iMode      - Indicates what should be createed, Radio button or CheckBox control. ;                                $iMode = 0 Radio button, $iMode <> 0 CheckBox. ;                  $Left       - The left side of the control. ;                  $Top        - The top of the control. ;                  $Width      - [optional] The width of the control (default is the previously used width). ;                  $Height     - [optional] The height of the control (default is the previously used height). ;                  $Style      - [optional] Defines the style of the control (default is -1). ;                  $exStyle    - [optional] Defines the extended style of the control (default is -1). ; ; Requirement(s):  None. ; ; Return Value(s): On Seccess: ;                    Return 2-elements array: ;                      $RetArr[0] = Identifier (controlID) of the Radio/CheckBox. ;                      $RetArr[0] = Identifier (controlID) of the Label with the text. ;                  On Failure: ;                     @error set to 1 if "Left" direction used, and $Width not defined (Default keyword or -1). ;                     If unable to create control(s), returned 0 in the host element of the array. ; ; Author(s):       G.Sandler a.k.a CreatoR ; ; Example(s): ;       Will create radio button with text align to the Bottom ;     _GUICtrlCreateRadioCBox("My Custom Radio at the Bottom", "Bottom", 0, 20, 80) ;=============================================================================== Func _GUICtrlCreateRadioCBox($sText, $sDirection, $iMode, $Left, $Top, $Width=Default, $Height=Default, $Style=-1, $exStyle=-1)     Local $RetArr[2]     Local $rLeft = $Left, $rTop = $Top         Switch $sDirection         Case "Bottom"             $Top += 20         Case "Top"             $rTop += 18         Case "Left"             If $Width = Default Or $Width = -1 Then Return SetError(1, 0, 0)             $Width -= 10             $rLeft += $Width             $Top += 3         Case Else             $Left += 22             $Top += 3     EndSwitch         If $iMode = 0 Then         $RetArr[0] = GUICtrlCreateRadio("", $rLeft, $rTop, 20, 20, $Style, $exStyle)     Else         $RetArr[0] = GUICtrlCreateCheckbox("", $rLeft, $rTop, 20, 20, $Style, $exStyle)     EndIf     $RetArr[1] = GUICtrlCreateLabel($sText, $Left, $Top, $Width, $Height, $Style, $exStyle)     Return $RetArr EndFunc


Edit: Spell; Buttom replaced with Bottom, thanks martin :)

Edited by MsCreatoR, 06 December 2007 - 06:21 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1


AutoIt_Rus_Community.png AutoIt Russian Community

AutoIt_Icon_small.pngProjects:



AutoIt_Icon_small.pngUDFs:
 
AutoIt_Icon_small.pngExamples:


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *
==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team








#2 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,331 posts

Posted 06 December 2007 - 06:08 PM

Hi all,

This is a simple UDF that allows to create radio button or checkbox with text align to different sides:

AutoIt         
;Example #include <GuiConstants.au3> $Gui = GuiCreate("_GUICtrlCreateRadioCBox Demo") $Radio_1 = _GUICtrlCreateRadioCBox("My Custom Radio at the Right", "Right", 0, 20, 30) $Radio_2 = _GUICtrlCreateRadioCBox("My Custom Radio at the Buttom", "Buttom", 0, 20, 80) $Radio_3 = _GUICtrlCreateRadioCBox("My Custom Radio at the Left", "Left", 0, 20, 150, 150) $Radio_4 = _GUICtrlCreateRadioCBox("My Custom Radio at the top", "Top", 0, 20, 200) $CheckBox = _GUICtrlCreateRadioCBox("My Custom CheckBox with text at the Left", "Left", 1, 20, 290, 215) GUISetState() While 1     $Msg = GUIGetMsg()     Switch $Msg         Case $GUI_EVENT_CLOSE             Exit         Case $Radio_1[1]             ControlClick($Gui, "", $Radio_1[0])         Case $Radio_2[1]             ControlClick($Gui, "", $Radio_2[0])         Case $Radio_3[1]             ControlClick($Gui, "", $Radio_3[0])         Case $Radio_4[1]             ControlClick($Gui, "", $Radio_4[0])         Case $CheckBox[1]             ControlClick($Gui, "", $CheckBox[0])     EndSwitch WEnd ;The UDF ;=============================================================================== ; Function Name:    _GUICtrlCreateRadioCBox() ; Description:     Create a radio/checkbox control, with ability to set text in different directions. ; Syntax:          _GUICtrlCreateRadioCBox($sText, $sDirection, $iMode [,$Left [,$Top [,$Width [,$Height [,$Style [,$exStyle ]]]]]]) ; ; Parameter(s):    $sText      - The text of the control. ;                  $sDirection - a string that indicate the text align direction (Right, Left, Top, Buttom). ;                  $iMode      - Indicates what should be createed, Radio button or CheckBox control. ;                                $iMode = 0 Radio button, $iMode <> 0 CheckBox. ;                  $Left       - The left side of the control. ;                  $Top        - The top of the control. ;                  $Width      - [optional] The width of the control (default is the previously used width). ;                  $Height     - [optional] The height of the control (default is the previously used height). ;                  $Style      - [optional] Defines the style of the control (default is -1). ;                  $exStyle    - [optional] Defines the extended style of the control (default is -1). ; ; Requirement(s):  None. ; ; Return Value(s): On Seccess: ;                    Return 2-elements array: ;                      $RetArr[0] = Identifier (controlID) of the Radio/CheckBox. ;                      $RetArr[1] = Identifier (controlID) of the Label with the text. ;                  On Failure: ;                     @error set to 1 if "Left" direction used, and $Width not defined (Default keyword or -1). ;                     If unable to create control(s), returned 0 in the host element of the array. ; ; Author(s):       G.Sandler a.k.a CreatoR ; ; Example(s): ;       Will create radio button with text align to the buttom ;     _GUICtrlCreateRadioCBox("My Custom Radio at the Buttom", "Buttom", 0, 20, 80) ;=============================================================================== Func _GUICtrlCreateRadioCBox($sText, $sDirection, $iMode, $Left, $Top, $Width=Default, $Height=Default, $Style=-1, $exStyle=-1)     Local $RetArr[2]     Local $rLeft = $Left, $rTop = $Top         Switch $sDirection         Case "Buttom"             $Top += 20         Case "Top"             $rTop += 18         Case "Left"             If $Width = Default Or $Width = -1 Then Return SetError(1, 0, 0)             $Width -= 10             $rLeft += $Width             $Top += 3         Case Else             $Left += 22             $Top += 3     EndSwitch         If $iMode = 0 Then         $RetArr[0] = GUICtrlCreateRadio("", $rLeft, $rTop, 20, 20, $Style, $exStyle)     Else         $RetArr[0] = GUICtrlCreateCheckbox("", $rLeft, $rTop, 20, 20, $Style, $exStyle)     EndIf     $RetArr[1] = GUICtrlCreateLabel($sText, $Left, $Top, $Width, $Height, $Style, $exStyle)     Return $RetArr EndFunc


Nice idea MsCreatoR.

(Perhaps you could correct Buttom to Bottom) which brings me to the next point; you seem to have a parameter (I need to get my glasss to verify this), which is call SexStyle! Maybe you've posted in the wrong forum :)
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.

#3 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,266 posts

Posted 06 December 2007 - 06:24 PM

Nice idea MsCreatoR.

Thanks, i thought so too.

Perhaps you could correct Buttom to Bottom

Thanks, corrected first post :)

you seem to have a parameter (I need to get my glasss to verify this), which is call SexStyle!

I can't find it ^_^
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1


AutoIt_Rus_Community.png AutoIt Russian Community

AutoIt_Icon_small.pngProjects:



AutoIt_Icon_small.pngUDFs:
 
AutoIt_Icon_small.pngExamples:


Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *
==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#4 Achilles

Achilles

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,897 posts

Posted 06 December 2007 - 09:06 PM

Nice work! Is there any change of you encorporating your hover udf with this to make it appear like it's hovering when you're over the label?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users