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

InvertRect

関数
指定矩形内の色を反転する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL InvertRect(
    HDC hDC,
    const RECT* lprc
);

パラメーター

名前方向
hDCHDCin
lprcRECT*in

戻り値の型: BOOL

各言語での呼び出し定義

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

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

InvertRect = ctypes.windll.user32.InvertRect
InvertRect.restype = wintypes.BOOL
InvertRect.argtypes = [
    wintypes.HANDLE,  # hDC : HDC
    ctypes.c_void_p,  # lprc : RECT*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procInvertRect = user32.NewProc("InvertRect")
)

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