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

ChildWindowFromPoint

関数
親ウィンドウ内の指定座標にある子ウィンドウを取得する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HWND ChildWindowFromPoint(
    HWND hWndParent,
    POINT Point
);

パラメーター

名前方向
hWndParentHWNDin
PointPOINTin

戻り値の型: HWND

各言語での呼び出し定義

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

HWND ChildWindowFromPoint(
    HWND hWndParent,
    POINT Point
);
[DllImport("USER32.dll", ExactSpelling = true)]
static extern IntPtr ChildWindowFromPoint(
    IntPtr hWndParent,   // HWND
    POINT Point   // POINT
);
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function ChildWindowFromPoint(
    hWndParent As IntPtr,   ' HWND
    Point As POINT   ' POINT
) As IntPtr
End Function
' hWndParent : HWND
' Point : POINT
Declare PtrSafe Function ChildWindowFromPoint Lib "user32" ( _
    ByVal hWndParent As LongPtr, _
    ByVal Point As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ChildWindowFromPoint = ctypes.windll.user32.ChildWindowFromPoint
ChildWindowFromPoint.restype = ctypes.c_void_p
ChildWindowFromPoint.argtypes = [
    wintypes.HANDLE,  # hWndParent : HWND
    POINT,  # Point : POINT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
ChildWindowFromPoint = Fiddle::Function.new(
  lib['ChildWindowFromPoint'],
  [
    Fiddle::TYPE_VOIDP,  # hWndParent : HWND
    Fiddle::TYPE_VOIDP,  # Point : POINT
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "user32")]
extern "system" {
    fn ChildWindowFromPoint(
        hWndParent: *mut core::ffi::c_void,  // HWND
        Point: POINT  // POINT
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll")]
public static extern IntPtr ChildWindowFromPoint(IntPtr hWndParent, POINT Point);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_ChildWindowFromPoint' -Namespace Win32 -PassThru
# $api::ChildWindowFromPoint(hWndParent, Point)
#uselib "USER32.dll"
#func global ChildWindowFromPoint "ChildWindowFromPoint" sptr, sptr
; ChildWindowFromPoint hWndParent, Point   ; 戻り値は stat
; hWndParent : HWND -> "sptr"
; Point : POINT -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global ChildWindowFromPoint "ChildWindowFromPoint" sptr, int
; res = ChildWindowFromPoint(hWndParent, Point)
; hWndParent : HWND -> "sptr"
; Point : POINT -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; HWND ChildWindowFromPoint(HWND hWndParent, POINT Point)
#uselib "USER32.dll"
#cfunc global ChildWindowFromPoint "ChildWindowFromPoint" intptr, int
; res = ChildWindowFromPoint(hWndParent, Point)
; hWndParent : HWND -> "intptr"
; Point : POINT -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procChildWindowFromPoint = user32.NewProc("ChildWindowFromPoint")
)

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