ホーム › Graphics.Gdi › CreatePolygonRgn
CreatePolygonRgn
関数頂点配列から多角形リージョンを作成する。
シグネチャ
// GDI32.dll
#include <windows.h>
HRGN CreatePolygonRgn(
const POINT* pptl,
INT cPoint,
CREATE_POLYGON_RGN_MODE iMode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pptl | POINT* | in |
| cPoint | INT | in |
| iMode | CREATE_POLYGON_RGN_MODE | in |
戻り値の型: HRGN
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
HRGN CreatePolygonRgn(
const POINT* pptl,
INT cPoint,
CREATE_POLYGON_RGN_MODE iMode
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr CreatePolygonRgn(
IntPtr pptl, // POINT*
int cPoint, // INT
int iMode // CREATE_POLYGON_RGN_MODE
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CreatePolygonRgn(
pptl As IntPtr, ' POINT*
cPoint As Integer, ' INT
iMode As Integer ' CREATE_POLYGON_RGN_MODE
) As IntPtr
End Function' pptl : POINT*
' cPoint : INT
' iMode : CREATE_POLYGON_RGN_MODE
Declare PtrSafe Function CreatePolygonRgn Lib "gdi32" ( _
ByVal pptl As LongPtr, _
ByVal cPoint As Long, _
ByVal iMode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreatePolygonRgn = ctypes.windll.gdi32.CreatePolygonRgn
CreatePolygonRgn.restype = ctypes.c_void_p
CreatePolygonRgn.argtypes = [
ctypes.c_void_p, # pptl : POINT*
ctypes.c_int, # cPoint : INT
ctypes.c_int, # iMode : CREATE_POLYGON_RGN_MODE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
CreatePolygonRgn = Fiddle::Function.new(
lib['CreatePolygonRgn'],
[
Fiddle::TYPE_VOIDP, # pptl : POINT*
Fiddle::TYPE_INT, # cPoint : INT
Fiddle::TYPE_INT, # iMode : CREATE_POLYGON_RGN_MODE
],
Fiddle::TYPE_VOIDP)#[link(name = "gdi32")]
extern "system" {
fn CreatePolygonRgn(
pptl: *const POINT, // POINT*
cPoint: i32, // INT
iMode: i32 // CREATE_POLYGON_RGN_MODE
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr CreatePolygonRgn(IntPtr pptl, int cPoint, int iMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreatePolygonRgn' -Namespace Win32 -PassThru
# $api::CreatePolygonRgn(pptl, cPoint, iMode)#uselib "GDI32.dll"
#func global CreatePolygonRgn "CreatePolygonRgn" sptr, sptr, sptr
; CreatePolygonRgn varptr(pptl), cPoint, iMode ; 戻り値は stat
; pptl : POINT* -> "sptr"
; cPoint : INT -> "sptr"
; iMode : CREATE_POLYGON_RGN_MODE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global CreatePolygonRgn "CreatePolygonRgn" var, int, int ; res = CreatePolygonRgn(pptl, cPoint, iMode) ; pptl : POINT* -> "var" ; cPoint : INT -> "int" ; iMode : CREATE_POLYGON_RGN_MODE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global CreatePolygonRgn "CreatePolygonRgn" sptr, int, int ; res = CreatePolygonRgn(varptr(pptl), cPoint, iMode) ; pptl : POINT* -> "sptr" ; cPoint : INT -> "int" ; iMode : CREATE_POLYGON_RGN_MODE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRGN CreatePolygonRgn(POINT* pptl, INT cPoint, CREATE_POLYGON_RGN_MODE iMode) #uselib "GDI32.dll" #cfunc global CreatePolygonRgn "CreatePolygonRgn" var, int, int ; res = CreatePolygonRgn(pptl, cPoint, iMode) ; pptl : POINT* -> "var" ; cPoint : INT -> "int" ; iMode : CREATE_POLYGON_RGN_MODE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRGN CreatePolygonRgn(POINT* pptl, INT cPoint, CREATE_POLYGON_RGN_MODE iMode) #uselib "GDI32.dll" #cfunc global CreatePolygonRgn "CreatePolygonRgn" intptr, int, int ; res = CreatePolygonRgn(varptr(pptl), cPoint, iMode) ; pptl : POINT* -> "intptr" ; cPoint : INT -> "int" ; iMode : CREATE_POLYGON_RGN_MODE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procCreatePolygonRgn = gdi32.NewProc("CreatePolygonRgn")
)
// pptl (POINT*), cPoint (INT), iMode (CREATE_POLYGON_RGN_MODE)
r1, _, err := procCreatePolygonRgn.Call(
uintptr(pptl),
uintptr(cPoint),
uintptr(iMode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRGNfunction CreatePolygonRgn(
pptl: Pointer; // POINT*
cPoint: Integer; // INT
iMode: Integer // CREATE_POLYGON_RGN_MODE
): THandle; stdcall;
external 'GDI32.dll' name 'CreatePolygonRgn';result := DllCall("GDI32\CreatePolygonRgn"
, "Ptr", pptl ; POINT*
, "Int", cPoint ; INT
, "Int", iMode ; CREATE_POLYGON_RGN_MODE
, "Ptr") ; return: HRGN●CreatePolygonRgn(pptl, cPoint, iMode) = DLL("GDI32.dll", "void* CreatePolygonRgn(void*, int, int)")
# 呼び出し: CreatePolygonRgn(pptl, cPoint, iMode)
# pptl : POINT* -> "void*"
# cPoint : INT -> "int"
# iMode : CREATE_POLYGON_RGN_MODE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。