ホーム › UI.Accessibility › TextRange_MoveEndpointByUnit
TextRange_MoveEndpointByUnit
関数テキスト範囲の端点を指定単位ぶん移動する。
シグネチャ
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_MoveEndpointByUnit(
HUIATEXTRANGE hobj,
TextPatternRangeEndpoint endpoint,
TextUnit unit,
INT count,
INT* pRetVal
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hobj | HUIATEXTRANGE | in |
| endpoint | TextPatternRangeEndpoint | in |
| unit | TextUnit | in |
| count | INT | in |
| pRetVal | INT* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// UIAutomationCore.dll
#include <windows.h>
HRESULT TextRange_MoveEndpointByUnit(
HUIATEXTRANGE hobj,
TextPatternRangeEndpoint endpoint,
TextUnit unit,
INT count,
INT* pRetVal
);[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int TextRange_MoveEndpointByUnit(
IntPtr hobj, // HUIATEXTRANGE
int endpoint, // TextPatternRangeEndpoint
int unit, // TextUnit
int count, // INT
ref int pRetVal // INT* in/out
);<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function TextRange_MoveEndpointByUnit(
hobj As IntPtr, ' HUIATEXTRANGE
endpoint As Integer, ' TextPatternRangeEndpoint
unit As Integer, ' TextUnit
count As Integer, ' INT
ByRef pRetVal As Integer ' INT* in/out
) As Integer
End Function' hobj : HUIATEXTRANGE
' endpoint : TextPatternRangeEndpoint
' unit : TextUnit
' count : INT
' pRetVal : INT* in/out
Declare PtrSafe Function TextRange_MoveEndpointByUnit Lib "uiautomationcore" ( _
ByVal hobj As LongPtr, _
ByVal endpoint As Long, _
ByVal unit As Long, _
ByVal count As Long, _
ByRef pRetVal As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TextRange_MoveEndpointByUnit = ctypes.windll.uiautomationcore.TextRange_MoveEndpointByUnit
TextRange_MoveEndpointByUnit.restype = ctypes.c_int
TextRange_MoveEndpointByUnit.argtypes = [
wintypes.HANDLE, # hobj : HUIATEXTRANGE
ctypes.c_int, # endpoint : TextPatternRangeEndpoint
ctypes.c_int, # unit : TextUnit
ctypes.c_int, # count : INT
ctypes.POINTER(ctypes.c_int), # pRetVal : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UIAutomationCore.dll')
TextRange_MoveEndpointByUnit = Fiddle::Function.new(
lib['TextRange_MoveEndpointByUnit'],
[
Fiddle::TYPE_VOIDP, # hobj : HUIATEXTRANGE
Fiddle::TYPE_INT, # endpoint : TextPatternRangeEndpoint
Fiddle::TYPE_INT, # unit : TextUnit
Fiddle::TYPE_INT, # count : INT
Fiddle::TYPE_VOIDP, # pRetVal : INT* in/out
],
Fiddle::TYPE_INT)#[link(name = "uiautomationcore")]
extern "system" {
fn TextRange_MoveEndpointByUnit(
hobj: *mut core::ffi::c_void, // HUIATEXTRANGE
endpoint: i32, // TextPatternRangeEndpoint
unit: i32, // TextUnit
count: i32, // INT
pRetVal: *mut i32 // INT* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int TextRange_MoveEndpointByUnit(IntPtr hobj, int endpoint, int unit, int count, ref int pRetVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_TextRange_MoveEndpointByUnit' -Namespace Win32 -PassThru
# $api::TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, pRetVal)#uselib "UIAutomationCore.dll"
#func global TextRange_MoveEndpointByUnit "TextRange_MoveEndpointByUnit" sptr, sptr, sptr, sptr, sptr
; TextRange_MoveEndpointByUnit hobj, endpoint, unit, count, varptr(pRetVal) ; 戻り値は stat
; hobj : HUIATEXTRANGE -> "sptr"
; endpoint : TextPatternRangeEndpoint -> "sptr"
; unit : TextUnit -> "sptr"
; count : INT -> "sptr"
; pRetVal : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UIAutomationCore.dll" #cfunc global TextRange_MoveEndpointByUnit "TextRange_MoveEndpointByUnit" sptr, int, int, int, var ; res = TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, pRetVal) ; hobj : HUIATEXTRANGE -> "sptr" ; endpoint : TextPatternRangeEndpoint -> "int" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UIAutomationCore.dll" #cfunc global TextRange_MoveEndpointByUnit "TextRange_MoveEndpointByUnit" sptr, int, int, int, sptr ; res = TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, varptr(pRetVal)) ; hobj : HUIATEXTRANGE -> "sptr" ; endpoint : TextPatternRangeEndpoint -> "int" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT TextRange_MoveEndpointByUnit(HUIATEXTRANGE hobj, TextPatternRangeEndpoint endpoint, TextUnit unit, INT count, INT* pRetVal) #uselib "UIAutomationCore.dll" #cfunc global TextRange_MoveEndpointByUnit "TextRange_MoveEndpointByUnit" intptr, int, int, int, var ; res = TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, pRetVal) ; hobj : HUIATEXTRANGE -> "intptr" ; endpoint : TextPatternRangeEndpoint -> "int" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT TextRange_MoveEndpointByUnit(HUIATEXTRANGE hobj, TextPatternRangeEndpoint endpoint, TextUnit unit, INT count, INT* pRetVal) #uselib "UIAutomationCore.dll" #cfunc global TextRange_MoveEndpointByUnit "TextRange_MoveEndpointByUnit" intptr, int, int, int, intptr ; res = TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, varptr(pRetVal)) ; hobj : HUIATEXTRANGE -> "intptr" ; endpoint : TextPatternRangeEndpoint -> "int" ; unit : TextUnit -> "int" ; count : INT -> "int" ; pRetVal : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
procTextRange_MoveEndpointByUnit = uiautomationcore.NewProc("TextRange_MoveEndpointByUnit")
)
// hobj (HUIATEXTRANGE), endpoint (TextPatternRangeEndpoint), unit (TextUnit), count (INT), pRetVal (INT* in/out)
r1, _, err := procTextRange_MoveEndpointByUnit.Call(
uintptr(hobj),
uintptr(endpoint),
uintptr(unit),
uintptr(count),
uintptr(pRetVal),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction TextRange_MoveEndpointByUnit(
hobj: THandle; // HUIATEXTRANGE
endpoint: Integer; // TextPatternRangeEndpoint
unit: Integer; // TextUnit
count: Integer; // INT
pRetVal: Pointer // INT* in/out
): Integer; stdcall;
external 'UIAutomationCore.dll' name 'TextRange_MoveEndpointByUnit';result := DllCall("UIAutomationCore\TextRange_MoveEndpointByUnit"
, "Ptr", hobj ; HUIATEXTRANGE
, "Int", endpoint ; TextPatternRangeEndpoint
, "Int", unit ; TextUnit
, "Int", count ; INT
, "Ptr", pRetVal ; INT* in/out
, "Int") ; return: HRESULT●TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, pRetVal) = DLL("UIAutomationCore.dll", "int TextRange_MoveEndpointByUnit(void*, int, int, int, void*)")
# 呼び出し: TextRange_MoveEndpointByUnit(hobj, endpoint, unit, count, pRetVal)
# hobj : HUIATEXTRANGE -> "void*"
# endpoint : TextPatternRangeEndpoint -> "int"
# unit : TextUnit -> "int"
# count : INT -> "int"
# pRetVal : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。