ホーム › UI.WindowsAndMessaging › CreateWindowExA
CreateWindowExA
関数拡張スタイル指定でウィンドウを作成する(ANSI)。
シグネチャ
// USER32.dll (ANSI / -A)
#include <windows.h>
HWND CreateWindowExA(
WINDOW_EX_STYLE dwExStyle,
LPCSTR lpClassName, // optional
LPCSTR lpWindowName, // optional
WINDOW_STYLE dwStyle,
INT X,
INT Y,
INT nWidth,
INT nHeight,
HWND hWndParent, // optional
HMENU hMenu, // optional
HINSTANCE hInstance, // optional
void* lpParam // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwExStyle | WINDOW_EX_STYLE | in |
| lpClassName | LPCSTR | inoptional |
| lpWindowName | LPCSTR | inoptional |
| dwStyle | WINDOW_STYLE | in |
| X | INT | in |
| Y | INT | in |
| nWidth | INT | in |
| nHeight | INT | in |
| hWndParent | HWND | inoptional |
| hMenu | HMENU | inoptional |
| hInstance | HINSTANCE | inoptional |
| lpParam | void* | inoptional |
戻り値の型: HWND
各言語での呼び出し定義
// USER32.dll (ANSI / -A)
#include <windows.h>
HWND CreateWindowExA(
WINDOW_EX_STYLE dwExStyle,
LPCSTR lpClassName, // optional
LPCSTR lpWindowName, // optional
WINDOW_STYLE dwStyle,
INT X,
INT Y,
INT nWidth,
INT nHeight,
HWND hWndParent, // optional
HMENU hMenu, // optional
HINSTANCE hInstance, // optional
void* lpParam // optional
);[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateWindowExA(
uint dwExStyle, // WINDOW_EX_STYLE
[MarshalAs(UnmanagedType.LPStr)] string lpClassName, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string lpWindowName, // LPCSTR optional
uint dwStyle, // WINDOW_STYLE
int X, // INT
int Y, // INT
int nWidth, // INT
int nHeight, // INT
IntPtr hWndParent, // HWND optional
IntPtr hMenu, // HMENU optional
IntPtr hInstance, // HINSTANCE optional
IntPtr lpParam // void* optional
);<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateWindowExA(
dwExStyle As UInteger, ' WINDOW_EX_STYLE
<MarshalAs(UnmanagedType.LPStr)> lpClassName As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> lpWindowName As String, ' LPCSTR optional
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
hMenu As IntPtr, ' HMENU optional
hInstance As IntPtr, ' HINSTANCE optional
lpParam As IntPtr ' void* optional
) As IntPtr
End Function' dwExStyle : WINDOW_EX_STYLE
' lpClassName : LPCSTR optional
' lpWindowName : LPCSTR optional
' dwStyle : WINDOW_STYLE
' X : INT
' Y : INT
' nWidth : INT
' nHeight : INT
' hWndParent : HWND optional
' hMenu : HMENU optional
' hInstance : HINSTANCE optional
' lpParam : void* optional
Declare PtrSafe Function CreateWindowExA Lib "user32" ( _
ByVal dwExStyle As Long, _
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 hMenu As LongPtr, _
ByVal hInstance As LongPtr, _
ByVal lpParam As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateWindowExA = ctypes.windll.user32.CreateWindowExA
CreateWindowExA.restype = ctypes.c_void_p
CreateWindowExA.argtypes = [
wintypes.DWORD, # dwExStyle : WINDOW_EX_STYLE
wintypes.LPCSTR, # lpClassName : LPCSTR optional
wintypes.LPCSTR, # lpWindowName : LPCSTR optional
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, # hMenu : HMENU optional
wintypes.HANDLE, # hInstance : HINSTANCE optional
ctypes.POINTER(None), # lpParam : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
CreateWindowExA = Fiddle::Function.new(
lib['CreateWindowExA'],
[
-Fiddle::TYPE_INT, # dwExStyle : WINDOW_EX_STYLE
Fiddle::TYPE_VOIDP, # lpClassName : LPCSTR optional
Fiddle::TYPE_VOIDP, # lpWindowName : LPCSTR optional
-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, # hMenu : HMENU optional
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
Fiddle::TYPE_VOIDP, # lpParam : void* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "user32")]
extern "system" {
fn CreateWindowExA(
dwExStyle: u32, // WINDOW_EX_STYLE
lpClassName: *const u8, // LPCSTR optional
lpWindowName: *const u8, // LPCSTR optional
dwStyle: u32, // WINDOW_STYLE
X: i32, // INT
Y: i32, // INT
nWidth: i32, // INT
nHeight: i32, // INT
hWndParent: *mut core::ffi::c_void, // HWND optional
hMenu: *mut core::ffi::c_void, // HMENU optional
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
lpParam: *mut () // void* optional
) -> *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 CreateWindowExA(uint dwExStyle, [MarshalAs(UnmanagedType.LPStr)] string lpClassName, [MarshalAs(UnmanagedType.LPStr)] string lpWindowName, uint dwStyle, int X, int Y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_CreateWindowExA' -Namespace Win32 -PassThru
# $api::CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)#uselib "USER32.dll"
#func global CreateWindowExA "CreateWindowExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CreateWindowExA dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam ; 戻り値は stat
; dwExStyle : WINDOW_EX_STYLE -> "sptr"
; lpClassName : LPCSTR optional -> "sptr"
; lpWindowName : LPCSTR optional -> "sptr"
; dwStyle : WINDOW_STYLE -> "sptr"
; X : INT -> "sptr"
; Y : INT -> "sptr"
; nWidth : INT -> "sptr"
; nHeight : INT -> "sptr"
; hWndParent : HWND optional -> "sptr"
; hMenu : HMENU optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; lpParam : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global CreateWindowExA "CreateWindowExA" int, str, str, int, int, int, int, int, sptr, sptr, sptr, sptr
; res = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
; dwExStyle : WINDOW_EX_STYLE -> "int"
; lpClassName : LPCSTR optional -> "str"
; lpWindowName : LPCSTR optional -> "str"
; dwStyle : WINDOW_STYLE -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hWndParent : HWND optional -> "sptr"
; hMenu : HMENU optional -> "sptr"
; hInstance : HINSTANCE optional -> "sptr"
; lpParam : void* optional -> "sptr"; HWND CreateWindowExA(WINDOW_EX_STYLE dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, WINDOW_STYLE dwStyle, INT X, INT Y, INT nWidth, INT nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, void* lpParam)
#uselib "USER32.dll"
#cfunc global CreateWindowExA "CreateWindowExA" int, str, str, int, int, int, int, int, intptr, intptr, intptr, intptr
; res = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
; dwExStyle : WINDOW_EX_STYLE -> "int"
; lpClassName : LPCSTR optional -> "str"
; lpWindowName : LPCSTR optional -> "str"
; dwStyle : WINDOW_STYLE -> "int"
; X : INT -> "int"
; Y : INT -> "int"
; nWidth : INT -> "int"
; nHeight : INT -> "int"
; hWndParent : HWND optional -> "intptr"
; hMenu : HMENU optional -> "intptr"
; hInstance : HINSTANCE optional -> "intptr"
; lpParam : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procCreateWindowExA = user32.NewProc("CreateWindowExA")
)
// dwExStyle (WINDOW_EX_STYLE), lpClassName (LPCSTR optional), lpWindowName (LPCSTR optional), dwStyle (WINDOW_STYLE), X (INT), Y (INT), nWidth (INT), nHeight (INT), hWndParent (HWND optional), hMenu (HMENU optional), hInstance (HINSTANCE optional), lpParam (void* optional)
r1, _, err := procCreateWindowExA.Call(
uintptr(dwExStyle),
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(hMenu),
uintptr(hInstance),
uintptr(lpParam),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HWNDfunction CreateWindowExA(
dwExStyle: DWORD; // WINDOW_EX_STYLE
lpClassName: PAnsiChar; // LPCSTR optional
lpWindowName: PAnsiChar; // LPCSTR optional
dwStyle: DWORD; // WINDOW_STYLE
X: Integer; // INT
Y: Integer; // INT
nWidth: Integer; // INT
nHeight: Integer; // INT
hWndParent: THandle; // HWND optional
hMenu: THandle; // HMENU optional
hInstance: THandle; // HINSTANCE optional
lpParam: Pointer // void* optional
): THandle; stdcall;
external 'USER32.dll' name 'CreateWindowExA';result := DllCall("USER32\CreateWindowExA"
, "UInt", dwExStyle ; WINDOW_EX_STYLE
, "AStr", lpClassName ; LPCSTR optional
, "AStr", lpWindowName ; LPCSTR optional
, "UInt", dwStyle ; WINDOW_STYLE
, "Int", X ; INT
, "Int", Y ; INT
, "Int", nWidth ; INT
, "Int", nHeight ; INT
, "Ptr", hWndParent ; HWND optional
, "Ptr", hMenu ; HMENU optional
, "Ptr", hInstance ; HINSTANCE optional
, "Ptr", lpParam ; void* optional
, "Ptr") ; return: HWND●CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) = DLL("USER32.dll", "void* CreateWindowExA(dword, char*, char*, dword, int, int, int, int, void*, void*, void*, void*)")
# 呼び出し: CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
# dwExStyle : WINDOW_EX_STYLE -> "dword"
# lpClassName : LPCSTR optional -> "char*"
# lpWindowName : LPCSTR optional -> "char*"
# dwStyle : WINDOW_STYLE -> "dword"
# X : INT -> "int"
# Y : INT -> "int"
# nWidth : INT -> "int"
# nHeight : INT -> "int"
# hWndParent : HWND optional -> "void*"
# hMenu : HMENU optional -> "void*"
# hInstance : HINSTANCE optional -> "void*"
# lpParam : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。