ホーム › UI.WindowsAndMessaging › CreateMDIWindowW
CreateMDIWindowW
関数MDI子ウィンドウを作成する(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
HWND CreateMDIWindowW(
LPCWSTR lpClassName,
LPCWSTR lpWindowName,
WINDOW_STYLE dwStyle,
INT X,
INT Y,
INT nWidth,
INT nHeight,
HWND hWndParent, // optional
HINSTANCE hInstance, // optional
LPARAM lParam
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| lpClassName | LPCWSTR | in | MDI 子ウィンドウのウィンドウクラスです。クラス名は、RegisterClassEx 関数の呼び出しによって登録されている必要があります。 | ||||||||||
| lpWindowName | LPCWSTR | in | ウィンドウ名です。システムはこの名前を子ウィンドウのタイトルバーに表示します。 | ||||||||||
| dwStyle | WINDOW_STYLE | in | MDI 子ウィンドウのスタイルです。MDI クライアントウィンドウが MDIS_ALLCHILDSTYLES ウィンドウスタイルで作成されている場合、このパラメーターには Window Styles ページに記載されているウィンドウスタイルの任意の組み合わせを指定できます。それ以外の場合、このパラメーターは次の値のうち 1 つ以上に限定されます。
| ||||||||||
| X | INT | in | MDI 子ウィンドウの初期の水平位置 (クライアント座標) です。このパラメーターが CW_USEDEFAULT ((int)0x80000000) の場合、MDI 子ウィンドウには既定の水平位置が割り当てられます。 | ||||||||||
| Y | INT | in | MDI 子ウィンドウの初期の垂直位置 (クライアント座標) です。このパラメーターが CW_USEDEFAULT の場合、MDI 子ウィンドウには既定の垂直位置が割り当てられます。 | ||||||||||
| nWidth | INT | in | MDI 子ウィンドウの初期の幅 (デバイス単位) です。このパラメーターが CW_USEDEFAULT の場合、MDI 子ウィンドウには既定の幅が割り当てられます。 | ||||||||||
| nHeight | INT | in | MDI 子ウィンドウの初期の高さ (デバイス単位) です。このパラメーターが CW_USEDEFAULT に設定されている場合、MDI 子ウィンドウには既定の高さが割り当てられます。 | ||||||||||
| hWndParent | HWND | inoptional | 新しい MDI 子ウィンドウの親となる MDI クライアントウィンドウへのハンドルです。 | ||||||||||
| hInstance | HINSTANCE | inoptional | MDI 子ウィンドウを作成するアプリケーションのインスタンスへのハンドルです。 | ||||||||||
| lParam | LPARAM | in | アプリケーション定義の値です。 |
戻り値の型: HWND
公式ドキュメント
マルチドキュメントインターフェイス (MDI) の子ウィンドウを作成します。(Unicode)
戻り値
型: HWND
関数が成功した場合、戻り値は作成されたウィンドウへのハンドルです。
関数が失敗した場合、戻り値は NULL です。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
メモ
winuser.h ヘッダーは、CreateMDIWindow を、UNICODE プリプロセッサ定数の定義に基づいて ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在して使用すると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
HWND CreateMDIWindowW(
LPCWSTR lpClassName,
LPCWSTR 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.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateMDIWindowW(
[MarshalAs(UnmanagedType.LPWStr)] string lpClassName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, // LPCWSTR
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.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateMDIWindowW(
<MarshalAs(UnmanagedType.LPWStr)> lpClassName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpWindowName As String, ' LPCWSTR
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 : LPCWSTR
' lpWindowName : LPCWSTR
' dwStyle : WINDOW_STYLE
' X : INT
' Y : INT
' nWidth : INT
' nHeight : INT
' hWndParent : HWND optional
' hInstance : HINSTANCE optional
' lParam : LPARAM
Declare PtrSafe Function CreateMDIWindowW Lib "user32" ( _
ByVal lpClassName As LongPtr, _
ByVal lpWindowName As LongPtr, _
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
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateMDIWindowW = ctypes.windll.user32.CreateMDIWindowW
CreateMDIWindowW.restype = ctypes.c_void_p
CreateMDIWindowW.argtypes = [
wintypes.LPCWSTR, # lpClassName : LPCWSTR
wintypes.LPCWSTR, # lpWindowName : LPCWSTR
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')
CreateMDIWindowW = Fiddle::Function.new(
lib['CreateMDIWindowW'],
[
Fiddle::TYPE_VOIDP, # lpClassName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpWindowName : LPCWSTR
-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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn CreateMDIWindowW(
lpClassName: *const u16, // LPCWSTR
lpWindowName: *const u16, // LPCWSTR
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.Unicode, SetLastError = true)]
public static extern IntPtr CreateMDIWindowW([MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] 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_CreateMDIWindowW' -Namespace Win32 -PassThru
# $api::CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)#uselib "USER32.dll"
#func global CreateMDIWindowW "CreateMDIWindowW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; CreateMDIWindowW lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam ; 戻り値は stat
; lpClassName : LPCWSTR -> "wptr"
; lpWindowName : LPCWSTR -> "wptr"
; dwStyle : WINDOW_STYLE -> "wptr"
; X : INT -> "wptr"
; Y : INT -> "wptr"
; nWidth : INT -> "wptr"
; nHeight : INT -> "wptr"
; hWndParent : HWND optional -> "wptr"
; hInstance : HINSTANCE optional -> "wptr"
; lParam : LPARAM -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global CreateMDIWindowW "CreateMDIWindowW" wstr, wstr, int, int, int, int, int, sptr, sptr, sptr
; res = CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
; lpClassName : LPCWSTR -> "wstr"
; lpWindowName : LPCWSTR -> "wstr"
; 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 CreateMDIWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName, WINDOW_STYLE dwStyle, INT X, INT Y, INT nWidth, INT nHeight, HWND hWndParent, HINSTANCE hInstance, LPARAM lParam)
#uselib "USER32.dll"
#cfunc global CreateMDIWindowW "CreateMDIWindowW" wstr, wstr, int, int, int, int, int, intptr, intptr, intptr
; res = CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
; lpClassName : LPCWSTR -> "wstr"
; lpWindowName : LPCWSTR -> "wstr"
; 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")
procCreateMDIWindowW = user32.NewProc("CreateMDIWindowW")
)
// lpClassName (LPCWSTR), lpWindowName (LPCWSTR), dwStyle (WINDOW_STYLE), X (INT), Y (INT), nWidth (INT), nHeight (INT), hWndParent (HWND optional), hInstance (HINSTANCE optional), lParam (LPARAM)
r1, _, err := procCreateMDIWindowW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpClassName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(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 // HWNDfunction CreateMDIWindowW(
lpClassName: PWideChar; // LPCWSTR
lpWindowName: PWideChar; // LPCWSTR
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 'CreateMDIWindowW';result := DllCall("USER32\CreateMDIWindowW"
, "WStr", lpClassName ; LPCWSTR
, "WStr", lpWindowName ; LPCWSTR
, "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●CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam) = DLL("USER32.dll", "void* CreateMDIWindowW(char*, char*, dword, int, int, int, int, void*, void*, int)")
# 呼び出し: CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
# lpClassName : LPCWSTR -> "char*"
# lpWindowName : LPCWSTR -> "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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "user32" fn CreateMDIWindowW(
lpClassName: [*c]const u16, // LPCWSTR
lpWindowName: [*c]const u16, // LPCWSTR
dwStyle: u32, // WINDOW_STYLE
X: i32, // INT
Y: i32, // INT
nWidth: i32, // INT
nHeight: i32, // INT
hWndParent: ?*anyopaque, // HWND optional
hInstance: ?*anyopaque, // HINSTANCE optional
lParam: isize // LPARAM
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc CreateMDIWindowW(
lpClassName: WideCString, # LPCWSTR
lpWindowName: WideCString, # LPCWSTR
dwStyle: uint32, # WINDOW_STYLE
X: int32, # INT
Y: int32, # INT
nWidth: int32, # INT
nHeight: int32, # INT
hWndParent: pointer, # HWND optional
hInstance: pointer, # HINSTANCE optional
lParam: int # LPARAM
): pointer {.importc: "CreateMDIWindowW", stdcall, dynlib: "USER32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "user32");
extern(Windows)
void* CreateMDIWindowW(
const(wchar)* lpClassName, // LPCWSTR
const(wchar)* lpWindowName, // LPCWSTR
uint dwStyle, // WINDOW_STYLE
int X, // INT
int Y, // INT
int nWidth, // INT
int nHeight, // INT
void* hWndParent, // HWND optional
void* hInstance, // HINSTANCE optional
ptrdiff_t lParam // LPARAM
);ccall((:CreateMDIWindowW, "USER32.dll"), stdcall, Ptr{Cvoid},
(Cwstring, Cwstring, UInt32, Int32, Int32, Int32, Int32, Ptr{Cvoid}, Ptr{Cvoid}, Int),
lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
# lpClassName : LPCWSTR -> Cwstring
# lpWindowName : LPCWSTR -> Cwstring
# dwStyle : WINDOW_STYLE -> UInt32
# X : INT -> Int32
# Y : INT -> Int32
# nWidth : INT -> Int32
# nHeight : INT -> Int32
# hWndParent : HWND optional -> Ptr{Cvoid}
# hInstance : HINSTANCE optional -> Ptr{Cvoid}
# lParam : LPARAM -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
void* CreateMDIWindowW(
const uint16_t* lpClassName,
const uint16_t* lpWindowName,
uint32_t dwStyle,
int32_t X,
int32_t Y,
int32_t nWidth,
int32_t nHeight,
void* hWndParent,
void* hInstance,
intptr_t lParam);
]]
local user32 = ffi.load("user32")
-- user32.CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
-- lpClassName : LPCWSTR
-- lpWindowName : LPCWSTR
-- dwStyle : WINDOW_STYLE
-- X : INT
-- Y : INT
-- nWidth : INT
-- nHeight : INT
-- hWndParent : HWND optional
-- hInstance : HINSTANCE optional
-- lParam : LPARAM
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const CreateMDIWindowW = lib.func('__stdcall', 'CreateMDIWindowW', 'void *', ['str16', 'str16', 'uint32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'void *', 'void *', 'intptr_t']);
// CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
// lpClassName : LPCWSTR -> 'str16'
// lpWindowName : LPCWSTR -> 'str16'
// dwStyle : WINDOW_STYLE -> 'uint32_t'
// X : INT -> 'int32_t'
// Y : INT -> 'int32_t'
// nWidth : INT -> 'int32_t'
// nHeight : INT -> 'int32_t'
// hWndParent : HWND optional -> 'void *'
// hInstance : HINSTANCE optional -> 'void *'
// lParam : LPARAM -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
CreateMDIWindowW: { parameters: ["buffer", "buffer", "u32", "i32", "i32", "i32", "i32", "pointer", "pointer", "isize"], result: "pointer" },
});
// lib.symbols.CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam)
// lpClassName : LPCWSTR -> "buffer"
// lpWindowName : LPCWSTR -> "buffer"
// dwStyle : WINDOW_STYLE -> "u32"
// X : INT -> "i32"
// Y : INT -> "i32"
// nWidth : INT -> "i32"
// nHeight : INT -> "i32"
// hWndParent : HWND optional -> "pointer"
// hInstance : HINSTANCE optional -> "pointer"
// lParam : LPARAM -> "isize"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* CreateMDIWindowW(
const uint16_t* lpClassName,
const uint16_t* lpWindowName,
uint32_t dwStyle,
int32_t X,
int32_t Y,
int32_t nWidth,
int32_t nHeight,
void* hWndParent,
void* hInstance,
intptr_t lParam);
C, "USER32.dll");
// $ffi->CreateMDIWindowW(lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hInstance, lParam);
// lpClassName : LPCWSTR
// lpWindowName : LPCWSTR
// dwStyle : WINDOW_STYLE
// X : INT
// Y : INT
// nWidth : INT
// nHeight : INT
// hWndParent : HWND optional
// hInstance : HINSTANCE optional
// lParam : LPARAM
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.UNICODE_OPTIONS);
Pointer CreateMDIWindowW(
WString lpClassName, // LPCWSTR
WString lpWindowName, // LPCWSTR
int dwStyle, // WINDOW_STYLE
int X, // INT
int Y, // INT
int nWidth, // INT
int nHeight, // INT
Pointer hWndParent, // HWND optional
Pointer hInstance, // HINSTANCE optional
long lParam // LPARAM
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("user32")]
lib LibUSER32
fun CreateMDIWindowW = CreateMDIWindowW(
lpClassName : UInt16*, # LPCWSTR
lpWindowName : UInt16*, # LPCWSTR
dwStyle : UInt32, # WINDOW_STYLE
X : Int32, # INT
Y : Int32, # INT
nWidth : Int32, # INT
nHeight : Int32, # INT
hWndParent : Void*, # HWND optional
hInstance : Void*, # HINSTANCE optional
lParam : LibC::SSizeT # LPARAM
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CreateMDIWindowWNative = Pointer<Void> Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Int32, Int32, Int32, Int32, Pointer<Void>, Pointer<Void>, IntPtr);
typedef CreateMDIWindowWDart = Pointer<Void> Function(Pointer<Utf16>, Pointer<Utf16>, int, int, int, int, int, Pointer<Void>, Pointer<Void>, int);
final CreateMDIWindowW = DynamicLibrary.open('USER32.dll')
.lookupFunction<CreateMDIWindowWNative, CreateMDIWindowWDart>('CreateMDIWindowW');
// lpClassName : LPCWSTR -> Pointer<Utf16>
// lpWindowName : LPCWSTR -> Pointer<Utf16>
// dwStyle : WINDOW_STYLE -> Uint32
// X : INT -> Int32
// Y : INT -> Int32
// nWidth : INT -> Int32
// nHeight : INT -> Int32
// hWndParent : HWND optional -> Pointer<Void>
// hInstance : HINSTANCE optional -> Pointer<Void>
// lParam : LPARAM -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CreateMDIWindowW(
lpClassName: PWideChar; // LPCWSTR
lpWindowName: PWideChar; // LPCWSTR
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 'CreateMDIWindowW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CreateMDIWindowW"
c_CreateMDIWindowW :: CWString -> CWString -> Word32 -> Int32 -> Int32 -> Int32 -> Int32 -> Ptr () -> Ptr () -> CIntPtr -> IO (Ptr ())
-- lpClassName : LPCWSTR -> CWString
-- lpWindowName : LPCWSTR -> CWString
-- dwStyle : WINDOW_STYLE -> Word32
-- X : INT -> Int32
-- Y : INT -> Int32
-- nWidth : INT -> Int32
-- nHeight : INT -> Int32
-- hWndParent : HWND optional -> Ptr ()
-- hInstance : HINSTANCE optional -> Ptr ()
-- lParam : LPARAM -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let createmdiwindoww =
foreign "CreateMDIWindowW"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> (ptr void) @-> intptr_t @-> returning (ptr void))
(* lpClassName : LPCWSTR -> (ptr uint16_t) *)
(* lpWindowName : LPCWSTR -> (ptr uint16_t) *)
(* dwStyle : WINDOW_STYLE -> uint32_t *)
(* X : INT -> int32_t *)
(* Y : INT -> int32_t *)
(* nWidth : INT -> int32_t *)
(* nHeight : INT -> int32_t *)
(* hWndParent : HWND optional -> (ptr void) *)
(* hInstance : HINSTANCE optional -> (ptr void) *)
(* lParam : LPARAM -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("CreateMDIWindowW" create-mdiwindow-w :convention :stdcall) :pointer
(lp-class-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-window-name (:string :encoding :utf-16le)) ; LPCWSTR
(dw-style :uint32) ; WINDOW_STYLE
(x :int32) ; INT
(y :int32) ; INT
(n-width :int32) ; INT
(n-height :int32) ; INT
(h-wnd-parent :pointer) ; HWND optional
(h-instance :pointer) ; HINSTANCE optional
(l-param :int64)) ; LPARAM
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CreateMDIWindowW = Win32::API::More->new('USER32',
'HANDLE CreateMDIWindowW(LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HANDLE hWndParent, HANDLE hInstance, LPARAM lParam)');
# my $ret = $CreateMDIWindowW->Call($lpClassName, $lpWindowName, $dwStyle, $X, $Y, $nWidth, $nHeight, $hWndParent, $hInstance, $lParam);
# lpClassName : LPCWSTR -> LPCWSTR
# lpWindowName : LPCWSTR -> LPCWSTR
# dwStyle : WINDOW_STYLE -> DWORD
# X : INT -> int
# Y : INT -> int
# nWidth : INT -> int
# nHeight : INT -> int
# hWndParent : HWND optional -> HANDLE
# hInstance : HINSTANCE optional -> HANDLE
# lParam : LPARAM -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f CreateMDIWindowA (ANSI版) — MDI子ウィンドウを作成する(ANSI版)。
公式の関連項目
- f RegisterClassExW — 拡張属性付きでウィンドウクラスを登録する(Unicode)。
使用する型