Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipSetPenColor

GdipSetPenColor

関数
ペンの描画色をARGB値で設定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// gdiplus.dll
#include <windows.h>

Status GdipSetPenColor(
    GpPen* pen,
    DWORD argb
);

パラメーター

名前方向
penGpPen*inout
argbDWORDin

戻り値の型: Status

各言語での呼び出し定義

// gdiplus.dll
#include <windows.h>

Status GdipSetPenColor(
    GpPen* pen,
    DWORD argb
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipSetPenColor(
    IntPtr pen,   // GpPen* in/out
    uint argb   // DWORD
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipSetPenColor(
    pen As IntPtr,   ' GpPen* in/out
    argb As UInteger   ' DWORD
) As Integer
End Function
' pen : GpPen* in/out
' argb : DWORD
Declare PtrSafe Function GdipSetPenColor Lib "gdiplus" ( _
    ByVal pen As LongPtr, _
    ByVal argb As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipSetPenColor = ctypes.windll.gdiplus.GdipSetPenColor
GdipSetPenColor.restype = ctypes.c_int
GdipSetPenColor.argtypes = [
    ctypes.c_void_p,  # pen : GpPen* in/out
    wintypes.DWORD,  # argb : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipSetPenColor = Fiddle::Function.new(
  lib['GdipSetPenColor'],
  [
    Fiddle::TYPE_VOIDP,  # pen : GpPen* in/out
    -Fiddle::TYPE_INT,  # argb : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipSetPenColor(
        pen: *mut GpPen,  // GpPen* in/out
        argb: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipSetPenColor(IntPtr pen, uint argb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipSetPenColor' -Namespace Win32 -PassThru
# $api::GdipSetPenColor(pen, argb)
#uselib "gdiplus.dll"
#func global GdipSetPenColor "GdipSetPenColor" sptr, sptr
; GdipSetPenColor varptr(pen), argb   ; 戻り値は stat
; pen : GpPen* in/out -> "sptr"
; argb : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipSetPenColor "GdipSetPenColor" var, int
; res = GdipSetPenColor(pen, argb)
; pen : GpPen* in/out -> "var"
; argb : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipSetPenColor(GpPen* pen, DWORD argb)
#uselib "gdiplus.dll"
#cfunc global GdipSetPenColor "GdipSetPenColor" var, int
; res = GdipSetPenColor(pen, argb)
; pen : GpPen* in/out -> "var"
; argb : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipSetPenColor = gdiplus.NewProc("GdipSetPenColor")
)

// pen (GpPen* in/out), argb (DWORD)
r1, _, err := procGdipSetPenColor.Call(
	uintptr(pen),
	uintptr(argb),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipSetPenColor(
  pen: Pointer;   // GpPen* in/out
  argb: DWORD   // DWORD
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipSetPenColor';
result := DllCall("gdiplus\GdipSetPenColor"
    , "Ptr", pen   ; GpPen* in/out
    , "UInt", argb   ; DWORD
    , "Int")   ; return: Status
●GdipSetPenColor(pen, argb) = DLL("gdiplus.dll", "int GdipSetPenColor(void*, dword)")
# 呼び出し: GdipSetPenColor(pen, argb)
# pen : GpPen* in/out -> "void*"
# argb : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。