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

CreatePolyPolygonRgn

関数
複数の多角形からなる領域を作成する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRGN CreatePolyPolygonRgn(
    const POINT* pptl,
    const INT* pc,
    INT cPoly,
    CREATE_POLYGON_RGN_MODE iMode
);

パラメーター

名前方向説明
pptlPOINT*inポリゴンの頂点を論理単位で定義する POINT 構造体の配列へのポインターです。各ポリゴンは連続して指定します。各ポリゴンは閉じているものとみなされ、各頂点は一度だけ指定します。
pcINT*in整数の配列へのポインターで、各整数は lppt が指す配列内のポリゴンのいずれか 1 つに含まれる点の数を指定します。
cPolyINTinlpPolyCounts が指す配列内の整数の総数です。
iModeCREATE_POLYGON_RGN_MODEin

リージョンに含まれるピクセルを決定するために使用される塗りつぶしモードです。このパラメーターには次の値のいずれかを指定できます。

意味
ALTERNATE
ALTERNATE モードを選択します(各走査線上で、奇数番目のポリゴン辺と偶数番目のポリゴン辺との間の領域を塗りつぶします)。
WINDING
WINDING モードを選択します(巻き数 (winding value) が 0 でない領域をすべて塗りつぶします)。

これらのモードの詳細については、SetPolyFillMode 関数を参照してください。

戻り値の型: HRGN

公式ドキュメント

CreatePolyPolygonRgn 関数は、一連のポリゴンから成るリージョンを作成します。これらのポリゴンは重なり合うことができます。

戻り値

関数が成功すると、戻り値はリージョンのハンドルになります。

関数が失敗すると、戻り値は 0 になります。

解説(Remarks)

HRGN オブジェクトが不要になったら、DeleteObject 関数を呼び出して削除してください。

リージョンの座標は 27 ビットの符号付き整数として表現されます。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRGN CreatePolyPolygonRgn(
    const POINT* pptl,
    const INT* pc,
    INT cPoly,
    CREATE_POLYGON_RGN_MODE iMode
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr CreatePolyPolygonRgn(
    IntPtr pptl,   // POINT*
    ref int pc,   // INT*
    int cPoly,   // INT
    int iMode   // CREATE_POLYGON_RGN_MODE
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function CreatePolyPolygonRgn(
    pptl As IntPtr,   ' POINT*
    ByRef pc As Integer,   ' INT*
    cPoly As Integer,   ' INT
    iMode As Integer   ' CREATE_POLYGON_RGN_MODE
) As IntPtr
End Function
' pptl : POINT*
' pc : INT*
' cPoly : INT
' iMode : CREATE_POLYGON_RGN_MODE
Declare PtrSafe Function CreatePolyPolygonRgn Lib "gdi32" ( _
    ByVal pptl As LongPtr, _
    ByRef pc As Long, _
    ByVal cPoly 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

CreatePolyPolygonRgn = ctypes.windll.gdi32.CreatePolyPolygonRgn
CreatePolyPolygonRgn.restype = ctypes.c_void_p
CreatePolyPolygonRgn.argtypes = [
    ctypes.c_void_p,  # pptl : POINT*
    ctypes.POINTER(ctypes.c_int),  # pc : INT*
    ctypes.c_int,  # cPoly : INT
    ctypes.c_int,  # iMode : CREATE_POLYGON_RGN_MODE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreatePolyPolygonRgn = Fiddle::Function.new(
  lib['CreatePolyPolygonRgn'],
  [
    Fiddle::TYPE_VOIDP,  # pptl : POINT*
    Fiddle::TYPE_VOIDP,  # pc : INT*
    Fiddle::TYPE_INT,  # cPoly : INT
    Fiddle::TYPE_INT,  # iMode : CREATE_POLYGON_RGN_MODE
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn CreatePolyPolygonRgn(
        pptl: *const POINT,  // POINT*
        pc: *const i32,  // INT*
        cPoly: 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 CreatePolyPolygonRgn(IntPtr pptl, ref int pc, int cPoly, int iMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreatePolyPolygonRgn' -Namespace Win32 -PassThru
# $api::CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
#uselib "GDI32.dll"
#func global CreatePolyPolygonRgn "CreatePolyPolygonRgn" sptr, sptr, sptr, sptr
; CreatePolyPolygonRgn varptr(pptl), varptr(pc), cPoly, iMode   ; 戻り値は stat
; pptl : POINT* -> "sptr"
; pc : INT* -> "sptr"
; cPoly : INT -> "sptr"
; iMode : CREATE_POLYGON_RGN_MODE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global CreatePolyPolygonRgn "CreatePolyPolygonRgn" var, var, int, int
; res = CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
; pptl : POINT* -> "var"
; pc : INT* -> "var"
; cPoly : INT -> "int"
; iMode : CREATE_POLYGON_RGN_MODE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRGN CreatePolyPolygonRgn(POINT* pptl, INT* pc, INT cPoly, CREATE_POLYGON_RGN_MODE iMode)
#uselib "GDI32.dll"
#cfunc global CreatePolyPolygonRgn "CreatePolyPolygonRgn" var, var, int, int
; res = CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
; pptl : POINT* -> "var"
; pc : INT* -> "var"
; cPoly : INT -> "int"
; iMode : CREATE_POLYGON_RGN_MODE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreatePolyPolygonRgn = gdi32.NewProc("CreatePolyPolygonRgn")
)

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

extern "gdi32" fn CreatePolyPolygonRgn(
    pptl: [*c]POINT, // POINT*
    pc: [*c]i32, // INT*
    cPoly: i32, // INT
    iMode: i32 // CREATE_POLYGON_RGN_MODE
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc CreatePolyPolygonRgn(
    pptl: ptr POINT,  # POINT*
    pc: ptr int32,  # INT*
    cPoly: int32,  # INT
    iMode: int32  # CREATE_POLYGON_RGN_MODE
): pointer {.importc: "CreatePolyPolygonRgn", stdcall, dynlib: "GDI32.dll".}
pragma(lib, "gdi32");
extern(Windows)
void* CreatePolyPolygonRgn(
    POINT* pptl,   // POINT*
    int* pc,   // INT*
    int cPoly,   // INT
    int iMode   // CREATE_POLYGON_RGN_MODE
);
ccall((:CreatePolyPolygonRgn, "GDI32.dll"), stdcall, Ptr{Cvoid},
      (Ptr{POINT}, Ptr{Int32}, Int32, Int32),
      pptl, pc, cPoly, iMode)
# pptl : POINT* -> Ptr{POINT}
# pc : INT* -> Ptr{Int32}
# cPoly : INT -> Int32
# iMode : CREATE_POLYGON_RGN_MODE -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* CreatePolyPolygonRgn(
    void* pptl,
    int32_t* pc,
    int32_t cPoly,
    int32_t iMode);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
-- pptl : POINT*
-- pc : INT*
-- cPoly : INT
-- iMode : CREATE_POLYGON_RGN_MODE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const CreatePolyPolygonRgn = lib.func('__stdcall', 'CreatePolyPolygonRgn', 'void *', ['void *', 'int32_t *', 'int32_t', 'int32_t']);
// CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
// pptl : POINT* -> 'void *'
// pc : INT* -> 'int32_t *'
// cPoly : INT -> 'int32_t'
// iMode : CREATE_POLYGON_RGN_MODE -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("GDI32.dll", {
  CreatePolyPolygonRgn: { parameters: ["pointer", "pointer", "i32", "i32"], result: "pointer" },
});
// lib.symbols.CreatePolyPolygonRgn(pptl, pc, cPoly, iMode)
// pptl : POINT* -> "pointer"
// pc : INT* -> "pointer"
// cPoly : INT -> "i32"
// iMode : CREATE_POLYGON_RGN_MODE -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* CreatePolyPolygonRgn(
    void* pptl,
    int32_t* pc,
    int32_t cPoly,
    int32_t iMode);
C, "GDI32.dll");
// $ffi->CreatePolyPolygonRgn(pptl, pc, cPoly, iMode);
// pptl : POINT*
// pc : INT*
// cPoly : INT
// iMode : CREATE_POLYGON_RGN_MODE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Gdi32 extends StdCallLibrary {
    Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
    Pointer CreatePolyPolygonRgn(
        Pointer pptl,   // POINT*
        IntByReference pc,   // INT*
        int cPoly,   // INT
        int iMode   // CREATE_POLYGON_RGN_MODE
    );
}
@[Link("gdi32")]
lib LibGDI32
  fun CreatePolyPolygonRgn = CreatePolyPolygonRgn(
    pptl : POINT*,   # POINT*
    pc : Int32*,   # INT*
    cPoly : Int32,   # INT
    iMode : Int32   # CREATE_POLYGON_RGN_MODE
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CreatePolyPolygonRgnNative = Pointer<Void> Function(Pointer<Void>, Pointer<Int32>, Int32, Int32);
typedef CreatePolyPolygonRgnDart = Pointer<Void> Function(Pointer<Void>, Pointer<Int32>, int, int);
final CreatePolyPolygonRgn = DynamicLibrary.open('GDI32.dll')
    .lookupFunction<CreatePolyPolygonRgnNative, CreatePolyPolygonRgnDart>('CreatePolyPolygonRgn');
// pptl : POINT* -> Pointer<Void>
// pc : INT* -> Pointer<Int32>
// cPoly : INT -> Int32
// iMode : CREATE_POLYGON_RGN_MODE -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreatePolyPolygonRgn(
  pptl: Pointer;   // POINT*
  pc: Pointer;   // INT*
  cPoly: Integer;   // INT
  iMode: Integer   // CREATE_POLYGON_RGN_MODE
): THandle; stdcall;
  external 'GDI32.dll' name 'CreatePolyPolygonRgn';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreatePolyPolygonRgn"
  c_CreatePolyPolygonRgn :: Ptr () -> Ptr Int32 -> Int32 -> Int32 -> IO (Ptr ())
-- pptl : POINT* -> Ptr ()
-- pc : INT* -> Ptr Int32
-- cPoly : INT -> Int32
-- iMode : CREATE_POLYGON_RGN_MODE -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createpolypolygonrgn =
  foreign "CreatePolyPolygonRgn"
    ((ptr void) @-> (ptr int32_t) @-> int32_t @-> int32_t @-> returning (ptr void))
(* pptl : POINT* -> (ptr void) *)
(* pc : INT* -> (ptr int32_t) *)
(* cPoly : INT -> int32_t *)
(* iMode : CREATE_POLYGON_RGN_MODE -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)

(cffi:defcfun ("CreatePolyPolygonRgn" create-poly-polygon-rgn :convention :stdcall) :pointer
  (pptl :pointer)   ; POINT*
  (pc :pointer)   ; INT*
  (c-poly :int32)   ; INT
  (i-mode :int32))   ; CREATE_POLYGON_RGN_MODE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreatePolyPolygonRgn = Win32::API::More->new('GDI32',
    'HANDLE CreatePolyPolygonRgn(LPVOID pptl, LPVOID pc, int cPoly, int iMode)');
# my $ret = $CreatePolyPolygonRgn->Call($pptl, $pc, $cPoly, $iMode);
# pptl : POINT* -> LPVOID
# pc : INT* -> LPVOID
# cPoly : INT -> int
# iMode : CREATE_POLYGON_RGN_MODE -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型