ホーム › Graphics.GdiPlus › GdipCreateFromHWNDICM
GdipCreateFromHWNDICM
関数ウィンドウからICM対応のGraphicsオブジェクトを作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreateFromHWNDICM(
HWND hwnd,
GpGraphics** graphics
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | 描画先となるウィンドウのハンドル(HWND)。 |
| graphics | GpGraphics** | inout | 生成されたGpGraphicsを受け取る出力先ポインタのアドレス。ICM色補正が有効。 |
戻り値の型: 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 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreateFromHWNDICM "GdipCreateFromHWNDICM" sptr, sptr ; res = GdipCreateFromHWNDICM(hwnd, varptr(graphics)) ; hwnd : HWND -> "sptr" ; graphics : GpGraphics** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; Status GdipCreateFromHWNDICM(HWND hwnd, GpGraphics** graphics) #uselib "gdiplus.dll" #cfunc global GdipCreateFromHWNDICM "GdipCreateFromHWNDICM" intptr, intptr ; res = GdipCreateFromHWNDICM(hwnd, varptr(graphics)) ; hwnd : HWND -> "intptr" ; graphics : GpGraphics** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // Statusfunction 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)。const std = @import("std");
extern "gdiplus" fn GdipCreateFromHWNDICM(
hwnd: ?*anyopaque, // HWND
graphics: [*c][*c]GpGraphics // GpGraphics** in/out
) callconv(std.os.windows.WINAPI) i32;proc GdipCreateFromHWNDICM(
hwnd: pointer, # HWND
graphics: ptr GpGraphics # GpGraphics** in/out
): int32 {.importc: "GdipCreateFromHWNDICM", stdcall, dynlib: "gdiplus.dll".}pragma(lib, "gdiplus");
extern(Windows)
int GdipCreateFromHWNDICM(
void* hwnd, // HWND
GpGraphics** graphics // GpGraphics** in/out
);ccall((:GdipCreateFromHWNDICM, "gdiplus.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{GpGraphics}),
hwnd, graphics)
# hwnd : HWND -> Ptr{Cvoid}
# graphics : GpGraphics** in/out -> Ptr{GpGraphics}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipCreateFromHWNDICM(
void* hwnd,
void* graphics);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipCreateFromHWNDICM(hwnd, graphics)
-- hwnd : HWND
-- graphics : GpGraphics** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipCreateFromHWNDICM = lib.func('__stdcall', 'GdipCreateFromHWNDICM', 'int32_t', ['void *', 'void *']);
// GdipCreateFromHWNDICM(hwnd, graphics)
// hwnd : HWND -> 'void *'
// graphics : GpGraphics** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipCreateFromHWNDICM: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipCreateFromHWNDICM(hwnd, graphics)
// hwnd : HWND -> "pointer"
// graphics : GpGraphics** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipCreateFromHWNDICM(
void* hwnd,
void* graphics);
C, "gdiplus.dll");
// $ffi->GdipCreateFromHWNDICM(hwnd, graphics);
// hwnd : HWND
// graphics : GpGraphics** in/out
// 構造体/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 Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class);
int GdipCreateFromHWNDICM(
Pointer hwnd, // HWND
Pointer graphics // GpGraphics** in/out
);
}@[Link("gdiplus")]
lib Libgdiplus
fun GdipCreateFromHWNDICM = GdipCreateFromHWNDICM(
hwnd : Void*, # HWND
graphics : GpGraphics** # GpGraphics** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipCreateFromHWNDICMNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef GdipCreateFromHWNDICMDart = int Function(Pointer<Void>, Pointer<Void>);
final GdipCreateFromHWNDICM = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipCreateFromHWNDICMNative, GdipCreateFromHWNDICMDart>('GdipCreateFromHWNDICM');
// hwnd : HWND -> Pointer<Void>
// graphics : GpGraphics** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipCreateFromHWNDICM(
hwnd: THandle; // HWND
graphics: Pointer // GpGraphics** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateFromHWNDICM';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipCreateFromHWNDICM"
c_GdipCreateFromHWNDICM :: Ptr () -> Ptr () -> IO Int32
-- hwnd : HWND -> Ptr ()
-- graphics : GpGraphics** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipcreatefromhwndicm =
foreign "GdipCreateFromHWNDICM"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* graphics : GpGraphics** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipCreateFromHWNDICM" gdip-create-from-hwndicm :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(graphics :pointer)) ; GpGraphics** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipCreateFromHWNDICM = Win32::API::More->new('gdiplus',
'int GdipCreateFromHWNDICM(HANDLE hwnd, LPVOID graphics)');
# my $ret = $GdipCreateFromHWNDICM->Call($hwnd, $graphics);
# hwnd : HWND -> HANDLE
# graphics : GpGraphics** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型