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

CreateRectRgn

関数
指定座標の矩形領域を作成する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRGN CreateRectRgn(
    INT x1,
    INT y1,
    INT x2,
    INT y2
);

パラメーター

名前方向
x1INTin
y1INTin
x2INTin
y2INTin

戻り値の型: HRGN

各言語での呼び出し定義

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

HRGN CreateRectRgn(
    INT x1,
    INT y1,
    INT x2,
    INT y2
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr CreateRectRgn(
    int x1,   // INT
    int y1,   // INT
    int x2,   // INT
    int y2   // INT
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CreateRectRgn(
    x1 As Integer,   ' INT
    y1 As Integer,   ' INT
    x2 As Integer,   ' INT
    y2 As Integer   ' INT
) As IntPtr
End Function
' x1 : INT
' y1 : INT
' x2 : INT
' y2 : INT
Declare PtrSafe Function CreateRectRgn Lib "gdi32" ( _
    ByVal x1 As Long, _
    ByVal y1 As Long, _
    ByVal x2 As Long, _
    ByVal y2 As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateRectRgn = ctypes.windll.gdi32.CreateRectRgn
CreateRectRgn.restype = ctypes.c_void_p
CreateRectRgn.argtypes = [
    ctypes.c_int,  # x1 : INT
    ctypes.c_int,  # y1 : INT
    ctypes.c_int,  # x2 : INT
    ctypes.c_int,  # y2 : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateRectRgn = Fiddle::Function.new(
  lib['CreateRectRgn'],
  [
    Fiddle::TYPE_INT,  # x1 : INT
    Fiddle::TYPE_INT,  # y1 : INT
    Fiddle::TYPE_INT,  # x2 : INT
    Fiddle::TYPE_INT,  # y2 : INT
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn CreateRectRgn(
        x1: i32,  // INT
        y1: i32,  // INT
        x2: i32,  // INT
        y2: i32  // INT
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateRectRgn' -Namespace Win32 -PassThru
# $api::CreateRectRgn(x1, y1, x2, y2)
#uselib "GDI32.dll"
#func global CreateRectRgn "CreateRectRgn" sptr, sptr, sptr, sptr
; CreateRectRgn x1, y1, x2, y2   ; 戻り値は stat
; x1 : INT -> "sptr"
; y1 : INT -> "sptr"
; x2 : INT -> "sptr"
; y2 : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global CreateRectRgn "CreateRectRgn" int, int, int, int
; res = CreateRectRgn(x1, y1, x2, y2)
; x1 : INT -> "int"
; y1 : INT -> "int"
; x2 : INT -> "int"
; y2 : INT -> "int"
; HRGN CreateRectRgn(INT x1, INT y1, INT x2, INT y2)
#uselib "GDI32.dll"
#cfunc global CreateRectRgn "CreateRectRgn" int, int, int, int
; res = CreateRectRgn(x1, y1, x2, y2)
; x1 : INT -> "int"
; y1 : INT -> "int"
; x2 : INT -> "int"
; y2 : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateRectRgn = gdi32.NewProc("CreateRectRgn")
)

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