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

ScrollDC

関数
デバイスコンテキスト内の矩形をスクロールする。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL ScrollDC(
    HDC hDC,
    INT dx,
    INT dy,
    const RECT* lprcScroll,   // optional
    const RECT* lprcClip,   // optional
    HRGN hrgnUpdate,   // optional
    RECT* lprcUpdate   // optional
);

パラメーター

名前方向
hDCHDCin
dxINTin
dyINTin
lprcScrollRECT*inoptional
lprcClipRECT*inoptional
hrgnUpdateHRGNinoptional
lprcUpdateRECT*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ScrollDC(
    HDC hDC,
    INT dx,
    INT dy,
    const RECT* lprcScroll,   // optional
    const RECT* lprcClip,   // optional
    HRGN hrgnUpdate,   // optional
    RECT* lprcUpdate   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool ScrollDC(
    IntPtr hDC,   // HDC
    int dx,   // INT
    int dy,   // INT
    IntPtr lprcScroll,   // RECT* optional
    IntPtr lprcClip,   // RECT* optional
    IntPtr hrgnUpdate,   // HRGN optional
    IntPtr lprcUpdate   // RECT* optional, out
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ScrollDC(
    hDC As IntPtr,   ' HDC
    dx As Integer,   ' INT
    dy As Integer,   ' INT
    lprcScroll As IntPtr,   ' RECT* optional
    lprcClip As IntPtr,   ' RECT* optional
    hrgnUpdate As IntPtr,   ' HRGN optional
    lprcUpdate As IntPtr   ' RECT* optional, out
) As Boolean
End Function
' hDC : HDC
' dx : INT
' dy : INT
' lprcScroll : RECT* optional
' lprcClip : RECT* optional
' hrgnUpdate : HRGN optional
' lprcUpdate : RECT* optional, out
Declare PtrSafe Function ScrollDC Lib "user32" ( _
    ByVal hDC As LongPtr, _
    ByVal dx As Long, _
    ByVal dy As Long, _
    ByVal lprcScroll As LongPtr, _
    ByVal lprcClip As LongPtr, _
    ByVal hrgnUpdate As LongPtr, _
    ByVal lprcUpdate As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScrollDC = ctypes.windll.user32.ScrollDC
ScrollDC.restype = wintypes.BOOL
ScrollDC.argtypes = [
    wintypes.HANDLE,  # hDC : HDC
    ctypes.c_int,  # dx : INT
    ctypes.c_int,  # dy : INT
    ctypes.c_void_p,  # lprcScroll : RECT* optional
    ctypes.c_void_p,  # lprcClip : RECT* optional
    wintypes.HANDLE,  # hrgnUpdate : HRGN optional
    ctypes.c_void_p,  # lprcUpdate : RECT* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
ScrollDC = Fiddle::Function.new(
  lib['ScrollDC'],
  [
    Fiddle::TYPE_VOIDP,  # hDC : HDC
    Fiddle::TYPE_INT,  # dx : INT
    Fiddle::TYPE_INT,  # dy : INT
    Fiddle::TYPE_VOIDP,  # lprcScroll : RECT* optional
    Fiddle::TYPE_VOIDP,  # lprcClip : RECT* optional
    Fiddle::TYPE_VOIDP,  # hrgnUpdate : HRGN optional
    Fiddle::TYPE_VOIDP,  # lprcUpdate : RECT* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn ScrollDC(
        hDC: *mut core::ffi::c_void,  // HDC
        dx: i32,  // INT
        dy: i32,  // INT
        lprcScroll: *const RECT,  // RECT* optional
        lprcClip: *const RECT,  // RECT* optional
        hrgnUpdate: *mut core::ffi::c_void,  // HRGN optional
        lprcUpdate: *mut RECT  // RECT* optional, 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 ScrollDC(IntPtr hDC, int dx, int dy, IntPtr lprcScroll, IntPtr lprcClip, IntPtr hrgnUpdate, IntPtr lprcUpdate);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_ScrollDC' -Namespace Win32 -PassThru
# $api::ScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate)
#uselib "USER32.dll"
#func global ScrollDC "ScrollDC" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScrollDC hDC, dx, dy, varptr(lprcScroll), varptr(lprcClip), hrgnUpdate, varptr(lprcUpdate)   ; 戻り値は stat
; hDC : HDC -> "sptr"
; dx : INT -> "sptr"
; dy : INT -> "sptr"
; lprcScroll : RECT* optional -> "sptr"
; lprcClip : RECT* optional -> "sptr"
; hrgnUpdate : HRGN optional -> "sptr"
; lprcUpdate : RECT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global ScrollDC "ScrollDC" sptr, int, int, var, var, sptr, var
; res = ScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate)
; hDC : HDC -> "sptr"
; dx : INT -> "int"
; dy : INT -> "int"
; lprcScroll : RECT* optional -> "var"
; lprcClip : RECT* optional -> "var"
; hrgnUpdate : HRGN optional -> "sptr"
; lprcUpdate : RECT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL ScrollDC(HDC hDC, INT dx, INT dy, RECT* lprcScroll, RECT* lprcClip, HRGN hrgnUpdate, RECT* lprcUpdate)
#uselib "USER32.dll"
#cfunc global ScrollDC "ScrollDC" intptr, int, int, var, var, intptr, var
; res = ScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate)
; hDC : HDC -> "intptr"
; dx : INT -> "int"
; dy : INT -> "int"
; lprcScroll : RECT* optional -> "var"
; lprcClip : RECT* optional -> "var"
; hrgnUpdate : HRGN optional -> "intptr"
; lprcUpdate : RECT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procScrollDC = user32.NewProc("ScrollDC")
)

// hDC (HDC), dx (INT), dy (INT), lprcScroll (RECT* optional), lprcClip (RECT* optional), hrgnUpdate (HRGN optional), lprcUpdate (RECT* optional, out)
r1, _, err := procScrollDC.Call(
	uintptr(hDC),
	uintptr(dx),
	uintptr(dy),
	uintptr(lprcScroll),
	uintptr(lprcClip),
	uintptr(hrgnUpdate),
	uintptr(lprcUpdate),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ScrollDC(
  hDC: THandle;   // HDC
  dx: Integer;   // INT
  dy: Integer;   // INT
  lprcScroll: Pointer;   // RECT* optional
  lprcClip: Pointer;   // RECT* optional
  hrgnUpdate: THandle;   // HRGN optional
  lprcUpdate: Pointer   // RECT* optional, out
): BOOL; stdcall;
  external 'USER32.dll' name 'ScrollDC';
result := DllCall("USER32\ScrollDC"
    , "Ptr", hDC   ; HDC
    , "Int", dx   ; INT
    , "Int", dy   ; INT
    , "Ptr", lprcScroll   ; RECT* optional
    , "Ptr", lprcClip   ; RECT* optional
    , "Ptr", hrgnUpdate   ; HRGN optional
    , "Ptr", lprcUpdate   ; RECT* optional, out
    , "Int")   ; return: BOOL
●ScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate) = DLL("USER32.dll", "bool ScrollDC(void*, int, int, void*, void*, void*, void*)")
# 呼び出し: ScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate)
# hDC : HDC -> "void*"
# dx : INT -> "int"
# dy : INT -> "int"
# lprcScroll : RECT* optional -> "void*"
# lprcClip : RECT* optional -> "void*"
# hrgnUpdate : HRGN optional -> "void*"
# lprcUpdate : RECT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。