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

CREATESTRUCTW

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

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

フィールド

フィールドサイズx64x86説明
lpCreateParamsvoid*8/4+0+0ウィンドウ作成に使用する追加データへのポインタである。
hInstanceHINSTANCE8/4+8+4新しいウィンドウを所有するモジュールのインスタンスハンドルである。
hMenuHMENU8/4+16+8新しいウィンドウが使用するメニューのハンドル、または子ウィンドウの場合は子 ID である。
hwndParentHWND8/4+24+12親ウィンドウまたはオーナーウィンドウのハンドルである。トップレベルウィンドウでは NULL となる。
cyINT4+32+16新しいウィンドウの高さ(ピクセル)である。
cxINT4+36+20新しいウィンドウの幅(ピクセル)である。
yINT4+40+24新しいウィンドウの上端の位置である。
xINT4+44+28新しいウィンドウの左端の位置である。
styleINT4+48+32新しいウィンドウのスタイルである。
lpszNameLPWSTR8/4+56+36新しいウィンドウの名前(Unicode 文字列)へのポインタである。
lpszClassLPWSTR8/4+64+40新しいウィンドウのクラス名(Unicode 文字列)へのポインタである。
dwExStyleWINDOW_EX_STYLE4+72+44新しいウィンドウの拡張スタイルである。

各言語での定義

#include <windows.h>

// CREATESTRUCTW  (x64 80 / x86 48 バイト)
typedef struct CREATESTRUCTW {
    void* lpCreateParams;
    HINSTANCE hInstance;
    HMENU hMenu;
    HWND hwndParent;
    INT cy;
    INT cx;
    INT y;
    INT x;
    INT style;
    LPWSTR lpszName;
    LPWSTR lpszClass;
    WINDOW_EX_STYLE dwExStyle;
} CREATESTRUCTW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CREATESTRUCTW
{
    public IntPtr lpCreateParams;
    public IntPtr hInstance;
    public IntPtr hMenu;
    public IntPtr hwndParent;
    public int cy;
    public int cx;
    public int y;
    public int x;
    public int style;
    public IntPtr lpszName;
    public IntPtr lpszClass;
    public uint dwExStyle;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CREATESTRUCTW
    Public lpCreateParams As IntPtr
    Public hInstance As IntPtr
    Public hMenu As IntPtr
    Public hwndParent As IntPtr
    Public cy As Integer
    Public cx As Integer
    Public y As Integer
    Public x As Integer
    Public style As Integer
    Public lpszName As IntPtr
    Public lpszClass As IntPtr
    Public dwExStyle As UInteger
End Structure
import ctypes
from ctypes import wintypes

class CREATESTRUCTW(ctypes.Structure):
    _fields_ = [
        ("lpCreateParams", ctypes.c_void_p),
        ("hInstance", ctypes.c_void_p),
        ("hMenu", ctypes.c_void_p),
        ("hwndParent", ctypes.c_void_p),
        ("cy", ctypes.c_int),
        ("cx", ctypes.c_int),
        ("y", ctypes.c_int),
        ("x", ctypes.c_int),
        ("style", ctypes.c_int),
        ("lpszName", ctypes.c_void_p),
        ("lpszClass", ctypes.c_void_p),
        ("dwExStyle", wintypes.DWORD),
    ]
#[repr(C)]
pub struct CREATESTRUCTW {
    pub lpCreateParams: *mut core::ffi::c_void,
    pub hInstance: *mut core::ffi::c_void,
    pub hMenu: *mut core::ffi::c_void,
    pub hwndParent: *mut core::ffi::c_void,
    pub cy: i32,
    pub cx: i32,
    pub y: i32,
    pub x: i32,
    pub style: i32,
    pub lpszName: *mut core::ffi::c_void,
    pub lpszClass: *mut core::ffi::c_void,
    pub dwExStyle: u32,
}
import "golang.org/x/sys/windows"

type CREATESTRUCTW struct {
	lpCreateParams uintptr
	hInstance uintptr
	hMenu uintptr
	hwndParent uintptr
	cy int32
	cx int32
	y int32
	x int32
	style int32
	lpszName uintptr
	lpszClass uintptr
	dwExStyle uint32
}
type
  CREATESTRUCTW = record
    lpCreateParams: Pointer;
    hInstance: Pointer;
    hMenu: Pointer;
    hwndParent: Pointer;
    cy: Integer;
    cx: Integer;
    y: Integer;
    x: Integer;
    style: Integer;
    lpszName: Pointer;
    lpszClass: Pointer;
    dwExStyle: DWORD;
  end;
const CREATESTRUCTW = extern struct {
    lpCreateParams: ?*anyopaque,
    hInstance: ?*anyopaque,
    hMenu: ?*anyopaque,
    hwndParent: ?*anyopaque,
    cy: i32,
    cx: i32,
    y: i32,
    x: i32,
    style: i32,
    lpszName: ?*anyopaque,
    lpszClass: ?*anyopaque,
    dwExStyle: u32,
};
type
  CREATESTRUCTW {.bycopy.} = object
    lpCreateParams: pointer
    hInstance: pointer
    hMenu: pointer
    hwndParent: pointer
    cy: int32
    cx: int32
    y: int32
    x: int32
    style: int32
    lpszName: pointer
    lpszClass: pointer
    dwExStyle: uint32
struct CREATESTRUCTW
{
    void* lpCreateParams;
    void* hInstance;
    void* hMenu;
    void* hwndParent;
    int cy;
    int cx;
    int y;
    int x;
    int style;
    void* lpszName;
    void* lpszClass;
    uint dwExStyle;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; CREATESTRUCTW サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; lpCreateParams : void* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; hInstance : HINSTANCE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; hMenu : HMENU (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; hwndParent : HWND (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; cy : INT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; cx : INT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; y : INT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; x : INT (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; style : INT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; lpszName : LPWSTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; lpszClass : LPWSTR (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; dwExStyle : WINDOW_EX_STYLE (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CREATESTRUCTW サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; lpCreateParams : void* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; hInstance : HINSTANCE (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; hMenu : HMENU (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; hwndParent : HWND (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; cy : INT (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; cx : INT (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; y : INT (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; x : INT (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; style : INT (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; lpszName : LPWSTR (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; lpszClass : LPWSTR (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; dwExStyle : WINDOW_EX_STYLE (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CREATESTRUCTW
    #field intptr lpCreateParams
    #field intptr hInstance
    #field intptr hMenu
    #field intptr hwndParent
    #field int cy
    #field int cx
    #field int y
    #field int x
    #field int style
    #field intptr lpszName
    #field intptr lpszClass
    #field int dwExStyle
#endstruct

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