Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
resolve #13 - User32 - GetMenuItemID
Browse files Browse the repository at this point in the history
  • Loading branch information
ergoz committed Aug 11, 2019
1 parent 6dc5c73 commit 20c46fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

0 comments on commit 20c46fe

Please sign in to comment.