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

ImageList_SetDragCursorImage

関数
ドラッグ画像とカーソル画像を合成して設定する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL ImageList_SetDragCursorImage(
    HIMAGELIST himlDrag,
    INT iDrag,
    INT dxHotspot,
    INT dyHotspot
);

パラメーター

名前方向説明
himlDragHIMAGELISTinドラッグ画像と合成する新しい画像を含むイメージリストへのハンドルです。
iDragINTinドラッグ画像と合成する新しい画像のインデックスです。
dxHotspotINTin新しい画像内におけるホットスポットの x 座標です。
dyHotspotINTin新しい画像内におけるホットスポットの y 座標です。

戻り値の型: BOOL

公式ドキュメント

指定された画像(通常はマウスカーソルの画像)を現在のドラッグ画像と合成して、新しいドラッグ画像を作成します。

戻り値

型: BOOL

成功した場合は 0 以外の値を返し、それ以外の場合は 0 を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL ImageList_SetDragCursorImage(
    HIMAGELIST himlDrag,
    INT iDrag,
    INT dxHotspot,
    INT dyHotspot
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern bool ImageList_SetDragCursorImage(
    IntPtr himlDrag,   // HIMAGELIST
    int iDrag,   // INT
    int dxHotspot,   // INT
    int dyHotspot   // INT
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function ImageList_SetDragCursorImage(
    himlDrag As IntPtr,   ' HIMAGELIST
    iDrag As Integer,   ' INT
    dxHotspot As Integer,   ' INT
    dyHotspot As Integer   ' INT
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' himlDrag : HIMAGELIST
' iDrag : INT
' dxHotspot : INT
' dyHotspot : INT
Declare PtrSafe Function ImageList_SetDragCursorImage Lib "comctl32" ( _
    ByVal himlDrag As LongPtr, _
    ByVal iDrag As Long, _
    ByVal dxHotspot As Long, _
    ByVal dyHotspot As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ImageList_SetDragCursorImage = ctypes.windll.comctl32.ImageList_SetDragCursorImage
ImageList_SetDragCursorImage.restype = wintypes.BOOL
ImageList_SetDragCursorImage.argtypes = [
    ctypes.c_ssize_t,  # himlDrag : HIMAGELIST
    ctypes.c_int,  # iDrag : INT
    ctypes.c_int,  # dxHotspot : INT
    ctypes.c_int,  # dyHotspot : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
ImageList_SetDragCursorImage = Fiddle::Function.new(
  lib['ImageList_SetDragCursorImage'],
  [
    Fiddle::TYPE_INTPTR_T,  # himlDrag : HIMAGELIST
    Fiddle::TYPE_INT,  # iDrag : INT
    Fiddle::TYPE_INT,  # dxHotspot : INT
    Fiddle::TYPE_INT,  # dyHotspot : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "comctl32")]
extern "system" {
    fn ImageList_SetDragCursorImage(
        himlDrag: isize,  // HIMAGELIST
        iDrag: i32,  // INT
        dxHotspot: i32,  // INT
        dyHotspot: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll")]
public static extern bool ImageList_SetDragCursorImage(IntPtr himlDrag, int iDrag, int dxHotspot, int dyHotspot);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_ImageList_SetDragCursorImage' -Namespace Win32 -PassThru
# $api::ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
#uselib "COMCTL32.dll"
#func global ImageList_SetDragCursorImage "ImageList_SetDragCursorImage" sptr, sptr, sptr, sptr
; ImageList_SetDragCursorImage himlDrag, iDrag, dxHotspot, dyHotspot   ; 戻り値は stat
; himlDrag : HIMAGELIST -> "sptr"
; iDrag : INT -> "sptr"
; dxHotspot : INT -> "sptr"
; dyHotspot : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global ImageList_SetDragCursorImage "ImageList_SetDragCursorImage" sptr, int, int, int
; res = ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
; himlDrag : HIMAGELIST -> "sptr"
; iDrag : INT -> "int"
; dxHotspot : INT -> "int"
; dyHotspot : INT -> "int"
; BOOL ImageList_SetDragCursorImage(HIMAGELIST himlDrag, INT iDrag, INT dxHotspot, INT dyHotspot)
#uselib "COMCTL32.dll"
#cfunc global ImageList_SetDragCursorImage "ImageList_SetDragCursorImage" intptr, int, int, int
; res = ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
; himlDrag : HIMAGELIST -> "intptr"
; iDrag : INT -> "int"
; dxHotspot : INT -> "int"
; dyHotspot : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procImageList_SetDragCursorImage = comctl32.NewProc("ImageList_SetDragCursorImage")
)

// himlDrag (HIMAGELIST), iDrag (INT), dxHotspot (INT), dyHotspot (INT)
r1, _, err := procImageList_SetDragCursorImage.Call(
	uintptr(himlDrag),
	uintptr(iDrag),
	uintptr(dxHotspot),
	uintptr(dyHotspot),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ImageList_SetDragCursorImage(
  himlDrag: NativeInt;   // HIMAGELIST
  iDrag: Integer;   // INT
  dxHotspot: Integer;   // INT
  dyHotspot: Integer   // INT
): BOOL; stdcall;
  external 'COMCTL32.dll' name 'ImageList_SetDragCursorImage';
result := DllCall("COMCTL32\ImageList_SetDragCursorImage"
    , "Ptr", himlDrag   ; HIMAGELIST
    , "Int", iDrag   ; INT
    , "Int", dxHotspot   ; INT
    , "Int", dyHotspot   ; INT
    , "Int")   ; return: BOOL
●ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot) = DLL("COMCTL32.dll", "bool ImageList_SetDragCursorImage(int, int, int, int)")
# 呼び出し: ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
# himlDrag : HIMAGELIST -> "int"
# iDrag : INT -> "int"
# dxHotspot : INT -> "int"
# dyHotspot : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "comctl32" fn ImageList_SetDragCursorImage(
    himlDrag: isize, // HIMAGELIST
    iDrag: i32, // INT
    dxHotspot: i32, // INT
    dyHotspot: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
proc ImageList_SetDragCursorImage(
    himlDrag: int,  # HIMAGELIST
    iDrag: int32,  # INT
    dxHotspot: int32,  # INT
    dyHotspot: int32  # INT
): int32 {.importc: "ImageList_SetDragCursorImage", stdcall, dynlib: "COMCTL32.dll".}
pragma(lib, "comctl32");
extern(Windows)
int ImageList_SetDragCursorImage(
    ptrdiff_t himlDrag,   // HIMAGELIST
    int iDrag,   // INT
    int dxHotspot,   // INT
    int dyHotspot   // INT
);
ccall((:ImageList_SetDragCursorImage, "COMCTL32.dll"), stdcall, Int32,
      (Int, Int32, Int32, Int32),
      himlDrag, iDrag, dxHotspot, dyHotspot)
# himlDrag : HIMAGELIST -> Int
# iDrag : INT -> Int32
# dxHotspot : INT -> Int32
# dyHotspot : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ImageList_SetDragCursorImage(
    intptr_t himlDrag,
    int32_t iDrag,
    int32_t dxHotspot,
    int32_t dyHotspot);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
-- himlDrag : HIMAGELIST
-- iDrag : INT
-- dxHotspot : INT
-- dyHotspot : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const ImageList_SetDragCursorImage = lib.func('__stdcall', 'ImageList_SetDragCursorImage', 'int32_t', ['intptr_t', 'int32_t', 'int32_t', 'int32_t']);
// ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
// himlDrag : HIMAGELIST -> 'intptr_t'
// iDrag : INT -> 'int32_t'
// dxHotspot : INT -> 'int32_t'
// dyHotspot : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("COMCTL32.dll", {
  ImageList_SetDragCursorImage: { parameters: ["isize", "i32", "i32", "i32"], result: "i32" },
});
// lib.symbols.ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot)
// himlDrag : HIMAGELIST -> "isize"
// iDrag : INT -> "i32"
// dxHotspot : INT -> "i32"
// dyHotspot : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ImageList_SetDragCursorImage(
    intptr_t himlDrag,
    int32_t iDrag,
    int32_t dxHotspot,
    int32_t dyHotspot);
C, "COMCTL32.dll");
// $ffi->ImageList_SetDragCursorImage(himlDrag, iDrag, dxHotspot, dyHotspot);
// himlDrag : HIMAGELIST
// iDrag : INT
// dxHotspot : INT
// dyHotspot : INT
// 構造体/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 Comctl32 extends StdCallLibrary {
    Comctl32 INSTANCE = Native.load("comctl32", Comctl32.class);
    boolean ImageList_SetDragCursorImage(
        long himlDrag,   // HIMAGELIST
        int iDrag,   // INT
        int dxHotspot,   // INT
        int dyHotspot   // INT
    );
}
@[Link("comctl32")]
lib LibCOMCTL32
  fun ImageList_SetDragCursorImage = ImageList_SetDragCursorImage(
    himlDrag : LibC::SSizeT,   # HIMAGELIST
    iDrag : Int32,   # INT
    dxHotspot : Int32,   # INT
    dyHotspot : Int32   # INT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ImageList_SetDragCursorImageNative = Int32 Function(IntPtr, Int32, Int32, Int32);
typedef ImageList_SetDragCursorImageDart = int Function(int, int, int, int);
final ImageList_SetDragCursorImage = DynamicLibrary.open('COMCTL32.dll')
    .lookupFunction<ImageList_SetDragCursorImageNative, ImageList_SetDragCursorImageDart>('ImageList_SetDragCursorImage');
// himlDrag : HIMAGELIST -> IntPtr
// iDrag : INT -> Int32
// dxHotspot : INT -> Int32
// dyHotspot : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ImageList_SetDragCursorImage(
  himlDrag: NativeInt;   // HIMAGELIST
  iDrag: Integer;   // INT
  dxHotspot: Integer;   // INT
  dyHotspot: Integer   // INT
): BOOL; stdcall;
  external 'COMCTL32.dll' name 'ImageList_SetDragCursorImage';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ImageList_SetDragCursorImage"
  c_ImageList_SetDragCursorImage :: CIntPtr -> Int32 -> Int32 -> Int32 -> IO CInt
-- himlDrag : HIMAGELIST -> CIntPtr
-- iDrag : INT -> Int32
-- dxHotspot : INT -> Int32
-- dyHotspot : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let imagelist_setdragcursorimage =
  foreign "ImageList_SetDragCursorImage"
    (intptr_t @-> int32_t @-> int32_t @-> int32_t @-> returning int32_t)
(* himlDrag : HIMAGELIST -> intptr_t *)
(* iDrag : INT -> int32_t *)
(* dxHotspot : INT -> int32_t *)
(* dyHotspot : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)

(cffi:defcfun ("ImageList_SetDragCursorImage" image-list-set-drag-cursor-image :convention :stdcall) :int32
  (himl-drag :int64)   ; HIMAGELIST
  (i-drag :int32)   ; INT
  (dx-hotspot :int32)   ; INT
  (dy-hotspot :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ImageList_SetDragCursorImage = Win32::API::More->new('COMCTL32',
    'BOOL ImageList_SetDragCursorImage(LPARAM himlDrag, int iDrag, int dxHotspot, int dyHotspot)');
# my $ret = $ImageList_SetDragCursorImage->Call($himlDrag, $iDrag, $dxHotspot, $dyHotspot);
# himlDrag : HIMAGELIST -> LPARAM
# iDrag : INT -> int
# dxHotspot : INT -> int
# dyHotspot : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。