函数参考


_GUIScrollBars_SetScrollRange

设置滚动条的最小和最大位置

#Include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollRange($hWnd, $nBar, $nMinPos, $nMaxPos)

参数

$hWnd 窗口句柄
$nBar 指定滚动控件的类型. 参数可以是以下值之一:
$SB_CTL - 设置滚动条范围. $hWnd 参数值必须是滚动控件的窗口句柄.
$SB_HORZ - 设置窗口标准水平滚动条范围.
$SB_VERT - 设置窗口标准垂直滚动条范围.
$nMinPos 指定最小滚动位置
$nMaxPos 指定最大滚动位置

返回值

成功: 返回 True
失败: 返回 False

注意/说明

 以上常数需要 ScrollBarConstants.au3

相关

_GUIScrollBars_SetScrollInfoMin, _GUIScrollBars_SetScrollInfoMax, _GUIScrollBars_GetScrollRange

详情参考

在MSDN中搜索


示例/演示


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>

Global $iMemo

_Main()

Func _Main()
    Local $GUIMsg, $hGUI, $RangeMinMax

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $iMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($iMemo, $GUI_DOCKALL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState()

    _GUIScrollBars_Init($hGUI)

    $RangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("Vertical Min/Max: " & $RangeMinMax[0] & "/" & $RangeMinMax[1])
    $RangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("Horizontal Min/Max: " & $RangeMinMax[0] & "/" & $RangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 3, 30)
    $RangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("New Vertical Min/Max: " & $RangeMinMax[0] & "/" & $RangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_HORZ, 10, 98)
    $RangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("New Horizontal Min/Max: " & $RangeMinMax[0] & "/" & $RangeMinMax[1])

    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main

; 写入一行到 memo 控件
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite