Win32 API 日本語リファレンス
ホームUI.Controls › SetScrollInfo

SetScrollInfo

関数
スクロールバーの位置・範囲・ページサイズなどの情報を設定する。
DLLUSER32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// USER32.dll
#include <windows.h>

INT SetScrollInfo(
    HWND hwnd,
    SCROLLBAR_CONSTANTS nBar,
    SCROLLINFO* lpsi,
    BOOL redraw
);

パラメーター

名前方向
hwndHWNDin
nBarSCROLLBAR_CONSTANTSin
lpsiSCROLLINFO*in
redrawBOOLin

戻り値の型: INT

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

INT SetScrollInfo(
    HWND hwnd,
    SCROLLBAR_CONSTANTS nBar,
    SCROLLINFO* lpsi,
    BOOL redraw
);
[DllImport("USER32.dll", ExactSpelling = true)]
static extern int SetScrollInfo(
    IntPtr hwnd,   // HWND
    int nBar,   // SCROLLBAR_CONSTANTS
    IntPtr lpsi,   // SCROLLINFO*
    bool redraw   // BOOL
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function SetScrollInfo(
    hwnd As IntPtr,   ' HWND
    nBar As Integer,   ' SCROLLBAR_CONSTANTS
    lpsi As IntPtr,   ' SCROLLINFO*
    redraw As Boolean   ' BOOL
) As Integer
End Function
' hwnd : HWND
' nBar : SCROLLBAR_CONSTANTS
' lpsi : SCROLLINFO*
' redraw : BOOL
Declare PtrSafe Function SetScrollInfo Lib "user32" ( _
    ByVal hwnd As LongPtr, _
    ByVal nBar As Long, _
    ByVal lpsi As LongPtr, _
    ByVal redraw As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetScrollInfo = ctypes.windll.user32.SetScrollInfo
SetScrollInfo.restype = ctypes.c_int
SetScrollInfo.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    ctypes.c_int,  # nBar : SCROLLBAR_CONSTANTS
    ctypes.c_void_p,  # lpsi : SCROLLINFO*
    wintypes.BOOL,  # redraw : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetScrollInfo = Fiddle::Function.new(
  lib['SetScrollInfo'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_INT,  # nBar : SCROLLBAR_CONSTANTS
    Fiddle::TYPE_VOIDP,  # lpsi : SCROLLINFO*
    Fiddle::TYPE_INT,  # redraw : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn SetScrollInfo(
        hwnd: *mut core::ffi::c_void,  // HWND
        nBar: i32,  // SCROLLBAR_CONSTANTS
        lpsi: *mut SCROLLINFO,  // SCROLLINFO*
        redraw: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll")]
public static extern int SetScrollInfo(IntPtr hwnd, int nBar, IntPtr lpsi, bool redraw);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetScrollInfo' -Namespace Win32 -PassThru
# $api::SetScrollInfo(hwnd, nBar, lpsi, redraw)
#uselib "USER32.dll"
#func global SetScrollInfo "SetScrollInfo" sptr, sptr, sptr, sptr
; SetScrollInfo hwnd, nBar, varptr(lpsi), redraw   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; nBar : SCROLLBAR_CONSTANTS -> "sptr"
; lpsi : SCROLLINFO* -> "sptr"
; redraw : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global SetScrollInfo "SetScrollInfo" sptr, int, var, int
; res = SetScrollInfo(hwnd, nBar, lpsi, redraw)
; hwnd : HWND -> "sptr"
; nBar : SCROLLBAR_CONSTANTS -> "int"
; lpsi : SCROLLINFO* -> "var"
; redraw : BOOL -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT SetScrollInfo(HWND hwnd, SCROLLBAR_CONSTANTS nBar, SCROLLINFO* lpsi, BOOL redraw)
#uselib "USER32.dll"
#cfunc global SetScrollInfo "SetScrollInfo" intptr, int, var, int
; res = SetScrollInfo(hwnd, nBar, lpsi, redraw)
; hwnd : HWND -> "intptr"
; nBar : SCROLLBAR_CONSTANTS -> "int"
; lpsi : SCROLLINFO* -> "var"
; redraw : BOOL -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetScrollInfo = user32.NewProc("SetScrollInfo")
)

// hwnd (HWND), nBar (SCROLLBAR_CONSTANTS), lpsi (SCROLLINFO*), redraw (BOOL)
r1, _, err := procSetScrollInfo.Call(
	uintptr(hwnd),
	uintptr(nBar),
	uintptr(lpsi),
	uintptr(redraw),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function SetScrollInfo(
  hwnd: THandle;   // HWND
  nBar: Integer;   // SCROLLBAR_CONSTANTS
  lpsi: Pointer;   // SCROLLINFO*
  redraw: BOOL   // BOOL
): Integer; stdcall;
  external 'USER32.dll' name 'SetScrollInfo';
result := DllCall("USER32\SetScrollInfo"
    , "Ptr", hwnd   ; HWND
    , "Int", nBar   ; SCROLLBAR_CONSTANTS
    , "Ptr", lpsi   ; SCROLLINFO*
    , "Int", redraw   ; BOOL
    , "Int")   ; return: INT
●SetScrollInfo(hwnd, nBar, lpsi, redraw) = DLL("USER32.dll", "int SetScrollInfo(void*, int, void*, bool)")
# 呼び出し: SetScrollInfo(hwnd, nBar, lpsi, redraw)
# hwnd : HWND -> "void*"
# nBar : SCROLLBAR_CONSTANTS -> "int"
# lpsi : SCROLLINFO* -> "void*"
# redraw : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。