ホーム › Graphics.Gdi › InvalidateRect
InvalidateRect
関数指定矩形を無効化して再描画対象に追加する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL InvalidateRect(
HWND hWnd, // optional
const RECT* lpRect, // optional
BOOL bErase
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | inoptional |
| lpRect | RECT* | inoptional |
| bErase | BOOL | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL InvalidateRect(
HWND hWnd, // optional
const RECT* lpRect, // optional
BOOL bErase
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool InvalidateRect(
IntPtr hWnd, // HWND optional
IntPtr lpRect, // RECT* optional
bool bErase // BOOL
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function InvalidateRect(
hWnd As IntPtr, ' HWND optional
lpRect As IntPtr, ' RECT* optional
bErase As Boolean ' BOOL
) As Boolean
End Function' hWnd : HWND optional
' lpRect : RECT* optional
' bErase : BOOL
Declare PtrSafe Function InvalidateRect 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
InvalidateRect = ctypes.windll.user32.InvalidateRect
InvalidateRect.restype = wintypes.BOOL
InvalidateRect.argtypes = [
wintypes.HANDLE, # hWnd : HWND optional
ctypes.c_void_p, # lpRect : RECT* optional
wintypes.BOOL, # bErase : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
InvalidateRect = Fiddle::Function.new(
lib['InvalidateRect'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND optional
Fiddle::TYPE_VOIDP, # lpRect : RECT* optional
Fiddle::TYPE_INT, # bErase : BOOL
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn InvalidateRect(
hWnd: *mut core::ffi::c_void, // HWND optional
lpRect: *const RECT, // RECT* optional
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 InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_InvalidateRect' -Namespace Win32 -PassThru
# $api::InvalidateRect(hWnd, lpRect, bErase)#uselib "USER32.dll"
#func global InvalidateRect "InvalidateRect" sptr, sptr, sptr
; InvalidateRect hWnd, varptr(lpRect), bErase ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; lpRect : RECT* optional -> "sptr"
; bErase : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global InvalidateRect "InvalidateRect" sptr, var, int ; res = InvalidateRect(hWnd, lpRect, bErase) ; hWnd : HWND optional -> "sptr" ; lpRect : RECT* optional -> "var" ; bErase : BOOL -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global InvalidateRect "InvalidateRect" sptr, sptr, int ; res = InvalidateRect(hWnd, varptr(lpRect), bErase) ; hWnd : HWND optional -> "sptr" ; lpRect : RECT* optional -> "sptr" ; bErase : BOOL -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL InvalidateRect(HWND hWnd, RECT* lpRect, BOOL bErase) #uselib "USER32.dll" #cfunc global InvalidateRect "InvalidateRect" intptr, var, int ; res = InvalidateRect(hWnd, lpRect, bErase) ; hWnd : HWND optional -> "intptr" ; lpRect : RECT* optional -> "var" ; bErase : BOOL -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL InvalidateRect(HWND hWnd, RECT* lpRect, BOOL bErase) #uselib "USER32.dll" #cfunc global InvalidateRect "InvalidateRect" intptr, intptr, int ; res = InvalidateRect(hWnd, varptr(lpRect), bErase) ; hWnd : HWND optional -> "intptr" ; lpRect : RECT* optional -> "intptr" ; bErase : BOOL -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procInvalidateRect = user32.NewProc("InvalidateRect")
)
// hWnd (HWND optional), lpRect (RECT* optional), bErase (BOOL)
r1, _, err := procInvalidateRect.Call(
uintptr(hWnd),
uintptr(lpRect),
uintptr(bErase),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InvalidateRect(
hWnd: THandle; // HWND optional
lpRect: Pointer; // RECT* optional
bErase: BOOL // BOOL
): BOOL; stdcall;
external 'USER32.dll' name 'InvalidateRect';result := DllCall("USER32\InvalidateRect"
, "Ptr", hWnd ; HWND optional
, "Ptr", lpRect ; RECT* optional
, "Int", bErase ; BOOL
, "Int") ; return: BOOL●InvalidateRect(hWnd, lpRect, bErase) = DLL("USER32.dll", "bool InvalidateRect(void*, void*, bool)")
# 呼び出し: InvalidateRect(hWnd, lpRect, bErase)
# hWnd : HWND optional -> "void*"
# lpRect : RECT* optional -> "void*"
# bErase : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。