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

GetCharABCWidthsI

関数
グリフインデックスごとのABC幅を取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GetCharABCWidthsI(
    HDC hdc,
    DWORD giFirst,
    DWORD cgi,
    WORD* pgi,   // optional
    ABC* pabc
);

パラメーター

名前方向
hdcHDCin
giFirstDWORDin
cgiDWORDin
pgiWORD*inoptional
pabcABC*out

戻り値の型: BOOL

各言語での呼び出し定義

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

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

GetCharABCWidthsI = ctypes.windll.gdi32.GetCharABCWidthsI
GetCharABCWidthsI.restype = wintypes.BOOL
GetCharABCWidthsI.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # giFirst : DWORD
    wintypes.DWORD,  # cgi : DWORD
    ctypes.POINTER(ctypes.c_ushort),  # pgi : WORD* optional
    ctypes.c_void_p,  # pabc : ABC* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetCharABCWidthsI = gdi32.NewProc("GetCharABCWidthsI")
)

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