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

GdipMeasureCharacterRanges

関数
文字列内の文字範囲ごとの領域を測定する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipMeasureCharacterRanges(
    GpGraphics* graphics,
    LPCWSTR string,
    INT length,
    const GpFont* font,
    const RectF* layoutRect,
    const GpStringFormat* stringFormat,
    INT regionCount,
    GpRegion** regions
);

パラメーター

名前方向
graphicsGpGraphics*inout
stringLPCWSTRin
lengthINTin
fontGpFont*in
layoutRectRectF*in
stringFormatGpStringFormat*in
regionCountINTin
regionsGpRegion**inout

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipMeasureCharacterRanges(
    GpGraphics* graphics,
    LPCWSTR string,
    INT length,
    const GpFont* font,
    const RectF* layoutRect,
    const GpStringFormat* stringFormat,
    INT regionCount,
    GpRegion** regions
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipMeasureCharacterRanges(
    IntPtr graphics,   // GpGraphics* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string string,   // LPCWSTR
    int length,   // INT
    IntPtr font,   // GpFont*
    IntPtr layoutRect,   // RectF*
    IntPtr stringFormat,   // GpStringFormat*
    int regionCount,   // INT
    IntPtr regions   // GpRegion** in/out
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipMeasureCharacterRanges(
    graphics As IntPtr,   ' GpGraphics* in/out
    <MarshalAs(UnmanagedType.LPWStr)> [string] As String,   ' LPCWSTR
    length As Integer,   ' INT
    font As IntPtr,   ' GpFont*
    layoutRect As IntPtr,   ' RectF*
    stringFormat As IntPtr,   ' GpStringFormat*
    regionCount As Integer,   ' INT
    regions As IntPtr   ' GpRegion** in/out
) As Integer
End Function
' graphics : GpGraphics* in/out
' string : LPCWSTR
' length : INT
' font : GpFont*
' layoutRect : RectF*
' stringFormat : GpStringFormat*
' regionCount : INT
' regions : GpRegion** in/out
Declare PtrSafe Function GdipMeasureCharacterRanges Lib "gdiplus" ( _
    ByVal graphics As LongPtr, _
    ByVal string As LongPtr, _
    ByVal length As Long, _
    ByVal font As LongPtr, _
    ByVal layoutRect As LongPtr, _
    ByVal stringFormat As LongPtr, _
    ByVal regionCount As Long, _
    ByVal regions As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipMeasureCharacterRanges = ctypes.windll.gdiplus.GdipMeasureCharacterRanges
GdipMeasureCharacterRanges.restype = ctypes.c_int
GdipMeasureCharacterRanges.argtypes = [
    ctypes.c_void_p,  # graphics : GpGraphics* in/out
    wintypes.LPCWSTR,  # string : LPCWSTR
    ctypes.c_int,  # length : INT
    ctypes.c_void_p,  # font : GpFont*
    ctypes.c_void_p,  # layoutRect : RectF*
    ctypes.c_void_p,  # stringFormat : GpStringFormat*
    ctypes.c_int,  # regionCount : INT
    ctypes.c_void_p,  # regions : GpRegion** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipMeasureCharacterRanges = Fiddle::Function.new(
  lib['GdipMeasureCharacterRanges'],
  [
    Fiddle::TYPE_VOIDP,  # graphics : GpGraphics* in/out
    Fiddle::TYPE_VOIDP,  # string : LPCWSTR
    Fiddle::TYPE_INT,  # length : INT
    Fiddle::TYPE_VOIDP,  # font : GpFont*
    Fiddle::TYPE_VOIDP,  # layoutRect : RectF*
    Fiddle::TYPE_VOIDP,  # stringFormat : GpStringFormat*
    Fiddle::TYPE_INT,  # regionCount : INT
    Fiddle::TYPE_VOIDP,  # regions : GpRegion** in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipMeasureCharacterRanges(
        graphics: *mut GpGraphics,  // GpGraphics* in/out
        string: *const u16,  // LPCWSTR
        length: i32,  // INT
        font: *const GpFont,  // GpFont*
        layoutRect: *const RectF,  // RectF*
        stringFormat: *const GpStringFormat,  // GpStringFormat*
        regionCount: i32,  // INT
        regions: *mut *mut GpRegion  // GpRegion** in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipMeasureCharacterRanges(IntPtr graphics, [MarshalAs(UnmanagedType.LPWStr)] string string, int length, IntPtr font, IntPtr layoutRect, IntPtr stringFormat, int regionCount, IntPtr regions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipMeasureCharacterRanges' -Namespace Win32 -PassThru
# $api::GdipMeasureCharacterRanges(graphics, string, length, font, layoutRect, stringFormat, regionCount, regions)
#uselib "gdiplus.dll"
#func global GdipMeasureCharacterRanges "GdipMeasureCharacterRanges" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GdipMeasureCharacterRanges varptr(graphics), string, length, varptr(font), varptr(layoutRect), varptr(stringFormat), regionCount, varptr(regions)   ; 戻り値は stat
; graphics : GpGraphics* in/out -> "sptr"
; string : LPCWSTR -> "sptr"
; length : INT -> "sptr"
; font : GpFont* -> "sptr"
; layoutRect : RectF* -> "sptr"
; stringFormat : GpStringFormat* -> "sptr"
; regionCount : INT -> "sptr"
; regions : GpRegion** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipMeasureCharacterRanges "GdipMeasureCharacterRanges" var, wstr, int, var, var, var, int, var
; res = GdipMeasureCharacterRanges(graphics, string, length, font, layoutRect, stringFormat, regionCount, regions)
; graphics : GpGraphics* in/out -> "var"
; string : LPCWSTR -> "wstr"
; length : INT -> "int"
; font : GpFont* -> "var"
; layoutRect : RectF* -> "var"
; stringFormat : GpStringFormat* -> "var"
; regionCount : INT -> "int"
; regions : GpRegion** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipMeasureCharacterRanges(GpGraphics* graphics, LPCWSTR string, INT length, GpFont* font, RectF* layoutRect, GpStringFormat* stringFormat, INT regionCount, GpRegion** regions)
#uselib "gdiplus.dll"
#cfunc global GdipMeasureCharacterRanges "GdipMeasureCharacterRanges" var, wstr, int, var, var, var, int, var
; res = GdipMeasureCharacterRanges(graphics, string, length, font, layoutRect, stringFormat, regionCount, regions)
; graphics : GpGraphics* in/out -> "var"
; string : LPCWSTR -> "wstr"
; length : INT -> "int"
; font : GpFont* -> "var"
; layoutRect : RectF* -> "var"
; stringFormat : GpStringFormat* -> "var"
; regionCount : INT -> "int"
; regions : GpRegion** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipMeasureCharacterRanges = gdiplus.NewProc("GdipMeasureCharacterRanges")
)

// graphics (GpGraphics* in/out), string (LPCWSTR), length (INT), font (GpFont*), layoutRect (RectF*), stringFormat (GpStringFormat*), regionCount (INT), regions (GpRegion** in/out)
r1, _, err := procGdipMeasureCharacterRanges.Call(
	uintptr(graphics),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(string))),
	uintptr(length),
	uintptr(font),
	uintptr(layoutRect),
	uintptr(stringFormat),
	uintptr(regionCount),
	uintptr(regions),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipMeasureCharacterRanges(
  graphics: Pointer;   // GpGraphics* in/out
  string: PWideChar;   // LPCWSTR
  length: Integer;   // INT
  font: Pointer;   // GpFont*
  layoutRect: Pointer;   // RectF*
  stringFormat: Pointer;   // GpStringFormat*
  regionCount: Integer;   // INT
  regions: Pointer   // GpRegion** in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipMeasureCharacterRanges';
result := DllCall("gdiplus\GdipMeasureCharacterRanges"
    , "Ptr", graphics   ; GpGraphics* in/out
    , "WStr", string   ; LPCWSTR
    , "Int", length   ; INT
    , "Ptr", font   ; GpFont*
    , "Ptr", layoutRect   ; RectF*
    , "Ptr", stringFormat   ; GpStringFormat*
    , "Int", regionCount   ; INT
    , "Ptr", regions   ; GpRegion** in/out
    , "Int")   ; return: Status
●GdipMeasureCharacterRanges(graphics, string, length, font, layoutRect, stringFormat, regionCount, regions) = DLL("gdiplus.dll", "int GdipMeasureCharacterRanges(void*, char*, int, void*, void*, void*, int, void*)")
# 呼び出し: GdipMeasureCharacterRanges(graphics, string, length, font, layoutRect, stringFormat, regionCount, regions)
# graphics : GpGraphics* in/out -> "void*"
# string : LPCWSTR -> "char*"
# length : INT -> "int"
# font : GpFont* -> "void*"
# layoutRect : RectF* -> "void*"
# stringFormat : GpStringFormat* -> "void*"
# regionCount : INT -> "int"
# regions : GpRegion** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。