ホーム › UI.WindowsAndMessaging › MenuItemFromPoint
MenuItemFromPoint
関数指定座標にあるメニュー項目の位置を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
INT MenuItemFromPoint(
HWND hWnd, // optional
HMENU hMenu,
POINT ptScreen
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | inoptional |
| hMenu | HMENU | in |
| ptScreen | POINT | in |
戻り値の型: INT
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
INT MenuItemFromPoint(
HWND hWnd, // optional
HMENU hMenu,
POINT ptScreen
);[DllImport("USER32.dll", ExactSpelling = true)]
static extern int MenuItemFromPoint(
IntPtr hWnd, // HWND optional
IntPtr hMenu, // HMENU
POINT ptScreen // POINT
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function MenuItemFromPoint(
hWnd As IntPtr, ' HWND optional
hMenu As IntPtr, ' HMENU
ptScreen As POINT ' POINT
) As Integer
End Function' hWnd : HWND optional
' hMenu : HMENU
' ptScreen : POINT
Declare PtrSafe Function MenuItemFromPoint Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal hMenu As LongPtr, _
ByVal ptScreen As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MenuItemFromPoint = ctypes.windll.user32.MenuItemFromPoint
MenuItemFromPoint.restype = ctypes.c_int
MenuItemFromPoint.argtypes = [
wintypes.HANDLE, # hWnd : HWND optional
wintypes.HANDLE, # hMenu : HMENU
POINT, # ptScreen : POINT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
MenuItemFromPoint = Fiddle::Function.new(
lib['MenuItemFromPoint'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND optional
Fiddle::TYPE_VOIDP, # hMenu : HMENU
Fiddle::TYPE_VOIDP, # ptScreen : POINT
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn MenuItemFromPoint(
hWnd: *mut core::ffi::c_void, // HWND optional
hMenu: *mut core::ffi::c_void, // HMENU
ptScreen: POINT // POINT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll")]
public static extern int MenuItemFromPoint(IntPtr hWnd, IntPtr hMenu, POINT ptScreen);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_MenuItemFromPoint' -Namespace Win32 -PassThru
# $api::MenuItemFromPoint(hWnd, hMenu, ptScreen)#uselib "USER32.dll"
#func global MenuItemFromPoint "MenuItemFromPoint" sptr, sptr, sptr
; MenuItemFromPoint hWnd, hMenu, ptScreen ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; hMenu : HMENU -> "sptr"
; ptScreen : POINT -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global MenuItemFromPoint "MenuItemFromPoint" sptr, sptr, int
; res = MenuItemFromPoint(hWnd, hMenu, ptScreen)
; hWnd : HWND optional -> "sptr"
; hMenu : HMENU -> "sptr"
; ptScreen : POINT -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。; INT MenuItemFromPoint(HWND hWnd, HMENU hMenu, POINT ptScreen)
#uselib "USER32.dll"
#cfunc global MenuItemFromPoint "MenuItemFromPoint" intptr, intptr, int
; res = MenuItemFromPoint(hWnd, hMenu, ptScreen)
; hWnd : HWND optional -> "intptr"
; hMenu : HMENU -> "intptr"
; ptScreen : POINT -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procMenuItemFromPoint = user32.NewProc("MenuItemFromPoint")
)
// hWnd (HWND optional), hMenu (HMENU), ptScreen (POINT)
r1, _, err := procMenuItemFromPoint.Call(
uintptr(hWnd),
uintptr(hMenu),
uintptr(ptScreen),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction MenuItemFromPoint(
hWnd: THandle; // HWND optional
hMenu: THandle; // HMENU
ptScreen: POINT // POINT
): Integer; stdcall;
external 'USER32.dll' name 'MenuItemFromPoint';result := DllCall("USER32\MenuItemFromPoint"
, "Ptr", hWnd ; HWND optional
, "Ptr", hMenu ; HMENU
, "Ptr", ptScreen ; POINT
, "Int") ; return: INT●MenuItemFromPoint(hWnd, hMenu, ptScreen) = DLL("USER32.dll", "int MenuItemFromPoint(void*, void*, void*)")
# 呼び出し: MenuItemFromPoint(hWnd, hMenu, ptScreen)
# hWnd : HWND optional -> "void*"
# hMenu : HMENU -> "void*"
# ptScreen : POINT -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。