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

SetROP2

関数
前景描画のラスタ演算モード(描画モード)を設定する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT SetROP2(
    HDC hdc,
    R2_MODE rop2
);

パラメーター

名前方向
hdcHDCin
rop2R2_MODEin

戻り値の型: INT

各言語での呼び出し定義

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

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

SetROP2 = ctypes.windll.gdi32.SetROP2
SetROP2.restype = ctypes.c_int
SetROP2.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_int,  # rop2 : R2_MODE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procSetROP2 = gdi32.NewProc("SetROP2")
)

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