Win32 API 日本語リファレンス
ホームGraphics.Printing › MESSAGEBOX_PARAMS

MESSAGEBOX_PARAMS

構造体
サイズx64: 40 バイト / x86: 24 バイト

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

フィールド

フィールドサイズx64x86説明
cbSizeDWORD4+0+0この構造体のサイズをバイト単位で指定する。
pTitleLPWSTR8/4+8+4メッセージボックスのタイトル文字列を指すUnicode文字列。
pMessageLPWSTR8/4+16+8メッセージボックスの本文を指すUnicode文字列。
StyleDWORD4+24+12MessageBoxのスタイルフラグ(MB_OK等)。
dwTimeoutDWORD4+28+16メッセージボックスを自動的に閉じるまでの秒数。0で無制限。
bWaitBOOL4+32+20ユーザー応答を待機するか示すBOOL。

各言語での定義

#include <windows.h>

// MESSAGEBOX_PARAMS  (x64 40 / x86 24 バイト)
typedef struct MESSAGEBOX_PARAMS {
    DWORD cbSize;
    LPWSTR pTitle;
    LPWSTR pMessage;
    DWORD Style;
    DWORD dwTimeout;
    BOOL bWait;
} MESSAGEBOX_PARAMS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MESSAGEBOX_PARAMS
{
    public uint cbSize;
    public IntPtr pTitle;
    public IntPtr pMessage;
    public uint Style;
    public uint dwTimeout;
    [MarshalAs(UnmanagedType.Bool)] public bool bWait;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MESSAGEBOX_PARAMS
    Public cbSize As UInteger
    Public pTitle As IntPtr
    Public pMessage As IntPtr
    Public Style As UInteger
    Public dwTimeout As UInteger
    <MarshalAs(UnmanagedType.Bool)> Public bWait As Boolean
End Structure
import ctypes
from ctypes import wintypes

class MESSAGEBOX_PARAMS(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("pTitle", ctypes.c_void_p),
        ("pMessage", ctypes.c_void_p),
        ("Style", wintypes.DWORD),
        ("dwTimeout", wintypes.DWORD),
        ("bWait", wintypes.BOOL),
    ]
#[repr(C)]
pub struct MESSAGEBOX_PARAMS {
    pub cbSize: u32,
    pub pTitle: *mut core::ffi::c_void,
    pub pMessage: *mut core::ffi::c_void,
    pub Style: u32,
    pub dwTimeout: u32,
    pub bWait: i32,
}
import "golang.org/x/sys/windows"

type MESSAGEBOX_PARAMS struct {
	cbSize uint32
	pTitle uintptr
	pMessage uintptr
	Style uint32
	dwTimeout uint32
	bWait int32
}
type
  MESSAGEBOX_PARAMS = record
    cbSize: DWORD;
    pTitle: Pointer;
    pMessage: Pointer;
    Style: DWORD;
    dwTimeout: DWORD;
    bWait: BOOL;
  end;
const MESSAGEBOX_PARAMS = extern struct {
    cbSize: u32,
    pTitle: ?*anyopaque,
    pMessage: ?*anyopaque,
    Style: u32,
    dwTimeout: u32,
    bWait: i32,
};
type
  MESSAGEBOX_PARAMS {.bycopy.} = object
    cbSize: uint32
    pTitle: pointer
    pMessage: pointer
    Style: uint32
    dwTimeout: uint32
    bWait: int32
struct MESSAGEBOX_PARAMS
{
    uint cbSize;
    void* pTitle;
    void* pMessage;
    uint Style;
    uint dwTimeout;
    int bWait;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MESSAGEBOX_PARAMS サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pTitle : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; pMessage : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Style : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwTimeout : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; bWait : BOOL (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MESSAGEBOX_PARAMS サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; pTitle : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; pMessage : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; Style : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; dwTimeout : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; bWait : BOOL (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MESSAGEBOX_PARAMS
    #field int cbSize
    #field intptr pTitle
    #field intptr pMessage
    #field int Style
    #field int dwTimeout
    #field bool bWait
#endstruct

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