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