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

MENUITEMINFOA

構造体
サイズx64: 80 バイト / x86: 48 バイト

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズ(バイト数)である。
fMaskMENU_ITEM_MASK4+4+4取得または設定するメンバを示すマスクである。
fTypeMENU_ITEM_TYPE4+8+8メニュー項目の種類である。
fStateMENU_ITEM_STATE4+12+12メニュー項目の状態である。
wIDDWORD4+16+16メニュー項目の識別子である。
hSubMenuHMENU8/4+24+20サブメニューのハンドルである。サブメニューを持たない場合は NULL となる。
hbmpCheckedHBITMAP8/4+32+24チェック状態で表示するビットマップのハンドルである。
hbmpUncheckedHBITMAP8/4+40+28未チェック状態で表示するビットマップのハンドルである。
dwItemDataUINT_PTR8/4+48+32メニュー項目に関連付けられたアプリケーション定義の値である。
dwTypeDataLPSTR8/4+56+36メニュー項目の内容(通常は文字列、ANSI)へのポインタである。
cchDWORD4+64+40dwTypeData が指す文字列の長さ(文字数)である。取得時はバッファサイズを渡し、コピーされた文字数を受け取る。
hbmpItemHBITMAP8/4+72+44メニュー項目に表示するビットマップのハンドルである。

各言語での定義

#include <windows.h>

// MENUITEMINFOA  (x64 80 / x86 48 バイト)
typedef struct MENUITEMINFOA {
    DWORD cbSize;
    MENU_ITEM_MASK fMask;
    MENU_ITEM_TYPE fType;
    MENU_ITEM_STATE fState;
    DWORD wID;
    HMENU hSubMenu;
    HBITMAP hbmpChecked;
    HBITMAP hbmpUnchecked;
    UINT_PTR dwItemData;
    LPSTR dwTypeData;
    DWORD cch;
    HBITMAP hbmpItem;
} MENUITEMINFOA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MENUITEMINFOA
{
    public uint cbSize;
    public uint fMask;
    public uint fType;
    public uint fState;
    public uint wID;
    public IntPtr hSubMenu;
    public IntPtr hbmpChecked;
    public IntPtr hbmpUnchecked;
    public UIntPtr dwItemData;
    public IntPtr dwTypeData;
    public uint cch;
    public IntPtr hbmpItem;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MENUITEMINFOA
    Public cbSize As UInteger
    Public fMask As UInteger
    Public fType As UInteger
    Public fState As UInteger
    Public wID As UInteger
    Public hSubMenu As IntPtr
    Public hbmpChecked As IntPtr
    Public hbmpUnchecked As IntPtr
    Public dwItemData As UIntPtr
    Public dwTypeData As IntPtr
    Public cch As UInteger
    Public hbmpItem As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class MENUITEMINFOA(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("fMask", wintypes.DWORD),
        ("fType", wintypes.DWORD),
        ("fState", wintypes.DWORD),
        ("wID", wintypes.DWORD),
        ("hSubMenu", ctypes.c_void_p),
        ("hbmpChecked", ctypes.c_void_p),
        ("hbmpUnchecked", ctypes.c_void_p),
        ("dwItemData", ctypes.c_size_t),
        ("dwTypeData", ctypes.c_void_p),
        ("cch", wintypes.DWORD),
        ("hbmpItem", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct MENUITEMINFOA {
    pub cbSize: u32,
    pub fMask: u32,
    pub fType: u32,
    pub fState: u32,
    pub wID: u32,
    pub hSubMenu: *mut core::ffi::c_void,
    pub hbmpChecked: *mut core::ffi::c_void,
    pub hbmpUnchecked: *mut core::ffi::c_void,
    pub dwItemData: usize,
    pub dwTypeData: *mut core::ffi::c_void,
    pub cch: u32,
    pub hbmpItem: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type MENUITEMINFOA struct {
	cbSize uint32
	fMask uint32
	fType uint32
	fState uint32
	wID uint32
	hSubMenu uintptr
	hbmpChecked uintptr
	hbmpUnchecked uintptr
	dwItemData uintptr
	dwTypeData uintptr
	cch uint32
	hbmpItem uintptr
}
type
  MENUITEMINFOA = record
    cbSize: DWORD;
    fMask: DWORD;
    fType: DWORD;
    fState: DWORD;
    wID: DWORD;
    hSubMenu: Pointer;
    hbmpChecked: Pointer;
    hbmpUnchecked: Pointer;
    dwItemData: NativeUInt;
    dwTypeData: Pointer;
    cch: DWORD;
    hbmpItem: Pointer;
  end;
const MENUITEMINFOA = extern struct {
    cbSize: u32,
    fMask: u32,
    fType: u32,
    fState: u32,
    wID: u32,
    hSubMenu: ?*anyopaque,
    hbmpChecked: ?*anyopaque,
    hbmpUnchecked: ?*anyopaque,
    dwItemData: usize,
    dwTypeData: ?*anyopaque,
    cch: u32,
    hbmpItem: ?*anyopaque,
};
type
  MENUITEMINFOA {.bycopy.} = object
    cbSize: uint32
    fMask: uint32
    fType: uint32
    fState: uint32
    wID: uint32
    hSubMenu: pointer
    hbmpChecked: pointer
    hbmpUnchecked: pointer
    dwItemData: uint
    dwTypeData: pointer
    cch: uint32
    hbmpItem: pointer
struct MENUITEMINFOA
{
    uint cbSize;
    uint fMask;
    uint fType;
    uint fState;
    uint wID;
    void* hSubMenu;
    void* hbmpChecked;
    void* hbmpUnchecked;
    size_t dwItemData;
    void* dwTypeData;
    uint cch;
    void* hbmpItem;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MENUITEMINFOA サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; fMask : MENU_ITEM_MASK (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; fType : MENU_ITEM_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; fState : MENU_ITEM_STATE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; wID : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; hSubMenu : HMENU (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; hbmpChecked : HBITMAP (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; hbmpUnchecked : HBITMAP (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; dwItemData : UINT_PTR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; dwTypeData : LPSTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; cch : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; hbmpItem : HBITMAP (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MENUITEMINFOA サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; fMask : MENU_ITEM_MASK (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; fType : MENU_ITEM_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; fState : MENU_ITEM_STATE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; wID : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; hSubMenu : HMENU (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; hbmpChecked : HBITMAP (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; hbmpUnchecked : HBITMAP (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; dwItemData : UINT_PTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; dwTypeData : LPSTR (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; cch : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; hbmpItem : HBITMAP (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MENUITEMINFOA
    #field int cbSize
    #field int fMask
    #field int fType
    #field int fState
    #field int wID
    #field intptr hSubMenu
    #field intptr hbmpChecked
    #field intptr hbmpUnchecked
    #field intptr dwItemData
    #field intptr dwTypeData
    #field int cch
    #field intptr hbmpItem
#endstruct

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