Function Reference


Create a Slider control

#include <GuiSlider.au3>
_GUICtrlSlider_Create ( $hWnd, $iX, $iY [, $iWidth = 100 [, $iHeight = 20 [, $iStyle = $TBS_AUTOTICKS [, $iExStyle = 0x00000000]]]] )


$hWnd Handle to parent or owner window
$iX Horizontal position of the control
$iY Vertical position of the control
$iWidth [optional] Control width
$iHeight [optional] Control height
$iStyle [optional] Control style:
    $TBS_AUTOTICKS - Adds tick marks when you set the range on the slider by using the TBM_SETRANGE message
    $TBS_BOTH - Places ticks on both sides of the slider
    $TBS_BOTTOM - Places ticks on the bottom of a horizontal slider
    $TBS_DOWNISLEFT - Down equal left and up equal right
    $TBS_ENABLESELRANGE - The tick marks at the starting and ending positions of a selection range are displayed as triangles
        (instead of vertical dashes), and the selection range is highlighted.
    $TBS_FIXEDLENGTH - allows the size of the slider to be changed with the $TBM_SETTHUMBLENGTH message
    $TBS_HORZ - Specifies a horizontal slider. This is the default
    $TBS_LEFT - Places ticks on the left side of a vertical slider
    $TBS_NOTHUMB - Specifies that the slider has no slider
    $TBS_NOTICKS - Specifies that no ticks are placed on the slider
    $TBS_REVERSED - Smaller number indicates "higher" and a larger number indicates "lower"
    $TBS_RIGHT - Places ticks on the right side of a vertical slider
    $TBS_TOP - Places ticks on the top of a horizontal slider
    $TBS_TOOLTIPS - Creates a default ToolTip control that displays the slider's current position
    $TBS_VERT - Creates a vertical slider

$iExStyle [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: the handle to the slider control.
Failure: 0


This function is for Advanced users and for learning how the control works.




#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <WindowsConstants.au3>

Global $g_hSlider


Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Slider Create", 400, 296)
    $g_hSlider = _GUICtrlSlider_Create($hGUI, 2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndSlider
    $hWndSlider = $g_hSlider
    If Not IsHWnd($g_hSlider) Then $hWndSlider = GUICtrlGetHandle($g_hSlider)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndSlider
            Switch $iCode
                Case $NM_RELEASEDCAPTURE ; The control is releasing mouse capture
                    _DebugPrint("$NM_RELEASEDCAPTURE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint