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

SelectClipRgn

関数
指定した領域をクリッピング領域に設定する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

GDI_REGION_TYPE SelectClipRgn(
    HDC hdc,
    HRGN hrgn   // optional
);

パラメーター

名前方向
hdcHDCin
hrgnHRGNinoptional

戻り値の型: GDI_REGION_TYPE

各言語での呼び出し定義

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

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

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

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procSelectClipRgn = gdi32.NewProc("SelectClipRgn")
)

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