ホーム › 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 |
| wID | DWORD | in |
| nBitmaps | INT | in |
| hBMInst | HINSTANCE | in |
| wBMID | UINT_PTR | in |
| lpButtons | TBBUTTON* | inout |
| iNumButtons | INT | in |
| dxButton | INT | in |
| dyButton | INT | in |
| dxBitmap | INT | in |
| dyBitmap | INT | in |
| uStructSize | DWORD | in |
戻り値の型: HWND
各言語での呼び出し定義
// 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)。