ホーム › UI.Accessibility › TextRange_GetEnclosingElement
TextRange_GetEnclosingElement
関数テキスト範囲を内包する最小の要素を取得する。
シグネチャ
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_GetEnclosingElement(
HUIATEXTRANGE hobj,
HUIANODE* pRetVal
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hobj | HUIATEXTRANGE | in | 対象のテキスト範囲ハンドル。 |
| pRetVal | HUIANODE* | inout | 範囲全体を内包する最小のUI要素ノードハンドルを受け取る出力先。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_GetEnclosingElement(
HUIATEXTRANGE hobj,
HUIANODE* pRetVal
);[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int TextRange_GetEnclosingElement(
IntPtr hobj, // HUIATEXTRANGE
IntPtr pRetVal // HUIANODE* in/out
);<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function TextRange_GetEnclosingElement(
hobj As IntPtr, ' HUIATEXTRANGE
pRetVal As IntPtr ' HUIANODE* in/out
) As Integer
End Function' hobj : HUIATEXTRANGE
' pRetVal : HUIANODE* in/out
Declare PtrSafe Function TextRange_GetEnclosingElement Lib "uiautomationcore" ( _
ByVal hobj As LongPtr, _
ByVal pRetVal As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TextRange_GetEnclosingElement = ctypes.windll.uiautomationcore.TextRange_GetEnclosingElement
TextRange_GetEnclosingElement.restype = ctypes.c_int
TextRange_GetEnclosingElement.argtypes = [
wintypes.HANDLE, # hobj : HUIATEXTRANGE
ctypes.c_void_p, # pRetVal : HUIANODE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UIAutomationCore.dll')
TextRange_GetEnclosingElement = Fiddle::Function.new(
lib['TextRange_GetEnclosingElement'],
[
Fiddle::TYPE_VOIDP, # hobj : HUIATEXTRANGE
Fiddle::TYPE_VOIDP, # pRetVal : HUIANODE* in/out
],
Fiddle::TYPE_INT)#[link(name = "uiautomationcore")]
extern "system" {
fn TextRange_GetEnclosingElement(
hobj: *mut core::ffi::c_void, // HUIATEXTRANGE
pRetVal: *mut *mut core::ffi::c_void // HUIANODE* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int TextRange_GetEnclosingElement(IntPtr hobj, IntPtr pRetVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_TextRange_GetEnclosingElement' -Namespace Win32 -PassThru
# $api::TextRange_GetEnclosingElement(hobj, pRetVal)#uselib "UIAutomationCore.dll"
#func global TextRange_GetEnclosingElement "TextRange_GetEnclosingElement" sptr, sptr
; TextRange_GetEnclosingElement hobj, pRetVal ; 戻り値は stat
; hobj : HUIATEXTRANGE -> "sptr"
; pRetVal : HUIANODE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "UIAutomationCore.dll"
#cfunc global TextRange_GetEnclosingElement "TextRange_GetEnclosingElement" sptr, sptr
; res = TextRange_GetEnclosingElement(hobj, pRetVal)
; hobj : HUIATEXTRANGE -> "sptr"
; pRetVal : HUIANODE* in/out -> "sptr"; HRESULT TextRange_GetEnclosingElement(HUIATEXTRANGE hobj, HUIANODE* pRetVal)
#uselib "UIAutomationCore.dll"
#cfunc global TextRange_GetEnclosingElement "TextRange_GetEnclosingElement" intptr, intptr
; res = TextRange_GetEnclosingElement(hobj, pRetVal)
; hobj : HUIATEXTRANGE -> "intptr"
; pRetVal : HUIANODE* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
procTextRange_GetEnclosingElement = uiautomationcore.NewProc("TextRange_GetEnclosingElement")
)
// hobj (HUIATEXTRANGE), pRetVal (HUIANODE* in/out)
r1, _, err := procTextRange_GetEnclosingElement.Call(
uintptr(hobj),
uintptr(pRetVal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction TextRange_GetEnclosingElement(
hobj: THandle; // HUIATEXTRANGE
pRetVal: Pointer // HUIANODE* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'TextRange_GetEnclosingElement';result := DllCall("UIAutomationCore\TextRange_GetEnclosingElement"
, "Ptr", hobj ; HUIATEXTRANGE
, "Ptr", pRetVal ; HUIANODE* in/out
, "Int") ; return: HRESULT●TextRange_GetEnclosingElement(hobj, pRetVal) = DLL("UIAutomationCore.dll", "int TextRange_GetEnclosingElement(void*, void*)")
# 呼び出し: TextRange_GetEnclosingElement(hobj, pRetVal)
# hobj : HUIATEXTRANGE -> "void*"
# pRetVal : HUIANODE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uiautomationcore" fn TextRange_GetEnclosingElement(
hobj: ?*anyopaque, // HUIATEXTRANGE
pRetVal: ?*anyopaque // HUIANODE* in/out
) callconv(std.os.windows.WINAPI) i32;proc TextRange_GetEnclosingElement(
hobj: pointer, # HUIATEXTRANGE
pRetVal: pointer # HUIANODE* in/out
): int32 {.importc: "TextRange_GetEnclosingElement", stdcall, dynlib: "UIAutomationCore.dll".}pragma(lib, "uiautomationcore");
extern(Windows)
int TextRange_GetEnclosingElement(
void* hobj, // HUIATEXTRANGE
void* pRetVal // HUIANODE* in/out
);ccall((:TextRange_GetEnclosingElement, "UIAutomationCore.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
hobj, pRetVal)
# hobj : HUIATEXTRANGE -> Ptr{Cvoid}
# pRetVal : HUIANODE* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t TextRange_GetEnclosingElement(
void* hobj,
void* pRetVal);
]]
local uiautomationcore = ffi.load("uiautomationcore")
-- uiautomationcore.TextRange_GetEnclosingElement(hobj, pRetVal)
-- hobj : HUIATEXTRANGE
-- pRetVal : HUIANODE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UIAutomationCore.dll');
const TextRange_GetEnclosingElement = lib.func('__stdcall', 'TextRange_GetEnclosingElement', 'int32_t', ['void *', 'void *']);
// TextRange_GetEnclosingElement(hobj, pRetVal)
// hobj : HUIATEXTRANGE -> 'void *'
// pRetVal : HUIANODE* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UIAutomationCore.dll", {
TextRange_GetEnclosingElement: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.TextRange_GetEnclosingElement(hobj, pRetVal)
// hobj : HUIATEXTRANGE -> "pointer"
// pRetVal : HUIANODE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t TextRange_GetEnclosingElement(
void* hobj,
void* pRetVal);
C, "UIAutomationCore.dll");
// $ffi->TextRange_GetEnclosingElement(hobj, pRetVal);
// hobj : HUIATEXTRANGE
// pRetVal : HUIANODE* in/out
// 構造体/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 Uiautomationcore extends StdCallLibrary {
Uiautomationcore INSTANCE = Native.load("uiautomationcore", Uiautomationcore.class);
int TextRange_GetEnclosingElement(
Pointer hobj, // HUIATEXTRANGE
Pointer pRetVal // HUIANODE* in/out
);
}@[Link("uiautomationcore")]
lib LibUIAutomationCore
fun TextRange_GetEnclosingElement = TextRange_GetEnclosingElement(
hobj : Void*, # HUIATEXTRANGE
pRetVal : Void* # HUIANODE* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef TextRange_GetEnclosingElementNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef TextRange_GetEnclosingElementDart = int Function(Pointer<Void>, Pointer<Void>);
final TextRange_GetEnclosingElement = DynamicLibrary.open('UIAutomationCore.dll')
.lookupFunction<TextRange_GetEnclosingElementNative, TextRange_GetEnclosingElementDart>('TextRange_GetEnclosingElement');
// hobj : HUIATEXTRANGE -> Pointer<Void>
// pRetVal : HUIANODE* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function TextRange_GetEnclosingElement(
hobj: THandle; // HUIATEXTRANGE
pRetVal: Pointer // HUIANODE* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'TextRange_GetEnclosingElement';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "TextRange_GetEnclosingElement"
c_TextRange_GetEnclosingElement :: Ptr () -> Ptr () -> IO Int32
-- hobj : HUIATEXTRANGE -> Ptr ()
-- pRetVal : HUIANODE* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let textrange_getenclosingelement =
foreign "TextRange_GetEnclosingElement"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hobj : HUIATEXTRANGE -> (ptr void) *)
(* pRetVal : HUIANODE* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)
(cffi:defcfun ("TextRange_GetEnclosingElement" text-range-get-enclosing-element :convention :stdcall) :int32
(hobj :pointer) ; HUIATEXTRANGE
(p-ret-val :pointer)) ; HUIANODE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $TextRange_GetEnclosingElement = Win32::API::More->new('UIAutomationCore',
'int TextRange_GetEnclosingElement(HANDLE hobj, HANDLE pRetVal)');
# my $ret = $TextRange_GetEnclosingElement->Call($hobj, $pRetVal);
# hobj : HUIATEXTRANGE -> HANDLE
# pRetVal : HUIANODE* in/out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。