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

GdipCreateFromHWNDICM

関数
ウィンドウからICM対応のGraphicsオブジェクトを作成する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipCreateFromHWNDICM(
    HWND hwnd,
    GpGraphics** graphics
);

パラメーター

名前方向
hwndHWNDin
graphicsGpGraphics**inout

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipCreateFromHWNDICM(
    HWND hwnd,
    GpGraphics** graphics
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreateFromHWNDICM(
    IntPtr hwnd,   // HWND
    IntPtr graphics   // GpGraphics** in/out
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreateFromHWNDICM(
    hwnd As IntPtr,   ' HWND
    graphics As IntPtr   ' GpGraphics** in/out
) As Integer
End Function
' hwnd : HWND
' graphics : GpGraphics** in/out
Declare PtrSafe Function GdipCreateFromHWNDICM Lib "gdiplus" ( _
    ByVal hwnd As LongPtr, _
    ByVal graphics As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipCreateFromHWNDICM = ctypes.windll.gdiplus.GdipCreateFromHWNDICM
GdipCreateFromHWNDICM.restype = ctypes.c_int
GdipCreateFromHWNDICM.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    ctypes.c_void_p,  # graphics : GpGraphics** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateFromHWNDICM = Fiddle::Function.new(
  lib['GdipCreateFromHWNDICM'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_VOIDP,  # graphics : GpGraphics** in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipCreateFromHWNDICM(
        hwnd: *mut core::ffi::c_void,  // HWND
        graphics: *mut *mut GpGraphics  // GpGraphics** in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipCreateFromHWNDICM(IntPtr hwnd, IntPtr graphics);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateFromHWNDICM' -Namespace Win32 -PassThru
# $api::GdipCreateFromHWNDICM(hwnd, graphics)
#uselib "gdiplus.dll"
#func global GdipCreateFromHWNDICM "GdipCreateFromHWNDICM" sptr, sptr
; GdipCreateFromHWNDICM hwnd, varptr(graphics)   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; graphics : GpGraphics** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipCreateFromHWNDICM "GdipCreateFromHWNDICM" sptr, var
; res = GdipCreateFromHWNDICM(hwnd, graphics)
; hwnd : HWND -> "sptr"
; graphics : GpGraphics** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipCreateFromHWNDICM(HWND hwnd, GpGraphics** graphics)
#uselib "gdiplus.dll"
#cfunc global GdipCreateFromHWNDICM "GdipCreateFromHWNDICM" intptr, var
; res = GdipCreateFromHWNDICM(hwnd, graphics)
; hwnd : HWND -> "intptr"
; graphics : GpGraphics** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipCreateFromHWNDICM = gdiplus.NewProc("GdipCreateFromHWNDICM")
)

// hwnd (HWND), graphics (GpGraphics** in/out)
r1, _, err := procGdipCreateFromHWNDICM.Call(
	uintptr(hwnd),
	uintptr(graphics),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipCreateFromHWNDICM(
  hwnd: THandle;   // HWND
  graphics: Pointer   // GpGraphics** in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipCreateFromHWNDICM';
result := DllCall("gdiplus\GdipCreateFromHWNDICM"
    , "Ptr", hwnd   ; HWND
    , "Ptr", graphics   ; GpGraphics** in/out
    , "Int")   ; return: Status
●GdipCreateFromHWNDICM(hwnd, graphics) = DLL("gdiplus.dll", "int GdipCreateFromHWNDICM(void*, void*)")
# 呼び出し: GdipCreateFromHWNDICM(hwnd, graphics)
# hwnd : HWND -> "void*"
# graphics : GpGraphics** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。