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

TextRange_ScrollIntoView

関数
テキスト範囲が見えるようにスクロールする。
DLLUIAutomationCore.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT TextRange_ScrollIntoView(
    HUIATEXTRANGE hobj,
    BOOL alignToTop
);

パラメーター

名前方向
hobjHUIATEXTRANGEin
alignToTopBOOLin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT TextRange_ScrollIntoView(
    HUIATEXTRANGE hobj,
    BOOL alignToTop
);
[DllImport("UIAutomationCore.dll", ExactSpelling = true)]
static extern int TextRange_ScrollIntoView(
    IntPtr hobj,   // HUIATEXTRANGE
    bool alignToTop   // BOOL
);
<DllImport("UIAutomationCore.dll", ExactSpelling:=True)>
Public Shared Function TextRange_ScrollIntoView(
    hobj As IntPtr,   ' HUIATEXTRANGE
    alignToTop As Boolean   ' BOOL
) As Integer
End Function
' hobj : HUIATEXTRANGE
' alignToTop : BOOL
Declare PtrSafe Function TextRange_ScrollIntoView Lib "uiautomationcore" ( _
    ByVal hobj As LongPtr, _
    ByVal alignToTop As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

TextRange_ScrollIntoView = ctypes.windll.uiautomationcore.TextRange_ScrollIntoView
TextRange_ScrollIntoView.restype = ctypes.c_int
TextRange_ScrollIntoView.argtypes = [
    wintypes.HANDLE,  # hobj : HUIATEXTRANGE
    wintypes.BOOL,  # alignToTop : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UIAutomationCore.dll')
TextRange_ScrollIntoView = Fiddle::Function.new(
  lib['TextRange_ScrollIntoView'],
  [
    Fiddle::TYPE_VOIDP,  # hobj : HUIATEXTRANGE
    Fiddle::TYPE_INT,  # alignToTop : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "uiautomationcore")]
extern "system" {
    fn TextRange_ScrollIntoView(
        hobj: *mut core::ffi::c_void,  // HUIATEXTRANGE
        alignToTop: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UIAutomationCore.dll")]
public static extern int TextRange_ScrollIntoView(IntPtr hobj, bool alignToTop);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UIAutomationCore_TextRange_ScrollIntoView' -Namespace Win32 -PassThru
# $api::TextRange_ScrollIntoView(hobj, alignToTop)
#uselib "UIAutomationCore.dll"
#func global TextRange_ScrollIntoView "TextRange_ScrollIntoView" sptr, sptr
; TextRange_ScrollIntoView hobj, alignToTop   ; 戻り値は stat
; hobj : HUIATEXTRANGE -> "sptr"
; alignToTop : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UIAutomationCore.dll"
#cfunc global TextRange_ScrollIntoView "TextRange_ScrollIntoView" sptr, int
; res = TextRange_ScrollIntoView(hobj, alignToTop)
; hobj : HUIATEXTRANGE -> "sptr"
; alignToTop : BOOL -> "int"
; HRESULT TextRange_ScrollIntoView(HUIATEXTRANGE hobj, BOOL alignToTop)
#uselib "UIAutomationCore.dll"
#cfunc global TextRange_ScrollIntoView "TextRange_ScrollIntoView" intptr, int
; res = TextRange_ScrollIntoView(hobj, alignToTop)
; hobj : HUIATEXTRANGE -> "intptr"
; alignToTop : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uiautomationcore = windows.NewLazySystemDLL("UIAutomationCore.dll")
	procTextRange_ScrollIntoView = uiautomationcore.NewProc("TextRange_ScrollIntoView")
)

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