ホーム › UI.Controls › CreateToolbarEx
CreateToolbarEx
関数ボタン定義を指定してツールバーコントロールを作成する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
HWND CreateToolbarEx(
HWND hwnd,
DWORD ws,
DWORD wID,
INT nBitmaps,
HINSTANCE hBMInst,
UINT_PTR wBMID,
TBBUTTON* lpButtons,
INT iNumButtons,
INT dxButton,
INT dyButton,
INT dxBitmap,
INT dyBitmap,
DWORD uStructSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | ツールバーの親ウィンドウへのハンドルです。 |
| ws | DWORD | in | ツールバーのウィンドウスタイルです。既定で WS_CHILD スタイルが含まれます。このパラメーターには、Toolbar Control and Button Styles で説明されているスタイルの組み合わせを含めることもできます。 |
| wID | DWORD | in | ツールバーのコントロール識別子です。 |
| nBitmaps | INT | in | hBMInst および wBMID で指定されたビットマップに含まれるボタンイメージの数です。 |
| hBMInst | HINSTANCE | in | ビットマップリソースを含む実行可能ファイルのモジュールインスタンスです。 |
| wBMID | UINT_PTR | in | ビットマップリソースのリソース識別子です。hBMInst が NULL の場合、このパラメーターは有効なビットマップハンドルである必要があります。 |
| lpButtons | TBBUTTON* | inout | ツールバーに追加するボタンに関する情報を含む TBBUTTON 構造体の配列へのポインターです。 |
| iNumButtons | INT | in | ツールバーに追加するボタンの数です。 |
| dxButton | INT | in | ツールバーに追加するボタンの幅(ピクセル単位)です。 |
| dyButton | INT | in | ツールバーに追加するボタンの高さ(ピクセル単位)です。 |
| dxBitmap | INT | in | ツールバーのボタンに追加するボタンイメージの幅(ピクセル単位)です。 |
| dyBitmap | INT | in | ツールバーのボタンに追加するボタンイメージの高さ(ピクセル単位)です。 |
| uStructSize | DWORD | in | TBBUTTON 構造体のサイズです。 |
戻り値の型: HWND
公式ドキュメント
ツールバーウィンドウを作成し、指定されたボタンをツールバーに追加します。
戻り値
型: HWND
成功した場合はツールバーのウィンドウハンドルを返し、それ以外の場合は NULL を返します。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
Windows 95: システムは最大 16,364 個のウィンドウハンドルをサポートできます。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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>
HWND CreateToolbarEx(
HWND hwnd,
DWORD ws,
DWORD wID,
INT nBitmaps,
HINSTANCE hBMInst,
UINT_PTR wBMID,
TBBUTTON* lpButtons,
INT iNumButtons,
INT dxButton,
INT dyButton,
INT dxBitmap,
INT dyBitmap,
DWORD uStructSize
);[DllImport("COMCTL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateToolbarEx(
IntPtr hwnd, // HWND
uint ws, // DWORD
uint wID, // DWORD
int nBitmaps, // INT
IntPtr hBMInst, // HINSTANCE
UIntPtr wBMID, // UINT_PTR
IntPtr lpButtons, // TBBUTTON* in/out
int iNumButtons, // INT
int dxButton, // INT
int dyButton, // INT
int dxBitmap, // INT
int dyBitmap, // INT
uint uStructSize // DWORD
);<DllImport("COMCTL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateToolbarEx(
hwnd As IntPtr, ' HWND
ws As UInteger, ' DWORD
wID As UInteger, ' DWORD
nBitmaps As Integer, ' INT
hBMInst As IntPtr, ' HINSTANCE
wBMID As UIntPtr, ' UINT_PTR
lpButtons As IntPtr, ' TBBUTTON* in/out
iNumButtons As Integer, ' INT
dxButton As Integer, ' INT
dyButton As Integer, ' INT
dxBitmap As Integer, ' INT
dyBitmap As Integer, ' INT
uStructSize As UInteger ' DWORD
) As IntPtr
End Function' hwnd : HWND
' ws : DWORD
' wID : DWORD
' nBitmaps : INT
' hBMInst : HINSTANCE
' wBMID : UINT_PTR
' lpButtons : TBBUTTON* in/out
' iNumButtons : INT
' dxButton : INT
' dyButton : INT
' dxBitmap : INT
' dyBitmap : INT
' uStructSize : DWORD
Declare PtrSafe Function CreateToolbarEx Lib "comctl32" ( _
ByVal hwnd As LongPtr, _
ByVal ws As Long, _
ByVal wID As Long, _
ByVal nBitmaps As Long, _
ByVal hBMInst As LongPtr, _
ByVal wBMID As LongPtr, _
ByVal lpButtons As LongPtr, _
ByVal iNumButtons As Long, _
ByVal dxButton As Long, _
ByVal dyButton As Long, _
ByVal dxBitmap As Long, _
ByVal dyBitmap As Long, _
ByVal uStructSize As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateToolbarEx = ctypes.windll.comctl32.CreateToolbarEx
CreateToolbarEx.restype = ctypes.c_void_p
CreateToolbarEx.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.DWORD, # ws : DWORD
wintypes.DWORD, # wID : DWORD
ctypes.c_int, # nBitmaps : INT
wintypes.HANDLE, # hBMInst : HINSTANCE
ctypes.c_size_t, # wBMID : UINT_PTR
ctypes.c_void_p, # lpButtons : TBBUTTON* in/out
ctypes.c_int, # iNumButtons : INT
ctypes.c_int, # dxButton : INT
ctypes.c_int, # dyButton : INT
ctypes.c_int, # dxBitmap : INT
ctypes.c_int, # dyBitmap : INT
wintypes.DWORD, # uStructSize : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
CreateToolbarEx = Fiddle::Function.new(
lib['CreateToolbarEx'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
-Fiddle::TYPE_INT, # ws : DWORD
-Fiddle::TYPE_INT, # wID : DWORD
Fiddle::TYPE_INT, # nBitmaps : INT
Fiddle::TYPE_VOIDP, # hBMInst : HINSTANCE
Fiddle::TYPE_UINTPTR_T, # wBMID : UINT_PTR
Fiddle::TYPE_VOIDP, # lpButtons : TBBUTTON* in/out
Fiddle::TYPE_INT, # iNumButtons : INT
Fiddle::TYPE_INT, # dxButton : INT
Fiddle::TYPE_INT, # dyButton : INT
Fiddle::TYPE_INT, # dxBitmap : INT
Fiddle::TYPE_INT, # dyBitmap : INT
-Fiddle::TYPE_INT, # uStructSize : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "comctl32")]
extern "system" {
fn CreateToolbarEx(
hwnd: *mut core::ffi::c_void, // HWND
ws: u32, // DWORD
wID: u32, // DWORD
nBitmaps: i32, // INT
hBMInst: *mut core::ffi::c_void, // HINSTANCE
wBMID: usize, // UINT_PTR
lpButtons: *mut TBBUTTON, // TBBUTTON* in/out
iNumButtons: i32, // INT
dxButton: i32, // INT
dyButton: i32, // INT
dxBitmap: i32, // INT
dyBitmap: i32, // INT
uStructSize: u32 // DWORD
) -> *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 CreateToolbarEx(IntPtr hwnd, uint ws, uint wID, int nBitmaps, IntPtr hBMInst, UIntPtr wBMID, IntPtr lpButtons, int iNumButtons, int dxButton, int dyButton, int dxBitmap, int dyBitmap, uint uStructSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_CreateToolbarEx' -Namespace Win32 -PassThru
# $api::CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)#uselib "COMCTL32.dll"
#func global CreateToolbarEx "CreateToolbarEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateToolbarEx hwnd, ws, wID, nBitmaps, hBMInst, wBMID, varptr(lpButtons), iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize ; 戻り値は stat
; hwnd : HWND -> "sptr"
; ws : DWORD -> "sptr"
; wID : DWORD -> "sptr"
; nBitmaps : INT -> "sptr"
; hBMInst : HINSTANCE -> "sptr"
; wBMID : UINT_PTR -> "sptr"
; lpButtons : TBBUTTON* in/out -> "sptr"
; iNumButtons : INT -> "sptr"
; dxButton : INT -> "sptr"
; dyButton : INT -> "sptr"
; dxBitmap : INT -> "sptr"
; dyBitmap : INT -> "sptr"
; uStructSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "COMCTL32.dll" #cfunc global CreateToolbarEx "CreateToolbarEx" sptr, int, int, int, sptr, sptr, var, int, int, int, int, int, int ; res = CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize) ; hwnd : HWND -> "sptr" ; ws : DWORD -> "int" ; wID : DWORD -> "int" ; nBitmaps : INT -> "int" ; hBMInst : HINSTANCE -> "sptr" ; wBMID : UINT_PTR -> "sptr" ; lpButtons : TBBUTTON* in/out -> "var" ; iNumButtons : INT -> "int" ; dxButton : INT -> "int" ; dyButton : INT -> "int" ; dxBitmap : INT -> "int" ; dyBitmap : INT -> "int" ; uStructSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "COMCTL32.dll" #cfunc global CreateToolbarEx "CreateToolbarEx" sptr, int, int, int, sptr, sptr, sptr, int, int, int, int, int, int ; res = CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, varptr(lpButtons), iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize) ; hwnd : HWND -> "sptr" ; ws : DWORD -> "int" ; wID : DWORD -> "int" ; nBitmaps : INT -> "int" ; hBMInst : HINSTANCE -> "sptr" ; wBMID : UINT_PTR -> "sptr" ; lpButtons : TBBUTTON* in/out -> "sptr" ; iNumButtons : INT -> "int" ; dxButton : INT -> "int" ; dyButton : INT -> "int" ; dxBitmap : INT -> "int" ; dyBitmap : INT -> "int" ; uStructSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HWND CreateToolbarEx(HWND hwnd, DWORD ws, DWORD wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, TBBUTTON* lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, DWORD uStructSize) #uselib "COMCTL32.dll" #cfunc global CreateToolbarEx "CreateToolbarEx" intptr, int, int, int, intptr, intptr, var, int, int, int, int, int, int ; res = CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize) ; hwnd : HWND -> "intptr" ; ws : DWORD -> "int" ; wID : DWORD -> "int" ; nBitmaps : INT -> "int" ; hBMInst : HINSTANCE -> "intptr" ; wBMID : UINT_PTR -> "intptr" ; lpButtons : TBBUTTON* in/out -> "var" ; iNumButtons : INT -> "int" ; dxButton : INT -> "int" ; dyButton : INT -> "int" ; dxBitmap : INT -> "int" ; dyBitmap : INT -> "int" ; uStructSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HWND CreateToolbarEx(HWND hwnd, DWORD ws, DWORD wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, TBBUTTON* lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, DWORD uStructSize) #uselib "COMCTL32.dll" #cfunc global CreateToolbarEx "CreateToolbarEx" intptr, int, int, int, intptr, intptr, intptr, int, int, int, int, int, int ; res = CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, varptr(lpButtons), iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize) ; hwnd : HWND -> "intptr" ; ws : DWORD -> "int" ; wID : DWORD -> "int" ; nBitmaps : INT -> "int" ; hBMInst : HINSTANCE -> "intptr" ; wBMID : UINT_PTR -> "intptr" ; lpButtons : TBBUTTON* in/out -> "intptr" ; iNumButtons : INT -> "int" ; dxButton : INT -> "int" ; dyButton : INT -> "int" ; dxBitmap : INT -> "int" ; dyBitmap : INT -> "int" ; uStructSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procCreateToolbarEx = comctl32.NewProc("CreateToolbarEx")
)
// hwnd (HWND), ws (DWORD), wID (DWORD), nBitmaps (INT), hBMInst (HINSTANCE), wBMID (UINT_PTR), lpButtons (TBBUTTON* in/out), iNumButtons (INT), dxButton (INT), dyButton (INT), dxBitmap (INT), dyBitmap (INT), uStructSize (DWORD)
r1, _, err := procCreateToolbarEx.Call(
uintptr(hwnd),
uintptr(ws),
uintptr(wID),
uintptr(nBitmaps),
uintptr(hBMInst),
uintptr(wBMID),
uintptr(lpButtons),
uintptr(iNumButtons),
uintptr(dxButton),
uintptr(dyButton),
uintptr(dxBitmap),
uintptr(dyBitmap),
uintptr(uStructSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HWNDfunction CreateToolbarEx(
hwnd: THandle; // HWND
ws: DWORD; // DWORD
wID: DWORD; // DWORD
nBitmaps: Integer; // INT
hBMInst: THandle; // HINSTANCE
wBMID: NativeUInt; // UINT_PTR
lpButtons: Pointer; // TBBUTTON* in/out
iNumButtons: Integer; // INT
dxButton: Integer; // INT
dyButton: Integer; // INT
dxBitmap: Integer; // INT
dyBitmap: Integer; // INT
uStructSize: DWORD // DWORD
): THandle; stdcall;
external 'COMCTL32.dll' name 'CreateToolbarEx';result := DllCall("COMCTL32\CreateToolbarEx"
, "Ptr", hwnd ; HWND
, "UInt", ws ; DWORD
, "UInt", wID ; DWORD
, "Int", nBitmaps ; INT
, "Ptr", hBMInst ; HINSTANCE
, "UPtr", wBMID ; UINT_PTR
, "Ptr", lpButtons ; TBBUTTON* in/out
, "Int", iNumButtons ; INT
, "Int", dxButton ; INT
, "Int", dyButton ; INT
, "Int", dxBitmap ; INT
, "Int", dyBitmap ; INT
, "UInt", uStructSize ; DWORD
, "Ptr") ; return: HWND●CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize) = DLL("COMCTL32.dll", "void* CreateToolbarEx(void*, dword, dword, int, void*, int, void*, int, int, int, int, int, dword)")
# 呼び出し: CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)
# hwnd : HWND -> "void*"
# ws : DWORD -> "dword"
# wID : DWORD -> "dword"
# nBitmaps : INT -> "int"
# hBMInst : HINSTANCE -> "void*"
# wBMID : UINT_PTR -> "int"
# lpButtons : TBBUTTON* in/out -> "void*"
# iNumButtons : INT -> "int"
# dxButton : INT -> "int"
# dyButton : INT -> "int"
# dxBitmap : INT -> "int"
# dyBitmap : INT -> "int"
# uStructSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "comctl32" fn CreateToolbarEx(
hwnd: ?*anyopaque, // HWND
ws: u32, // DWORD
wID: u32, // DWORD
nBitmaps: i32, // INT
hBMInst: ?*anyopaque, // HINSTANCE
wBMID: usize, // UINT_PTR
lpButtons: [*c]TBBUTTON, // TBBUTTON* in/out
iNumButtons: i32, // INT
dxButton: i32, // INT
dyButton: i32, // INT
dxBitmap: i32, // INT
dyBitmap: i32, // INT
uStructSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc CreateToolbarEx(
hwnd: pointer, # HWND
ws: uint32, # DWORD
wID: uint32, # DWORD
nBitmaps: int32, # INT
hBMInst: pointer, # HINSTANCE
wBMID: uint, # UINT_PTR
lpButtons: ptr TBBUTTON, # TBBUTTON* in/out
iNumButtons: int32, # INT
dxButton: int32, # INT
dyButton: int32, # INT
dxBitmap: int32, # INT
dyBitmap: int32, # INT
uStructSize: uint32 # DWORD
): pointer {.importc: "CreateToolbarEx", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
void* CreateToolbarEx(
void* hwnd, // HWND
uint ws, // DWORD
uint wID, // DWORD
int nBitmaps, // INT
void* hBMInst, // HINSTANCE
size_t wBMID, // UINT_PTR
TBBUTTON* lpButtons, // TBBUTTON* in/out
int iNumButtons, // INT
int dxButton, // INT
int dyButton, // INT
int dxBitmap, // INT
int dyBitmap, // INT
uint uStructSize // DWORD
);ccall((:CreateToolbarEx, "COMCTL32.dll"), stdcall, Ptr{Cvoid},
(Ptr{Cvoid}, UInt32, UInt32, Int32, Ptr{Cvoid}, Csize_t, Ptr{TBBUTTON}, Int32, Int32, Int32, Int32, Int32, UInt32),
hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)
# hwnd : HWND -> Ptr{Cvoid}
# ws : DWORD -> UInt32
# wID : DWORD -> UInt32
# nBitmaps : INT -> Int32
# hBMInst : HINSTANCE -> Ptr{Cvoid}
# wBMID : UINT_PTR -> Csize_t
# lpButtons : TBBUTTON* in/out -> Ptr{TBBUTTON}
# iNumButtons : INT -> Int32
# dxButton : INT -> Int32
# dyButton : INT -> Int32
# dxBitmap : INT -> Int32
# dyBitmap : INT -> Int32
# uStructSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* CreateToolbarEx(
void* hwnd,
uint32_t ws,
uint32_t wID,
int32_t nBitmaps,
void* hBMInst,
uintptr_t wBMID,
void* lpButtons,
int32_t iNumButtons,
int32_t dxButton,
int32_t dyButton,
int32_t dxBitmap,
int32_t dyBitmap,
uint32_t uStructSize);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)
-- hwnd : HWND
-- ws : DWORD
-- wID : DWORD
-- nBitmaps : INT
-- hBMInst : HINSTANCE
-- wBMID : UINT_PTR
-- lpButtons : TBBUTTON* in/out
-- iNumButtons : INT
-- dxButton : INT
-- dyButton : INT
-- dxBitmap : INT
-- dyBitmap : INT
-- uStructSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const CreateToolbarEx = lib.func('__stdcall', 'CreateToolbarEx', 'void *', ['void *', 'uint32_t', 'uint32_t', 'int32_t', 'void *', 'uintptr_t', 'void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t']);
// CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)
// hwnd : HWND -> 'void *'
// ws : DWORD -> 'uint32_t'
// wID : DWORD -> 'uint32_t'
// nBitmaps : INT -> 'int32_t'
// hBMInst : HINSTANCE -> 'void *'
// wBMID : UINT_PTR -> 'uintptr_t'
// lpButtons : TBBUTTON* in/out -> 'void *'
// iNumButtons : INT -> 'int32_t'
// dxButton : INT -> 'int32_t'
// dyButton : INT -> 'int32_t'
// dxBitmap : INT -> 'int32_t'
// dyBitmap : INT -> 'int32_t'
// uStructSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("COMCTL32.dll", {
CreateToolbarEx: { parameters: ["pointer", "u32", "u32", "i32", "pointer", "usize", "pointer", "i32", "i32", "i32", "i32", "i32", "u32"], result: "pointer" },
});
// lib.symbols.CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize)
// hwnd : HWND -> "pointer"
// ws : DWORD -> "u32"
// wID : DWORD -> "u32"
// nBitmaps : INT -> "i32"
// hBMInst : HINSTANCE -> "pointer"
// wBMID : UINT_PTR -> "usize"
// lpButtons : TBBUTTON* in/out -> "pointer"
// iNumButtons : INT -> "i32"
// dxButton : INT -> "i32"
// dyButton : INT -> "i32"
// dxBitmap : INT -> "i32"
// dyBitmap : INT -> "i32"
// uStructSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* CreateToolbarEx(
void* hwnd,
uint32_t ws,
uint32_t wID,
int32_t nBitmaps,
void* hBMInst,
size_t wBMID,
void* lpButtons,
int32_t iNumButtons,
int32_t dxButton,
int32_t dyButton,
int32_t dxBitmap,
int32_t dyBitmap,
uint32_t uStructSize);
C, "COMCTL32.dll");
// $ffi->CreateToolbarEx(hwnd, ws, wID, nBitmaps, hBMInst, wBMID, lpButtons, iNumButtons, dxButton, dyButton, dxBitmap, dyBitmap, uStructSize);
// hwnd : HWND
// ws : DWORD
// wID : DWORD
// nBitmaps : INT
// hBMInst : HINSTANCE
// wBMID : UINT_PTR
// lpButtons : TBBUTTON* in/out
// iNumButtons : INT
// dxButton : INT
// dyButton : INT
// dxBitmap : INT
// dyBitmap : INT
// uStructSize : DWORD
// 構造体/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);
Pointer CreateToolbarEx(
Pointer hwnd, // HWND
int ws, // DWORD
int wID, // DWORD
int nBitmaps, // INT
Pointer hBMInst, // HINSTANCE
long wBMID, // UINT_PTR
Pointer lpButtons, // TBBUTTON* in/out
int iNumButtons, // INT
int dxButton, // INT
int dyButton, // INT
int dxBitmap, // INT
int dyBitmap, // INT
int uStructSize // DWORD
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun CreateToolbarEx = CreateToolbarEx(
hwnd : Void*, # HWND
ws : UInt32, # DWORD
wID : UInt32, # DWORD
nBitmaps : Int32, # INT
hBMInst : Void*, # HINSTANCE
wBMID : LibC::SizeT, # UINT_PTR
lpButtons : TBBUTTON*, # TBBUTTON* in/out
iNumButtons : Int32, # INT
dxButton : Int32, # INT
dyButton : Int32, # INT
dxBitmap : Int32, # INT
dyBitmap : Int32, # INT
uStructSize : UInt32 # DWORD
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateToolbarExNative = Pointer<Void> Function(Pointer<Void>, Uint32, Uint32, Int32, Pointer<Void>, UintPtr, Pointer<Void>, Int32, Int32, Int32, Int32, Int32, Uint32);
typedef CreateToolbarExDart = Pointer<Void> Function(Pointer<Void>, int, int, int, Pointer<Void>, int, Pointer<Void>, int, int, int, int, int, int);
final CreateToolbarEx = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<CreateToolbarExNative, CreateToolbarExDart>('CreateToolbarEx');
// hwnd : HWND -> Pointer<Void>
// ws : DWORD -> Uint32
// wID : DWORD -> Uint32
// nBitmaps : INT -> Int32
// hBMInst : HINSTANCE -> Pointer<Void>
// wBMID : UINT_PTR -> UintPtr
// lpButtons : TBBUTTON* in/out -> Pointer<Void>
// iNumButtons : INT -> Int32
// dxButton : INT -> Int32
// dyButton : INT -> Int32
// dxBitmap : INT -> Int32
// dyBitmap : INT -> Int32
// uStructSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateToolbarEx(
hwnd: THandle; // HWND
ws: DWORD; // DWORD
wID: DWORD; // DWORD
nBitmaps: Integer; // INT
hBMInst: THandle; // HINSTANCE
wBMID: NativeUInt; // UINT_PTR
lpButtons: Pointer; // TBBUTTON* in/out
iNumButtons: Integer; // INT
dxButton: Integer; // INT
dyButton: Integer; // INT
dxBitmap: Integer; // INT
dyBitmap: Integer; // INT
uStructSize: DWORD // DWORD
): THandle; stdcall;
external 'COMCTL32.dll' name 'CreateToolbarEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateToolbarEx"
c_CreateToolbarEx :: Ptr () -> Word32 -> Word32 -> Int32 -> Ptr () -> CUIntPtr -> Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Word32 -> IO (Ptr ())
-- hwnd : HWND -> Ptr ()
-- ws : DWORD -> Word32
-- wID : DWORD -> Word32
-- nBitmaps : INT -> Int32
-- hBMInst : HINSTANCE -> Ptr ()
-- wBMID : UINT_PTR -> CUIntPtr
-- lpButtons : TBBUTTON* in/out -> Ptr ()
-- iNumButtons : INT -> Int32
-- dxButton : INT -> Int32
-- dyButton : INT -> Int32
-- dxBitmap : INT -> Int32
-- dyBitmap : INT -> Int32
-- uStructSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createtoolbarex =
foreign "CreateToolbarEx"
((ptr void) @-> uint32_t @-> uint32_t @-> int32_t @-> (ptr void) @-> size_t @-> (ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> returning (ptr void))
(* hwnd : HWND -> (ptr void) *)
(* ws : DWORD -> uint32_t *)
(* wID : DWORD -> uint32_t *)
(* nBitmaps : INT -> int32_t *)
(* hBMInst : HINSTANCE -> (ptr void) *)
(* wBMID : UINT_PTR -> size_t *)
(* lpButtons : TBBUTTON* in/out -> (ptr void) *)
(* iNumButtons : INT -> int32_t *)
(* dxButton : INT -> int32_t *)
(* dyButton : INT -> int32_t *)
(* dxBitmap : INT -> int32_t *)
(* dyBitmap : INT -> int32_t *)
(* uStructSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)
(cffi:defcfun ("CreateToolbarEx" create-toolbar-ex :convention :stdcall) :pointer
(hwnd :pointer) ; HWND
(ws :uint32) ; DWORD
(w-id :uint32) ; DWORD
(n-bitmaps :int32) ; INT
(h-bminst :pointer) ; HINSTANCE
(w-bmid :uint64) ; UINT_PTR
(lp-buttons :pointer) ; TBBUTTON* in/out
(i-num-buttons :int32) ; INT
(dx-button :int32) ; INT
(dy-button :int32) ; INT
(dx-bitmap :int32) ; INT
(dy-bitmap :int32) ; INT
(u-struct-size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateToolbarEx = Win32::API::More->new('COMCTL32',
'HANDLE CreateToolbarEx(HANDLE hwnd, DWORD ws, DWORD wID, int nBitmaps, HANDLE hBMInst, WPARAM wBMID, LPVOID lpButtons, int iNumButtons, int dxButton, int dyButton, int dxBitmap, int dyBitmap, DWORD uStructSize)');
# my $ret = $CreateToolbarEx->Call($hwnd, $ws, $wID, $nBitmaps, $hBMInst, $wBMID, $lpButtons, $iNumButtons, $dxButton, $dyButton, $dxBitmap, $dyBitmap, $uStructSize);
# hwnd : HWND -> HANDLE
# ws : DWORD -> DWORD
# wID : DWORD -> DWORD
# nBitmaps : INT -> int
# hBMInst : HINSTANCE -> HANDLE
# wBMID : UINT_PTR -> WPARAM
# lpButtons : TBBUTTON* in/out -> LPVOID
# iNumButtons : INT -> int
# dxButton : INT -> int
# dyButton : INT -> int
# dxBitmap : INT -> int
# dyBitmap : INT -> int
# uStructSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型