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

Commit

Permalink
add new function [user32] CreateMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
ergoz committed Aug 10, 2019
1 parent 7698cc9 commit 2f8d46e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var (
procSetProcessDPIAware = moduser32.NewProc("SetProcessDPIAware")
procUnregisterClassW = moduser32.NewProc("UnregisterClassW")
procCreatePopupMenu = moduser32.NewProc("CreatePopupMenu")
procCreateMenu = moduser32.NewProc("CreateMenu")
)

func SendMessageTimeout(hwnd HWND, msg uint32, wParam, lParam uintptr, fuFlags, uTimeout uint32, lpdwResult uintptr) uintptr {
Expand Down Expand Up @@ -1303,3 +1304,16 @@ func CreatePopupMenu() (HMENU, error) {

return HMENU(ret), nil
}

// CreateMenu Creates a menu. The menu is initially empty, but it can be filled with menu items
// by using the **InsertMenuItem**, **AppendMenu**, and **InsertMenu** functions.
// See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createmenu
func CreateMenu() (HMENU, error) {
ret, _, err := procCreateMenu.Call()

if ret == 0 && err.(syscall.Errno) != ERROR_SUCCESS {
return HMENU(ret), err
}

return HMENU(ret), nil
}

0 comments on commit 2f8d46e

Please sign in to comment.