ホーム › Graphics.Dwm › DwmDefWindowProc
DwmDefWindowProc
関数DWMが処理すべきウィンドウメッセージの既定処理を行う。
シグネチャ
// dwmapi.dll
#include <windows.h>
BOOL DwmDefWindowProc(
HWND hWnd,
DWORD msg,
WPARAM wParam,
LPARAM lParam,
LRESULT* plResult
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hWnd | HWND | in | メッセージ処理対象のウィンドウハンドル。 |
| msg | DWORD | in | 処理するウィンドウメッセージの識別子。 |
| wParam | WPARAM | in | メッセージに付随する第1パラメーター(WPARAM)。 |
| lParam | LPARAM | in | メッセージに付随する第2パラメーター(LPARAM)。 |
| plResult | LRESULT* | out | DWMが処理した場合の戻り値を受け取る出力先。 |
戻り値の型: BOOL
各言語での呼び出し定義
// dwmapi.dll
#include <windows.h>
BOOL DwmDefWindowProc(
HWND hWnd,
DWORD msg,
WPARAM wParam,
LPARAM lParam,
LRESULT* plResult
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dwmapi.dll", ExactSpelling = true)]
static extern bool DwmDefWindowProc(
IntPtr hWnd, // HWND
uint msg, // DWORD
UIntPtr wParam, // WPARAM
IntPtr lParam, // LPARAM
out IntPtr plResult // LRESULT* out
);<DllImport("dwmapi.dll", ExactSpelling:=True)>
Public Shared Function DwmDefWindowProc(
hWnd As IntPtr, ' HWND
msg As UInteger, ' DWORD
wParam As UIntPtr, ' WPARAM
lParam As IntPtr, ' LPARAM
<Out> ByRef plResult As IntPtr ' LRESULT* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hWnd : HWND
' msg : DWORD
' wParam : WPARAM
' lParam : LPARAM
' plResult : LRESULT* out
Declare PtrSafe Function DwmDefWindowProc Lib "dwmapi" ( _
ByVal hWnd As LongPtr, _
ByVal msg As Long, _
ByVal wParam As LongPtr, _
ByVal lParam As LongPtr, _
ByRef plResult As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DwmDefWindowProc = ctypes.windll.dwmapi.DwmDefWindowProc
DwmDefWindowProc.restype = wintypes.BOOL
DwmDefWindowProc.argtypes = [
wintypes.HANDLE, # hWnd : HWND
wintypes.DWORD, # msg : DWORD
ctypes.c_size_t, # wParam : WPARAM
ctypes.c_ssize_t, # lParam : LPARAM
ctypes.c_void_p, # plResult : LRESULT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dwmapi.dll')
DwmDefWindowProc = Fiddle::Function.new(
lib['DwmDefWindowProc'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
-Fiddle::TYPE_INT, # msg : DWORD
Fiddle::TYPE_UINTPTR_T, # wParam : WPARAM
Fiddle::TYPE_INTPTR_T, # lParam : LPARAM
Fiddle::TYPE_VOIDP, # plResult : LRESULT* out
],
Fiddle::TYPE_INT)#[link(name = "dwmapi")]
extern "system" {
fn DwmDefWindowProc(
hWnd: *mut core::ffi::c_void, // HWND
msg: u32, // DWORD
wParam: usize, // WPARAM
lParam: isize, // LPARAM
plResult: *mut isize // LRESULT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dwmapi.dll")]
public static extern bool DwmDefWindowProc(IntPtr hWnd, uint msg, UIntPtr wParam, IntPtr lParam, out IntPtr plResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dwmapi_DwmDefWindowProc' -Namespace Win32 -PassThru
# $api::DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult)#uselib "dwmapi.dll"
#func global DwmDefWindowProc "DwmDefWindowProc" sptr, sptr, sptr, sptr, sptr
; DwmDefWindowProc hWnd, msg, wParam, lParam, varptr(plResult) ; 戻り値は stat
; hWnd : HWND -> "sptr"
; msg : DWORD -> "sptr"
; wParam : WPARAM -> "sptr"
; lParam : LPARAM -> "sptr"
; plResult : LRESULT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dwmapi.dll" #cfunc global DwmDefWindowProc "DwmDefWindowProc" sptr, int, sptr, sptr, var ; res = DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult) ; hWnd : HWND -> "sptr" ; msg : DWORD -> "int" ; wParam : WPARAM -> "sptr" ; lParam : LPARAM -> "sptr" ; plResult : LRESULT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dwmapi.dll" #cfunc global DwmDefWindowProc "DwmDefWindowProc" sptr, int, sptr, sptr, sptr ; res = DwmDefWindowProc(hWnd, msg, wParam, lParam, varptr(plResult)) ; hWnd : HWND -> "sptr" ; msg : DWORD -> "int" ; wParam : WPARAM -> "sptr" ; lParam : LPARAM -> "sptr" ; plResult : LRESULT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DwmDefWindowProc(HWND hWnd, DWORD msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult) #uselib "dwmapi.dll" #cfunc global DwmDefWindowProc "DwmDefWindowProc" intptr, int, intptr, intptr, var ; res = DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult) ; hWnd : HWND -> "intptr" ; msg : DWORD -> "int" ; wParam : WPARAM -> "intptr" ; lParam : LPARAM -> "intptr" ; plResult : LRESULT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DwmDefWindowProc(HWND hWnd, DWORD msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult) #uselib "dwmapi.dll" #cfunc global DwmDefWindowProc "DwmDefWindowProc" intptr, int, intptr, intptr, intptr ; res = DwmDefWindowProc(hWnd, msg, wParam, lParam, varptr(plResult)) ; hWnd : HWND -> "intptr" ; msg : DWORD -> "int" ; wParam : WPARAM -> "intptr" ; lParam : LPARAM -> "intptr" ; plResult : LRESULT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dwmapi = windows.NewLazySystemDLL("dwmapi.dll")
procDwmDefWindowProc = dwmapi.NewProc("DwmDefWindowProc")
)
// hWnd (HWND), msg (DWORD), wParam (WPARAM), lParam (LPARAM), plResult (LRESULT* out)
r1, _, err := procDwmDefWindowProc.Call(
uintptr(hWnd),
uintptr(msg),
uintptr(wParam),
uintptr(lParam),
uintptr(plResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DwmDefWindowProc(
hWnd: THandle; // HWND
msg: DWORD; // DWORD
wParam: NativeUInt; // WPARAM
lParam: NativeInt; // LPARAM
plResult: Pointer // LRESULT* out
): BOOL; stdcall;
external 'dwmapi.dll' name 'DwmDefWindowProc';result := DllCall("dwmapi\DwmDefWindowProc"
, "Ptr", hWnd ; HWND
, "UInt", msg ; DWORD
, "UPtr", wParam ; WPARAM
, "Ptr", lParam ; LPARAM
, "Ptr", plResult ; LRESULT* out
, "Int") ; return: BOOL●DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult) = DLL("dwmapi.dll", "bool DwmDefWindowProc(void*, dword, int, int, void*)")
# 呼び出し: DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult)
# hWnd : HWND -> "void*"
# msg : DWORD -> "dword"
# wParam : WPARAM -> "int"
# lParam : LPARAM -> "int"
# plResult : LRESULT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dwmapi" fn DwmDefWindowProc(
hWnd: ?*anyopaque, // HWND
msg: u32, // DWORD
wParam: usize, // WPARAM
lParam: isize, // LPARAM
plResult: [*c]isize // LRESULT* out
) callconv(std.os.windows.WINAPI) i32;proc DwmDefWindowProc(
hWnd: pointer, # HWND
msg: uint32, # DWORD
wParam: uint, # WPARAM
lParam: int, # LPARAM
plResult: ptr int # LRESULT* out
): int32 {.importc: "DwmDefWindowProc", stdcall, dynlib: "dwmapi.dll".}pragma(lib, "dwmapi");
extern(Windows)
int DwmDefWindowProc(
void* hWnd, // HWND
uint msg, // DWORD
size_t wParam, // WPARAM
ptrdiff_t lParam, // LPARAM
ptrdiff_t* plResult // LRESULT* out
);ccall((:DwmDefWindowProc, "dwmapi.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Csize_t, Int, Ptr{Int}),
hWnd, msg, wParam, lParam, plResult)
# hWnd : HWND -> Ptr{Cvoid}
# msg : DWORD -> UInt32
# wParam : WPARAM -> Csize_t
# lParam : LPARAM -> Int
# plResult : LRESULT* out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DwmDefWindowProc(
void* hWnd,
uint32_t msg,
uintptr_t wParam,
intptr_t lParam,
intptr_t* plResult);
]]
local dwmapi = ffi.load("dwmapi")
-- dwmapi.DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult)
-- hWnd : HWND
-- msg : DWORD
-- wParam : WPARAM
-- lParam : LPARAM
-- plResult : LRESULT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('dwmapi.dll');
const DwmDefWindowProc = lib.func('__stdcall', 'DwmDefWindowProc', 'int32_t', ['void *', 'uint32_t', 'uintptr_t', 'intptr_t', 'intptr_t *']);
// DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult)
// hWnd : HWND -> 'void *'
// msg : DWORD -> 'uint32_t'
// wParam : WPARAM -> 'uintptr_t'
// lParam : LPARAM -> 'intptr_t'
// plResult : LRESULT* out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("dwmapi.dll", {
DwmDefWindowProc: { parameters: ["pointer", "u32", "usize", "isize", "pointer"], result: "i32" },
});
// lib.symbols.DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult)
// hWnd : HWND -> "pointer"
// msg : DWORD -> "u32"
// wParam : WPARAM -> "usize"
// lParam : LPARAM -> "isize"
// plResult : LRESULT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DwmDefWindowProc(
void* hWnd,
uint32_t msg,
size_t wParam,
intptr_t lParam,
intptr_t* plResult);
C, "dwmapi.dll");
// $ffi->DwmDefWindowProc(hWnd, msg, wParam, lParam, plResult);
// hWnd : HWND
// msg : DWORD
// wParam : WPARAM
// lParam : LPARAM
// plResult : LRESULT* out
// 構造体/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 Dwmapi extends StdCallLibrary {
Dwmapi INSTANCE = Native.load("dwmapi", Dwmapi.class);
boolean DwmDefWindowProc(
Pointer hWnd, // HWND
int msg, // DWORD
long wParam, // WPARAM
long lParam, // LPARAM
LongByReference plResult // LRESULT* out
);
}@[Link("dwmapi")]
lib Libdwmapi
fun DwmDefWindowProc = DwmDefWindowProc(
hWnd : Void*, # HWND
msg : UInt32, # DWORD
wParam : LibC::SizeT, # WPARAM
lParam : LibC::SSizeT, # LPARAM
plResult : LibC::SSizeT* # LRESULT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DwmDefWindowProcNative = Int32 Function(Pointer<Void>, Uint32, UintPtr, IntPtr, Pointer<IntPtr>);
typedef DwmDefWindowProcDart = int Function(Pointer<Void>, int, int, int, Pointer<IntPtr>);
final DwmDefWindowProc = DynamicLibrary.open('dwmapi.dll')
.lookupFunction<DwmDefWindowProcNative, DwmDefWindowProcDart>('DwmDefWindowProc');
// hWnd : HWND -> Pointer<Void>
// msg : DWORD -> Uint32
// wParam : WPARAM -> UintPtr
// lParam : LPARAM -> IntPtr
// plResult : LRESULT* out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DwmDefWindowProc(
hWnd: THandle; // HWND
msg: DWORD; // DWORD
wParam: NativeUInt; // WPARAM
lParam: NativeInt; // LPARAM
plResult: Pointer // LRESULT* out
): BOOL; stdcall;
external 'dwmapi.dll' name 'DwmDefWindowProc';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DwmDefWindowProc"
c_DwmDefWindowProc :: Ptr () -> Word32 -> CUIntPtr -> CIntPtr -> Ptr CIntPtr -> IO CInt
-- hWnd : HWND -> Ptr ()
-- msg : DWORD -> Word32
-- wParam : WPARAM -> CUIntPtr
-- lParam : LPARAM -> CIntPtr
-- plResult : LRESULT* out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dwmdefwindowproc =
foreign "DwmDefWindowProc"
((ptr void) @-> uint32_t @-> size_t @-> intptr_t @-> (ptr intptr_t) @-> returning int32_t)
(* hWnd : HWND -> (ptr void) *)
(* msg : DWORD -> uint32_t *)
(* wParam : WPARAM -> size_t *)
(* lParam : LPARAM -> intptr_t *)
(* plResult : LRESULT* out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dwmapi (t "dwmapi.dll"))
(cffi:use-foreign-library dwmapi)
(cffi:defcfun ("DwmDefWindowProc" dwm-def-window-proc :convention :stdcall) :int32
(h-wnd :pointer) ; HWND
(msg :uint32) ; DWORD
(w-param :uint64) ; WPARAM
(l-param :int64) ; LPARAM
(pl-result :pointer)) ; LRESULT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DwmDefWindowProc = Win32::API::More->new('dwmapi',
'BOOL DwmDefWindowProc(HANDLE hWnd, DWORD msg, WPARAM wParam, LPARAM lParam, LPVOID plResult)');
# my $ret = $DwmDefWindowProc->Call($hWnd, $msg, $wParam, $lParam, $plResult);
# hWnd : HWND -> HANDLE
# msg : DWORD -> DWORD
# wParam : WPARAM -> WPARAM
# lParam : LPARAM -> LPARAM
# plResult : LRESULT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。