Jump to content

_GUICtrlSegment UDF (Segmented digits)


jennico
 Share

Recommended Posts

don't know if this might be useful for anyone, but it's worthy enough to post it.

i imagine it to be used for tickertapes, marquees....

updated v1.1 now possible to manipulate single segments for more effects. (and a fixed bug nobody noticed it)

the UDF: _GUICtrlSegment.au3

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#cs
    User Calltips:
    _GUICtrlSegment_Create ( $hwnd, $seg_data, $seg_lb_x, $seg_lb_y, $seg_lb_wd, $seg_lb_ht [, $seg_out_style [, $seg_out_Ex_style [, $seg_in_style [, $seg_in_Ex_style [, $seg_segment_style [, $seg_segment_Ex_style]]]]]] ) Creates a Segmented Control for the GUI.
    _GUICtrlSegment_Delete ( $s_seg ) Deletes a Segmented Control.
    _GUICtrlSegment_SetColor ( $s_seg [, $seg_font_color] ) Sets the text color of a Segmented Control.
    _GUICtrlSegment_SetBkColor( $s_seg, $seg_lb_bc ) Sets the background color of a Segmented Control.
    _GUICtrlSegment_SetDigitColor ( $s_seg, $s_number, $seg_digit_color ) Sets the text color for a single digit in a Segmented Control.
    _GUICtrlSegment_SetSegmentColor ( $s_seg, $s_number, $s_count, $seg_segment_color ) Sets the text color for a single segment of a digit in a Segmented Control.
    _GUICtrlSegment_Read ( $s_seg ) Reads the text of a Segmented Control.
    _GUICtrlSegment_Hide ( $s_seg ) Hides a Segmented Control.
    _GUICtrlSegment_Show ( $s_seg ) Shows a Segmented Control.
    _GUICtrlSegment_GetColor ( $s_seg ) Retrieves the text color a Segmented Control.
    _GUICtrlSegment_GetBkColor ( $s_seg ) Retrieves the background color a Segmented Control.
    _GUICtrlSegment_GetPos ( $s_seg ) Retrieves the position and size of a Segmented Control relative to its window.
    _GUICtrlSegment_SetPos ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] ) Moves a Segmented Control within a window.
    _GUICtrlSegment_Move ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] ) Moves a Segmented Control within a window.
    _GUICtrlSegment_GetHandle ( $s_seg ) Retrieves the internal handle of a control.
    _GUICtrlSegment_GetOuterStyle ( $s_seg ) Retrieves the "outer" styles of a Segmented Control.
    _GUICtrlSegment_SetOuterStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] ) Changes the "outer" styles of a Segmented Control.
    _GUICtrlSegment_SetInnerStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] ) Changes the "inner" styles of a Segmented Control.
    _GUICtrlSegment_SetSegmentStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] ) Changes the styles of each segment in a Segmented Control.
    _GUICtrlSegment_SetSingleSegmentStyle ( $s_seg, $s_number, $s_count [, $seg_style [, $seg_Ex_style]] ) Changes the styles of a single segment in a Segmented Control.
    _GUICtrlSegment_SetSegmentState ( $s_seg, $s_number, $s_count, $s_state ) Hides or Shows a single segment of a Segmented Control.
    _GUICtrlSegment_SetState ( $s_seg, $s_state ) Changes the state of a Segmented Control.
    _GUICtrlSegment_GetState ( $s_seg ) Gets the current state of a Segmented Control.
    _GUICtrlSegment_SetFont ( $s_seg [, $x [, $y [, $z [, $s [, $a [, $b]]]]]] ) Sets the segment dimensions in a Segmented Control.
    _GUICtrlSegment_GetFont ( $s_seg ) Gets the segment dimensions in a Segmented Control.
    _GUICtrlSegment_SetCursor ( $s_seg, $cursor ) Sets the mouse cursor icon for the Segmented Control.
    _GUICtrlSegment_SetTip ( $s_seg, $txt [, $title [, $icon [, $options]]] ) Sets the tip text associated with a Segmented Control.
    _GUICtrlSegment_SetTrans ( $s_seg, $trans ) => not working.
    _GUICtrlSegment_SetData ( $s_seg, $seg_data ) Sets the text for a Segmented Control.
    _GUICtrlSegment_SetSingleData ( $s_seg, $s_number, $seg_data ) Sets the data (one char) for a single digit in a Segmented Control.
    _GUICtrlSegment_AlignRight( $s_seg [, $s_count] ) Sets a Segmented Control to right align mode to the specified places.
#ce

#cs
    ;#=#INDEX#===================================================#
    ;#  Title .........: _GUICtrlSegment.au3
    ;#  Description ...: Creates and manipulates a Segmented (Digit) Control for the GUI.
    ;#  Date ..........: 20.11.08
    ;#  Version .......: 1.1 (added _GUICtrlSegment_SetDigitColor, _GUICtrlSegment_SetSegmentColor, _GUICtrlSegment_SetSingleSegmentStyle, _GUICtrlSegment_SetSingleData, __CreateDigit; changed _GUICtrlSegment_SetColor, _GUICtrlSegment_SetData; fixed _GUICtrlSegment_SetData)
    ;#  History .......: v 1.0 11.11.08
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#  Main Functions : _GUICtrlSegment_Create ( $hwnd, $seg_data, $seg_lb_x, $seg_lb_y, $seg_lb_wd, $seg_lb_ht [, $seg_out_style [, $seg_out_Ex_style [, $seg_in_style [, $seg_in_Ex_style [, $seg_segment_style [, $seg_segment_Ex_style]]]]]] )
    ;#                   _GUICtrlSegment_Delete ( $s_seg )
    ;#                   _GUICtrlSegment_SetColor ( $s_seg [, $seg_font_color] )
    ;#                   _GUICtrlSegment_SetBkColor( $s_seg, $seg_lb_bc )
    ;#                   _GUICtrlSegment_SetDigitColor ( $s_seg, $s_number, $seg_digit_color )
    ;#                   _GUICtrlSegment_SetSegmentColor ( $s_seg, $s_number, $s_count, $seg_segment_color )
    ;#                   _GUICtrlSegment_Read ( $s_seg )
    ;#                   _GUICtrlSegment_Hide ( $s_seg )
    ;#                   _GUICtrlSegment_Show ( $s_seg )
    ;#                   _GUICtrlSegment_GetColor ( $s_seg )
    ;#                   _GUICtrlSegment_GetBkColor ( $s_seg )
    ;#                   _GUICtrlSegment_GetPos ( $s_seg )
    ;#                   _GUICtrlSegment_SetPos ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] )
    ;#                   _GUICtrlSegment_Move ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] )
    ;#                   _GUICtrlSegment_GetHandle ( $s_seg )
    ;#                   _GUICtrlSegment_GetOuterStyle ( $s_seg )
    ;#                   _GUICtrlSegment_SetOuterStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#                   _GUICtrlSegment_SetInnerStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#                   _GUICtrlSegment_SetSegmentStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#                   _GUICtrlSegment_SetSingleSegmentStyle ( $s_seg, $s_number, $s_count [, $seg_style [, $seg_Ex_style]] )
    ;#                   _GUICtrlSegment_SetSegmentState ( $s_seg, $s_number, $s_count, $s_state )
    ;#                   _GUICtrlSegment_SetState ( $s_seg, $s_state )
    ;#                   _GUICtrlSegment_GetState ( $s_seg )
    ;#                   _GUICtrlSegment_SetFont ( $s_seg [, $x [, $y [, $z [, $s [, $a [, $b]]]]]] )
    ;#                   _GUICtrlSegment_GetFont ( $s_seg )
    ;#                   _GUICtrlSegment_SetCursor ( $s_seg, $cursor )
    ;#                   _GUICtrlSegment_SetTip ( $s_seg, $txt [, $title [, $icon [, $options]]] )
    ;#                   _GUICtrlSegment_SetTrans ( $s_seg, $trans ) => not working
    ;#                   _GUICtrlSegment_SetData ( $s_seg, $seg_data )
    ;#                   _GUICtrlSegment_SetSingleData ( $s_seg, $s_number, $seg_data )
    ;#                   _GUICtrlSegment_AlignRight( $s_seg, $s_count = 0 )
    ;#  Subfunctions ..: __GetSegmentID ( $x )
    ;#                   __CreateDigit ( $x, $l )
    ;#                   __SetSegmentPos ( [$x [, $y [, $z [, $s [, $a [, $b ]]]]]] )
    ;#                   __Binary ( $s_number )
    ;#                   __WinGetClientPos ( $hWnd [, $s_text] )
    ;#===========================================================#
#ce

#include-once

#Region;--------------------------Global declarations

Global $seg_digits[70] = ["0001000", "1101101", "0100010", "0100100", "1000101", _
        "0010100", "0010000", "0101101", "0000000", "0000100", "", "", "", "", "", "", "", _
        "0000001", "00000000", "0011010", "", "0010010", "0010011", "0010000", "1000001", _
        "1101101", "0101100", "", "1011010", "", "", "0001000", "00000111", "", "", _
        "0010100", "", "1001000", "", "", "", "1000101", "", "", "", "", "", "", "", "", _
        "1010000", "1110010", "1100000", "", "", "", "1010001", "1111101", "", "", _
        "1011010", "", "", "1110000", "", "", "", "", "1010010", "1111000"  ];u
Global $seg_pos[7][4], $seg_lb[7][1][1], $seg_gui[1], $seg_lo[1], $seg_hi[1], $seg_lb_data[1]
Global $seg_lb_state[1], $seg_dt_length[1], $seg_ft_cl[1], $seg_bk_cl[1], $seg_font[1]
Global $seg_cnt = 0, $seg_max_length = 1, $seg_hwnd[1], $seg_seg_style[1], $seg_seg_Ex_style[1]
Global $seg_dist, $seg_align[1]

#EndRegion;--------------------------Global declarations
#region;--------------------------Main Functions
#region;--------_GUICtrlSegment_Create

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Create ( $hwnd, $seg_data, $seg_lb_x, $seg_lb_y, $seg_lb_wd, $seg_lb_ht [, $seg_out_style [, $seg_out_Ex_style [, $seg_in_style [, $seg_in_Ex_style [, $seg_segment_style [, $seg_segment_Ex_style]]]]]] )
    ;#  Description....: Creates a Segmented Control for the GUI.
    ;#  Parameters.....: $hwnd = The handle of the target window.
    ;#                   $seg_data = The text of the control.
    ;#                   $seg_lb_x = The left side of the control.
    ;#                   $seg_lb_y = The top of the control.
    ;#                   $seg_lb_wd = The width of the control.
    ;#                   $seg_lb_ht = The height of the control.
    ;#                   $seg_out_style [optional] = Defines the "outer" style of the entire control. See GUI Control Styles Appendix (Default is -1).
    ;#                   $seg_out_Ex_style [optional] = Defines the "outer" extended style of the entire control. See Extended Style Table (Default is -1).
    ;#                   $seg_in_style [optional] = Defines the "inner" style of the entire control. See GUI Control Styles Appendix (Default is -1).
    ;#                   $seg_in_Ex_style [optional] = Defines the "inner" extended style of the entire control. See Extended Style Table (Default is -1).
    ;#                   $seg_segment_style [optional] = Defines the style of the segments themselves. See GUI Control Styles Appendix (Default is -1).
    ;#                   $seg_segment_Ex_style [optional] = Defines the extended style of the segments themselves. See Extended Style Table (Default is -1).
    ;#  Return Value ..: Returns the identifier (controlID) of the new control.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: @extended provides a secondary handle. Might be useful if controlID fails.
    ;#                   If necessary, you have reactivate the parent GUI by GUISwitch afterwards.
    ;#                   In some cases, you will have to define the parent GUI in GUISetState() afterwards [ GUISetState(@SW_SHOW,$parent) ].
    ;#                   A Segmented Control has one text line only and is not resizable.
    ;#                   Three sets of styles can be defined to the control. Be careful when mixing them.
    ;#                   The outer style corresponds to Window Control Styles, the inner and the segment style to Static Control Styles.
    ;#  Related........: _GUICtrlSegment_Delete
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Create($hwnd, $seg_data, $seg_lb_x, $seg_lb_y, $seg_lb_wd, $seg_lb_ht, _
        $seg_out_style = -1, $seg_out_Ex_style = -1, $seg_in_style = -1, $seg_in_Ex_style = _
         -1, $seg_segment_style = -1, $seg_segment_Ex_style = -1)
    $seg_cnt += 1
    ReDim $seg_gui[$seg_cnt + 1], $seg_seg_Ex_style[$seg_cnt + 1], $seg_lo[$seg_cnt + 1], _
            $seg_hi[$seg_cnt + 1], $seg_lb_data[$seg_cnt + 1], $seg_lb_state[$seg_cnt + 1], _
            $seg_dt_length[$seg_cnt + 1], $seg_ft_cl[$seg_cnt + 1], $seg_bk_cl[$seg_cnt + 1], _
            $seg_font[$seg_cnt + 1], $seg_align[$seg_cnt + 1], $seg_hwnd[$seg_cnt + 1], _
            $seg_seg_style[$seg_cnt + 1], $seg_lb[7][$seg_cnt + 1][$seg_max_length]
    If $seg_in_style = -1 Then $seg_in_style = 0
    If $seg_out_style = -1 Then $seg_out_style = 0
    If $seg_in_Ex_style = -1 Then $seg_in_Ex_style = 0
    If $seg_out_Ex_style = -1 Then $seg_out_Ex_style = 0
    If $seg_segment_style = -1 Then $seg_segment_style = 0
    If $seg_segment_Ex_style = -1 Then $seg_segment_Ex_style = 0
    $seg_seg_Ex_style[$seg_cnt] = $seg_segment_Ex_style
    $seg_seg_style[$seg_cnt] = $seg_segment_style
    $seg_bk_cl[$seg_cnt] = 0xD4D0C8
    $seg_hwnd[$seg_cnt] = $hwnd
    $seg_ft_cl[$seg_cnt] = 0
    $seg_gui[$seg_cnt] = GUICreate("", $seg_lb_wd, $seg_lb_ht, $seg_lb_x, $seg_lb_y, BitOR _
            (0x40000000, $seg_out_style), $seg_out_Ex_style, $hwnd);$WS_CHILD
    $seg_lo[$seg_cnt] = GUICtrlCreateLabel("", 0, 0, $seg_lb_wd, $seg_lb_ht, $seg_in_style, _
            $seg_in_Ex_style)
    GUICtrlSetState(-1, 128)
    $seg_hi[$seg_cnt] = GUICtrlCreateLabel("", 0, 0, $seg_lb_wd, $seg_lb_ht)
    GUICtrlSetBkColor(-1, -2)
    $seg_font[$seg_cnt] = __SetSegmentPos();nested array !
    _GUICtrlSegment_SetData(-1, $seg_data)
    GUISetState(@SW_SHOW, $seg_gui[$seg_cnt])
    GUISwitch($hwnd)
    Return SetExtended($seg_gui[$seg_cnt], $seg_hi[$seg_cnt])
EndFunc   ;==>_GUICtrlSegment_Create

#EndRegion;--------_GUICtrlSegment_Create
#region;--------_GUICtrlSegment_Delete

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Delete ( $s_seg )
    ;#  Description....: Deletes a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: None.
    ;#  Related........: _GUICtrlSegment_Create
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Delete($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUIDelete($seg_gui[$x])
    $seg_hi[$x] = ""
    Return 1
EndFunc   ;==>_GUICtrlSegment_Delete

#EndRegion;--------_GUICtrlSegment_Delete
#region;--------_GUICtrlSegment_SetColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetColor ( $s_seg [, $seg_font_color] )
    ;#  Description....: Sets the text color of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_font_color [optional] = The RGB color to use. Default is the last text color used for this control.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   To reset text color after _GUICtrlSegment_SetDigitColor or _GUICtrlSegment_SetSegmentColor, leave second parameter away or pass <0 or "" (blank string).
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetBkColor, _GUICtrlSegment_SetDigitColor, _GUICtrlSegment_SetSegmentColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetColor($s_seg, $seg_font_color = -1)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    If $seg_font_color < 0 Then $seg_font_color = $seg_ft_cl[$x]
    For $j = 0 To $seg_dt_length[$x] - 1
        For $i = 0 To 6
            GUICtrlSetBkColor($seg_lb[$i][$x][$j], $seg_font_color)
        Next
    Next
    $seg_ft_cl[$x] = $seg_font_color
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetColor

#EndRegion;--------_GUICtrlSegment_SetColor
#region;--------_GUICtrlSegment_SetBkColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetBkColor ( $s_seg, $seg_lb_bc )
    ;#  Description....: Sets the background color of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_lb_bc = The RGB color to use.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   If necessary, you have reactivate the parent GUI by GUISwitch.
    ;#                   $GUI_BKCOLOR_TRANSPARENT is not supported.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetBkColor($s_seg, $seg_lb_bc)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUICtrlSetBkColor($seg_lo[$seg_cnt], $seg_lb_bc)
    $seg_bk_cl[$x] = $seg_lb_bc
    GUISwitch($seg_hwnd[$x])
    Return 1;guiswitch
EndFunc   ;==>_GUICtrlSegment_SetBkColor

#EndRegion;--------_GUICtrlSegment_SetBkColor
#region;--------_GUICtrlSegment_SetDigitColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetDigitColor ( $s_seg, $s_number, $seg_digit_color )
    ;#  Description....: Sets the text color for a single segment of a digit in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_number = The number (count from left = 1) of the digit to be painted.
    ;#                   $seg_digit_color = The RGB color to use.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#                            Returns -1 if $s_number is < 1.
    ;#  Author ........: jennico
    ;#  Date ..........: 19.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   To reset text color, use _GUICtrlSegment_SetColor ( $s_seg ).
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetBkColor, _GUICtrlSegment_SetColor, _GUICtrlSegment_SetSegmentColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetDigitColor($s_seg, $s_number, $seg_digit_color)
    If $s_number < 1 Then Return -1
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    If $s_number > $seg_dt_length[$x] Then __CreateDigit($x, $s_number)
    For $i = 0 To 6
        GUICtrlSetBkColor($seg_lb[$i][$x][$s_number - 1], $seg_digit_color)
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetDigitColor

#EndRegion;--------_GUICtrlSegment_SetDigitColor
#region;--------_GUICtrlSegment_SetSegmentColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetSegmentColor ( $s_seg, $s_number, $s_count, $seg_segment_color )
    ;#  Description....: Sets the text color for a single digit in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_number = The number (count from left = 1) of the digit to be painted.
    ;#                   $s_count = The segment number (count from top=0 to bottom=6 and from left to right) of the digit to be painted.
    ;#                   $seg_segment_color = The RGB color to use.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#                            Returns -1 if $s_count is out of range.
    ;#  Author ........: jennico
    ;#  Date ..........: 19.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Use value < 1 for $s_number if you want to adress the specified segment of all digits in the Segmented Control.
    ;#                   Count is (0-6): top, top left, top right, center, bottom left, bottom right, bottom.
    ;#                   To reset text color, use _GUICtrlSegment_SetColor ( $s_seg ).
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetBkColor, _GUICtrlSegment_SetColor, _GUICtrlSegment_SetDigitColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetSegmentColor($s_seg, $s_number, $s_count, $seg_segment_color)
    If $s_count < 0 Or $s_count > 6 Then Return -1
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    If $s_number > $seg_dt_length[$x] Then __CreateDigit($x, $s_number)
    If $s_number > 0 Then Return GUICtrlSetBkColor($seg_lb[$s_count][$x][$s_number - 1], _
            $seg_segment_color)
    For $i = 0 To $seg_dt_length[$x] - 1
        GUICtrlSetBkColor($seg_lb[$s_count][$x][$i], $seg_segment_color)
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetSegmentColor

#EndRegion;--------_GUICtrlSegment_SetSegmentColor
#region;--------_GUICtrlSegment_Read

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Read ( $s_seg )
    ;#  Description....: Reads the text of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns text of the control.
    ;#                   Failure: Returns 0 and sets @error to 1 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: No advanced mode.
    ;#                   Use -1 for $s_seg to adress the last created control.
    ;#                   If last Data was set by _GUICtrlSegment_SetSingleData or _GUICtrlSegment_SetSegmentState, an empty string ("") will be returned.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetData
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Read($s_seg, $adv = 0)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return SetError(1, 0, 0)
    Return $seg_lb_data[$x]
EndFunc   ;==>_GUICtrlSegment_Read

#EndRegion;--------_GUICtrlSegment_Read
#region;--------_GUICtrlSegment_Hide

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Hide ( $s_seg )
    ;#  Description....: Hides a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_Show
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Hide($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUISetState(@SW_HIDE, $seg_gui[$x])
    Return 1
EndFunc   ;==>_GUICtrlSegment_Hide

#EndRegion;--------_GUICtrlSegment_Hide
#region;--------_GUICtrlSegment_Show

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Show ( $s_seg )
    ;#  Description....: Shows a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_Show
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Show($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUISetState(@SW_SHOW, $seg_gui[$x])
    Return 1
EndFunc   ;==>_GUICtrlSegment_Show

#EndRegion;--------_GUICtrlSegment_Show
#region;--------_GUICtrlSegment_GetColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetColor ( $s_seg )
    ;#  Description....: Retrieves the text color a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns RGB color.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetColor, _GUICtrlSegment_GetBkColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetColor($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return $seg_ft_cl[$x]
EndFunc   ;==>_GUICtrlSegment_GetColor

#EndRegion;--------_GUICtrlSegment_GetColor
#region;--------_GUICtrlSegment_GetBkColor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetBkColor ( $s_seg )
    ;#  Description....: Retrieves the background color a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns RGB color.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetBkColor, _GUICtrlSegment_GetColor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetBkColor($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return $seg_bk_cl[$x]
EndFunc   ;==>_GUICtrlSegment_GetBkColor

#EndRegion;--------_GUICtrlSegment_GetBkColor
#region;--------_GUICtrlSegment_GetPos

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetPos ( $s_seg )
    ;#  Description....: Retrieves the position and size of a Segmented Control relative to its window.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns an array containing the size and the control's position relative to it's client window.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   $array[0] = X position
    ;#                   $array[1] = Y position
    ;#                   $array[2] = Width
    ;#                   $array[3] = Height
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetPos, _GUICtrlSegment_Move, __WinGetClientPos
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetPos($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Local $a = WinGetPos($seg_gui[$x]), $b = __WinGetClientPos($seg_hwnd[$x])
    $a[0] = $a[0] - $b[0]
    $a[1] = $a[1] - $b[1]
    Return $a
EndFunc   ;==>_GUICtrlSegment_GetPos

#EndRegion;--------_GUICtrlSegment_GetPos
#region;--------_GUICtrlSegment_SetPos

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetPos ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] )
    ;#  Description....: Moves a Segmented Control within a window.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $x [optional] = X coordinate to move to relative to the window client area.
    ;#                   $y [optional] = Y coordinate to move to relative to the window client area.
    ;#                   $w [optional] = New width of the Segmented Control.
    ;#                   $h [optional] = New height of the Segmented Control.
    ;#                   $s [optional] = Speed to move the Segmented Control in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous.
    ;#                      apparently, speed does not seem to work (no repainting).
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   If you want to leave a parameter unchanged, use "" (Blank string)
    ;#                   For width and height -1 is accepted, too.
    ;#                   apparently, the speed parameter does not work (no repainting).
    ;#                   Same as _GUICtrlSegment_Move.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_GetPos, _GUICtrlSegment_Move, __WinGetClientPos
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetPos($s_seg, $x = "", $y = "", $w = "", $h = "", $s = 0)
    Local $t = __GetSegmentID($s_seg)
    If $t = 0 Then Return
    Local $a = WinGetPos($seg_gui[$t]), $b = __WinGetClientPos($seg_hwnd[$t])
    If String($x) = "" Then $x = $a[0] - $b[0]
    If String($y) = "" Then $y = $a[1] - $b[1]
    If String($w) = "" Or $w < 0 Then $w = $a[2]
    If String($h) = "" Or $h < 0 Then $h = $a[3]
    If $s < 1 Or $s > 100 Then $s = 0;speed not working
    Return WinMove($seg_gui[$t], "", $x, $y, $w, $h);speed not working
EndFunc   ;==>_GUICtrlSegment_SetPos

#EndRegion;--------_GUICtrlSegment_SetPos
#region;--------_GUICtrlSegment_Move

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_Move ( $s_seg [, $x [, $y [, $w  [, $h [, $s]]]]] )
    ;#  Description....: Moves a Segmented Control within a window.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $x [optional] = X coordinate to move to relative to the window client area.
    ;#                   $y [optional] = Y coordinate to move to relative to the window client area.
    ;#                   $w [optional] = New width of the Segmented Control.
    ;#                   $h [optional] = New height of the Segmented Control.
    ;#                   $s [optional] = Speed to move the Segmented Control in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous.
    ;#                      apparently, speed does not seem to work (no repainting).
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   If you want to leave a parameter unchanged, use "" (Blank string)
    ;#                   For width and height -1 is accepted, too.
    ;#                   apparently, the speed parameter does not work (no repainting).
    ;#                   Same as _GUICtrlSegment_GetPos
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_GetPos, _GUICtrlSegment_SetPos, __WinGetClientPos
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_Move($s_seg, $x = "", $y = "", $w = "", $h = "", $s = "")
    Local $t = __GetSegmentID($s_seg)
    If $t = 0 Then Return
    Local $a = WinGetPos($seg_gui[$t]), $b = __WinGetClientPos($seg_hwnd[$t])
    If String($x) = "" Then $x = $a[0] - $b[0]
    If String($y) = "" Then $y = $a[1] - $b[1]
    If String($w) = "" Or $w < 0 Then $w = $a[2]
    If String($h) = "" Or $h < 0 Then $h = $a[3]
    If $s < 1 Or $s > 100 Then $s = 0;speed not working
    Return WinMove($seg_gui[$t], "", $x, $y, $w, $h);speed not working
EndFunc   ;==>_GUICtrlSegment_Move

#EndRegion;--------_GUICtrlSegment_Move
#region;--------_GUICtrlSegment_GetHandle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetHandle ( $s_seg )
    ;#  Description....: Retrieves the internal handle of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns the handle (HWND) value.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   @extended provides a secondary handle. Might be useful if controlID fails.
    ;#  Related........: _GUICtrlSegment_Create
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetHandle($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return SetExtended(WinGetHandle($seg_gui[$x]), _
            ControlGetHandle($seg_gui[$x], "", $seg_hi[$x]))
EndFunc   ;==>_GUICtrlSegment_GetHandle

#EndRegion;--------_GUICtrlSegment_GetHandle
#region;--------_GUICtrlSegment_GetOuterStyle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetOuterStyle ( $s_seg )
    ;#  Description....: Retrieves the "outer" styles of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns a two-element array.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 11.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   $array[0] = Style.
    ;#                   $array[1] = ExStyle.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetOuterStyle
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetOuterStyle($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return GUIGetStyle($seg_gui[$x])
EndFunc   ;==>_GUICtrlSegment_GetOuterStyle

#EndRegion;--------_GUICtrlSegment_GetOuterStyle
#region;--------_GUICtrlSegment_SetOuterStyle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetOuterStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#  Description....: Changes the "outer" styles of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_style [optional] = defines the "outer" style of the Segmented Control See GUI Control Styles Appendix.
    ;#                   $seg_Ex_style [optional] = defines the "outer" extended style of the Segmented Control. See the Extended Style Table.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Use -1 or "" (blank string) to leave $seg_style unchanged.
    ;#                   The "outer" Style corresponds to GUI styles.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetInnerStyle, _GUICtrlSegment_SetSegmentStyle, _GUICtrlSegment_GetOuterStyle
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetOuterStyle($s_seg, $seg_style = -1, $seg_Ex_style = 1)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return GUISetStyle($seg_style, $seg_Ex_style, $seg_gui[$x])
EndFunc   ;==>_GUICtrlSegment_SetOuterStyle

#EndRegion;--------_GUICtrlSegment_SetOuterStyle
#region;--------_GUICtrlSegment_SetInnerStyle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetInnerStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#  Description....: Changes the "inner" styles of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_style [optional] = defines the "inner" style of the Segmented Control See GUI Control Styles Appendix.
    ;#                   $seg_Ex_style [optional] = defines the "inner" extended style of the Segmented Control. See the Extended Style Table.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Use -1 or "" (blank string) to leave $seg_style unchanged.
    ;#                   The "inner" Style corresponds to label/static styles.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetOuterStyle, _GUICtrlSegment_SetSegmentStyle
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetInnerStyle($s_seg, $seg_in_style = -1, $seg_in_Ex_style = -1)
    Local $x = __GetSegmentID($s_seg), $t = $seg_font[$x]
    If $x = 0 Then Return
    _GUICtrlSegment_SetFont($s_seg, $t[0], $t[1], $t[2], $t[3], $t[4], $t[5]); not always necessary, but better correct font
    Return GUICtrlSetStyle($seg_lo[$x], $seg_in_style, $seg_in_Ex_style)
EndFunc   ;==>_GUICtrlSegment_SetInnerStyle

#EndRegion;--------_GUICtrlSegment_SetInnerStyle
#region;--------_GUICtrlSegment_SetSegmentStyle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetSegmentStyle ( $s_seg [, $seg_style [, $seg_Ex_style]] )
    ;#  Description....: Changes the styles of each segment in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_style [optional] = defines the style of all segments in the Segmented Control See GUI Control Styles Appendix.
    ;#                   $seg_Ex_style [optional] = defines the extended style of all segments in the Segmented Control. See the Extended Style Table.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 11.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Use -1 or "" (blank string) to leave $seg_style unchanged.
    ;#  reset
    ;#                   The segment style corresponds to label/static styles.
    ;#                   In fact, there don't seem to be many styles working, however, try it out.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetInnerStyle, _GUICtrlSegment_SetOuterStyle
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetSegmentStyle($s_seg, $seg_style = -1, $seg_Ex_style = -1)
    Local $x = __GetSegmentID($s_seg), $t
    If $x = 0 Then Return
    If $seg_style = -1 Then $seg_style = 0
    If $seg_Ex_style = -1 Then $seg_Ex_style = 0
    For $j = 0 To $seg_dt_length[$x] - 1
        For $i = 0 To 6
            $t = GUICtrlGetState($seg_lb[$i][$x][$j])
            GUICtrlSetStyle($seg_lb[$i][$x][$j], $seg_style, $seg_Ex_style)
            GUICtrlSetState($seg_lb[$i][$x][$j], $t)
        Next
    Next
    $seg_seg_Ex_style[$x] = $seg_Ex_style
    $seg_seg_style[$x] = $seg_style
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetSegmentStyle

#EndRegion;--------_GUICtrlSegment_SetSegmentStyle
#region;--------_GUICtrlSegment_SetSingleSegmentStyle

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetSingleSegmentStyle ( $s_seg, $s_number, $s_count [, $seg_style [, $seg_Ex_style]] )
    ;#  Description....: Changes the styles of a single segment in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_number = The number (count from left = 1) of the digit to be applied to.
    ;#                   $s_count = The segment number (count from top=0 to bottom=6 and from left to right) of the digit to be applied to.
    ;#                   $seg_style [optional] = defines the style of all segments in the Segmented Control See GUI Control Styles Appendix.
    ;#                   $seg_Ex_style [optional] = defines the extended style of all segments in the Segmented Control. See the Extended Style Table.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#                            Returns -1 if $s_count is out of range.
    ;#  Author ........: jennico
    ;#  Date ..........: 19.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Use value < 1 for $s_number if you want to adress the specified segment of all digits in the Segmented Control.
    ;#                   Count is (0-6): top, top left, top right, center, bottom left, bottom right, bottom.
    ;#                   Use -1 or "" (blank string) to leave $seg_style unchanged.
    ;#                   The segment style corresponds to label/static styles.
    ;#                   In fact, there don't seem to be many styles working, however, try it out.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetInnerStyle, _GUICtrlSegment_SetOuterStyle
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetSingleSegmentStyle($s_seg, $s_number, $s_count, $seg_style = -1, _
        $seg_Ex_style = -1)
    If $s_count < 0 Or $s_count > 6 Then Return -1
    Local $x = __GetSegmentID($s_seg), $s_min = $s_number - 1, $s_max = $s_number - 1, $t
    If $x = 0 Then Return
    If $seg_style = -1 Then $seg_style = 0
    If $seg_Ex_style = -1 Then $seg_Ex_style = 0
    If $s_number > $seg_dt_length[$x] Then __CreateDigit($x, $s_number)
    If $s_number < 1 Then Dim $s_min = 0, $s_max = $seg_dt_length[$x] - 1
    For $i = $s_min To $s_max
        $t = GUICtrlGetState($seg_lb[$s_count][$x][$i])
        GUICtrlSetStyle($seg_lb[$s_count][$x][$i], $seg_style, $seg_Ex_style)
        GUICtrlSetState($seg_lb[$s_count][$x][$i], $t)
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetSingleSegmentStyle

#EndRegion;--------_GUICtrlSegment_SetSingleSegmentStyle
#region;--------_GUICtrlSegment_SetSegmentState

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetSegmentState ( $s_seg, $s_number, $s_count, $s_state )
    ;#  Description....: Hides or Shows a single segment of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_number = The number (count from left = 1) of the digit to be applied to.
    ;#                   $s_count = The segment number (count from top=0 to bottom=6 and from left to right) of the digit to be applied to.
    ;#                   $s_state = See the State table below.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#                            Returns -1 if $s_count is out of range.
    ;#                            Returns -2 if $s_state is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 19.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   1 or $GUI_SHOW : Control will be visible.
    ;#                   0 or $GUI_HIDE : Control will not be visible.
    ;#                   Use value < 1 for $s_number if you want to adress the specified segment of all digits in the Segmented Control.
    ;#                   Count is (0-6): top, top left, top right, center, bottom left, bottom right, bottom.
    ;#                   Data can not be read by _GUICtrlSegment_Read.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_GetState, _GUICtrlSegment_Hide, _GUICtrlSegment_Show
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetSegmentState($s_seg, $s_number, $s_count, $s_state)
    If $s_count < 0 Or $s_count > 6 Then Return -1
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    If $s_state = 0 Or $s_state = 1 Then $s_state = 16 * Abs($s_state - 2)
    If $s_state <> 16 And $s_state <> 32 Then Return -2
    If $s_number > $seg_dt_length[$x] Then __CreateDigit($x, $s_number)
    $seg_lb_data[$x] = ""
    If $s_number > 0 Then Return GUICtrlSetState($seg_lb[$s_count][$x][$s_number - 1], $s_state)
    For $i = 0 To $seg_dt_length[$x] - 1
        GUICtrlSetState($seg_lb[$s_count][$x][$i], $s_state)
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetSegmentState

#EndRegion;--------_GUICtrlSegment_SetSegmentState
#region;--------_GUICtrlSegment_SetState

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetState ( $s_seg, $s_state )
    ;#  Description....: Changes the state of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_state = See the State table below.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   $GUI_SHOW Control will be visible.
    ;#                   $GUI_HIDE Control will not be visible.
    ;#                   $GUI_ENABLE Control will be enabled.
    ;#                   $GUI_DISABLE Control will be disabled.
    ;#                   $GUI_FOCUS Control will be given focus.
    ;#                   $GUI_ONTOP Control will be have the ontop attribute for the window (zOrdering).
    ;#                   State values can be summed up as for example $GUI_DISABLE + $GUI_HIDE sets the control in an disabled and hidden state.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_GetState, _GUICtrlSegment_Hide, _GUICtrlSegment_Show
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetState($s_seg, $s_state)
    Local $x = __GetSegmentID($s_seg), $t = __Binary($s_state)
    If $x = 0 Then Return
    If StringMid($t, 5, 1) = "1"  Then GUISetState(@SW_SHOW, $seg_gui[$x])
    If StringMid($t, 6, 1) = "1"  Then GUISetState(@SW_HIDE, $seg_gui[$x])
    If StringMid($t, 7, 1) = "1"  Then GUISetState(@SW_ENABLE, $seg_gui[$x])
    If StringMid($t, 8, 1) = "1"  Then GUISetState(@SW_DISABLE, $seg_gui[$x])
    If StringMid($t, 9, 1) = "1"  Then WinActivate($seg_gui[$x])
    If StringMid($t, 14, 1) = "1"  Then WinSetOnTop($seg_gui[$x], "", 1)
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetState

#EndRegion;--------_GUICtrlSegment_SetState
#region;--------_GUICtrlSegment_GetState

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetState ( $s_seg )
    ;#  Description....: Gets the current state of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns the state. See GUICtrlSetState for values.
    ;#                   Failure: Returns -1 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   This function returns ONLY the state of a control enabled/disabled/hidden/show.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetState
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetState($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return -1
    Local $t = __Binary(WinGetState($seg_gui[$x]))
    Return 80 + 16 * ((StringMid($t, 2, 1) = 0) + 2 * (StringMid($t, 3, 1) = 0))
EndFunc   ;==>_GUICtrlSegment_GetState

#EndRegion;--------_GUICtrlSegment_SetState
#region;--------_GUICtrlSegment_SetFont

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetFont ( $s_seg [, $x [, $y [, $z [, $s [, $a [, $b]]]]]] )
    ;#  Description....: Sets the segment dimensions in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $x [optional] = The length of a segment (Pixel).
    ;#                   $y [optional] = The width of a segment (Pixel).
    ;#                   $z [optional] = The free space between two segments (Pixel). If negastive or 0, segments will be "melted".
    ;#                   $s [optional] = Spacing, the space between two segmented groups / digits (Pixel). Can be negative.
    ;#                   $a [optional] = The distance of the first segment group / digit to the left label border (Pixel). Can be negative.
    ;#                   $b [optional] = The distance to the top label border (Pixel). Can be negative.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   To leave one parameter unchanged, use "" (blank string).
    ;#                   For length and width, values below 0 will do the same.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_GetFont
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetFont($s_seg, $x = "", $y = "", $z = "", $s = "", $a = "", $b = "")
    Local $t = __GetSegmentID($s_seg), $c = $seg_font[$t]
    If $t = 0 Then Return
    If String($x) = "" Or $x < 0 Then $x = $c[0]
    If String($y) = "" Or $x < 0 Then $y = $c[1]
    If String($z) = "" Then $z = $c[2]
    If String($s) = "" Then $s = $c[3]
    If String($a) = "" Then $a = $c[4]
    If String($b) = "" Then $b = $c[5]
    $seg_font[$t] = __SetSegmentPos($x, $y, $z, $s, $a, $b)
    For $j = 0 To $seg_dt_length[$t] - 1
        For $i = 0 To 6
            ControlMove($seg_gui[$t], "", $seg_lb[$i][$t][$j], $j * $seg_dist + _
                    $seg_pos[$i][0], $seg_pos[$i][1], $seg_pos[$i][2], $seg_pos[$i][3])
            GUICtrlSetResizing($seg_lb[$i][$t][$j], 802)
        Next
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetFont

#EndRegion;--------_GUICtrlSegment_SetFont
#region;--------_GUICtrlSegment_GetFont

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_GetFont ( $s_seg )
    ;#  Description....: Gets the segment dimensions in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#  Return Value ..: Success: Returns a 6 element array containing segment dimensions.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Array[0] = The length of a segment (Pixel).
    ;#                   Array[1] = The width of a segment (Pixel).
    ;#                   Array[2] = The free space between two segments (Pixel).
    ;#                   Array[3] = Spacing, the space between two segmented groups (Pixel).
    ;#                   Array[4] = The distance of the group to the left label border (Pixel).
    ;#                   Array[5] = The distance to the top label border (Pixel).
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetFont
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_GetFont($s_seg)
    Local $x = __GetSegmentID($s_seg)
    If $x > 0 Then Return $seg_font[$x]
EndFunc   ;==>_GUICtrlSegment_GetFont

#EndRegion;--------_GUICtrlSegment_GetFont
#region;--------_GUICtrlSegment_SetCursor

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetCursor ( $s_seg, $cursor )
    ;#  Description....: Sets the mouse cursor icon for the Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $cursor = cursor ID as used by Windows SetCursor API (use -1 for the default mouse cursor for the control).
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   For a list of valid cursor IDs see MouseGetCursor.
    ;#                   CursorId = 16 will hide the mouse cursor.
    ;#                   Usually GUICtrlSetCursor will work equally, if you specify the Control-ID.
    ;#  Related........: _GUICtrlSegment_Create, MouseGetCursor, GUICtrlSetCursor
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetCursor($s_seg, $cursor)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUISetCursor($cursor, 1, $seg_gui[$x])
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetCursor

#EndRegion;--------_GUICtrlSegment_SetCursor
#region;--------_GUICtrlSegment_SetTip

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetTip ( $s_seg, $txt [, $title [, $icon [, $options]]] )
    ;#  Description....: Sets the tip text associated with a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $txt = Tip text that will be displayed when the mouse is hovered over the control.
    ;#                   $title [optional] = The title for the tooltip.
    ;#                   $icon [optional] = Pre-defined icon to show next to the title. Requires a title. 0 = No icon, 1 = Info icon, 2 = Warning icon, 3 = Error Icon.
    ;#                   $options [optional] = Sets different options for how the tooltip will be displayed (Can be added together): 1 = Display as Balloon Tip. 2 = Center the tip horizontally along the control.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   To skip an optional parameter, leaving it's default value intact, use the Default keyword..
    ;#                   Usually GUICtrlSetTip  will work equally, if you specify the Control-ID.
    ;#  Related........: _GUICtrlSegment_Create, GUICtrlSetTip
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetTip($s_seg, $txt, $title = "", $icon = 0, $options = "")
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    GUICtrlSetTip($seg_hi[$x], $txt, $title, $icon, $options)
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetTip

#EndRegion;--------_GUICtrlSegment_SetTip
#region;--------_GUICtrlSegment_SetTrans

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetTrans ( $s_seg, $trans )
    ;#  Description....: Sets the transparency of a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $trans = A number in the range 0 - 255. The lower the number, the more transparent the window will become. 255 = Solid, 0 = Invisible.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   Unfortunately, this function does not work.
    ;#  Related........: _GUICtrlSegment_Create
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetTrans($s_seg, $trans); geht nicht
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    Return WinSetTrans($seg_gui[$x], "", $trans)
EndFunc   ;==>_GUICtrlSegment_SetTrans

#EndRegion;--------_GUICtrlSegment_SetTrans
#region;--------_GUICtrlSegment_SetData

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetData ( $s_seg, $seg_data )
    ;#  Description....: Sets the text for a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $seg_data = Text / Data for the control.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 20.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   If necessary, you have to reactivate the parent GUI by GUISwitch.
    ;#                   The Segmented Control natively is designed to display digits from 0-9.
    ;#                   Anyway, some letters can be displayed:
    ;#                   ABC EFGHIJ L  OP  S U   Y
    ;#                    bcd   hi  l  o    tu
    ;#                   Punctuation is not supported.
    ;#                   Only one line of text is displayed.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_Read, _GUICtrlSegment_AlignRight, _GUICtrlSegment_SetSingleData
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetData($s_seg, $seg_data)
    Local $x = __GetSegmentID($s_seg), $y
    If $x = 0 Then Return
    $seg_lb_data[$x] = $seg_data
    If $seg_align[$x] > 0 Then $seg_data = String(StringFormat("%" & _
            $seg_align[$x] & "s", $seg_data))
    Local $l = StringLen($seg_data)
    If $l > $seg_dt_length[$x] Then __CreateDigit($x, $l)
    For $j = 0 To $seg_dt_length[$x] - 1
        If $seg_data And $l > $j Then
            $y = Asc(StringMid($seg_data, $j + 1, 1))
            If $y > 47 And $y < 118 Then
                For $i = 0 To 6
                    GUICtrlSetState($seg_lb[$i][$x][$j], (StringMid($seg_digits[$y - 48], _
                            $i + 1, 1) + 1) * 16)
                Next
                ContinueLoop
            EndIf
        EndIf
        For $i = 0 To 6
            GUICtrlSetState($seg_lb[$i][$x][$j], 32)
        Next
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetData

#EndRegion;--------_GUICtrlSegment_SetData
#region;--------_GUICtrlSegment_SetSingleData

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_SetSingleData ( $s_seg, $s_number, $seg_data )
    ;#  Description....: Sets the data (one char) for a single digit in a Segmented Control.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_number = The number (count from left = 1) of the digit to be applied to.
    ;#                   $seg_data = Data (one char) for the specified digit of the Segmented Control.
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#                            Returns -1 if $s_number is < 1.
    ;#  Author ........: jennico
    ;#  Date ..........: 20.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   If necessary, you have to reactivate the parent GUI by GUISwitch.
    ;#                   The Segmented Control natively is designed to display digits from 0-9.
    ;#                   Anyway, some letters can be displayed:
    ;#                   ABC EFGHIJ L  OP  S U   Y
    ;#                    bcd   hi  l  o    tu
    ;#                   Punctuation is not supported.
    ;#                   If $seg_data contains more than one char, only the first will be set.
    ;#                   Data can not be read by _GUICtrlSegment_Read.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_Read, _GUICtrlSegment_AlignRight, _GUICtrlSegment_SetData
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_SetSingleData($s_seg, $s_number, $seg_data)
    If $s_number < 1 Then Return -1
    Local $x = __GetSegmentID($s_seg), $y
    If $x = 0 Then Return
    $seg_lb_data[$x] = ""
    If $s_number > $seg_dt_length[$x] Then __CreateDigit($x, $s_number)
    $y = Asc(StringLeft($seg_data, 1))
    For $i = 0 To 6
        GUICtrlSetState($seg_lb[$i][$x][$s_number - 1], 32)
        If $y > 47 And $y < 118 And StringMid($seg_digits[$y - 48], $i + 1, 1) = "0"  Then _
                GUICtrlSetState($seg_lb[$i][$x][$s_number - 1], 16)
    Next
    Return 1
EndFunc   ;==>_GUICtrlSegment_SetSingleData

#EndRegion;--------_GUICtrlSegment_SetSingleData
#region;--------_GUICtrlSegment_AlignRight

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _GUICtrlSegment_AlignRight ( $s_seg [, $s_count] )
    ;#  Description....: Sets a Segmented Control to right align mode to the specified places.
    ;#  Parameters.....: $s_seg = The Control-ID returned by a previous _GUICtrlSegment_Create call.
    ;#                   $s_count = Number of places the passed text will be right justified to (space padded).
    ;#  Return Value ..: Success: Returns 1.
    ;#                   Failure: Returns 0 if Control-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: Use -1 for $s_seg to adress the last created control.
    ;#                   When switched to right align mode, all text passed to the control will be right justified to the specified count of places.
    ;#                   To return to the normal mode, specify $count to < 1 or "" (blank string) or just don't define it.
    ;#  Related........: _GUICtrlSegment_Create, _GUICtrlSegment_SetData
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _GUICtrlSegment_AlignRight($s_seg, $s_count = 0)
    Local $x = __GetSegmentID($s_seg)
    If $x = 0 Then Return
    $seg_align[$x] = $s_count
    Return 1
EndFunc   ;==>_GUICtrlSegment_AlignRight

#EndRegion;--------_GUICtrlSegment_AlignRight
#EndRegion;--------------------------Main Functions
#Region;--------------------------Internal Functions

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __GetSegmentID ( $x )
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __GetSegmentID($x)
    If $x < 0 Then Return $seg_cnt
    If $x < 1 Then Return
    For $i = 1 To $seg_cnt
        If $seg_hi[$i] = $x Then Return $i
    Next
EndFunc   ;==>__GetSegmentID

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __CreateDigit ( $x, $l )
    ;#  Author ........: jennico
    ;#  Date ..........: 20.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __CreateDigit($x, $l)
    If $l > $seg_max_length Then $seg_max_length = $l
    ReDim $seg_lb[7][$seg_cnt + 1][$seg_max_length]
    GUISwitch($seg_gui[$x])
    For $j = $seg_dt_length[$x] To $l - 1
        For $i = 0 To 6
            $seg_lb[$i][$x][$j] = GUICtrlCreateLabel("", $j * $seg_dist + $seg_pos[$i][0], _
                    $seg_pos[$i][1], $seg_pos[$i][2], $seg_pos[$i][3], $seg_seg_style[$x], _
                    $seg_seg_Ex_style[$x])
            GUICtrlSetBkColor($seg_lb[$i][$x][$j], $seg_ft_cl[$x])
            GUICtrlSetResizing(-1, 802)
            GUICtrlSetState(-1, 160)
        Next
    Next
    $seg_dt_length[$x] = $l
    GUISwitch($seg_hwnd[$x])
EndFunc   ;==>__CreateDigit

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __SetSegmentPos ( [$x [, $y [, $z [, $s [, $a [, $b ]]]]]] )
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __SetSegmentPos($x = 12, $y = 2, $z = 1, $s = 5, $a = 10, $b = 10)
    Dim $seg_pos[7][4] = [[$a + $y + $z, $b, $x, $y], [$a, $b + $y + $z, $y, $x], _
            [$a + $x + $y + 2 * $z, $b + $y + $z, $y, $x], [$a + $y + $z, $b + _
            $x + $y + 2 * $z, $x, $y], [$a, $b + $x + 2 * $y + 3 * $z, $y, $x], _
            [$a + $x + $y + 2 * $z, $b + $x + 2 * $y + 3 * $z, $y, $x], _
            [$a + $y + $z, $b + 2 * ($x + $y + 2 * $z), $x, $y]]
    $seg_dist = $x + 2 * $y + 2 * $z + $s
    Local $t[6] = [$x, $y, $z, $s, $a, $b]
    Return $t
EndFunc   ;==>__SetSegmentPos

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __Binary ( $s_number )
    ;#  Author ........: jennico
    ;#  Date ..........: 10.11.08
    ;#  Remarks .......: internal use only, taken from _Primes.au3
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __Binary($s_number)
    Local $b, $t, $max = Int(Log($s_number) / Log(2)) + 1
    For $i = $max To 0 Step - 1
        $t = 2 ^ $i
        If $s_number < $t Then
            $b = "0" & $b
            ContinueLoop
        EndIf
        $b = "1" & $b
        $s_number -= $t
    Next
    If $b = "" Then $b = "0" 
    Return $b
EndFunc   ;==>__Binary

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __WinGetClientPos ( $hWnd [, $s_text] )
    ;#  Description....: Retrieves the position and size of a given window's client area.
    ;#  Parameters.....: $hWnd : The title of the window to read. See Title special definition.
    ;#                   $s_text :    [optional] The text of the window to read.
    ;#  Return Value ..: Success:   Returns a 4-element array containing the following information:
    ;#                   $array[0] = X position (absolute screen coordinates)
    ;#                   $array[1] = Y position (absolute screen coordinates)
    ;#                   $array[2] = Width
    ;#                   $array[3] = Height
    ;#                   Failure:   Returns 0 and sets @error to 1 if windows is not found.
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#  Date ..........: 14.10.08
    ;#  Remarks .......: _WinGetClientPos returns negative numbers such as -32000 for minimized windows, but works fine with
    ;#                   (non-minimized) hidden windows. If multiple windows match the criteria, the most recently active window is used.
    ;#                   taken from _Borders.au3
    ;#  Related .......: _WinGetBorderSize, WinGetPos, WinGetClientSize, WinMove
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func __WinGetClientPos($hwnd, $s_text = "")
    Local $s_pos = WinGetPos($hwnd, $s_text)
    If @error Then Return SetError(1, 0, 0)
    Local $s_size = WinGetClientSize($hwnd, $s_text)
    If @error Then Return SetError(1, 0, 0)
    Local $s_temp = ($s_pos[2] - $s_size[0]) / 2, $ret[4] = [$s_pos[0] + $s_temp, _
            $s_pos[1] + $s_pos[3] - $s_size[1] - $s_temp, $s_size[0], $s_size[1]]
    Return $ret
EndFunc   ;==>__WinGetClientPos

For $i = 0 To UBound($seg_digits) - 1
    If $seg_digits[$i] = "" Then $seg_digits[$i] = "1111111" 
Next
#EndRegion;--------------------------Internal Functions

have fun

j.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

updated for v1.1, too

the example script: _GUICtrlSegmentExample.au3

#cs
    ;#=#INDEX#===================================================#
    ;#  Title .........: _GUICtrlSegmentExample.au3
    ;#  Description ...: Example Script for _GUICtrlSegment UDF v1.1
    ;#  Date ..........: 20.11.08
    ;#  Version .......: 1.1
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#===========================================================#
#ce
#Include <_GUICtrlSegment.au3>
$gui=GUICreate(" Segmented Control Example")
$label=_GUICtrlSegment_Create($gui,"AutoIt3",20,50,300,100,0x00040000,0x00000001);,-1,-1,7)
    _GUICtrlSegment_SetBkColor(-1,0xFFFFFF)
    _GUICtrlSegment_SetColor($label,0xF20000)
    _GUICtrlSegment_SetCursor(-1,0)
    _GUICtrlSegment_SetTip(-1,"Hallo")
GUISetState(@SW_SHOW,$gui)
$t=_GUICtrlSegment_GetFont(-1)
MsgBox(0,$t[0],$t[1])
_GUICtrlSegment_SetTrans($label,0); trans not working
_GUICtrlSegment_SetFont(-1,30,6)
Sleep(1000)
For $z=0 To 400
    For $i=1 To 6
        For $j=0 To 6
            _GUICtrlSegment_SetSegmentColor(-1,$i,$j,Random(1,0xFFFFFF,1))
        Next
    Next
Next
Sleep(1000)
_GUICtrlSegment_SetColor(-1)
For $z=0 To 25
    For $j=0 To 6
        _GUICtrlSegment_SetSegmentColor(-1,-1,$j,0xF20000-$z*10)
        Sleep(50)
    Next
Next
For $z=0 To 25
    For $j=0 To 6
        _GUICtrlSegment_SetSegmentColor(-1,-1,$j,0xF20000+$z*10)
        Sleep(55)
    Next
Next
For $z=0 To 20
    For $j=0 To 6
        $f=$z*60
        _GUICtrlSegment_SetSegmentColor(-1,-1,$j,$f)
        If $j=1 Or $j=4 Then
            $j+=1
            _GUICtrlSegment_SetSegmentColor(-1,-1,$j,$f)
        EndIf
        Sleep(100)
    Next
Next
_GUICtrlSegment_SetColor(-1)
_GUICtrlSegment_SetSegmentStyle(-1,7)
For $i=1 To 50
    Sleep(100)
    _GUICtrlSegment_Move(-1,20+$i,50+$i,-1,-1);,50);speed not working
Next
_GUICtrlSegment_SetSegmentStyle(-1)
For $i=1 To 50
    Sleep(100)
    _GUICtrlSegment_Move(-1,"","",300-$i,100-$i);,50);speed not working
Next
_GUICtrlSegment_SetPos(-1,20,50,300,100);,50);speed not working
_GUICtrlSegment_SetFont(-1,"","",-2)
$t=_GUICtrlSegment_Getpos(-1)
MsgBox(0,$t[0]&" "&$t[1],$t[2]&" "&$t[3])
_GUICtrlSegment_SetSegmentStyle(-1,7)
MsgBox(0,"style","")
_GUICtrlSegment_SetData(-1,"")
Sleep(1000)
_GUICtrlSegment_SetSegmentStyle(-1)
_GUICtrlSegment_SetBkColor(-1,0xF20000)
Sleep(1000)
_GUICtrlSegment_SetColor(-1,0)
For $j=1 To 15
    $z=Mod($j,2)*3
    _GUICtrlSegment_SetSegmentState(-1,1,4,1)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,1,6,0)
        Sleep(20)
    If $z=0 Then
        _GUICtrlSegment_SetSegmentState(-1,1,1,1)
        Sleep(20)
    EndIf
    _GUICtrlSegment_SetSegmentState(-1,1,4,0)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,1,$z,1)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,1,1,0)
        If $z=0 Then Sleep(20)
    For $i=1 To 5
        _GUICtrlSegment_SetSegmentState(-1,$i+1,$z,1)
        Sleep(20)
        _GUICtrlSegment_SetSegmentState(-1,$i,$z,0)
        Sleep(20)
    Next
    If $z=0 Then
        _GUICtrlSegment_SetSegmentState(-1,6,2,1)
        Sleep(20)
    EndIf
    _GUICtrlSegment_SetSegmentState(-1,6,$z,0)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,6,5,1)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,6,2,0)
        If $z=0 Then Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,6,6,1)
        Sleep(20)
    _GUICtrlSegment_SetSegmentState(-1,6,5,0)
        Sleep(20)
    For $i=5 To 1 Step -1
        _GUICtrlSegment_SetSegmentState(-1,$i,6,1)
        Sleep(20)
        _GUICtrlSegment_SetSegmentState(-1,$i+1,6,0)
        Sleep(20)
    Next
Next
$y=6
For $h=1 To 6
    For $i=1 To 2
        For $j=1 To 8
            $z=StringMid("32013564",$j,1)
            _GUICtrlSegment_SetSegmentState(-1,$h,$z,1)
            _GUICtrlSegment_SetSegmentState(-1,$h,$y,0)
            $y=$z
            Sleep(100)
        Next
    Next
    _GUICtrlSegment_SetSingleData(-1,$h,StringMid("AutoIt",$h,1))
Next
_GUICtrlSegment_SetSingleData(-1,7,3)
Sleep(3000)
_GUICtrlSegment_SetData(-1,"")
For $i=1 To 20
    _GUICtrlSegment_SetSegmentState(-1,Random(1,6,1),Random(0,6,1),1)
    Sleep(30)
Next
For $j=5 To 6
    For $i=0 To 6
        _GUICtrlSegment_SetSingleSegmentStyle(-1,$j,$i,7)
    Next
Next
_GUICtrlSegment_SetData(-1,"AutoIt3")
Sleep(3000)
_GUICtrlSegment_SetData(-1,"")
_GUICtrlSegment_SetSegmentStyle(-1)
For $i=0 To 9
    Sleep(1000)
    _GUICtrlSegment_SetData(-1,$i*$i*$i)
Next
Sleep(2000)
_GUICtrlSegment_SetFont(-1,30,6,1)
Sleep(2000)
_GUICtrlSegment_AlignRight(-1,5)
_GUICtrlSegment_SetPos(-1,20,50,306,110)
_GUICtrlSegment_SetInnerStyle($label,0x07,0x09)
$t=_GUICtrlSegment_Getpos(-1)
MsgBox(0,$t[0]&" "&$t[1],$t[2]&" "&$t[3])
For $i=0 To 1009
    _GUICtrlSegment_SetData(-1,$i)
Next    
_GUICtrlSegment_SetInnerStyle($label,0,0)
Sleep(2000)
_GUICtrlSegment_SetState(-1,32)
MsgBox(0,"state",_GUICtrlSegment_GetState(-1))
_GUICtrlSegment_SetState(-1,16)
_GUICtrlSegment_AlignRight(-1)
MsgBox(0,"state",_GUICtrlSegment_GetState(-1))
_GUICtrlSegment_SetData(-1,_GUICtrlSegment_Read($label))
MsgBox(0,"",_GUICtrlSegment_Read($label))
_GUICtrlSegment_SetTip(-1,"Click me now")
_GUICtrlSegment_SetData(-1,"AutoIt")
$pos1=WinGetPos($gui)
$pos2=_GUICtrlSegment_Getpos(-1)
ToolTip("Click me now !",$pos1[0]+$pos2[0]+$pos2[2]-20,$pos1[1]+$pos2[1]+$pos2[3]-20,"",2,5)
Do
    $msg=GUIGetMsg()
    If $msg=$label Then
        ToolTip("")
        _GUICtrlSegment_SetData($label,InputBox("",""))
    EndIf
Until $msg=-3
_GUICtrlSegment_Delete($label)
Sleep(500)
Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

the alarm clock: the second version now comes with automatic Internet Time Sync (from here).

the v 1.3 improved, some bugs fixed, one ip adress not working exchanged and with beautiful modern traymenu.

you will need this wonderful UDF: ModernMenuRaw.au3 (credits to ProgAndy)

from this post (credits to Holger)

enjoy !

Edit 25.11.08: two stupid bugs fixed, sorry.

TimeSyncAlarmClock.au3

[autoit]#cs

;#=#INDEX#===================================================#

;# Title .........: TimeSyncAlarmClock.au3

;# Description ...: Example Script for _GUICtrlSegment UDF

;# Simple Alarm Clock with segmented digits

;# And Internet Time Synchronization

;# And Modern Tray Menu

;# Date ..........: 23.11.08

;# Version .......: 1.3

;# Author ........: jennico (jennicoattminusonlinedotde)

;#

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

thx. working fine ?

there might be problems with the icons, i don't know if the dlls are the same on every pc.

Edited by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

thx. working fine ?

there might be problems with the icons, i don't know if the dlls are the same on every pc.

Yes, has not crashed on me, no syntax errors, will keep looking :mellow:

Your clock examples looks like this on my PC (Windows XP SP2 Media Edition 2007)

Posted Image

The icon in the tray is a Clock.

Edited by mrRevoked
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

i was feeling that i needed an alarm clock in my laptop since i always fall asleep over it .... and i forgot important things like going to work.... :mellow:

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

once again i updated the alarm clock code. the time sync had a tendency to hang up and return error codes. now, the good old fashioned way is much better.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Link to comment
Share on other sites

updated to v1,1 UDF and Example script

new functions:

_GUICtrlSegment_SetDigitColor ( $s_seg, $s_number, $seg_digit_color ) Sets the text color for a single digit in a Segmented Control.
    _GUICtrlSegment_SetSegmentColor ( $s_seg, $s_number, $s_count, $seg_segment_color ) Sets the text color for a single segment of a digit in a Segmented Control.
    _GUICtrlSegment_SetSingleSegmentStyle ( $s_seg, $s_number, $s_count [, $seg_style [, $seg_Ex_style]] ) Changes the styles of a single segment in a Segmented Control.
    _GUICtrlSegment_SetSegmentState ( $s_seg, $s_number, $s_count, $s_state ) Hides or Shows a single segment of a Segmented Control.
    _GUICtrlSegment_SetSingleData ( $s_seg, $s_number, $seg_data ) Sets the data (one char) for a single digit in a Segmented Control.

j.

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

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