ホーム › Graphics.Gdi › GetTabbedTextExtentA
GetTabbedTextExtentA
関数タブを展開した文字列の表示寸法を取得する(ANSI版)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
DWORD GetTabbedTextExtentA(
HDC hdc,
LPCSTR lpString,
INT chCount,
INT nTabPositions,
const INT* lpnTabStopPositions // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| lpString | LPCSTR | in |
| chCount | INT | in |
| nTabPositions | INT | in |
| lpnTabStopPositions | INT* | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
DWORD GetTabbedTextExtentA(
HDC hdc,
LPCSTR lpString,
INT chCount,
INT nTabPositions,
const INT* lpnTabStopPositions // optional
);[DllImport("USER32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint GetTabbedTextExtentA(
IntPtr hdc, // HDC
[MarshalAs(UnmanagedType.LPStr)] string lpString, // LPCSTR
int chCount, // INT
int nTabPositions, // INT
IntPtr lpnTabStopPositions // INT* optional
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetTabbedTextExtentA(
hdc As IntPtr, ' HDC
<MarshalAs(UnmanagedType.LPStr)> lpString As String, ' LPCSTR
chCount As Integer, ' INT
nTabPositions As Integer, ' INT
lpnTabStopPositions As IntPtr ' INT* optional
) As UInteger
End Function' hdc : HDC
' lpString : LPCSTR
' chCount : INT
' nTabPositions : INT
' lpnTabStopPositions : INT* optional
Declare PtrSafe Function GetTabbedTextExtentA Lib "user32" ( _
ByVal hdc As LongPtr, _
ByVal lpString As String, _
ByVal chCount As Long, _
ByVal nTabPositions As Long, _
ByVal lpnTabStopPositions As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetTabbedTextExtentA = ctypes.windll.user32.GetTabbedTextExtentA
GetTabbedTextExtentA.restype = wintypes.DWORD
GetTabbedTextExtentA.argtypes = [
wintypes.HANDLE, # hdc : HDC
wintypes.LPCSTR, # lpString : LPCSTR
ctypes.c_int, # chCount : INT
ctypes.c_int, # nTabPositions : INT
ctypes.POINTER(ctypes.c_int), # lpnTabStopPositions : INT* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetTabbedTextExtentA = Fiddle::Function.new(
lib['GetTabbedTextExtentA'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # lpString : LPCSTR
Fiddle::TYPE_INT, # chCount : INT
Fiddle::TYPE_INT, # nTabPositions : INT
Fiddle::TYPE_VOIDP, # lpnTabStopPositions : INT* optional
],
-Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetTabbedTextExtentA(
hdc: *mut core::ffi::c_void, // HDC
lpString: *const u8, // LPCSTR
chCount: i32, // INT
nTabPositions: i32, // INT
lpnTabStopPositions: *const i32 // INT* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi)]
public static extern uint GetTabbedTextExtentA(IntPtr hdc, [MarshalAs(UnmanagedType.LPStr)] string lpString, int chCount, int nTabPositions, IntPtr lpnTabStopPositions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetTabbedTextExtentA' -Namespace Win32 -PassThru
# $api::GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, lpnTabStopPositions)#uselib "USER32.dll"
#func global GetTabbedTextExtentA "GetTabbedTextExtentA" sptr, sptr, sptr, sptr, sptr
; GetTabbedTextExtentA hdc, lpString, chCount, nTabPositions, varptr(lpnTabStopPositions) ; 戻り値は stat
; hdc : HDC -> "sptr"
; lpString : LPCSTR -> "sptr"
; chCount : INT -> "sptr"
; nTabPositions : INT -> "sptr"
; lpnTabStopPositions : INT* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetTabbedTextExtentA "GetTabbedTextExtentA" sptr, str, int, int, var ; res = GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, lpnTabStopPositions) ; hdc : HDC -> "sptr" ; lpString : LPCSTR -> "str" ; chCount : INT -> "int" ; nTabPositions : INT -> "int" ; lpnTabStopPositions : INT* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetTabbedTextExtentA "GetTabbedTextExtentA" sptr, str, int, int, sptr ; res = GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, varptr(lpnTabStopPositions)) ; hdc : HDC -> "sptr" ; lpString : LPCSTR -> "str" ; chCount : INT -> "int" ; nTabPositions : INT -> "int" ; lpnTabStopPositions : INT* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetTabbedTextExtentA(HDC hdc, LPCSTR lpString, INT chCount, INT nTabPositions, INT* lpnTabStopPositions) #uselib "USER32.dll" #cfunc global GetTabbedTextExtentA "GetTabbedTextExtentA" intptr, str, int, int, var ; res = GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, lpnTabStopPositions) ; hdc : HDC -> "intptr" ; lpString : LPCSTR -> "str" ; chCount : INT -> "int" ; nTabPositions : INT -> "int" ; lpnTabStopPositions : INT* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetTabbedTextExtentA(HDC hdc, LPCSTR lpString, INT chCount, INT nTabPositions, INT* lpnTabStopPositions) #uselib "USER32.dll" #cfunc global GetTabbedTextExtentA "GetTabbedTextExtentA" intptr, str, int, int, intptr ; res = GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, varptr(lpnTabStopPositions)) ; hdc : HDC -> "intptr" ; lpString : LPCSTR -> "str" ; chCount : INT -> "int" ; nTabPositions : INT -> "int" ; lpnTabStopPositions : INT* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetTabbedTextExtentA = user32.NewProc("GetTabbedTextExtentA")
)
// hdc (HDC), lpString (LPCSTR), chCount (INT), nTabPositions (INT), lpnTabStopPositions (INT* optional)
r1, _, err := procGetTabbedTextExtentA.Call(
uintptr(hdc),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpString))),
uintptr(chCount),
uintptr(nTabPositions),
uintptr(lpnTabStopPositions),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetTabbedTextExtentA(
hdc: THandle; // HDC
lpString: PAnsiChar; // LPCSTR
chCount: Integer; // INT
nTabPositions: Integer; // INT
lpnTabStopPositions: Pointer // INT* optional
): DWORD; stdcall;
external 'USER32.dll' name 'GetTabbedTextExtentA';result := DllCall("USER32\GetTabbedTextExtentA"
, "Ptr", hdc ; HDC
, "AStr", lpString ; LPCSTR
, "Int", chCount ; INT
, "Int", nTabPositions ; INT
, "Ptr", lpnTabStopPositions ; INT* optional
, "UInt") ; return: DWORD●GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, lpnTabStopPositions) = DLL("USER32.dll", "dword GetTabbedTextExtentA(void*, char*, int, int, void*)")
# 呼び出し: GetTabbedTextExtentA(hdc, lpString, chCount, nTabPositions, lpnTabStopPositions)
# hdc : HDC -> "void*"
# lpString : LPCSTR -> "char*"
# chCount : INT -> "int"
# nTabPositions : INT -> "int"
# lpnTabStopPositions : INT* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。