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

DLGITEMTEMPLATE

構造体
サイズx64: 18 バイト / x86: 18 バイトパッキング2

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

フィールド

フィールドサイズx64x86説明
styleDWORD4+0+0コントロールのスタイルである。
dwExtendedStyleDWORD4+4+4コントロールの拡張スタイルである。
xSHORT2+8+8コントロールの左端の x 座標(ダイアログ単位)である。
ySHORT2+10+10コントロールの上端の y 座標(ダイアログ単位)である。
cxSHORT2+12+12コントロールの幅(ダイアログ単位)である。
cySHORT2+14+14コントロールの高さ(ダイアログ単位)である。
idWORD2+16+16コントロールの識別子である。

各言語での定義

#include <windows.h>

// DLGITEMTEMPLATE  (x64 18 / x86 18 バイト)
#pragma pack(push, 2)
typedef struct DLGITEMTEMPLATE {
    DWORD style;
    DWORD dwExtendedStyle;
    SHORT x;
    SHORT y;
    SHORT cx;
    SHORT cy;
    WORD id;
} DLGITEMTEMPLATE;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct DLGITEMTEMPLATE
{
    public uint style;
    public uint dwExtendedStyle;
    public short x;
    public short y;
    public short cx;
    public short cy;
    public ushort id;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure DLGITEMTEMPLATE
    Public style As UInteger
    Public dwExtendedStyle As UInteger
    Public x As Short
    Public y As Short
    Public cx As Short
    Public cy As Short
    Public id As UShort
End Structure
import ctypes
from ctypes import wintypes

class DLGITEMTEMPLATE(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("style", wintypes.DWORD),
        ("dwExtendedStyle", wintypes.DWORD),
        ("x", ctypes.c_short),
        ("y", ctypes.c_short),
        ("cx", ctypes.c_short),
        ("cy", ctypes.c_short),
        ("id", ctypes.c_ushort),
    ]
#[repr(C, packed(2))]
pub struct DLGITEMTEMPLATE {
    pub style: u32,
    pub dwExtendedStyle: u32,
    pub x: i16,
    pub y: i16,
    pub cx: i16,
    pub cy: i16,
    pub id: u16,
}
import "golang.org/x/sys/windows"

type DLGITEMTEMPLATE struct {
	style uint32
	dwExtendedStyle uint32
	x int16
	y int16
	cx int16
	cy int16
	id uint16
}
type
  DLGITEMTEMPLATE = packed record
    style: DWORD;
    dwExtendedStyle: DWORD;
    x: Smallint;
    y: Smallint;
    cx: Smallint;
    cy: Smallint;
    id: Word;
  end;
const DLGITEMTEMPLATE = extern struct {
    style: u32,
    dwExtendedStyle: u32,
    x: i16,
    y: i16,
    cx: i16,
    cy: i16,
    id: u16,
};
type
  DLGITEMTEMPLATE {.packed.} = object
    style: uint32
    dwExtendedStyle: uint32
    x: int16
    y: int16
    cx: int16
    cy: int16
    id: uint16
align(2)
struct DLGITEMTEMPLATE
{
    uint style;
    uint dwExtendedStyle;
    short x;
    short y;
    short cx;
    short cy;
    ushort id;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DLGITEMTEMPLATE サイズ: 18 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 18 / 4 切り上げ)
; style : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwExtendedStyle : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; x : SHORT (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; y : SHORT (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; cx : SHORT (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; cy : SHORT (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; id : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DLGITEMTEMPLATE, pack=2
    #field int style
    #field int dwExtendedStyle
    #field short x
    #field short y
    #field short cx
    #field short cy
    #field short id
#endstruct

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