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

CreateMDIWindowA

関数
MDI子ウィンドウを作成する(ANSI版)。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

HWND CreateMDIWindowA(
    LPCSTR lpClassName,
    LPCSTR lpWindowName,
    WINDOW_STYLE dwStyle,
    INT X,
    INT Y,
    INT nWidth,
    INT nHeight,
    HWND hWndParent,   // optional
    HINSTANCE hInstance,   // optional
    LPARAM lParam
);

パラメーター

名前方向
lpClassNameLPCSTRin
lpWindowNameLPCSTRin
dwStyleWINDOW_STYLEin
XINTin
YINTin
nWidthINTin
nHeightINTin
hWndParentHWNDinoptional
hInstanceHINSTANCEinoptional
lParamLPARAMin

戻り値の型: HWND

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

HWND CreateMDIWindowA(
    LPCSTR lpClassName,
    LPCSTR lpWindowName,
    WINDOW_STYLE dwStyle,
    INT X,
    INT Y,
    INT nWidth,
    INT nHeight,
    HWND hWndParent,   // optional
    HINSTANCE hInstance,   // optional
    LPARAM lParam
);
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateMDIWindowA(
    [MarshalAs(UnmanagedType.LPStr)] string lpClassName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpWindowName,   // LPCSTR
    uint dwStyle,   // WINDOW_STYLE
    int X,   // INT
    int Y,   // INT
    int nWidth,   // INT
    int nHeight,   // INT
    IntPtr hWndParent,   // HWND optional
    IntPtr hInstance,   // HINSTANCE optional
    IntPtr lParam   // LPARAM
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateMDIWindowA(
    <MarshalAs(UnmanagedType.LPStr)> lpClassName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpWindowName As String,   ' LPCSTR
    dwStyle As UInteger,   ' WINDOW_STYLE
    X As Integer,   ' INT
    Y As Integer,   ' INT
    nWidth As Integer,   ' INT
    nHeight As Integer,   ' INT
    hWndParent As IntPtr,   ' HWND optional
    hInstance As IntPtr,   ' HINSTANCE optional
    lParam As IntPtr   ' LPARAM
) As IntPtr
End Function
' lpClassName : LPCSTR
' lpWindowName : LPCSTR
' dwStyle : WINDOW_STYLE
' X : INT
' Y : INT
' nWidth : INT
' nHeight : INT
' hWndParent : HWND optional
' hInstance : HINSTANCE optional
' lParam : LPARAM
Declare PtrSafe Function CreateMDIWindowA Lib "user32" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String, _
    ByVal dwStyle As Long, _
    ByVal X As Long, _
    ByVal Y As Long, _
    ByVal nWidth As Long, _
    ByVal nHeight As Long, _
    ByVal hWndParent As LongPtr, _
    ByVal hInstance As LongPtr, _
    ByVal lParam As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateMDIWindowA = ctypes.windll.user32.CreateMDIWindowA
CreateMDIWindowA.restype = ctypes.c_void_p
CreateMDIWindowA.argtypes = [
    wintypes.LPCSTR,  # lpClassName : LPCSTR
    wintypes.LPCSTR,  # lpWindowName : LPCSTR
    wintypes.DWORD,  # dwStyle : WINDOW_STYLE
    ctypes.c_int,  # X : INT
    ctypes.c_int,  # Y : INT
    ctypes.c_int,  # nWidth : INT
    ctypes.c_int,  # nHeight : INT
    wintypes.HANDLE,  # hWndParent : HWND optional
    wintypes.HANDLE,  # hInstance : HINSTANCE optional
    ctypes.c_ssize_t,  # lParam : LPARAM
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
CreateMDIWindowA = Fiddle::Function.new(
  lib['CreateMDIWindowA'],
  [
    Fiddle::TYPE_VOIDP,  # lpClassName : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpWindowName : LPCSTR
    -Fiddle::TYPE_INT,  # dwStyle : WINDOW_STYLE
    Fiddle::TYPE_INT,  # X : INT
    Fiddle::TYPE_INT,  # Y : INT
    Fiddle::TYPE_INT,  # nWidth : INT
    Fiddle::TYPE_INT,  # nHeight : INT
    Fiddle::TYPE_VOIDP,  # hWndParent : HWND optional
    Fiddle::TYPE_VOIDP,  # hInstance : HINSTANCE optional
    Fiddle::TYPE_INTPTR_T,  # lParam : LPARAM
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "user32")]
extern "system" {
    fn CreateMDIWindowA(
        lpClassName: *const u8,  // LPCSTR
        lpWindowName: *const u8,  // LPCSTR
        dwStyle: u32,  // WINDOW_STYLE
        X: i32,  // INT
        Y: i32,  // INT
        nWidth: i32,  // INT
        nHeight: i32,  // INT
        hWndParent: *mut core::ffi::c_void,  // HWND optional
        hInstance: *mut core::ffi::c_void,  // HINSTANCE optional
        lParam: isize  // LPARAM
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr CreateMDIWindowA([MarshalAs(UnmanagedType.LPStr)] string lpClassName, [MarshalAs(UnmanagedType.LPStr)] string lpWindowName, uint dwStyle, int X, int Y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hInstance, IntPtr lParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_CreateMDIWindowA' -Namespace Win32 -PassThru
# $api::CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
#uselib "USER32.dll"
#func global CreateMDIWindowA "CreateMDIWindowA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateMDIWindowA lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam   ; 戻り値は stat
; lpClassName : LPCSTR -> "sptr"
; lpWindowName : LPCSTR -> "sptr"
; dwStyle : WINDOW_STYLE -> "sptr"
; X : INT -> "sptr"
; Y : INT -> "sptr"
; nWidth : INT -> "sptr"
; nHeight : INT -> "sptr"
; hWndParent : HWND optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; lParam : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global CreateMDIWindowA "CreateMDIWindowA" str, str, int, int, int, int, int, sptr, sptr, sptr
; res = CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
; lpClassName : LPCSTR -> "str"
; lpWindowName : LPCSTR -> "str"
; dwStyle : WINDOW_STYLE -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hWndParent : HWND optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; lParam : LPARAM -> "sptr"
; HWND CreateMDIWindowA(LPCSTR lpClassName, LPCSTR lpWindowName, WINDOW_STYLE dwStyle, INT X, INT Y, INT nWidth, INT nHeight, HWND hWndParent, HINSTANCE hInstance, LPARAM lParam)
#uselib "USER32.dll"
#cfunc global CreateMDIWindowA "CreateMDIWindowA" str, str, int, int, int, int, int, intptr, intptr, intptr
; res = CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
; lpClassName : LPCSTR -> "str"
; lpWindowName : LPCSTR -> "str"
; dwStyle : WINDOW_STYLE -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hWndParent : HWND optional -> "intptr"
; hInstance : HINSTANCE optional -> "intptr"
; lParam : LPARAM -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procCreateMDIWindowA = user32.NewProc("CreateMDIWindowA")
)

// lpClassName (LPCSTR), lpWindowName (LPCSTR), dwStyle (WINDOW_STYLE), X (INT), Y (INT), nWidth (INT), nHeight (INT), hWndParent (HWND optional), hInstance (HINSTANCE optional), lParam (LPARAM)
r1, _, err := procCreateMDIWindowA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpClassName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpWindowName))),
	uintptr(dwStyle),
	uintptr(X),
	uintptr(Y),
	uintptr(nWidth),
	uintptr(nHeight),
	uintptr(hWndParent),
	uintptr(hInstance),
	uintptr(lParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HWND
function CreateMDIWindowA(
  lpClassName: PAnsiChar;   // LPCSTR
  lpWindowName: PAnsiChar;   // LPCSTR
  dwStyle: DWORD;   // WINDOW_STYLE
  X: Integer;   // INT
  Y: Integer;   // INT
  nWidth: Integer;   // INT
  nHeight: Integer;   // INT
  hWndParent: THandle;   // HWND optional
  hInstance: THandle;   // HINSTANCE optional
  lParam: NativeInt   // LPARAM
): THandle; stdcall;
  external 'USER32.dll' name 'CreateMDIWindowA';
result := DllCall("USER32\CreateMDIWindowA"
    , "AStr", lpClassName   ; LPCSTR
    , "AStr", lpWindowName   ; LPCSTR
    , "UInt", dwStyle   ; WINDOW_STYLE
    , "Int", X   ; INT
    , "Int", Y   ; INT
    , "Int", nWidth   ; INT
    , "Int", nHeight   ; INT
    , "Ptr", hWndParent   ; HWND optional
    , "Ptr", hInstance   ; HINSTANCE optional
    , "Ptr", lParam   ; LPARAM
    , "Ptr")   ; return: HWND
●CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam) = DLL("USER32.dll", "void* CreateMDIWindowA(char*, char*, dword, int, int, int, int, void*, void*, int)")
# 呼び出し: CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
# lpClassName : LPCSTR -> "char*"
# lpWindowName : LPCSTR -> "char*"
# dwStyle : WINDOW_STYLE -> "dword"
# X : INT -> "int"
# Y : INT -> "int"
# nWidth : INT -> "int"
# nHeight : INT -> "int"
# hWndParent : HWND optional -> "void*"
# hInstance : HINSTANCE optional -> "void*"
# lParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。