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表示位置の揃え方を指定する(TRUEで上端、FALSEで下端に揃える)。

戻り値の型: 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)。
const std = @import("std");

extern "uiautomationcore" fn TextRange_ScrollIntoView(
    hobj: ?*anyopaque, // HUIATEXTRANGE
    alignToTop: i32 // BOOL
) callconv(std.os.windows.WINAPI) i32;
proc TextRange_ScrollIntoView(
    hobj: pointer,  # HUIATEXTRANGE
    alignToTop: int32  # BOOL
): int32 {.importc: "TextRange_ScrollIntoView", stdcall, dynlib: "UIAutomationCore.dll".}
pragma(lib, "uiautomationcore");
extern(Windows)
int TextRange_ScrollIntoView(
    void* hobj,   // HUIATEXTRANGE
    int alignToTop   // BOOL
);
ccall((:TextRange_ScrollIntoView, "UIAutomationCore.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Int32),
      hobj, alignToTop)
# hobj : HUIATEXTRANGE -> Ptr{Cvoid}
# alignToTop : BOOL -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t TextRange_ScrollIntoView(
    void* hobj,
    int32_t alignToTop);
]]
local uiautomationcore = ffi.load("uiautomationcore")
-- uiautomationcore.TextRange_ScrollIntoView(hobj, alignToTop)
-- hobj : HUIATEXTRANGE
-- alignToTop : BOOL
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('UIAutomationCore.dll');
const TextRange_ScrollIntoView = lib.func('__stdcall', 'TextRange_ScrollIntoView', 'int32_t', ['void *', 'int32_t']);
// TextRange_ScrollIntoView(hobj, alignToTop)
// hobj : HUIATEXTRANGE -> 'void *'
// alignToTop : BOOL -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("UIAutomationCore.dll", {
  TextRange_ScrollIntoView: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.TextRange_ScrollIntoView(hobj, alignToTop)
// hobj : HUIATEXTRANGE -> "pointer"
// alignToTop : BOOL -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t TextRange_ScrollIntoView(
    void* hobj,
    int32_t alignToTop);
C, "UIAutomationCore.dll");
// $ffi->TextRange_ScrollIntoView(hobj, alignToTop);
// hobj : HUIATEXTRANGE
// alignToTop : 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 Uiautomationcore extends StdCallLibrary {
    Uiautomationcore INSTANCE = Native.load("uiautomationcore", Uiautomationcore.class);
    int TextRange_ScrollIntoView(
        Pointer hobj,   // HUIATEXTRANGE
        boolean alignToTop   // BOOL
    );
}
@[Link("uiautomationcore")]
lib LibUIAutomationCore
  fun TextRange_ScrollIntoView = TextRange_ScrollIntoView(
    hobj : Void*,   # HUIATEXTRANGE
    alignToTop : 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 TextRange_ScrollIntoViewNative = Int32 Function(Pointer<Void>, Int32);
typedef TextRange_ScrollIntoViewDart = int Function(Pointer<Void>, int);
final TextRange_ScrollIntoView = DynamicLibrary.open('UIAutomationCore.dll')
    .lookupFunction<TextRange_ScrollIntoViewNative, TextRange_ScrollIntoViewDart>('TextRange_ScrollIntoView');
// hobj : HUIATEXTRANGE -> Pointer<Void>
// alignToTop : BOOL -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function TextRange_ScrollIntoView(
  hobj: THandle;   // HUIATEXTRANGE
  alignToTop: BOOL   // BOOL
): Integer; stdcall;
  external 'UIAutomationCore.dll' name 'TextRange_ScrollIntoView';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "TextRange_ScrollIntoView"
  c_TextRange_ScrollIntoView :: Ptr () -> CInt -> IO Int32
-- hobj : HUIATEXTRANGE -> Ptr ()
-- alignToTop : BOOL -> CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let textrange_scrollintoview =
  foreign "TextRange_ScrollIntoView"
    ((ptr void) @-> int32_t @-> returning int32_t)
(* hobj : HUIATEXTRANGE -> (ptr void) *)
(* alignToTop : BOOL -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uiautomationcore (t "UIAutomationCore.dll"))
(cffi:use-foreign-library uiautomationcore)

(cffi:defcfun ("TextRange_ScrollIntoView" text-range-scroll-into-view :convention :stdcall) :int32
  (hobj :pointer)   ; HUIATEXTRANGE
  (align-to-top :int32))   ; BOOL
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $TextRange_ScrollIntoView = Win32::API::More->new('UIAutomationCore',
    'int TextRange_ScrollIntoView(HANDLE hobj, BOOL alignToTop)');
# my $ret = $TextRange_ScrollIntoView->Call($hobj, $alignToTop);
# hobj : HUIATEXTRANGE -> HANDLE
# alignToTop : BOOL -> BOOL
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。