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

ExtCreateRegion

関数
領域データと変換から領域を作成する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRGN ExtCreateRegion(
    const XFORM* lpx,   // optional
    DWORD nCount,
    const RGNDATA* lpData
);

パラメーター

名前方向
lpxXFORM*inoptional
nCountDWORDin
lpDataRGNDATA*in

戻り値の型: HRGN

各言語での呼び出し定義

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

HRGN ExtCreateRegion(
    const XFORM* lpx,   // optional
    DWORD nCount,
    const RGNDATA* lpData
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr ExtCreateRegion(
    IntPtr lpx,   // XFORM* optional
    uint nCount,   // DWORD
    IntPtr lpData   // RGNDATA*
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function ExtCreateRegion(
    lpx As IntPtr,   ' XFORM* optional
    nCount As UInteger,   ' DWORD
    lpData As IntPtr   ' RGNDATA*
) As IntPtr
End Function
' lpx : XFORM* optional
' nCount : DWORD
' lpData : RGNDATA*
Declare PtrSafe Function ExtCreateRegion Lib "gdi32" ( _
    ByVal lpx As LongPtr, _
    ByVal nCount As Long, _
    ByVal lpData As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ExtCreateRegion = ctypes.windll.gdi32.ExtCreateRegion
ExtCreateRegion.restype = ctypes.c_void_p
ExtCreateRegion.argtypes = [
    ctypes.c_void_p,  # lpx : XFORM* optional
    wintypes.DWORD,  # nCount : DWORD
    ctypes.c_void_p,  # lpData : RGNDATA*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procExtCreateRegion = gdi32.NewProc("ExtCreateRegion")
)

// lpx (XFORM* optional), nCount (DWORD), lpData (RGNDATA*)
r1, _, err := procExtCreateRegion.Call(
	uintptr(lpx),
	uintptr(nCount),
	uintptr(lpData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRGN
function ExtCreateRegion(
  lpx: Pointer;   // XFORM* optional
  nCount: DWORD;   // DWORD
  lpData: Pointer   // RGNDATA*
): THandle; stdcall;
  external 'GDI32.dll' name 'ExtCreateRegion';
result := DllCall("GDI32\ExtCreateRegion"
    , "Ptr", lpx   ; XFORM* optional
    , "UInt", nCount   ; DWORD
    , "Ptr", lpData   ; RGNDATA*
    , "Ptr")   ; return: HRGN
●ExtCreateRegion(lpx, nCount, lpData) = DLL("GDI32.dll", "void* ExtCreateRegion(void*, dword, void*)")
# 呼び出し: ExtCreateRegion(lpx, nCount, lpData)
# lpx : XFORM* optional -> "void*"
# nCount : DWORD -> "dword"
# lpData : RGNDATA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。