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

GetTextExtentPointI

関数
グリフインデックス列の描画寸法を取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GetTextExtentPointI(
    HDC hdc,
    WORD* pgiIn,
    INT cgi,
    SIZE* psize
);

パラメーター

名前方向
hdcHDCin
pgiInWORD*in
cgiINTin
psizeSIZE*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetTextExtentPointI(
    HDC hdc,
    WORD* pgiIn,
    INT cgi,
    SIZE* psize
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool GetTextExtentPointI(
    IntPtr hdc,   // HDC
    ref ushort pgiIn,   // WORD*
    int cgi,   // INT
    IntPtr psize   // SIZE* out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetTextExtentPointI(
    hdc As IntPtr,   ' HDC
    ByRef pgiIn As UShort,   ' WORD*
    cgi As Integer,   ' INT
    psize As IntPtr   ' SIZE* out
) As Boolean
End Function
' hdc : HDC
' pgiIn : WORD*
' cgi : INT
' psize : SIZE* out
Declare PtrSafe Function GetTextExtentPointI Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByRef pgiIn As Integer, _
    ByVal cgi As Long, _
    ByVal psize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetTextExtentPointI = ctypes.windll.gdi32.GetTextExtentPointI
GetTextExtentPointI.restype = wintypes.BOOL
GetTextExtentPointI.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.POINTER(ctypes.c_ushort),  # pgiIn : WORD*
    ctypes.c_int,  # cgi : INT
    ctypes.c_void_p,  # psize : SIZE* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetTextExtentPointI = gdi32.NewProc("GetTextExtentPointI")
)

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