Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › EnumChildWindows

EnumChildWindows

関数
親ウィンドウの全子ウィンドウをコールバックで列挙する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll
#include <windows.h>

BOOL EnumChildWindows(
    HWND hWndParent,   // optional
    WNDENUMPROC lpEnumFunc,
    LPARAM lParam
);

パラメーター

名前方向
hWndParentHWNDinoptional
lpEnumFuncWNDENUMPROCin
lParamLPARAMin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

BOOL EnumChildWindows(
    HWND hWndParent,   // optional
    WNDENUMPROC lpEnumFunc,
    LPARAM lParam
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool EnumChildWindows(
    IntPtr hWndParent,   // HWND optional
    IntPtr lpEnumFunc,   // WNDENUMPROC
    IntPtr lParam   // LPARAM
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function EnumChildWindows(
    hWndParent As IntPtr,   ' HWND optional
    lpEnumFunc As IntPtr,   ' WNDENUMPROC
    lParam As IntPtr   ' LPARAM
) As Boolean
End Function
' hWndParent : HWND optional
' lpEnumFunc : WNDENUMPROC
' lParam : LPARAM
Declare PtrSafe Function EnumChildWindows Lib "user32" ( _
    ByVal hWndParent As LongPtr, _
    ByVal lpEnumFunc As LongPtr, _
    ByVal lParam As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EnumChildWindows = ctypes.windll.user32.EnumChildWindows
EnumChildWindows.restype = wintypes.BOOL
EnumChildWindows.argtypes = [
    wintypes.HANDLE,  # hWndParent : HWND optional
    ctypes.c_void_p,  # lpEnumFunc : WNDENUMPROC
    ctypes.c_ssize_t,  # lParam : LPARAM
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
EnumChildWindows = Fiddle::Function.new(
  lib['EnumChildWindows'],
  [
    Fiddle::TYPE_VOIDP,  # hWndParent : HWND optional
    Fiddle::TYPE_VOIDP,  # lpEnumFunc : WNDENUMPROC
    Fiddle::TYPE_INTPTR_T,  # lParam : LPARAM
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn EnumChildWindows(
        hWndParent: *mut core::ffi::c_void,  // HWND optional
        lpEnumFunc: *const core::ffi::c_void,  // WNDENUMPROC
        lParam: isize  // LPARAM
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool EnumChildWindows(IntPtr hWndParent, IntPtr lpEnumFunc, IntPtr lParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_EnumChildWindows' -Namespace Win32 -PassThru
# $api::EnumChildWindows(hWndParent, lpEnumFunc, lParam)
#uselib "USER32.dll"
#func global EnumChildWindows "EnumChildWindows" sptr, sptr, sptr
; EnumChildWindows hWndParent, lpEnumFunc, lParam   ; 戻り値は stat
; hWndParent : HWND optional -> "sptr"
; lpEnumFunc : WNDENUMPROC -> "sptr"
; lParam : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global EnumChildWindows "EnumChildWindows" sptr, sptr, sptr
; res = EnumChildWindows(hWndParent, lpEnumFunc, lParam)
; hWndParent : HWND optional -> "sptr"
; lpEnumFunc : WNDENUMPROC -> "sptr"
; lParam : LPARAM -> "sptr"
; BOOL EnumChildWindows(HWND hWndParent, WNDENUMPROC lpEnumFunc, LPARAM lParam)
#uselib "USER32.dll"
#cfunc global EnumChildWindows "EnumChildWindows" intptr, intptr, intptr
; res = EnumChildWindows(hWndParent, lpEnumFunc, lParam)
; hWndParent : HWND optional -> "intptr"
; lpEnumFunc : WNDENUMPROC -> "intptr"
; lParam : LPARAM -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procEnumChildWindows = user32.NewProc("EnumChildWindows")
)

// hWndParent (HWND optional), lpEnumFunc (WNDENUMPROC), lParam (LPARAM)
r1, _, err := procEnumChildWindows.Call(
	uintptr(hWndParent),
	uintptr(lpEnumFunc),
	uintptr(lParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EnumChildWindows(
  hWndParent: THandle;   // HWND optional
  lpEnumFunc: Pointer;   // WNDENUMPROC
  lParam: NativeInt   // LPARAM
): BOOL; stdcall;
  external 'USER32.dll' name 'EnumChildWindows';
result := DllCall("USER32\EnumChildWindows"
    , "Ptr", hWndParent   ; HWND optional
    , "Ptr", lpEnumFunc   ; WNDENUMPROC
    , "Ptr", lParam   ; LPARAM
    , "Int")   ; return: BOOL
●EnumChildWindows(hWndParent, lpEnumFunc, lParam) = DLL("USER32.dll", "bool EnumChildWindows(void*, void*, int)")
# 呼び出し: EnumChildWindows(hWndParent, lpEnumFunc, lParam)
# hWndParent : HWND optional -> "void*"
# lpEnumFunc : WNDENUMPROC -> "void*"
# lParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。