ホーム › UI.WindowsAndMessaging › DialogBoxIndirectParamW
DialogBoxIndirectParamW
関数メモリ上テンプレートからモーダルダイアログを実行する(Unicode)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
INT_PTR DialogBoxIndirectParamW(
HINSTANCE hInstance, // optional
DLGTEMPLATE* hDialogTemplate,
HWND hWndParent, // optional
DLGPROC lpDialogFunc, // optional
LPARAM dwInitParam
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstance | HINSTANCE | inoptional |
| hDialogTemplate | DLGTEMPLATE* | in |
| hWndParent | HWND | inoptional |
| lpDialogFunc | DLGPROC | inoptional |
| dwInitParam | LPARAM | in |
戻り値の型: INT_PTR
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
INT_PTR DialogBoxIndirectParamW(
HINSTANCE hInstance, // optional
DLGTEMPLATE* hDialogTemplate,
HWND hWndParent, // optional
DLGPROC lpDialogFunc, // optional
LPARAM dwInitParam
);[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr DialogBoxIndirectParamW(
IntPtr hInstance, // HINSTANCE optional
IntPtr hDialogTemplate, // DLGTEMPLATE*
IntPtr hWndParent, // HWND optional
IntPtr lpDialogFunc, // DLGPROC optional
IntPtr dwInitParam // LPARAM
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DialogBoxIndirectParamW(
hInstance As IntPtr, ' HINSTANCE optional
hDialogTemplate As IntPtr, ' DLGTEMPLATE*
hWndParent As IntPtr, ' HWND optional
lpDialogFunc As IntPtr, ' DLGPROC optional
dwInitParam As IntPtr ' LPARAM
) As IntPtr
End Function' hInstance : HINSTANCE optional
' hDialogTemplate : DLGTEMPLATE*
' hWndParent : HWND optional
' lpDialogFunc : DLGPROC optional
' dwInitParam : LPARAM
Declare PtrSafe Function DialogBoxIndirectParamW Lib "user32" ( _
ByVal hInstance As LongPtr, _
ByVal hDialogTemplate As LongPtr, _
ByVal hWndParent As LongPtr, _
ByVal lpDialogFunc As LongPtr, _
ByVal dwInitParam 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
DialogBoxIndirectParamW = ctypes.windll.user32.DialogBoxIndirectParamW
DialogBoxIndirectParamW.restype = ctypes.c_ssize_t
DialogBoxIndirectParamW.argtypes = [
wintypes.HANDLE, # hInstance : HINSTANCE optional
ctypes.c_void_p, # hDialogTemplate : DLGTEMPLATE*
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')
DialogBoxIndirectParamW = Fiddle::Function.new(
lib['DialogBoxIndirectParamW'],
[
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
Fiddle::TYPE_VOIDP, # hDialogTemplate : DLGTEMPLATE*
Fiddle::TYPE_VOIDP, # hWndParent : HWND optional
Fiddle::TYPE_VOIDP, # lpDialogFunc : DLGPROC optional
Fiddle::TYPE_INTPTR_T, # dwInitParam : LPARAM
],
Fiddle::TYPE_INTPTR_T)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn DialogBoxIndirectParamW(
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
hDialogTemplate: *mut DLGTEMPLATE, // DLGTEMPLATE*
hWndParent: *mut core::ffi::c_void, // HWND optional
lpDialogFunc: *const core::ffi::c_void, // DLGPROC optional
dwInitParam: isize // LPARAM
) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr DialogBoxIndirectParamW(IntPtr hInstance, IntPtr hDialogTemplate, IntPtr hWndParent, IntPtr lpDialogFunc, IntPtr dwInitParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DialogBoxIndirectParamW' -Namespace Win32 -PassThru
# $api::DialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)#uselib "USER32.dll"
#func global DialogBoxIndirectParamW "DialogBoxIndirectParamW" wptr, wptr, wptr, wptr, wptr
; DialogBoxIndirectParamW hInstance, varptr(hDialogTemplate), hWndParent, lpDialogFunc, dwInitParam ; 戻り値は stat
; hInstance : HINSTANCE optional -> "wptr"
; hDialogTemplate : DLGTEMPLATE* -> "wptr"
; hWndParent : HWND optional -> "wptr"
; lpDialogFunc : DLGPROC optional -> "wptr"
; dwInitParam : LPARAM -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global DialogBoxIndirectParamW "DialogBoxIndirectParamW" sptr, var, sptr, sptr, sptr ; res = DialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam) ; hInstance : HINSTANCE optional -> "sptr" ; hDialogTemplate : DLGTEMPLATE* -> "var" ; hWndParent : HWND optional -> "sptr" ; lpDialogFunc : DLGPROC optional -> "sptr" ; dwInitParam : LPARAM -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global DialogBoxIndirectParamW "DialogBoxIndirectParamW" sptr, sptr, sptr, sptr, sptr ; res = DialogBoxIndirectParamW(hInstance, varptr(hDialogTemplate), hWndParent, lpDialogFunc, dwInitParam) ; hInstance : HINSTANCE optional -> "sptr" ; hDialogTemplate : DLGTEMPLATE* -> "sptr" ; hWndParent : HWND optional -> "sptr" ; lpDialogFunc : DLGPROC optional -> "sptr" ; dwInitParam : LPARAM -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT_PTR DialogBoxIndirectParamW(HINSTANCE hInstance, DLGTEMPLATE* hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) #uselib "USER32.dll" #cfunc global DialogBoxIndirectParamW "DialogBoxIndirectParamW" intptr, var, intptr, intptr, intptr ; res = DialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam) ; hInstance : HINSTANCE optional -> "intptr" ; hDialogTemplate : DLGTEMPLATE* -> "var" ; hWndParent : HWND optional -> "intptr" ; lpDialogFunc : DLGPROC optional -> "intptr" ; dwInitParam : LPARAM -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT_PTR DialogBoxIndirectParamW(HINSTANCE hInstance, DLGTEMPLATE* hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) #uselib "USER32.dll" #cfunc global DialogBoxIndirectParamW "DialogBoxIndirectParamW" intptr, intptr, intptr, intptr, intptr ; res = DialogBoxIndirectParamW(hInstance, varptr(hDialogTemplate), hWndParent, lpDialogFunc, dwInitParam) ; hInstance : HINSTANCE optional -> "intptr" ; hDialogTemplate : DLGTEMPLATE* -> "intptr" ; hWndParent : HWND optional -> "intptr" ; lpDialogFunc : DLGPROC optional -> "intptr" ; dwInitParam : LPARAM -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDialogBoxIndirectParamW = user32.NewProc("DialogBoxIndirectParamW")
)
// hInstance (HINSTANCE optional), hDialogTemplate (DLGTEMPLATE*), hWndParent (HWND optional), lpDialogFunc (DLGPROC optional), dwInitParam (LPARAM)
r1, _, err := procDialogBoxIndirectParamW.Call(
uintptr(hInstance),
uintptr(hDialogTemplate),
uintptr(hWndParent),
uintptr(lpDialogFunc),
uintptr(dwInitParam),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT_PTRfunction DialogBoxIndirectParamW(
hInstance: THandle; // HINSTANCE optional
hDialogTemplate: Pointer; // DLGTEMPLATE*
hWndParent: THandle; // HWND optional
lpDialogFunc: Pointer; // DLGPROC optional
dwInitParam: NativeInt // LPARAM
): NativeInt; stdcall;
external 'USER32.dll' name 'DialogBoxIndirectParamW';result := DllCall("USER32\DialogBoxIndirectParamW"
, "Ptr", hInstance ; HINSTANCE optional
, "Ptr", hDialogTemplate ; DLGTEMPLATE*
, "Ptr", hWndParent ; HWND optional
, "Ptr", lpDialogFunc ; DLGPROC optional
, "Ptr", dwInitParam ; LPARAM
, "Ptr") ; return: INT_PTR●DialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam) = DLL("USER32.dll", "int DialogBoxIndirectParamW(void*, void*, void*, void*, int)")
# 呼び出し: DialogBoxIndirectParamW(hInstance, hDialogTemplate, hWndParent, lpDialogFunc, dwInitParam)
# hInstance : HINSTANCE optional -> "void*"
# hDialogTemplate : DLGTEMPLATE* -> "void*"
# hWndParent : HWND optional -> "void*"
# lpDialogFunc : DLGPROC optional -> "void*"
# dwInitParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。