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

ValidateRect

関数
指定矩形を有効化して更新領域から除外する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL ValidateRect(
    HWND hWnd,   // optional
    const RECT* lpRect   // optional
);

パラメーター

名前方向
hWndHWNDinoptional
lpRectRECT*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procValidateRect = user32.NewProc("ValidateRect")
)

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