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