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