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