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

TBBUTTON

構造体
サイズx64: 32 バイト / x86: 20 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
iBitmapINT4+0+0ボタンに表示する画像のイメージリスト内インデックス。区切りの場合は幅を表す。
idCommandINT4+4+4ボタン押下時にWM_COMMANDで送られるコマンド識別子。
fsStateBYTE1+8+8ボタンの状態を示すTBSTATE_系フラグ。有効/押下/非表示などを表す。
fsStyleBYTE1+9+9ボタンのスタイルを示すTBSTYLE_系フラグ。区切り/チェック/ドロップダウン等を表す。
bReservedBYTE2+10+10予約フィールド。アライメント用に確保される。
dwDataUINT_PTR8/4+16+12ボタンに関連付けるアプリケーション定義データ。
iStringINT_PTR8/4+24+16ボタンの文字列のインデックス、または文字列ポインタ。

各言語での定義

#include <windows.h>

// TBBUTTON  (x64 32 / x86 20 バイト)
typedef struct TBBUTTON {
    INT iBitmap;
    INT idCommand;
    BYTE fsState;
    BYTE fsStyle;
    BYTE bReserved[2];
    UINT_PTR dwData;
    INT_PTR iString;
} TBBUTTON;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TBBUTTON
{
    public int iBitmap;
    public int idCommand;
    public byte fsState;
    public byte fsStyle;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] bReserved;
    public UIntPtr dwData;
    public IntPtr iString;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TBBUTTON
    Public iBitmap As Integer
    Public idCommand As Integer
    Public fsState As Byte
    Public fsStyle As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public bReserved() As Byte
    Public dwData As UIntPtr
    Public iString As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class TBBUTTON(ctypes.Structure):
    _fields_ = [
        ("iBitmap", ctypes.c_int),
        ("idCommand", ctypes.c_int),
        ("fsState", ctypes.c_ubyte),
        ("fsStyle", ctypes.c_ubyte),
        ("bReserved", ctypes.c_ubyte * 2),
        ("dwData", ctypes.c_size_t),
        ("iString", ctypes.c_ssize_t),
    ]
#[repr(C)]
pub struct TBBUTTON {
    pub iBitmap: i32,
    pub idCommand: i32,
    pub fsState: u8,
    pub fsStyle: u8,
    pub bReserved: [u8; 2],
    pub dwData: usize,
    pub iString: isize,
}
import "golang.org/x/sys/windows"

type TBBUTTON struct {
	iBitmap int32
	idCommand int32
	fsState byte
	fsStyle byte
	bReserved [2]byte
	dwData uintptr
	iString uintptr
}
type
  TBBUTTON = record
    iBitmap: Integer;
    idCommand: Integer;
    fsState: Byte;
    fsStyle: Byte;
    bReserved: array[0..1] of Byte;
    dwData: NativeUInt;
    iString: NativeInt;
  end;
const TBBUTTON = extern struct {
    iBitmap: i32,
    idCommand: i32,
    fsState: u8,
    fsStyle: u8,
    bReserved: [2]u8,
    dwData: usize,
    iString: isize,
};
type
  TBBUTTON {.bycopy.} = object
    iBitmap: int32
    idCommand: int32
    fsState: uint8
    fsStyle: uint8
    bReserved: array[2, uint8]
    dwData: uint
    iString: int
struct TBBUTTON
{
    int iBitmap;
    int idCommand;
    ubyte fsState;
    ubyte fsStyle;
    ubyte[2] bReserved;
    size_t dwData;
    ptrdiff_t iString;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; TBBUTTON サイズ: 20 バイト(x86)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; iBitmap : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; idCommand : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; fsState : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; fsStyle : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; bReserved : BYTE (+10, 2byte)  varptr(st)+10 を基点に操作(2byte:入れ子/配列)
; dwData : UINT_PTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; iString : INT_PTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TBBUTTON サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; iBitmap : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; idCommand : INT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; fsState : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; fsStyle : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; bReserved : BYTE (+10, 2byte)  varptr(st)+10 を基点に操作(2byte:入れ子/配列)
; dwData : UINT_PTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; iString : INT_PTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global TBBUTTON
    #field int iBitmap
    #field int idCommand
    #field byte fsState
    #field byte fsStyle
    #field byte bReserved 2
    #field intptr dwData
    #field intptr iString
#endstruct

stdim st, TBBUTTON        ; NSTRUCT 変数を確保
st->iBitmap = 100
mes "iBitmap=" + st->iBitmap