Win32 API 日本語リファレンス
ホームUI.Accessibility › TextRange_Move

TextRange_Move

関数
テキスト範囲を指定単位ぶん指定回数移動する。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT TextRange_Move(
    HUIATEXTRANGE hobj,
    TextUnit unit,
    INT count,
    INT* pRetVal
);

パラメーター

名前方向
hobjHUIATEXTRANGEin
unitTextUnitin
countINTin
pRetValINT*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT TextRange_Move(
    HUIATEXTRANGE hobj,
    TextUnit unit,
    INT count,
    INT* pRetVal
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int TextRange_Move(
    IntPtr hobj,   // HUIATEXTRANGE
    int unit,   // TextUnit
    int count,   // INT
    ref int pRetVal   // INT* in/out
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function TextRange_Move(
    hobj As IntPtr,   ' HUIATEXTRANGE
    unit As Integer,   ' TextUnit
    count As Integer,   ' INT
    ByRef pRetVal As Integer   ' INT* in/out
) As Integer
End Function
' hobj : HUIATEXTRANGE
' unit : TextUnit
' count : INT
' pRetVal : INT* in/out
Declare PtrSafe Function TextRange_Move Lib "uiautomationcore" ( _
    ByVal hobj As LongPtr, _
    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_Move = ctypes.windll.uiautomationcore.TextRange_Move
TextRange_Move.restype = ctypes.c_int
TextRange_Move.argtypes = [
    wintypes.HANDLE,  # hobj : HUIATEXTRANGE
    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_Move = Fiddle::Function.new(
  lib['TextRange_Move'],
  [
    Fiddle::TYPE_VOIDP,  # hobj : HUIATEXTRANGE
    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_Move(
        hobj: *mut core::ffi::c_void,  // HUIATEXTRANGE
        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_Move(IntPtr hobj, int unit, int count, ref int pRetVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_TextRange_Move' -Namespace Win32 -PassThru
# $api::TextRange_Move(hobj, unit, count, pRetVal)
#uselib "UIAutomationCore.dll"
#func global TextRange_Move "TextRange_Move" sptr, sptr, sptr, sptr
; TextRange_Move hobj, unit, count, varptr(pRetVal)   ; 戻り値は stat
; hobj : HUIATEXTRANGE -> "sptr"
; unit : TextUnit -> "sptr"
; count : INT -> "sptr"
; pRetVal : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "UIAutomationCore.dll"
#cfunc global TextRange_Move "TextRange_Move" sptr, int, int, var
; res = TextRange_Move(hobj, unit, count, pRetVal)
; hobj : HUIATEXTRANGE -> "sptr"
; unit : TextUnit -> "int"
; count : INT -> "int"
; pRetVal : INT* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT TextRange_Move(HUIATEXTRANGE hobj, TextUnit unit, INT count, INT* pRetVal)
#uselib "UIAutomationCore.dll"
#cfunc global TextRange_Move "TextRange_Move" intptr, int, int, var
; res = TextRange_Move(hobj, unit, count, pRetVal)
; hobj : HUIATEXTRANGE -> "intptr"
; unit : TextUnit -> "int"
; count : INT -> "int"
; pRetVal : INT* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procTextRange_Move = uiautomationcore.NewProc("TextRange_Move")
)

// hobj (HUIATEXTRANGE), unit (TextUnit), count (INT), pRetVal (INT* in/out)
r1, _, err := procTextRange_Move.Call(
	uintptr(hobj),
	uintptr(unit),
	uintptr(count),
	uintptr(pRetVal),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function TextRange_Move(
  hobj: THandle;   // HUIATEXTRANGE
  unit: Integer;   // TextUnit
  count: Integer;   // INT
  pRetVal: Pointer   // INT* in/out
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'TextRange_Move';
result := DllCall("UIAutomationCore\TextRange_Move"
    , "Ptr", hobj   ; HUIATEXTRANGE
    , "Int", unit   ; TextUnit
    , "Int", count   ; INT
    , "Ptr", pRetVal   ; INT* in/out
    , "Int")   ; return: HRESULT
●TextRange_Move(hobj, unit, count, pRetVal) = DLL("UIAutomationCore.dll", "int TextRange_Move(void*, int, int, void*)")
# 呼び出し: TextRange_Move(hobj, unit, count, pRetVal)
# hobj : HUIATEXTRANGE -> "void*"
# unit : TextUnit -> "int"
# count : INT -> "int"
# pRetVal : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。