ホーム › Graphics.Gdi › ExtCreatePen
ExtCreatePen
関数スタイルや幅を細かく指定した論理ペンを作成する。
シグネチャ
// GDI32.dll
#include <windows.h>
HPEN ExtCreatePen(
DWORD iPenStyle,
DWORD cWidth,
const LOGBRUSH* plbrush,
DWORD cStyle,
const DWORD* pstyle // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| iPenStyle | DWORD | in |
| cWidth | DWORD | in |
| plbrush | LOGBRUSH* | in |
| cStyle | DWORD | in |
| pstyle | DWORD* | inoptional |
戻り値の型: HPEN
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
HPEN ExtCreatePen(
DWORD iPenStyle,
DWORD cWidth,
const LOGBRUSH* plbrush,
DWORD cStyle,
const DWORD* pstyle // optional
);[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr ExtCreatePen(
uint iPenStyle, // DWORD
uint cWidth, // DWORD
IntPtr plbrush, // LOGBRUSH*
uint cStyle, // DWORD
IntPtr pstyle // DWORD* optional
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function ExtCreatePen(
iPenStyle As UInteger, ' DWORD
cWidth As UInteger, ' DWORD
plbrush As IntPtr, ' LOGBRUSH*
cStyle As UInteger, ' DWORD
pstyle As IntPtr ' DWORD* optional
) As IntPtr
End Function' iPenStyle : DWORD
' cWidth : DWORD
' plbrush : LOGBRUSH*
' cStyle : DWORD
' pstyle : DWORD* optional
Declare PtrSafe Function ExtCreatePen Lib "gdi32" ( _
ByVal iPenStyle As Long, _
ByVal cWidth As Long, _
ByVal plbrush As LongPtr, _
ByVal cStyle As Long, _
ByVal pstyle As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ExtCreatePen = ctypes.windll.gdi32.ExtCreatePen
ExtCreatePen.restype = ctypes.c_void_p
ExtCreatePen.argtypes = [
wintypes.DWORD, # iPenStyle : DWORD
wintypes.DWORD, # cWidth : DWORD
ctypes.c_void_p, # plbrush : LOGBRUSH*
wintypes.DWORD, # cStyle : DWORD
ctypes.POINTER(wintypes.DWORD), # pstyle : DWORD* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
ExtCreatePen = Fiddle::Function.new(
lib['ExtCreatePen'],
[
-Fiddle::TYPE_INT, # iPenStyle : DWORD
-Fiddle::TYPE_INT, # cWidth : DWORD
Fiddle::TYPE_VOIDP, # plbrush : LOGBRUSH*
-Fiddle::TYPE_INT, # cStyle : DWORD
Fiddle::TYPE_VOIDP, # pstyle : DWORD* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "gdi32")]
extern "system" {
fn ExtCreatePen(
iPenStyle: u32, // DWORD
cWidth: u32, // DWORD
plbrush: *const LOGBRUSH, // LOGBRUSH*
cStyle: u32, // DWORD
pstyle: *const u32 // DWORD* optional
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr ExtCreatePen(uint iPenStyle, uint cWidth, IntPtr plbrush, uint cStyle, IntPtr pstyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_ExtCreatePen' -Namespace Win32 -PassThru
# $api::ExtCreatePen(iPenStyle, cWidth, plbrush, cStyle, pstyle)#uselib "GDI32.dll"
#func global ExtCreatePen "ExtCreatePen" sptr, sptr, sptr, sptr, sptr
; ExtCreatePen iPenStyle, cWidth, varptr(plbrush), cStyle, varptr(pstyle) ; 戻り値は stat
; iPenStyle : DWORD -> "sptr"
; cWidth : DWORD -> "sptr"
; plbrush : LOGBRUSH* -> "sptr"
; cStyle : DWORD -> "sptr"
; pstyle : DWORD* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global ExtCreatePen "ExtCreatePen" int, int, var, int, var ; res = ExtCreatePen(iPenStyle, cWidth, plbrush, cStyle, pstyle) ; iPenStyle : DWORD -> "int" ; cWidth : DWORD -> "int" ; plbrush : LOGBRUSH* -> "var" ; cStyle : DWORD -> "int" ; pstyle : DWORD* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global ExtCreatePen "ExtCreatePen" int, int, sptr, int, sptr ; res = ExtCreatePen(iPenStyle, cWidth, varptr(plbrush), cStyle, varptr(pstyle)) ; iPenStyle : DWORD -> "int" ; cWidth : DWORD -> "int" ; plbrush : LOGBRUSH* -> "sptr" ; cStyle : DWORD -> "int" ; pstyle : DWORD* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HPEN ExtCreatePen(DWORD iPenStyle, DWORD cWidth, LOGBRUSH* plbrush, DWORD cStyle, DWORD* pstyle) #uselib "GDI32.dll" #cfunc global ExtCreatePen "ExtCreatePen" int, int, var, int, var ; res = ExtCreatePen(iPenStyle, cWidth, plbrush, cStyle, pstyle) ; iPenStyle : DWORD -> "int" ; cWidth : DWORD -> "int" ; plbrush : LOGBRUSH* -> "var" ; cStyle : DWORD -> "int" ; pstyle : DWORD* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HPEN ExtCreatePen(DWORD iPenStyle, DWORD cWidth, LOGBRUSH* plbrush, DWORD cStyle, DWORD* pstyle) #uselib "GDI32.dll" #cfunc global ExtCreatePen "ExtCreatePen" int, int, intptr, int, intptr ; res = ExtCreatePen(iPenStyle, cWidth, varptr(plbrush), cStyle, varptr(pstyle)) ; iPenStyle : DWORD -> "int" ; cWidth : DWORD -> "int" ; plbrush : LOGBRUSH* -> "intptr" ; cStyle : DWORD -> "int" ; pstyle : DWORD* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procExtCreatePen = gdi32.NewProc("ExtCreatePen")
)
// iPenStyle (DWORD), cWidth (DWORD), plbrush (LOGBRUSH*), cStyle (DWORD), pstyle (DWORD* optional)
r1, _, err := procExtCreatePen.Call(
uintptr(iPenStyle),
uintptr(cWidth),
uintptr(plbrush),
uintptr(cStyle),
uintptr(pstyle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HPENfunction ExtCreatePen(
iPenStyle: DWORD; // DWORD
cWidth: DWORD; // DWORD
plbrush: Pointer; // LOGBRUSH*
cStyle: DWORD; // DWORD
pstyle: Pointer // DWORD* optional
): THandle; stdcall;
external 'GDI32.dll' name 'ExtCreatePen';result := DllCall("GDI32\ExtCreatePen"
, "UInt", iPenStyle ; DWORD
, "UInt", cWidth ; DWORD
, "Ptr", plbrush ; LOGBRUSH*
, "UInt", cStyle ; DWORD
, "Ptr", pstyle ; DWORD* optional
, "Ptr") ; return: HPEN●ExtCreatePen(iPenStyle, cWidth, plbrush, cStyle, pstyle) = DLL("GDI32.dll", "void* ExtCreatePen(dword, dword, void*, dword, void*)")
# 呼び出し: ExtCreatePen(iPenStyle, cWidth, plbrush, cStyle, pstyle)
# iPenStyle : DWORD -> "dword"
# cWidth : DWORD -> "dword"
# plbrush : LOGBRUSH* -> "void*"
# cStyle : DWORD -> "dword"
# pstyle : DWORD* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。