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

GetCharABCWidthsA

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

シグネチャ

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

BOOL GetCharABCWidthsA(
    HDC hdc,
    DWORD wFirst,
    DWORD wLast,
    ABC* lpABC
);

パラメーター

名前方向
hdcHDCin
wFirstDWORDin
wLastDWORDin
lpABCABC*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetCharABCWidthsA(
    HDC hdc,
    DWORD wFirst,
    DWORD wLast,
    ABC* lpABC
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool GetCharABCWidthsA(
    IntPtr hdc,   // HDC
    uint wFirst,   // DWORD
    uint wLast,   // DWORD
    IntPtr lpABC   // ABC* out
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetCharABCWidthsA(
    hdc As IntPtr,   ' HDC
    wFirst As UInteger,   ' DWORD
    wLast As UInteger,   ' DWORD
    lpABC As IntPtr   ' ABC* out
) As Boolean
End Function
' hdc : HDC
' wFirst : DWORD
' wLast : DWORD
' lpABC : ABC* out
Declare PtrSafe Function GetCharABCWidthsA Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal wFirst As Long, _
    ByVal wLast 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

GetCharABCWidthsA = ctypes.windll.gdi32.GetCharABCWidthsA
GetCharABCWidthsA.restype = wintypes.BOOL
GetCharABCWidthsA.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # wFirst : DWORD
    wintypes.DWORD,  # wLast : DWORD
    ctypes.c_void_p,  # lpABC : ABC* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetCharABCWidthsA = Fiddle::Function.new(
  lib['GetCharABCWidthsA'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    -Fiddle::TYPE_INT,  # wFirst : DWORD
    -Fiddle::TYPE_INT,  # wLast : DWORD
    Fiddle::TYPE_VOIDP,  # lpABC : ABC* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn GetCharABCWidthsA(
        hdc: *mut core::ffi::c_void,  // HDC
        wFirst: u32,  // DWORD
        wLast: u32,  // DWORD
        lpABC: *mut ABC  // ABC* 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 GetCharABCWidthsA(IntPtr hdc, uint wFirst, uint wLast, IntPtr lpABC);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetCharABCWidthsA' -Namespace Win32 -PassThru
# $api::GetCharABCWidthsA(hdc, wFirst, wLast, lpABC)
#uselib "GDI32.dll"
#func global GetCharABCWidthsA "GetCharABCWidthsA" sptr, sptr, sptr, sptr
; GetCharABCWidthsA hdc, wFirst, wLast, varptr(lpABC)   ; 戻り値は stat
; hdc : HDC -> "sptr"
; wFirst : DWORD -> "sptr"
; wLast : DWORD -> "sptr"
; lpABC : ABC* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global GetCharABCWidthsA "GetCharABCWidthsA" sptr, int, int, var
; res = GetCharABCWidthsA(hdc, wFirst, wLast, lpABC)
; hdc : HDC -> "sptr"
; wFirst : DWORD -> "int"
; wLast : DWORD -> "int"
; lpABC : ABC* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetCharABCWidthsA(HDC hdc, DWORD wFirst, DWORD wLast, ABC* lpABC)
#uselib "GDI32.dll"
#cfunc global GetCharABCWidthsA "GetCharABCWidthsA" intptr, int, int, var
; res = GetCharABCWidthsA(hdc, wFirst, wLast, lpABC)
; hdc : HDC -> "intptr"
; wFirst : DWORD -> "int"
; wLast : DWORD -> "int"
; lpABC : ABC* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetCharABCWidthsA = gdi32.NewProc("GetCharABCWidthsA")
)

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