Win32 API 日本語リファレンス
ホームGlobalization › ScriptStringOut

ScriptStringOut

関数
解析済み文字列を選択範囲付きでデバイスに描画する。
DLLUSP10.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT ScriptStringOut(
    void* ssa,
    INT iX,
    INT iY,
    ETO_OPTIONS uOptions,
    const RECT* prc,   // optional
    INT iMinSel,
    INT iMaxSel,
    BOOL fDisabled
);

パラメーター

名前方向説明
ssavoid*in文字列に対応する SCRIPT_STRING_ANALYSIS 構造体です。
iXINTin文字列の位置を決めるために使用する基準点の x 座標です。
iYINTin文字列の位置を決めるために使用する基準点の y 座標です。
uOptionsETO_OPTIONSin

アプリケーション定義の矩形の使用方法を指定するオプションです。このパラメーターには 0 または次のいずれかの値を設定できます。これらの値はビット OR で組み合わせることができます。

意味
ETO_CLIPPED
テキストを矩形にクリップします。
ETO_OPAQUE
現在の背景色を使用して矩形を塗りつぶします。
prcRECT*inoptional使用する矩形を定義する RECT 構造体へのポインターです。uOptionsETO_OPAQUE が設定され、prcNULL が指定された場合、この関数は成功して S_OK を返します。ただし、アプリケーションが uOptions に ETO_CLIPPING を設定し、prcNULL を指定した場合は、この関数は E_INVALIDARG を返します。オプションが不要であることを示すために、アプリケーションはこのパラメーターに NULL を設定できます。
iMinSelINTin文字列内の開始位置を指定する 0 から始まるインデックスです。選択範囲がない場合、アプリケーションは iMinSel >= iMaxSel となるように設定する必要があります。
iMaxSelINTin文字列内の終了位置を指定する 0 から始まるインデックスです。
fDisabledBOOLinオペレーティングシステムが、選択されたすべての文字の背後の背景色を COLOR_HIGHLIGHT に設定して無効テキストのハイライト表示を適用する場合は TRUE を指定します。オペレーティングシステムが、選択された各文字について背景色を COLOR_HIGHLIGHT、テキスト色を COLOR_HIGHLIGHTTEXT に設定して有効テキストのハイライト表示を適用する場合、アプリケーションはこのパラメーターに FALSE を設定できます。

戻り値の型: HRESULT

公式ドキュメント

先行する ScriptStringAnalyse の呼び出しによって生成された文字列を表示し、必要に応じてハイライト表示を追加します。

戻り値

成功した場合は S_OK を返します。成功しなかった場合、この関数は 0 以外の HRESULT 値を返します。アプリケーションは SUCCEEDED マクロおよび FAILED マクロで戻り値をテストできません。

解説(Remarks)

この関数を使用するには、アプリケーションは ScriptStringAnalyse への最初の呼び出しで SSA_GLYPHS を指定する必要があります。

選択されたテキストは正しく描画できないため、アプリケーションは ScriptStringOut を使用する際に SetTextAlignTA_UPDATECP とともに使用しないでください。このフラグを使用する必要がある場合は、問題を回避するために必要に応じてフラグを解除および再設定できます。

重要 Windows 8 以降: Windows 7 上で実行できる状態を維持するため、Uniscribe を使用するモジュールは、ライブラリ一覧で gdi32.lib より前に Usp10.lib を指定する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT ScriptStringOut(
    void* ssa,
    INT iX,
    INT iY,
    ETO_OPTIONS uOptions,
    const RECT* prc,   // optional
    INT iMinSel,
    INT iMaxSel,
    BOOL fDisabled
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptStringOut(
    IntPtr ssa,   // void*
    int iX,   // INT
    int iY,   // INT
    uint uOptions,   // ETO_OPTIONS
    IntPtr prc,   // RECT* optional
    int iMinSel,   // INT
    int iMaxSel,   // INT
    bool fDisabled   // BOOL
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptStringOut(
    ssa As IntPtr,   ' void*
    iX As Integer,   ' INT
    iY As Integer,   ' INT
    uOptions As UInteger,   ' ETO_OPTIONS
    prc As IntPtr,   ' RECT* optional
    iMinSel As Integer,   ' INT
    iMaxSel As Integer,   ' INT
    fDisabled As Boolean   ' BOOL
) As Integer
End Function
' ssa : void*
' iX : INT
' iY : INT
' uOptions : ETO_OPTIONS
' prc : RECT* optional
' iMinSel : INT
' iMaxSel : INT
' fDisabled : BOOL
Declare PtrSafe Function ScriptStringOut Lib "usp10" ( _
    ByVal ssa As LongPtr, _
    ByVal iX As Long, _
    ByVal iY As Long, _
    ByVal uOptions As Long, _
    ByVal prc As LongPtr, _
    ByVal iMinSel As Long, _
    ByVal iMaxSel As Long, _
    ByVal fDisabled As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptStringOut = ctypes.windll.usp10.ScriptStringOut
ScriptStringOut.restype = ctypes.c_int
ScriptStringOut.argtypes = [
    ctypes.POINTER(None),  # ssa : void*
    ctypes.c_int,  # iX : INT
    ctypes.c_int,  # iY : INT
    wintypes.DWORD,  # uOptions : ETO_OPTIONS
    ctypes.c_void_p,  # prc : RECT* optional
    ctypes.c_int,  # iMinSel : INT
    ctypes.c_int,  # iMaxSel : INT
    wintypes.BOOL,  # fDisabled : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USP10.dll')
ScriptStringOut = Fiddle::Function.new(
  lib['ScriptStringOut'],
  [
    Fiddle::TYPE_VOIDP,  # ssa : void*
    Fiddle::TYPE_INT,  # iX : INT
    Fiddle::TYPE_INT,  # iY : INT
    -Fiddle::TYPE_INT,  # uOptions : ETO_OPTIONS
    Fiddle::TYPE_VOIDP,  # prc : RECT* optional
    Fiddle::TYPE_INT,  # iMinSel : INT
    Fiddle::TYPE_INT,  # iMaxSel : INT
    Fiddle::TYPE_INT,  # fDisabled : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "usp10")]
extern "system" {
    fn ScriptStringOut(
        ssa: *mut (),  // void*
        iX: i32,  // INT
        iY: i32,  // INT
        uOptions: u32,  // ETO_OPTIONS
        prc: *const RECT,  // RECT* optional
        iMinSel: i32,  // INT
        iMaxSel: i32,  // INT
        fDisabled: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptStringOut(IntPtr ssa, int iX, int iY, uint uOptions, IntPtr prc, int iMinSel, int iMaxSel, bool fDisabled);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptStringOut' -Namespace Win32 -PassThru
# $api::ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
#uselib "USP10.dll"
#func global ScriptStringOut "ScriptStringOut" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScriptStringOut ssa, iX, iY, uOptions, varptr(prc), iMinSel, iMaxSel, fDisabled   ; 戻り値は stat
; ssa : void* -> "sptr"
; iX : INT -> "sptr"
; iY : INT -> "sptr"
; uOptions : ETO_OPTIONS -> "sptr"
; prc : RECT* optional -> "sptr"
; iMinSel : INT -> "sptr"
; iMaxSel : INT -> "sptr"
; fDisabled : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USP10.dll"
#cfunc global ScriptStringOut "ScriptStringOut" sptr, int, int, int, var, int, int, int
; res = ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
; ssa : void* -> "sptr"
; iX : INT -> "int"
; iY : INT -> "int"
; uOptions : ETO_OPTIONS -> "int"
; prc : RECT* optional -> "var"
; iMinSel : INT -> "int"
; iMaxSel : INT -> "int"
; fDisabled : BOOL -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT ScriptStringOut(void* ssa, INT iX, INT iY, ETO_OPTIONS uOptions, RECT* prc, INT iMinSel, INT iMaxSel, BOOL fDisabled)
#uselib "USP10.dll"
#cfunc global ScriptStringOut "ScriptStringOut" intptr, int, int, int, var, int, int, int
; res = ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
; ssa : void* -> "intptr"
; iX : INT -> "int"
; iY : INT -> "int"
; uOptions : ETO_OPTIONS -> "int"
; prc : RECT* optional -> "var"
; iMinSel : INT -> "int"
; iMaxSel : INT -> "int"
; fDisabled : BOOL -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptStringOut = usp10.NewProc("ScriptStringOut")
)

// ssa (void*), iX (INT), iY (INT), uOptions (ETO_OPTIONS), prc (RECT* optional), iMinSel (INT), iMaxSel (INT), fDisabled (BOOL)
r1, _, err := procScriptStringOut.Call(
	uintptr(ssa),
	uintptr(iX),
	uintptr(iY),
	uintptr(uOptions),
	uintptr(prc),
	uintptr(iMinSel),
	uintptr(iMaxSel),
	uintptr(fDisabled),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ScriptStringOut(
  ssa: Pointer;   // void*
  iX: Integer;   // INT
  iY: Integer;   // INT
  uOptions: DWORD;   // ETO_OPTIONS
  prc: Pointer;   // RECT* optional
  iMinSel: Integer;   // INT
  iMaxSel: Integer;   // INT
  fDisabled: BOOL   // BOOL
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptStringOut';
result := DllCall("USP10\ScriptStringOut"
    , "Ptr", ssa   ; void*
    , "Int", iX   ; INT
    , "Int", iY   ; INT
    , "UInt", uOptions   ; ETO_OPTIONS
    , "Ptr", prc   ; RECT* optional
    , "Int", iMinSel   ; INT
    , "Int", iMaxSel   ; INT
    , "Int", fDisabled   ; BOOL
    , "Int")   ; return: HRESULT
●ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled) = DLL("USP10.dll", "int ScriptStringOut(void*, int, int, dword, void*, int, int, bool)")
# 呼び出し: ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
# ssa : void* -> "void*"
# iX : INT -> "int"
# iY : INT -> "int"
# uOptions : ETO_OPTIONS -> "dword"
# prc : RECT* optional -> "void*"
# iMinSel : INT -> "int"
# iMaxSel : INT -> "int"
# fDisabled : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "usp10" fn ScriptStringOut(
    ssa: ?*anyopaque, // void*
    iX: i32, // INT
    iY: i32, // INT
    uOptions: u32, // ETO_OPTIONS
    prc: [*c]RECT, // RECT* optional
    iMinSel: i32, // INT
    iMaxSel: i32, // INT
    fDisabled: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;
proc ScriptStringOut(
    ssa: pointer,  # void*
    iX: int32,  # INT
    iY: int32,  # INT
    uOptions: uint32,  # ETO_OPTIONS
    prc: ptr RECT,  # RECT* optional
    iMinSel: int32,  # INT
    iMaxSel: int32,  # INT
    fDisabled: int32  # BOOL
): int32 {.importc: "ScriptStringOut", stdcall, dynlib: "USP10.dll".}
pragma(lib, "usp10");
extern(Windows)
int ScriptStringOut(
    void* ssa,   // void*
    int iX,   // INT
    int iY,   // INT
    uint uOptions,   // ETO_OPTIONS
    RECT* prc,   // RECT* optional
    int iMinSel,   // INT
    int iMaxSel,   // INT
    int fDisabled   // BOOL
);
ccall((:ScriptStringOut, "USP10.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32, Int32, UInt32, Ptr{RECT}, Int32, Int32, Int32),
      ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
# ssa : void* -> Ptr{Cvoid}
# iX : INT -> Int32
# iY : INT -> Int32
# uOptions : ETO_OPTIONS -> UInt32
# prc : RECT* optional -> Ptr{RECT}
# iMinSel : INT -> Int32
# iMaxSel : INT -> Int32
# fDisabled : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptStringOut(
    void* ssa,
    int32_t iX,
    int32_t iY,
    uint32_t uOptions,
    void* prc,
    int32_t iMinSel,
    int32_t iMaxSel,
    int32_t fDisabled);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
-- ssa : void*
-- iX : INT
-- iY : INT
-- uOptions : ETO_OPTIONS
-- prc : RECT* optional
-- iMinSel : INT
-- iMaxSel : INT
-- fDisabled : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptStringOut = lib.func('__stdcall', 'ScriptStringOut', 'int32_t', ['void *', 'int32_t', 'int32_t', 'uint32_t', 'void *', 'int32_t', 'int32_t', 'int32_t']);
// ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
// ssa : void* -> 'void *'
// iX : INT -> 'int32_t'
// iY : INT -> 'int32_t'
// uOptions : ETO_OPTIONS -> 'uint32_t'
// prc : RECT* optional -> 'void *'
// iMinSel : INT -> 'int32_t'
// iMaxSel : INT -> 'int32_t'
// fDisabled : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("USP10.dll", {
  ScriptStringOut: { parameters: ["pointer", "i32", "i32", "u32", "pointer", "i32", "i32", "i32"], result: "i32" },
});
// lib.symbols.ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled)
// ssa : void* -> "pointer"
// iX : INT -> "i32"
// iY : INT -> "i32"
// uOptions : ETO_OPTIONS -> "u32"
// prc : RECT* optional -> "pointer"
// iMinSel : INT -> "i32"
// iMaxSel : INT -> "i32"
// fDisabled : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptStringOut(
    void* ssa,
    int32_t iX,
    int32_t iY,
    uint32_t uOptions,
    void* prc,
    int32_t iMinSel,
    int32_t iMaxSel,
    int32_t fDisabled);
C, "USP10.dll");
// $ffi->ScriptStringOut(ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled);
// ssa : void*
// iX : INT
// iY : INT
// uOptions : ETO_OPTIONS
// prc : RECT* optional
// iMinSel : INT
// iMaxSel : INT
// fDisabled : BOOL
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Usp10 extends StdCallLibrary {
    Usp10 INSTANCE = Native.load("usp10", Usp10.class);
    int ScriptStringOut(
        Pointer ssa,   // void*
        int iX,   // INT
        int iY,   // INT
        int uOptions,   // ETO_OPTIONS
        Pointer prc,   // RECT* optional
        int iMinSel,   // INT
        int iMaxSel,   // INT
        boolean fDisabled   // BOOL
    );
}
@[Link("usp10")]
lib LibUSP10
  fun ScriptStringOut = ScriptStringOut(
    ssa : Void*,   # void*
    iX : Int32,   # INT
    iY : Int32,   # INT
    uOptions : UInt32,   # ETO_OPTIONS
    prc : RECT*,   # RECT* optional
    iMinSel : Int32,   # INT
    iMaxSel : Int32,   # INT
    fDisabled : Int32   # BOOL
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ScriptStringOutNative = Int32 Function(Pointer<Void>, Int32, Int32, Uint32, Pointer<Void>, Int32, Int32, Int32);
typedef ScriptStringOutDart = int Function(Pointer<Void>, int, int, int, Pointer<Void>, int, int, int);
final ScriptStringOut = DynamicLibrary.open('USP10.dll')
    .lookupFunction<ScriptStringOutNative, ScriptStringOutDart>('ScriptStringOut');
// ssa : void* -> Pointer<Void>
// iX : INT -> Int32
// iY : INT -> Int32
// uOptions : ETO_OPTIONS -> Uint32
// prc : RECT* optional -> Pointer<Void>
// iMinSel : INT -> Int32
// iMaxSel : INT -> Int32
// fDisabled : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ScriptStringOut(
  ssa: Pointer;   // void*
  iX: Integer;   // INT
  iY: Integer;   // INT
  uOptions: DWORD;   // ETO_OPTIONS
  prc: Pointer;   // RECT* optional
  iMinSel: Integer;   // INT
  iMaxSel: Integer;   // INT
  fDisabled: BOOL   // BOOL
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptStringOut';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ScriptStringOut"
  c_ScriptStringOut :: Ptr () -> Int32 -> Int32 -> Word32 -> Ptr () -> Int32 -> Int32 -> CInt -> IO Int32
-- ssa : void* -> Ptr ()
-- iX : INT -> Int32
-- iY : INT -> Int32
-- uOptions : ETO_OPTIONS -> Word32
-- prc : RECT* optional -> Ptr ()
-- iMinSel : INT -> Int32
-- iMaxSel : INT -> Int32
-- fDisabled : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let scriptstringout =
  foreign "ScriptStringOut"
    ((ptr void) @-> int32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> returning int32_t)
(* ssa : void* -> (ptr void) *)
(* iX : INT -> int32_t *)
(* iY : INT -> int32_t *)
(* uOptions : ETO_OPTIONS -> uint32_t *)
(* prc : RECT* optional -> (ptr void) *)
(* iMinSel : INT -> int32_t *)
(* iMaxSel : INT -> int32_t *)
(* fDisabled : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)

(cffi:defcfun ("ScriptStringOut" script-string-out :convention :stdcall) :int32
  (ssa :pointer)   ; void*
  (i-x :int32)   ; INT
  (i-y :int32)   ; INT
  (u-options :uint32)   ; ETO_OPTIONS
  (prc :pointer)   ; RECT* optional
  (i-min-sel :int32)   ; INT
  (i-max-sel :int32)   ; INT
  (f-disabled :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ScriptStringOut = Win32::API::More->new('USP10',
    'int ScriptStringOut(LPVOID ssa, int iX, int iY, DWORD uOptions, LPVOID prc, int iMinSel, int iMaxSel, BOOL fDisabled)');
# my $ret = $ScriptStringOut->Call($ssa, $iX, $iY, $uOptions, $prc, $iMinSel, $iMaxSel, $fDisabled);
# ssa : void* -> LPVOID
# iX : INT -> int
# iY : INT -> int
# uOptions : ETO_OPTIONS -> DWORD
# prc : RECT* optional -> LPVOID
# iMinSel : INT -> int
# iMaxSel : INT -> int
# fDisabled : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型