Win32 API 日本語リファレンス
ホームGraphics.Gdi › GetUpdateRect

GetUpdateRect

関数
ウィンドウの更新が必要な領域の外接矩形を取得する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GetUpdateRect(
    HWND hWnd,
    RECT* lpRect,   // optional
    BOOL bErase
);

パラメーター

名前方向
hWndHWNDin
lpRectRECT*outoptional
bEraseBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetUpdateRect(
    HWND hWnd,
    RECT* lpRect,   // optional
    BOOL bErase
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool GetUpdateRect(
    IntPtr hWnd,   // HWND
    IntPtr lpRect,   // RECT* optional, out
    bool bErase   // BOOL
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function GetUpdateRect(
    hWnd As IntPtr,   ' HWND
    lpRect As IntPtr,   ' RECT* optional, out
    bErase As Boolean   ' BOOL
) As Boolean
End Function
' hWnd : HWND
' lpRect : RECT* optional, out
' bErase : BOOL
Declare PtrSafe Function GetUpdateRect Lib "user32" ( _
    ByVal hWnd As LongPtr, _
    ByVal lpRect As LongPtr, _
    ByVal bErase As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetUpdateRect = ctypes.windll.user32.GetUpdateRect
GetUpdateRect.restype = wintypes.BOOL
GetUpdateRect.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    ctypes.c_void_p,  # lpRect : RECT* optional, out
    wintypes.BOOL,  # bErase : BOOL
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetUpdateRect = user32.NewProc("GetUpdateRect")
)

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