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

GetCharABCWidthsFloatA

関数
文字のABC幅を小数値で取得する。
DLLGDI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (ANSI / -A)
#include <windows.h>

BOOL GetCharABCWidthsFloatA(
    HDC hdc,
    DWORD iFirst,
    DWORD iLast,
    ABCFLOAT* lpABC
);

パラメーター

名前方向
hdcHDCin
iFirstDWORDin
iLastDWORDin
lpABCABCFLOAT*out

戻り値の型: BOOL

各言語での呼び出し定義

// GDI32.dll  (ANSI / -A)
#include <windows.h>

BOOL GetCharABCWidthsFloatA(
    HDC hdc,
    DWORD iFirst,
    DWORD iLast,
    ABCFLOAT* lpABC
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool GetCharABCWidthsFloatA(
    IntPtr hdc,   // HDC
    uint iFirst,   // DWORD
    uint iLast,   // DWORD
    IntPtr lpABC   // ABCFLOAT* out
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetCharABCWidthsFloatA(
    hdc As IntPtr,   ' HDC
    iFirst As UInteger,   ' DWORD
    iLast As UInteger,   ' DWORD
    lpABC As IntPtr   ' ABCFLOAT* out
) As Boolean
End Function
' hdc : HDC
' iFirst : DWORD
' iLast : DWORD
' lpABC : ABCFLOAT* out
Declare PtrSafe Function GetCharABCWidthsFloatA Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal iFirst As Long, _
    ByVal iLast As Long, _
    ByVal lpABC As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetCharABCWidthsFloatA = ctypes.windll.gdi32.GetCharABCWidthsFloatA
GetCharABCWidthsFloatA.restype = wintypes.BOOL
GetCharABCWidthsFloatA.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # iFirst : DWORD
    wintypes.DWORD,  # iLast : DWORD
    ctypes.c_void_p,  # lpABC : ABCFLOAT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetCharABCWidthsFloatA = gdi32.NewProc("GetCharABCWidthsFloatA")
)

// hdc (HDC), iFirst (DWORD), iLast (DWORD), lpABC (ABCFLOAT* out)
r1, _, err := procGetCharABCWidthsFloatA.Call(
	uintptr(hdc),
	uintptr(iFirst),
	uintptr(iLast),
	uintptr(lpABC),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetCharABCWidthsFloatA(
  hdc: THandle;   // HDC
  iFirst: DWORD;   // DWORD
  iLast: DWORD;   // DWORD
  lpABC: Pointer   // ABCFLOAT* out
): BOOL; stdcall;
  external 'GDI32.dll' name 'GetCharABCWidthsFloatA';
result := DllCall("GDI32\GetCharABCWidthsFloatA"
    , "Ptr", hdc   ; HDC
    , "UInt", iFirst   ; DWORD
    , "UInt", iLast   ; DWORD
    , "Ptr", lpABC   ; ABCFLOAT* out
    , "Int")   ; return: BOOL
●GetCharABCWidthsFloatA(hdc, iFirst, iLast, lpABC) = DLL("GDI32.dll", "bool GetCharABCWidthsFloatA(void*, dword, dword, void*)")
# 呼び出し: GetCharABCWidthsFloatA(hdc, iFirst, iLast, lpABC)
# hdc : HDC -> "void*"
# iFirst : DWORD -> "dword"
# iLast : DWORD -> "dword"
# lpABC : ABCFLOAT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。