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