BOOL FASTCALL
IntDestroyMenuObject(PMENU Menu, BOOL bRecurse)
{
- if(Menu)
+ if (Menu)
{
PWND Window;
- ULONG Error;
-
- /* Remove all menu items */
- IntDestroyMenu( Menu, bRecurse);
if (PsGetCurrentProcessSessionId() == Menu->head.rpdesk->rpwinstaParent->dwSessionId)
{
}
}
}
- if (UserObjectInDestroy(Menu->head.h))
- {
- WARN("Menu already dead!\n");
- return FALSE;
- }
+
+ if (!UserMarkObjectDestroy(Menu)) return TRUE;
+
+ /* Remove all menu items */
+ IntDestroyMenu( Menu, bRecurse);
+
ret = UserDeleteObject(Menu->head.h, TYPE_MENU);
- if (!ret)
- { // Make sure it is really dead or just marked for deletion.
- Error = EngGetLastError();
- ret = UserObjectInDestroy(Menu->head.h);
- if (ret && EngGetLastError() == ERROR_INVALID_HANDLE)
- {
- EngSetLastError(Error);
- ret = FALSE;
- }
- } // See test_subpopup_locked_by_menu tests....
+ TRACE("IntDestroyMenuObject %d\n",ret);
return ret;
}
}
if (lpitem->fType & MF_SYSMENU)
{
- if ( (Wnd->style & WS_MINIMIZE))
+ if (!(Wnd->style & WS_MINIMIZE))
{
NC_GetInsideRect(Wnd, &rect);
UserDrawSysMenuButton(Wnd, hdc, &rect, lpitem->fState & (MF_HILITE | MF_MOUSESELECT));
UINT u;
item = menu->rgItems;
- for (u = 0; u < menu->cItems; u++, item++)
+ for( u = menu->cItems; u > 0; u--, item++)
{
MENU_DrawMenuItem(wnd, menu, menu->spwndNotify, hdc, item,
menu->cyMenu, FALSE, ODA_DRAWENTIRE);
// No menu. Do not reserve any space
return 0;
}
-
+
if (lprect == NULL)
{
return UserGetSystemMetrics(SM_CYMENU);
BOOL sendMenuSelect, PMENU topmenu)
{
HDC hdc;
- PWND pWnd = ValidateHwndNoErr(menu->hWnd);
+ PWND pWnd;
TRACE("M_SI: owner=%p menu=%p index=0x%04x select=0x%04x\n", pwndOwner, menu, wIndex, sendMenuSelect);
- if (!menu || !menu->cItems || !pWnd) return;
+ if (!menu || !menu->cItems) return;
+
+ pWnd = ValidateHwndNoErr(menu->hWnd);
+
+ if (!pWnd) return;
if (menu->iItem == wIndex) return;
TRACE("owner=%x menu=%p 0x%04x\n", WndOwner, Menu, SelectFirst);
+ if (!Menu) return Menu;
+
if (Menu->iItem == NO_SELECTED_ITEM) return Menu;
Item = &Menu->rgItems[Menu->iItem];
if ( PtMenu )
{
if (IS_SYSTEM_MENU(PtMenu))
+ {
Index = 0;
+ //// ReactOS only HACK: CORE-2338
+ // Windows tracks mouse moves to the system menu but does not open it.
+ // Only keyboard tracking can do that.
+ //
+ TRACE("SystemMenu\n");
+ return TRUE; // Stay inside the Loop!
+ }
else
MENU_FindItemByCoords( PtMenu, pmt->Pt, &Index );
}
{
/* switch to the system menu */
MenuTmp = get_win_sys_menu(hNewWnd);
- hNewMenu = UserHMGetHandle(MenuTmp);
+ if (MenuTmp) hNewMenu = UserHMGetHandle(MenuTmp);
}
else
return FALSE;
if (mt.TopMenu->fFlags & MNF_POPUP)
{
PWND pwndTM = ValidateHwndNoErr(mt.TopMenu->hWnd);
- IntNotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND, pwndTM, OBJID_CLIENT, CHILDID_SELF, 0);
+ if (pwndTM)
+ {
+ IntNotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND, pwndTM, OBJID_CLIENT, CHILDID_SELF, 0);
- co_UserDestroyWindow(pwndTM);
+ co_UserDestroyWindow(pwndTM);
+ }
mt.TopMenu->hWnd = NULL;
if (!(wFlags & TPM_NONOTIFY))
co_IntSendMessage( UserHMGetHandle(pWnd), WM_INITMENUPOPUP, (WPARAM) UserHMGetHandle(menu), 0);
}
+ if (menu->fFlags & MNF_SYSMENU)
+ MENU_InitSysMenuPopup( menu, pWnd->style, pWnd->pcls->style, HTSYSMENU);
+
if (MENU_ShowPopup(pWnd, menu, 0, wFlags, x, y, 0, 0 ))
ret = MENU_TrackMenu( menu, wFlags | TPM_POPUPMENU, 0, 0, pWnd,
lpTpm ? &lpTpm->rcExclude : NULL);
if (pItem->spSubMenu)
{
- return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType) & 0xff);
+ return (pItem->spSubMenu->cItems << 8) | ((pItem->fState|pItem->fType|MF_POPUP) & 0xff);
}
else
return (pItem->fType | pItem->fState);
ItemInfo.cbSize = sizeof(MENUITEMINFOW);
ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
- ItemInfo.fType = 0;
+ ItemInfo.fType = MF_POPUP;
ItemInfo.fState = MFS_ENABLED;
ItemInfo.dwTypeData = NULL;
ItemInfo.cch = 0;
if (OldMenu)
{
OldMenu->fFlags &= ~MNF_SYSMENU;
- IntDestroyMenuObject(OldMenu, TRUE);
+ IntDestroyMenuObject(OldMenu, TRUE);
}
}
}
+DWORD
+APIENTRY
+NtUserPaintMenuBar(
+ HWND hWnd,
+ HDC hDC,
+ ULONG left,
+ ULONG right,
+ ULONG top,
+ BOOL bActive)
+{
+ PWND Window;
+ RECT Rect;
+
+ UserEnterExclusive();
+
+ if(!(Window = UserGetWindowObject(hWnd)))
+ {
+ EngSetLastError(ERROR_INVALID_WINDOW_HANDLE);
+ UserLeave();
+ return 0;
+ }
+
+ Rect.left = left;
+ Rect.right = right;
+ Rect.top = top;
+ Rect.bottom = 0;
+
+ MENU_DrawMenuBar(hDC, &Rect, Window, FALSE);
+
+ UserLeave();
+
+ /* I am not sure about what this function returns */
+ return 0;
+}
+
/*
* @implemented
*/