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