ホーム › Graphics.GdiPlus › GdipCreateFromHDC
GdipCreateFromHDC
関数デバイスコンテキストからGraphicsオブジェクトを作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreateFromHDC(
HDC hdc,
GpGraphics** graphics
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| graphics | GpGraphics** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreateFromHDC(
HDC hdc,
GpGraphics** graphics
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreateFromHDC(
IntPtr hdc, // HDC
IntPtr graphics // GpGraphics** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreateFromHDC(
hdc As IntPtr, ' HDC
graphics As IntPtr ' GpGraphics** in/out
) As Integer
End Function' hdc : HDC
' graphics : GpGraphics** in/out
Declare PtrSafe Function GdipCreateFromHDC Lib "gdiplus" ( _
ByVal hdc 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
GdipCreateFromHDC = ctypes.windll.gdiplus.GdipCreateFromHDC
GdipCreateFromHDC.restype = ctypes.c_int
GdipCreateFromHDC.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # graphics : GpGraphics** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreateFromHDC = Fiddle::Function.new(
lib['GdipCreateFromHDC'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # graphics : GpGraphics** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipCreateFromHDC(
hdc: *mut core::ffi::c_void, // HDC
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 GdipCreateFromHDC(IntPtr hdc, IntPtr graphics);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreateFromHDC' -Namespace Win32 -PassThru
# $api::GdipCreateFromHDC(hdc, graphics)#uselib "gdiplus.dll"
#func global GdipCreateFromHDC "GdipCreateFromHDC" sptr, sptr
; GdipCreateFromHDC hdc, varptr(graphics) ; 戻り値は stat
; hdc : HDC -> "sptr"
; graphics : GpGraphics** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreateFromHDC "GdipCreateFromHDC" sptr, var ; res = GdipCreateFromHDC(hdc, graphics) ; hdc : HDC -> "sptr" ; graphics : GpGraphics** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreateFromHDC "GdipCreateFromHDC" sptr, sptr ; res = GdipCreateFromHDC(hdc, varptr(graphics)) ; hdc : HDC -> "sptr" ; graphics : GpGraphics** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreateFromHDC(HDC hdc, GpGraphics** graphics) #uselib "gdiplus.dll" #cfunc global GdipCreateFromHDC "GdipCreateFromHDC" intptr, var ; res = GdipCreateFromHDC(hdc, graphics) ; hdc : HDC -> "intptr" ; graphics : GpGraphics** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreateFromHDC(HDC hdc, GpGraphics** graphics) #uselib "gdiplus.dll" #cfunc global GdipCreateFromHDC "GdipCreateFromHDC" intptr, intptr ; res = GdipCreateFromHDC(hdc, varptr(graphics)) ; hdc : HDC -> "intptr" ; graphics : GpGraphics** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreateFromHDC = gdiplus.NewProc("GdipCreateFromHDC")
)
// hdc (HDC), graphics (GpGraphics** in/out)
r1, _, err := procGdipCreateFromHDC.Call(
uintptr(hdc),
uintptr(graphics),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipCreateFromHDC(
hdc: THandle; // HDC
graphics: Pointer // GpGraphics** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreateFromHDC';result := DllCall("gdiplus\GdipCreateFromHDC"
, "Ptr", hdc ; HDC
, "Ptr", graphics ; GpGraphics** in/out
, "Int") ; return: Status●GdipCreateFromHDC(hdc, graphics) = DLL("gdiplus.dll", "int GdipCreateFromHDC(void*, void*)")
# 呼び出し: GdipCreateFromHDC(hdc, graphics)
# hdc : HDC -> "void*"
# graphics : GpGraphics** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。