diff --git a/constants.go b/constants.go index a5c60f4..ebe26e2 100644 --- a/constants.go +++ b/constants.go @@ -3144,3 +3144,21 @@ const ( LR_SHARED = 0x00008000 LR_VGACOLOR = 0x00000080 ) + +const ( + MIM_APPLYTOSUBMENUS = 0x80000000 + MIM_BACKGROUND = 0x00000002 + MIM_HELPID = 0x00000004 + MIM_MAXHEIGHT = 0x00000001 + MIM_MENUDATA = 0x00000008 + MIM_STYLE = 0x00000010 +) + +const ( + MNS_AUTODISMISS = 0x10000000 + MNS_CHECKORBMP = 0x04000000 + MNS_DRAGDROP = 0x20000000 + MNS_MODELESS = 0x40000000 + MNS_NOCHECK = 0x80000000 + MNS_NOTIFYBYPOS = 0x08000000 +) diff --git a/typedef.go b/typedef.go index e2994a2..92530da 100644 --- a/typedef.go +++ b/typedef.go @@ -1368,6 +1368,16 @@ type PNOTIFYICONDATA struct { } type TPMPARAMS struct { - cbSize uint - rcExclude RECT + Size uint + Exclude RECT +} + +type MENUINFO struct { + Size DWORD + Mask DWORD + Style DWORD + Max uint32 + HBRBack HBRUSH + ContextHelpID DWORD + MenuData uintptr } diff --git a/user32.go b/user32.go index be73473..fccd3ca 100644 --- a/user32.go +++ b/user32.go @@ -152,6 +152,7 @@ var ( procTrackPopupMenu = moduser32.NewProc("TrackPopupMenu") procSetMenuItemBitmaps = moduser32.NewProc("SetMenuItemBitmaps") procLoadImageW = moduser32.NewProc("LoadImageW") + procSetMenuInfo = moduser32.NewProc("SetMenuInfo") ) func SendMessageTimeout(hwnd HWND, msg uint32, wParam, lParam uintptr, fuFlags, uTimeout uint32, lpdwResult uintptr) uintptr { @@ -1419,3 +1420,17 @@ func LoadImageW(hInst HINSTANCE, name string, ltype uint32, cx int, cy int, fuLo } return HANDLE(ret), nil } + +// SetMenuInfo Sets information for a specified menu. +// See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setmenuinfo +func SetMenuInfo(hMenu HMENU, menuInfo MENUINFO) (bool, error) { + ret, _, err := procSetMenuInfo.Call( + uintptr(hMenu), + uintptr(unsafe.Pointer(&menuInfo)), + ) + if !IsErrSuccess(err) { + return false, err + } + + return ret != 0, nil +}