ホーム › UI.WindowsAndMessaging › SetCaretPos
SetCaretPos
関数キャレットを指定座標へ移動する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL SetCaretPos(
INT X,
INT Y
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| X | INT | in |
| Y | INT | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL SetCaretPos(
INT X,
INT Y
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetCaretPos(
int X, // INT
int Y // INT
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetCaretPos(
X As Integer, ' INT
Y As Integer ' INT
) As Boolean
End Function' X : INT
' Y : INT
Declare PtrSafe Function SetCaretPos Lib "user32" ( _
ByVal X As Long, _
ByVal Y As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetCaretPos = ctypes.windll.user32.SetCaretPos
SetCaretPos.restype = wintypes.BOOL
SetCaretPos.argtypes = [
ctypes.c_int, # X : INT
ctypes.c_int, # Y : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
SetCaretPos = Fiddle::Function.new(
lib['SetCaretPos'],
[
Fiddle::TYPE_INT, # X : INT
Fiddle::TYPE_INT, # Y : INT
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn SetCaretPos(
X: i32, // INT
Y: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool SetCaretPos(int X, int Y);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetCaretPos' -Namespace Win32 -PassThru
# $api::SetCaretPos(X, Y)#uselib "USER32.dll"
#func global SetCaretPos "SetCaretPos" sptr, sptr
; SetCaretPos X, Y ; 戻り値は stat
; X : INT -> "sptr"
; Y : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetCaretPos "SetCaretPos" int, int
; res = SetCaretPos(X, Y)
; X : INT -> "int"
; Y : INT -> "int"; BOOL SetCaretPos(INT X, INT Y)
#uselib "USER32.dll"
#cfunc global SetCaretPos "SetCaretPos" int, int
; res = SetCaretPos(X, Y)
; X : INT -> "int"
; Y : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procSetCaretPos = user32.NewProc("SetCaretPos")
)
// X (INT), Y (INT)
r1, _, err := procSetCaretPos.Call(
uintptr(X),
uintptr(Y),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetCaretPos(
X: Integer; // INT
Y: Integer // INT
): BOOL; stdcall;
external 'USER32.dll' name 'SetCaretPos';result := DllCall("USER32\SetCaretPos"
, "Int", X ; INT
, "Int", Y ; INT
, "Int") ; return: BOOL●SetCaretPos(X, Y) = DLL("USER32.dll", "bool SetCaretPos(int, int)")
# 呼び出し: SetCaretPos(X, Y)
# X : INT -> "int"
# Y : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。