ホーム › UI.Controls › CreateMappedBitmap
CreateMappedBitmap
関数色を置換しながらリソースからビットマップを作成する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
HBITMAP CreateMappedBitmap(
HINSTANCE hInstance,
INT_PTR idBitmap,
DWORD wFlags,
COLORMAP* lpColorMap, // optional
INT iNumMaps
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstance | HINSTANCE | in |
| idBitmap | INT_PTR | in |
| wFlags | DWORD | in |
| lpColorMap | COLORMAP* | inoptional |
| iNumMaps | INT | in |
戻り値の型: HBITMAP
各言語での呼び出し定義
// COMCTL32.dll
#include <windows.h>
HBITMAP CreateMappedBitmap(
HINSTANCE hInstance,
INT_PTR idBitmap,
DWORD wFlags,
COLORMAP* lpColorMap, // optional
INT iNumMaps
);[DllImport("COMCTL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateMappedBitmap(
IntPtr hInstance, // HINSTANCE
IntPtr idBitmap, // INT_PTR
uint wFlags, // DWORD
IntPtr lpColorMap, // COLORMAP* optional
int iNumMaps // INT
);<DllImport("COMCTL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateMappedBitmap(
hInstance As IntPtr, ' HINSTANCE
idBitmap As IntPtr, ' INT_PTR
wFlags As UInteger, ' DWORD
lpColorMap As IntPtr, ' COLORMAP* optional
iNumMaps As Integer ' INT
) As IntPtr
End Function' hInstance : HINSTANCE
' idBitmap : INT_PTR
' wFlags : DWORD
' lpColorMap : COLORMAP* optional
' iNumMaps : INT
Declare PtrSafe Function CreateMappedBitmap Lib "comctl32" ( _
ByVal hInstance As LongPtr, _
ByVal idBitmap As LongPtr, _
ByVal wFlags As Long, _
ByVal lpColorMap As LongPtr, _
ByVal iNumMaps As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateMappedBitmap = ctypes.windll.comctl32.CreateMappedBitmap
CreateMappedBitmap.restype = ctypes.c_void_p
CreateMappedBitmap.argtypes = [
wintypes.HANDLE, # hInstance : HINSTANCE
ctypes.c_ssize_t, # idBitmap : INT_PTR
wintypes.DWORD, # wFlags : DWORD
ctypes.c_void_p, # lpColorMap : COLORMAP* optional
ctypes.c_int, # iNumMaps : INT
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
CreateMappedBitmap = Fiddle::Function.new(
lib['CreateMappedBitmap'],
[
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE
Fiddle::TYPE_INTPTR_T, # idBitmap : INT_PTR
-Fiddle::TYPE_INT, # wFlags : DWORD
Fiddle::TYPE_VOIDP, # lpColorMap : COLORMAP* optional
Fiddle::TYPE_INT, # iNumMaps : INT
],
Fiddle::TYPE_VOIDP)#[link(name = "comctl32")]
extern "system" {
fn CreateMappedBitmap(
hInstance: *mut core::ffi::c_void, // HINSTANCE
idBitmap: isize, // INT_PTR
wFlags: u32, // DWORD
lpColorMap: *mut COLORMAP, // COLORMAP* optional
iNumMaps: i32 // INT
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("COMCTL32.dll", SetLastError = true)]
public static extern IntPtr CreateMappedBitmap(IntPtr hInstance, IntPtr idBitmap, uint wFlags, IntPtr lpColorMap, int iNumMaps);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_CreateMappedBitmap' -Namespace Win32 -PassThru
# $api::CreateMappedBitmap(hInstance, idBitmap, wFlags, lpColorMap, iNumMaps)#uselib "COMCTL32.dll"
#func global CreateMappedBitmap "CreateMappedBitmap" sptr, sptr, sptr, sptr, sptr
; CreateMappedBitmap hInstance, idBitmap, wFlags, varptr(lpColorMap), iNumMaps ; 戻り値は stat
; hInstance : HINSTANCE -> "sptr"
; idBitmap : INT_PTR -> "sptr"
; wFlags : DWORD -> "sptr"
; lpColorMap : COLORMAP* optional -> "sptr"
; iNumMaps : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "COMCTL32.dll" #cfunc global CreateMappedBitmap "CreateMappedBitmap" sptr, sptr, int, var, int ; res = CreateMappedBitmap(hInstance, idBitmap, wFlags, lpColorMap, iNumMaps) ; hInstance : HINSTANCE -> "sptr" ; idBitmap : INT_PTR -> "sptr" ; wFlags : DWORD -> "int" ; lpColorMap : COLORMAP* optional -> "var" ; iNumMaps : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "COMCTL32.dll" #cfunc global CreateMappedBitmap "CreateMappedBitmap" sptr, sptr, int, sptr, int ; res = CreateMappedBitmap(hInstance, idBitmap, wFlags, varptr(lpColorMap), iNumMaps) ; hInstance : HINSTANCE -> "sptr" ; idBitmap : INT_PTR -> "sptr" ; wFlags : DWORD -> "int" ; lpColorMap : COLORMAP* optional -> "sptr" ; iNumMaps : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HBITMAP CreateMappedBitmap(HINSTANCE hInstance, INT_PTR idBitmap, DWORD wFlags, COLORMAP* lpColorMap, INT iNumMaps) #uselib "COMCTL32.dll" #cfunc global CreateMappedBitmap "CreateMappedBitmap" intptr, intptr, int, var, int ; res = CreateMappedBitmap(hInstance, idBitmap, wFlags, lpColorMap, iNumMaps) ; hInstance : HINSTANCE -> "intptr" ; idBitmap : INT_PTR -> "intptr" ; wFlags : DWORD -> "int" ; lpColorMap : COLORMAP* optional -> "var" ; iNumMaps : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HBITMAP CreateMappedBitmap(HINSTANCE hInstance, INT_PTR idBitmap, DWORD wFlags, COLORMAP* lpColorMap, INT iNumMaps) #uselib "COMCTL32.dll" #cfunc global CreateMappedBitmap "CreateMappedBitmap" intptr, intptr, int, intptr, int ; res = CreateMappedBitmap(hInstance, idBitmap, wFlags, varptr(lpColorMap), iNumMaps) ; hInstance : HINSTANCE -> "intptr" ; idBitmap : INT_PTR -> "intptr" ; wFlags : DWORD -> "int" ; lpColorMap : COLORMAP* optional -> "intptr" ; iNumMaps : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procCreateMappedBitmap = comctl32.NewProc("CreateMappedBitmap")
)
// hInstance (HINSTANCE), idBitmap (INT_PTR), wFlags (DWORD), lpColorMap (COLORMAP* optional), iNumMaps (INT)
r1, _, err := procCreateMappedBitmap.Call(
uintptr(hInstance),
uintptr(idBitmap),
uintptr(wFlags),
uintptr(lpColorMap),
uintptr(iNumMaps),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HBITMAPfunction CreateMappedBitmap(
hInstance: THandle; // HINSTANCE
idBitmap: NativeInt; // INT_PTR
wFlags: DWORD; // DWORD
lpColorMap: Pointer; // COLORMAP* optional
iNumMaps: Integer // INT
): THandle; stdcall;
external 'COMCTL32.dll' name 'CreateMappedBitmap';result := DllCall("COMCTL32\CreateMappedBitmap"
, "Ptr", hInstance ; HINSTANCE
, "Ptr", idBitmap ; INT_PTR
, "UInt", wFlags ; DWORD
, "Ptr", lpColorMap ; COLORMAP* optional
, "Int", iNumMaps ; INT
, "Ptr") ; return: HBITMAP●CreateMappedBitmap(hInstance, idBitmap, wFlags, lpColorMap, iNumMaps) = DLL("COMCTL32.dll", "void* CreateMappedBitmap(void*, int, dword, void*, int)")
# 呼び出し: CreateMappedBitmap(hInstance, idBitmap, wFlags, lpColorMap, iNumMaps)
# hInstance : HINSTANCE -> "void*"
# idBitmap : INT_PTR -> "int"
# wFlags : DWORD -> "dword"
# lpColorMap : COLORMAP* optional -> "void*"
# iNumMaps : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。