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

SetMiterLimit

関数
幾何ペンのマイター接合部の長さ制限を設定する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL SetMiterLimit(
    HDC hdc,
    FLOAT limit,
    FLOAT* old   // optional
);

パラメーター

名前方向
hdcHDCin
limitFLOATin
oldFLOAT*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetMiterLimit(
    HDC hdc,
    FLOAT limit,
    FLOAT* old   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool SetMiterLimit(
    IntPtr hdc,   // HDC
    float limit,   // FLOAT
    IntPtr old   // FLOAT* optional, out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function SetMiterLimit(
    hdc As IntPtr,   ' HDC
    limit As Single,   ' FLOAT
    old As IntPtr   ' FLOAT* optional, out
) As Boolean
End Function
' hdc : HDC
' limit : FLOAT
' old : FLOAT* optional, out
Declare PtrSafe Function SetMiterLimit Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal limit As Single, _
    ByVal old As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetMiterLimit = ctypes.windll.gdi32.SetMiterLimit
SetMiterLimit.restype = wintypes.BOOL
SetMiterLimit.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_float,  # limit : FLOAT
    ctypes.POINTER(ctypes.c_float),  # old : FLOAT* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
SetMiterLimit = Fiddle::Function.new(
  lib['SetMiterLimit'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_FLOAT,  # limit : FLOAT
    Fiddle::TYPE_VOIDP,  # old : FLOAT* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn SetMiterLimit(
        hdc: *mut core::ffi::c_void,  // HDC
        limit: f32,  // FLOAT
        old: *mut f32  // FLOAT* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool SetMiterLimit(IntPtr hdc, float limit, IntPtr old);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_SetMiterLimit' -Namespace Win32 -PassThru
# $api::SetMiterLimit(hdc, limit, old)
#uselib "GDI32.dll"
#func global SetMiterLimit "SetMiterLimit" sptr, float, sptr
; SetMiterLimit hdc, limit, varptr(old)   ; 戻り値は stat
; hdc : HDC -> "sptr"
; limit : FLOAT -> "float"
; old : FLOAT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global SetMiterLimit "SetMiterLimit" sptr, float, var
; res = SetMiterLimit(hdc, limit, old)
; hdc : HDC -> "sptr"
; limit : FLOAT -> "float"
; old : FLOAT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetMiterLimit(HDC hdc, FLOAT limit, FLOAT* old)
#uselib "GDI32.dll"
#cfunc global SetMiterLimit "SetMiterLimit" intptr, float, var
; res = SetMiterLimit(hdc, limit, old)
; hdc : HDC -> "intptr"
; limit : FLOAT -> "float"
; old : FLOAT* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procSetMiterLimit = gdi32.NewProc("SetMiterLimit")
)

// hdc (HDC), limit (FLOAT), old (FLOAT* optional, out)
r1, _, err := procSetMiterLimit.Call(
	uintptr(hdc),
	uintptr(math.Float32bits(limit)),
	uintptr(old),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function SetMiterLimit(
  hdc: THandle;   // HDC
  limit: Single;   // FLOAT
  old: Pointer   // FLOAT* optional, out
): BOOL; stdcall;
  external 'GDI32.dll' name 'SetMiterLimit';
result := DllCall("GDI32\SetMiterLimit"
    , "Ptr", hdc   ; HDC
    , "Float", limit   ; FLOAT
    , "Ptr", old   ; FLOAT* optional, out
    , "Int")   ; return: BOOL
●SetMiterLimit(hdc, limit, old) = DLL("GDI32.dll", "bool SetMiterLimit(void*, float, void*)")
# 呼び出し: SetMiterLimit(hdc, limit, old)
# hdc : HDC -> "void*"
# limit : FLOAT -> "float"
# old : FLOAT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。