ホーム › Graphics.GdiPlus › GdipCreatePen1
GdipCreatePen1
関数指定した色・幅・単位で線描画用のペンを新規作成する。
シグネチャ
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen1(
DWORD color,
FLOAT width,
Unit unit,
GpPen** pen
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| color | DWORD | in |
| width | FLOAT | in |
| unit | Unit | in |
| pen | GpPen** | inout |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll
#include <windows.h>
Status GdipCreatePen1(
DWORD color,
FLOAT width,
Unit unit,
GpPen** pen
);[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipCreatePen1(
uint color, // DWORD
float width, // FLOAT
int unit, // Unit
IntPtr pen // GpPen** in/out
);<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipCreatePen1(
color As UInteger, ' DWORD
width As Single, ' FLOAT
unit As Integer, ' Unit
pen As IntPtr ' GpPen** in/out
) As Integer
End Function' color : DWORD
' width : FLOAT
' unit : Unit
' pen : GpPen** in/out
Declare PtrSafe Function GdipCreatePen1 Lib "gdiplus" ( _
ByVal color As Long, _
ByVal width As Single, _
ByVal unit As Long, _
ByVal pen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GdipCreatePen1 = ctypes.windll.gdiplus.GdipCreatePen1
GdipCreatePen1.restype = ctypes.c_int
GdipCreatePen1.argtypes = [
wintypes.DWORD, # color : DWORD
ctypes.c_float, # width : FLOAT
ctypes.c_int, # unit : Unit
ctypes.c_void_p, # pen : GpPen** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipCreatePen1 = Fiddle::Function.new(
lib['GdipCreatePen1'],
[
-Fiddle::TYPE_INT, # color : DWORD
Fiddle::TYPE_FLOAT, # width : FLOAT
Fiddle::TYPE_INT, # unit : Unit
Fiddle::TYPE_VOIDP, # pen : GpPen** in/out
],
Fiddle::TYPE_INT)#[link(name = "gdiplus")]
extern "system" {
fn GdipCreatePen1(
color: u32, // DWORD
width: f32, // FLOAT
unit: i32, // Unit
pen: *mut *mut GpPen // GpPen** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipCreatePen1(uint color, float width, int unit, IntPtr pen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipCreatePen1' -Namespace Win32 -PassThru
# $api::GdipCreatePen1(color, width, unit, pen)#uselib "gdiplus.dll"
#func global GdipCreatePen1 "GdipCreatePen1" sptr, float, sptr, sptr
; GdipCreatePen1 color, width, unit, varptr(pen) ; 戻り値は stat
; color : DWORD -> "sptr"
; width : FLOAT -> "float"
; unit : Unit -> "sptr"
; pen : GpPen** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, var ; res = GdipCreatePen1(color, width, unit, pen) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, sptr ; res = GdipCreatePen1(color, width, unit, varptr(pen)) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipCreatePen1(DWORD color, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, var ; res = GdipCreatePen1(color, width, unit, pen) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipCreatePen1(DWORD color, FLOAT width, Unit unit, GpPen** pen) #uselib "gdiplus.dll" #cfunc global GdipCreatePen1 "GdipCreatePen1" int, float, int, intptr ; res = GdipCreatePen1(color, width, unit, varptr(pen)) ; color : DWORD -> "int" ; width : FLOAT -> "float" ; unit : Unit -> "int" ; pen : GpPen** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipCreatePen1 = gdiplus.NewProc("GdipCreatePen1")
)
// color (DWORD), width (FLOAT), unit (Unit), pen (GpPen** in/out)
r1, _, err := procGdipCreatePen1.Call(
uintptr(color),
uintptr(math.Float32bits(width)),
uintptr(unit),
uintptr(pen),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Status
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。function GdipCreatePen1(
color: DWORD; // DWORD
width: Single; // FLOAT
unit: Integer; // Unit
pen: Pointer // GpPen** in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipCreatePen1';result := DllCall("gdiplus\GdipCreatePen1"
, "UInt", color ; DWORD
, "Float", width ; FLOAT
, "Int", unit ; Unit
, "Ptr", pen ; GpPen** in/out
, "Int") ; return: Status●GdipCreatePen1(color, width, unit, pen) = DLL("gdiplus.dll", "int GdipCreatePen1(dword, float, int, void*)")
# 呼び出し: GdipCreatePen1(color, width, unit, pen)
# color : DWORD -> "dword"
# width : FLOAT -> "float"
# unit : Unit -> "int"
# pen : GpPen** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。