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