ホーム › UI.WindowsAndMessaging › SetSystemCursor
SetSystemCursor
関数指定したシステムカーソルを別のカーソルに置き換える。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL SetSystemCursor(
HCURSOR hcur,
SYSTEM_CURSOR_ID id
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hcur | HCURSOR | in |
| id | SYSTEM_CURSOR_ID | in |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL SetSystemCursor(
HCURSOR hcur,
SYSTEM_CURSOR_ID id
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetSystemCursor(
IntPtr hcur, // HCURSOR
uint id // SYSTEM_CURSOR_ID
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetSystemCursor(
hcur As IntPtr, ' HCURSOR
id As UInteger ' SYSTEM_CURSOR_ID
) As Boolean
End Function' hcur : HCURSOR
' id : SYSTEM_CURSOR_ID
Declare PtrSafe Function SetSystemCursor Lib "user32" ( _
ByVal hcur As LongPtr, _
ByVal id As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetSystemCursor = ctypes.windll.user32.SetSystemCursor
SetSystemCursor.restype = wintypes.BOOL
SetSystemCursor.argtypes = [
wintypes.HANDLE, # hcur : HCURSOR
wintypes.DWORD, # id : SYSTEM_CURSOR_ID
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
SetSystemCursor = Fiddle::Function.new(
lib['SetSystemCursor'],
[
Fiddle::TYPE_VOIDP, # hcur : HCURSOR
-Fiddle::TYPE_INT, # id : SYSTEM_CURSOR_ID
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn SetSystemCursor(
hcur: *mut core::ffi::c_void, // HCURSOR
id: u32 // SYSTEM_CURSOR_ID
) -> 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 SetSystemCursor(IntPtr hcur, uint id);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetSystemCursor' -Namespace Win32 -PassThru
# $api::SetSystemCursor(hcur, id)#uselib "USER32.dll"
#func global SetSystemCursor "SetSystemCursor" sptr, sptr
; SetSystemCursor hcur, id ; 戻り値は stat
; hcur : HCURSOR -> "sptr"
; id : SYSTEM_CURSOR_ID -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global SetSystemCursor "SetSystemCursor" sptr, int
; res = SetSystemCursor(hcur, id)
; hcur : HCURSOR -> "sptr"
; id : SYSTEM_CURSOR_ID -> "int"; BOOL SetSystemCursor(HCURSOR hcur, SYSTEM_CURSOR_ID id)
#uselib "USER32.dll"
#cfunc global SetSystemCursor "SetSystemCursor" intptr, int
; res = SetSystemCursor(hcur, id)
; hcur : HCURSOR -> "intptr"
; id : SYSTEM_CURSOR_ID -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procSetSystemCursor = user32.NewProc("SetSystemCursor")
)
// hcur (HCURSOR), id (SYSTEM_CURSOR_ID)
r1, _, err := procSetSystemCursor.Call(
uintptr(hcur),
uintptr(id),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetSystemCursor(
hcur: THandle; // HCURSOR
id: DWORD // SYSTEM_CURSOR_ID
): BOOL; stdcall;
external 'USER32.dll' name 'SetSystemCursor';result := DllCall("USER32\SetSystemCursor"
, "Ptr", hcur ; HCURSOR
, "UInt", id ; SYSTEM_CURSOR_ID
, "Int") ; return: BOOL●SetSystemCursor(hcur, id) = DLL("USER32.dll", "bool SetSystemCursor(void*, dword)")
# 呼び出し: SetSystemCursor(hcur, id)
# hcur : HCURSOR -> "void*"
# id : SYSTEM_CURSOR_ID -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。