Function Reference

首页  后退  前进

GUICtrlCreateSlider

 

创建滑动条(Slider)控件.

 

GUICtrlCreateSlider ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

参数

left

控件左侧的位置. 若此值为 -1, 则根据 GUICoordMode() 的设置计算左侧位置.

top

控件上方的位置. 若此值为 -1, 则根据 GUICoordMode() 的设置计算顶部位置.

width

[可选] 控件的宽度(默认使用先前的宽度).

height

[可选] 控件的高度(默认使用先前的高度).

style

[可选] 控件的样式. 查看附录 GUI 控件样式表.

默认样式 (-1) : $TBS_AUTOTICKS

exStyle

[可选] 控件的扩展样式. 查看附录 扩展样式表.

返回值

成功:

返回控件标识符(控件ID).

失败:

返回 0.

备注

要获得控件的值, 查看 GUICtrlRead().

设置或者修改控件信息, 参考 GUICtrlUpdate...() 控件更新控件更新类函数.

 

要更新滑动条位置, 使用 GUICtrlSetData().

要设置调节范围的最小/最大值请使用 GUICtrlSetLimit().

 

要在默认样式上添加新样式, 可使用 BitOR($GUI_SS_DEFAULT_SLIDER, 新样式,...) 语句.

使用上面列出的值必须将 #include <SliderConstants.au3> 语句写入脚本中.

 

默认大小 $GUI_DOCKAUTO 出现的大小和位置.

相关

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlUpdate..., GUIGetMsg

函数示例

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
    GUICreate("slider", 220, 100, 100, 200)
    GUISetBkColor(0x00E0FFFF) ; will change background color
    Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20)
    GUICtrlSetLimit(-1, 200, 0) ; change min/max value
    Local $idButton = GUICtrlCreateButton("Value?", 75, 70, 70, 20)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idSlider1, 45) ; set cursor
    Local $idMsg
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idButton Then
            MsgBox($MB_SYSTEMMODAL, "slider1", GUICtrlRead($idSlider1), 2)
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

----------------------------------------