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

FillRect

関数
指定矩形を指定ブラシで塗りつぶす。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT FillRect(
    HDC hDC,
    const RECT* lprc,
    HBRUSH hbr
);

パラメーター

名前方向
hDCHDCin
lprcRECT*in
hbrHBRUSHin

戻り値の型: INT

各言語での呼び出し定義

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

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

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

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procFillRect = user32.NewProc("FillRect")
)

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