From 20c46fec28e4b17eecbfdeb85eaf6f49631cb737 Mon Sep 17 00:00:00 2001 From: "BitBase [ErgoZ] Riftbit" Date: Sun, 11 Aug 2019 18:56:14 +0300 Subject: [PATCH] resolve #13 - User32 - GetMenuItemID --- user32.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user32.go b/user32.go index c5461a5..8a2f415 100644 --- a/user32.go +++ b/user32.go @@ -144,6 +144,7 @@ var ( procDestroyMenu = moduser32.NewProc("DestroyMenu") procGetSubMenu = moduser32.NewProc("GetSubMenu") procRegisterWindowMessageW = moduser32.NewProc("RegisterWindowMessageW") + procGetMenuItemID = moduser32.NewProc("GetMenuItemID") ) func SendMessageTimeout(hwnd HWND, msg uint32, wParam, lParam uintptr, fuFlags, uTimeout uint32, lpdwResult uintptr) uintptr { @@ -1285,3 +1286,14 @@ func RegisterWindowMessage(lpString string) (bool, error) { } return ret != 0, nil } + +// GetMenuItemID Retrieves the menu item identifier of a menu item located at the specified position in a menu. +// See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmenuitemid +func GetMenuItemID(hMenu HMENU, nPos int) (int32, error) { + ret, _, err := procGetMenuItemID.Call(uintptr(hMenu), uintptr(nPos)) + if err.(syscall.Errno) != ERROR_SUCCESS { + return -1, err + } + + return int32(ret), nil +}