ホーム › UI.Controls › ImageList_GetIconSize
ImageList_GetIconSize
関数イメージリストの画像の縦横サイズを取得する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
BOOL ImageList_GetIconSize(
HIMAGELIST himl,
INT* cx, // optional
INT* cy // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| himl | HIMAGELIST | in | イメージリストへのハンドル。 |
| cx | INT* | outoptional | 各イメージの幅(ピクセル単位)を受け取る整数変数へのポインター。 |
| cy | INT* | outoptional | 各イメージの高さ(ピクセル単位)を受け取る整数変数へのポインター。 |
戻り値の型: BOOL
公式ドキュメント
イメージリスト内のイメージの寸法を取得します。イメージリスト内のすべてのイメージは同じ寸法を持ちます。
戻り値
型: BOOL
成功した場合は 0 以外の値を、それ以外の場合は 0 を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// COMCTL32.dll
#include <windows.h>
BOOL ImageList_GetIconSize(
HIMAGELIST himl,
INT* cx, // optional
INT* cy // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern bool ImageList_GetIconSize(
IntPtr himl, // HIMAGELIST
IntPtr cx, // INT* optional, out
IntPtr cy // INT* optional, out
);<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function ImageList_GetIconSize(
himl As IntPtr, ' HIMAGELIST
cx As IntPtr, ' INT* optional, out
cy As IntPtr ' INT* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' himl : HIMAGELIST
' cx : INT* optional, out
' cy : INT* optional, out
Declare PtrSafe Function ImageList_GetIconSize Lib "comctl32" ( _
ByVal himl As LongPtr, _
ByVal cx As LongPtr, _
ByVal cy As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ImageList_GetIconSize = ctypes.windll.comctl32.ImageList_GetIconSize
ImageList_GetIconSize.restype = wintypes.BOOL
ImageList_GetIconSize.argtypes = [
ctypes.c_ssize_t, # himl : HIMAGELIST
ctypes.POINTER(ctypes.c_int), # cx : INT* optional, out
ctypes.POINTER(ctypes.c_int), # cy : INT* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
ImageList_GetIconSize = Fiddle::Function.new(
lib['ImageList_GetIconSize'],
[
Fiddle::TYPE_INTPTR_T, # himl : HIMAGELIST
Fiddle::TYPE_VOIDP, # cx : INT* optional, out
Fiddle::TYPE_VOIDP, # cy : INT* optional, out
],
Fiddle::TYPE_INT)#[link(name = "comctl32")]
extern "system" {
fn ImageList_GetIconSize(
himl: isize, // HIMAGELIST
cx: *mut i32, // INT* optional, out
cy: *mut i32 // INT* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll")]
public static extern bool ImageList_GetIconSize(IntPtr himl, IntPtr cx, IntPtr cy);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_ImageList_GetIconSize' -Namespace Win32 -PassThru
# $api::ImageList_GetIconSize(himl, cx, cy)#uselib "COMCTL32.dll"
#func global ImageList_GetIconSize "ImageList_GetIconSize" sptr, sptr, sptr
; ImageList_GetIconSize himl, varptr(cx), varptr(cy) ; 戻り値は stat
; himl : HIMAGELIST -> "sptr"
; cx : INT* optional, out -> "sptr"
; cy : INT* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "COMCTL32.dll" #cfunc global ImageList_GetIconSize "ImageList_GetIconSize" sptr, var, var ; res = ImageList_GetIconSize(himl, cx, cy) ; himl : HIMAGELIST -> "sptr" ; cx : INT* optional, out -> "var" ; cy : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "COMCTL32.dll" #cfunc global ImageList_GetIconSize "ImageList_GetIconSize" sptr, sptr, sptr ; res = ImageList_GetIconSize(himl, varptr(cx), varptr(cy)) ; himl : HIMAGELIST -> "sptr" ; cx : INT* optional, out -> "sptr" ; cy : INT* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL ImageList_GetIconSize(HIMAGELIST himl, INT* cx, INT* cy) #uselib "COMCTL32.dll" #cfunc global ImageList_GetIconSize "ImageList_GetIconSize" intptr, var, var ; res = ImageList_GetIconSize(himl, cx, cy) ; himl : HIMAGELIST -> "intptr" ; cx : INT* optional, out -> "var" ; cy : INT* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL ImageList_GetIconSize(HIMAGELIST himl, INT* cx, INT* cy) #uselib "COMCTL32.dll" #cfunc global ImageList_GetIconSize "ImageList_GetIconSize" intptr, intptr, intptr ; res = ImageList_GetIconSize(himl, varptr(cx), varptr(cy)) ; himl : HIMAGELIST -> "intptr" ; cx : INT* optional, out -> "intptr" ; cy : INT* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procImageList_GetIconSize = comctl32.NewProc("ImageList_GetIconSize")
)
// himl (HIMAGELIST), cx (INT* optional, out), cy (INT* optional, out)
r1, _, err := procImageList_GetIconSize.Call(
uintptr(himl),
uintptr(cx),
uintptr(cy),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ImageList_GetIconSize(
himl: NativeInt; // HIMAGELIST
cx: Pointer; // INT* optional, out
cy: Pointer // INT* optional, out
): BOOL; stdcall;
external 'COMCTL32.dll' name 'ImageList_GetIconSize';result := DllCall("COMCTL32\ImageList_GetIconSize"
, "Ptr", himl ; HIMAGELIST
, "Ptr", cx ; INT* optional, out
, "Ptr", cy ; INT* optional, out
, "Int") ; return: BOOL●ImageList_GetIconSize(himl, cx, cy) = DLL("COMCTL32.dll", "bool ImageList_GetIconSize(int, void*, void*)")
# 呼び出し: ImageList_GetIconSize(himl, cx, cy)
# himl : HIMAGELIST -> "int"
# cx : INT* optional, out -> "void*"
# cy : INT* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "comctl32" fn ImageList_GetIconSize(
himl: isize, // HIMAGELIST
cx: [*c]i32, // INT* optional, out
cy: [*c]i32 // INT* optional, out
) callconv(std.os.windows.WINAPI) i32;proc ImageList_GetIconSize(
himl: int, # HIMAGELIST
cx: ptr int32, # INT* optional, out
cy: ptr int32 # INT* optional, out
): int32 {.importc: "ImageList_GetIconSize", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
int ImageList_GetIconSize(
ptrdiff_t himl, // HIMAGELIST
int* cx, // INT* optional, out
int* cy // INT* optional, out
);ccall((:ImageList_GetIconSize, "COMCTL32.dll"), stdcall, Int32,
(Int, Ptr{Int32}, Ptr{Int32}),
himl, cx, cy)
# himl : HIMAGELIST -> Int
# cx : INT* optional, out -> Ptr{Int32}
# cy : INT* optional, out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ImageList_GetIconSize(
intptr_t himl,
int32_t* cx,
int32_t* cy);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.ImageList_GetIconSize(himl, cx, cy)
-- himl : HIMAGELIST
-- cx : INT* optional, out
-- cy : INT* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const ImageList_GetIconSize = lib.func('__stdcall', 'ImageList_GetIconSize', 'int32_t', ['intptr_t', 'int32_t *', 'int32_t *']);
// ImageList_GetIconSize(himl, cx, cy)
// himl : HIMAGELIST -> 'intptr_t'
// cx : INT* optional, out -> 'int32_t *'
// cy : INT* optional, out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("COMCTL32.dll", {
ImageList_GetIconSize: { parameters: ["isize", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ImageList_GetIconSize(himl, cx, cy)
// himl : HIMAGELIST -> "isize"
// cx : INT* optional, out -> "pointer"
// cy : INT* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ImageList_GetIconSize(
intptr_t himl,
int32_t* cx,
int32_t* cy);
C, "COMCTL32.dll");
// $ffi->ImageList_GetIconSize(himl, cx, cy);
// himl : HIMAGELIST
// cx : INT* optional, out
// cy : INT* optional, out
// 構造体/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_GetIconSize(
long himl, // HIMAGELIST
IntByReference cx, // INT* optional, out
IntByReference cy // INT* optional, out
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun ImageList_GetIconSize = ImageList_GetIconSize(
himl : LibC::SSizeT, # HIMAGELIST
cx : Int32*, # INT* optional, out
cy : Int32* # INT* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ImageList_GetIconSizeNative = Int32 Function(IntPtr, Pointer<Int32>, Pointer<Int32>);
typedef ImageList_GetIconSizeDart = int Function(int, Pointer<Int32>, Pointer<Int32>);
final ImageList_GetIconSize = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<ImageList_GetIconSizeNative, ImageList_GetIconSizeDart>('ImageList_GetIconSize');
// himl : HIMAGELIST -> IntPtr
// cx : INT* optional, out -> Pointer<Int32>
// cy : INT* optional, out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ImageList_GetIconSize(
himl: NativeInt; // HIMAGELIST
cx: Pointer; // INT* optional, out
cy: Pointer // INT* optional, out
): BOOL; stdcall;
external 'COMCTL32.dll' name 'ImageList_GetIconSize';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ImageList_GetIconSize"
c_ImageList_GetIconSize :: CIntPtr -> Ptr Int32 -> Ptr Int32 -> IO CInt
-- himl : HIMAGELIST -> CIntPtr
-- cx : INT* optional, out -> Ptr Int32
-- cy : INT* optional, out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let imagelist_geticonsize =
foreign "ImageList_GetIconSize"
(intptr_t @-> (ptr int32_t) @-> (ptr int32_t) @-> returning int32_t)
(* himl : HIMAGELIST -> intptr_t *)
(* cx : INT* optional, out -> (ptr int32_t) *)
(* cy : INT* optional, out -> (ptr 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_GetIconSize" image-list-get-icon-size :convention :stdcall) :int32
(himl :int64) ; HIMAGELIST
(cx :pointer) ; INT* optional, out
(cy :pointer)) ; INT* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ImageList_GetIconSize = Win32::API::More->new('COMCTL32',
'BOOL ImageList_GetIconSize(LPARAM himl, LPVOID cx, LPVOID cy)');
# my $ret = $ImageList_GetIconSize->Call($himl, $cx, $cy);
# himl : HIMAGELIST -> LPARAM
# cx : INT* optional, out -> LPVOID
# cy : INT* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。