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

ExtSelectClipRgn

関数
現在のクリッピング領域と指定領域を結合する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

GDI_REGION_TYPE ExtSelectClipRgn(
    HDC hdc,
    HRGN hrgn,   // optional
    RGN_COMBINE_MODE mode
);

パラメーター

名前方向説明
hdcHDCinデバイスコンテキストへのハンドル。
hrgnHRGNinoptional選択するリージョンへのハンドル。RGN_COPY モードを指定する場合を除き、このハンドルを NULL にすることはできません。
modeRGN_COMBINE_MODEin

実行する操作。次のいずれかの値を指定する必要があります。

意味
RGN_AND
新しいクリッピングリージョンは、現在のクリッピングリージョンと hrgn で指定されたリージョンの重なり合う領域を結合したものになります。
RGN_COPY
新しいクリッピングリージョンは、hrgn で指定されたリージョンのコピーになります。これは SelectClipRgn と同じです。hrgn で指定されたリージョンが NULL の場合、新しいクリッピングリージョンは既定のクリッピングリージョン(既定のクリッピングリージョンは null リージョン)になります。
RGN_DIFF
新しいクリッピングリージョンは、現在のクリッピングリージョンの領域から、hrgn で指定されたリージョンの領域を除いた領域を結合したものになります。
RGN_OR
新しいクリッピングリージョンは、現在のクリッピングリージョンと hrgn で指定されたリージョンを結合したものになります。
RGN_XOR
新しいクリッピングリージョンは、現在のクリッピングリージョンと hrgn で指定されたリージョンを結合しますが、重なり合う領域は除外されます。

戻り値の型: GDI_REGION_TYPE

公式ドキュメント

ExtSelectClipRgn 関数は、指定したリージョンを現在のクリッピングリージョンと指定したモードで結合します。

戻り値

戻り値は、新しいクリッピングリージョンの複雑度を示します。次のいずれかの値になります。

戻り値 説明
NULLREGION
リージョンは空です。
SIMPLEREGION
リージョンは単一の矩形です。
COMPLEXREGION
リージョンは複数の矩形です。
ERROR
エラーが発生しました。

解説(Remarks)

この関数の呼び出し時にエラーが発生した場合、指定したデバイスコンテキストの以前のクリッピングリージョンは影響を受けません。

ExtSelectClipRgn 関数は、指定したリージョンの座標がデバイス単位で指定されているものとみなします。

hrgn パラメーターで指定されたリージョンのコピーのみが使用されます。リージョン自体は、この呼び出しの後に再利用することも、削除することもできます。

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

各言語での呼び出し定義

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

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

ExtSelectClipRgn = ctypes.windll.gdi32.ExtSelectClipRgn
ExtSelectClipRgn.restype = ctypes.c_int
ExtSelectClipRgn.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.HANDLE,  # hrgn : HRGN optional
    ctypes.c_int,  # mode : RGN_COMBINE_MODE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procExtSelectClipRgn = gdi32.NewProc("ExtSelectClipRgn")
)

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

extern "gdi32" fn ExtSelectClipRgn(
    hdc: ?*anyopaque, // HDC
    hrgn: ?*anyopaque, // HRGN optional
    mode: i32 // RGN_COMBINE_MODE
) callconv(std.os.windows.WINAPI) i32;
proc ExtSelectClipRgn(
    hdc: pointer,  # HDC
    hrgn: pointer,  # HRGN optional
    mode: int32  # RGN_COMBINE_MODE
): int32 {.importc: "ExtSelectClipRgn", stdcall, dynlib: "GDI32.dll".}
pragma(lib, "gdi32");
extern(Windows)
int ExtSelectClipRgn(
    void* hdc,   // HDC
    void* hrgn,   // HRGN optional
    int mode   // RGN_COMBINE_MODE
);
ccall((:ExtSelectClipRgn, "GDI32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Int32),
      hdc, hrgn, mode)
# hdc : HDC -> Ptr{Cvoid}
# hrgn : HRGN optional -> Ptr{Cvoid}
# mode : RGN_COMBINE_MODE -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ExtSelectClipRgn(
    void* hdc,
    void* hrgn,
    int32_t mode);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.ExtSelectClipRgn(hdc, hrgn, mode)
-- hdc : HDC
-- hrgn : HRGN optional
-- mode : RGN_COMBINE_MODE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const ExtSelectClipRgn = lib.func('__stdcall', 'ExtSelectClipRgn', 'int32_t', ['void *', 'void *', 'int32_t']);
// ExtSelectClipRgn(hdc, hrgn, mode)
// hdc : HDC -> 'void *'
// hrgn : HRGN optional -> 'void *'
// mode : RGN_COMBINE_MODE -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("GDI32.dll", {
  ExtSelectClipRgn: { parameters: ["pointer", "pointer", "i32"], result: "i32" },
});
// lib.symbols.ExtSelectClipRgn(hdc, hrgn, mode)
// hdc : HDC -> "pointer"
// hrgn : HRGN optional -> "pointer"
// mode : RGN_COMBINE_MODE -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ExtSelectClipRgn(
    void* hdc,
    void* hrgn,
    int32_t mode);
C, "GDI32.dll");
// $ffi->ExtSelectClipRgn(hdc, hrgn, mode);
// hdc : HDC
// hrgn : HRGN optional
// mode : RGN_COMBINE_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);
    int ExtSelectClipRgn(
        Pointer hdc,   // HDC
        Pointer hrgn,   // HRGN optional
        int mode   // RGN_COMBINE_MODE
    );
}
@[Link("gdi32")]
lib LibGDI32
  fun ExtSelectClipRgn = ExtSelectClipRgn(
    hdc : Void*,   # HDC
    hrgn : Void*,   # HRGN optional
    mode : Int32   # RGN_COMBINE_MODE
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ExtSelectClipRgnNative = Int32 Function(Pointer<Void>, Pointer<Void>, Int32);
typedef ExtSelectClipRgnDart = int Function(Pointer<Void>, Pointer<Void>, int);
final ExtSelectClipRgn = DynamicLibrary.open('GDI32.dll')
    .lookupFunction<ExtSelectClipRgnNative, ExtSelectClipRgnDart>('ExtSelectClipRgn');
// hdc : HDC -> Pointer<Void>
// hrgn : HRGN optional -> Pointer<Void>
// mode : RGN_COMBINE_MODE -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ExtSelectClipRgn(
  hdc: THandle;   // HDC
  hrgn: THandle;   // HRGN optional
  mode: Integer   // RGN_COMBINE_MODE
): Integer; stdcall;
  external 'GDI32.dll' name 'ExtSelectClipRgn';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ExtSelectClipRgn"
  c_ExtSelectClipRgn :: Ptr () -> Ptr () -> Int32 -> IO Int32
-- hdc : HDC -> Ptr ()
-- hrgn : HRGN optional -> Ptr ()
-- mode : RGN_COMBINE_MODE -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let extselectcliprgn =
  foreign "ExtSelectClipRgn"
    ((ptr void) @-> (ptr void) @-> int32_t @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* hrgn : HRGN optional -> (ptr void) *)
(* mode : RGN_COMBINE_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 ("ExtSelectClipRgn" ext-select-clip-rgn :convention :stdcall) :int32
  (hdc :pointer)   ; HDC
  (hrgn :pointer)   ; HRGN optional
  (mode :int32))   ; RGN_COMBINE_MODE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ExtSelectClipRgn = Win32::API::More->new('GDI32',
    'int ExtSelectClipRgn(HANDLE hdc, HANDLE hrgn, int mode)');
# my $ret = $ExtSelectClipRgn->Call($hdc, $hrgn, $mode);
# hdc : HDC -> HANDLE
# hrgn : HRGN optional -> HANDLE
# mode : RGN_COMBINE_MODE -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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