ホーム › UI.Controls › SetScrollRange
SetScrollRange
関数スクロールバーの最小・最大範囲を設定する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL SetScrollRange(
HWND hWnd,
SCROLLBAR_CONSTANTS nBar,
INT nMinPos,
INT nMaxPos,
BOOL bRedraw
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| nBar | SCROLLBAR_CONSTANTS | in |
| nMinPos | INT | in |
| nMaxPos | INT | in |
| bRedraw | BOOL | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL SetScrollRange(
HWND hWnd,
SCROLLBAR_CONSTANTS nBar,
INT nMinPos,
INT nMaxPos,
BOOL bRedraw
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetScrollRange(
IntPtr hWnd, // HWND
int nBar, // SCROLLBAR_CONSTANTS
int nMinPos, // INT
int nMaxPos, // INT
bool bRedraw // BOOL
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetScrollRange(
hWnd As IntPtr, ' HWND
nBar As Integer, ' SCROLLBAR_CONSTANTS
nMinPos As Integer, ' INT
nMaxPos As Integer, ' INT
bRedraw As Boolean ' BOOL
) As Boolean
End Function' hWnd : HWND
' nBar : SCROLLBAR_CONSTANTS
' nMinPos : INT
' nMaxPos : INT
' bRedraw : BOOL
Declare PtrSafe Function SetScrollRange Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal nBar As Long, _
ByVal nMinPos As Long, _
ByVal nMaxPos As Long, _
ByVal bRedraw As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetScrollRange = ctypes.windll.user32.SetScrollRange
SetScrollRange.restype = wintypes.BOOL
SetScrollRange.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_int, # nBar : SCROLLBAR_CONSTANTS
ctypes.c_int, # nMinPos : INT
ctypes.c_int, # nMaxPos : INT
wintypes.BOOL, # bRedraw : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
SetScrollRange = Fiddle::Function.new(
lib['SetScrollRange'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_INT, # nBar : SCROLLBAR_CONSTANTS
Fiddle::TYPE_INT, # nMinPos : INT
Fiddle::TYPE_INT, # nMaxPos : INT
Fiddle::TYPE_INT, # bRedraw : BOOL
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn SetScrollRange(
hWnd: *mut core::ffi::c_void, // HWND
nBar: i32, // SCROLLBAR_CONSTANTS
nMinPos: i32, // INT
nMaxPos: i32, // INT
bRedraw: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool SetScrollRange(IntPtr hWnd, int nBar, int nMinPos, int nMaxPos, bool bRedraw);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetScrollRange' -Namespace Win32 -PassThru
# $api::SetScrollRange(hWnd, nBar, nMinPos, nMaxPos, bRedraw)#uselib "USER32.dll"
#func global SetScrollRange "SetScrollRange" sptr, sptr, sptr, sptr, sptr
; SetScrollRange hWnd, nBar, nMinPos, nMaxPos, bRedraw ; 戻り値は stat
; hWnd : HWND -> "sptr"
; nBar : SCROLLBAR_CONSTANTS -> "sptr"
; nMinPos : INT -> "sptr"
; nMaxPos : INT -> "sptr"
; bRedraw : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetScrollRange "SetScrollRange" sptr, int, int, int, int
; res = SetScrollRange(hWnd, nBar, nMinPos, nMaxPos, bRedraw)
; hWnd : HWND -> "sptr"
; nBar : SCROLLBAR_CONSTANTS -> "int"
; nMinPos : INT -> "int"
; nMaxPos : INT -> "int"
; bRedraw : BOOL -> "int"; BOOL SetScrollRange(HWND hWnd, SCROLLBAR_CONSTANTS nBar, INT nMinPos, INT nMaxPos, BOOL bRedraw)
#uselib "USER32.dll"
#cfunc global SetScrollRange "SetScrollRange" intptr, int, int, int, int
; res = SetScrollRange(hWnd, nBar, nMinPos, nMaxPos, bRedraw)
; hWnd : HWND -> "intptr"
; nBar : SCROLLBAR_CONSTANTS -> "int"
; nMinPos : INT -> "int"
; nMaxPos : INT -> "int"
; bRedraw : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procSetScrollRange = user32.NewProc("SetScrollRange")
)
// hWnd (HWND), nBar (SCROLLBAR_CONSTANTS), nMinPos (INT), nMaxPos (INT), bRedraw (BOOL)
r1, _, err := procSetScrollRange.Call(
uintptr(hWnd),
uintptr(nBar),
uintptr(nMinPos),
uintptr(nMaxPos),
uintptr(bRedraw),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetScrollRange(
hWnd: THandle; // HWND
nBar: Integer; // SCROLLBAR_CONSTANTS
nMinPos: Integer; // INT
nMaxPos: Integer; // INT
bRedraw: BOOL // BOOL
): BOOL; stdcall;
external 'USER32.dll' name 'SetScrollRange';result := DllCall("USER32\SetScrollRange"
, "Ptr", hWnd ; HWND
, "Int", nBar ; SCROLLBAR_CONSTANTS
, "Int", nMinPos ; INT
, "Int", nMaxPos ; INT
, "Int", bRedraw ; BOOL
, "Int") ; return: BOOL●SetScrollRange(hWnd, nBar, nMinPos, nMaxPos, bRedraw) = DLL("USER32.dll", "bool SetScrollRange(void*, int, int, int, bool)")
# 呼び出し: SetScrollRange(hWnd, nBar, nMinPos, nMaxPos, bRedraw)
# hWnd : HWND -> "void*"
# nBar : SCROLLBAR_CONSTANTS -> "int"
# nMinPos : INT -> "int"
# nMaxPos : INT -> "int"
# bRedraw : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。