* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Menus
- * FILE: subsys/win32k/ntuser/menu.c
+ * FILE: win32ss/user/ntuser/menu.c
* PROGRAMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
*/
return pMenu;
}
+BOOL
+FASTCALL
+IntIsMenu(HMENU Menu)
+{
+ if (UserGetMenuObject(Menu)) return TRUE;
+ return FALSE;
+}
+
+
PMENU WINAPI
IntGetMenu(HWND hWnd)
{
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 ( (!(GMDI_USEDISABLED & gmdiFlags)) && (MenuItem->fState & MFS_DISABLED )) return -1;
/* search rekursiv when needed */
- if ( (MenuItem->fType & MF_POPUP) && (gmdiFlags & GMDI_GOINTOPOPUPS) && MenuItem->spSubMenu)
+ if ( (gmdiFlags & GMDI_GOINTOPOPUPS) && MenuItem->spSubMenu )
{
UINT ret;
(*gismc)++;
if (lpitem->fType & MF_SYSMENU)
{
- if ( (Wnd->style & WS_MINIMIZE))
+ if (!(Wnd->style & WS_MINIMIZE))
{
- UserGetInsideRectNC(Wnd, &rect);
+ NC_GetInsideRect(Wnd, &rect);
UserDrawSysMenuButton(Wnd, hdc, &rect, lpitem->fState & (MF_HILITE | MF_MOUSESELECT));
}
return;
** the menu owner has finished drawing.
*/
DRAWITEMSTRUCT dis;
+ COLORREF old_bk, old_text;
dis.CtlType = ODT_MENU;
dis.CtlID = 0;
dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
dis.rcItem.bottom);
TRACE("Ownerdraw: Width %d Height %d\n", dis.rcItem.right-dis.rcItem.left, dis.rcItem.bottom-dis.rcItem.top);
+ old_bk = GreGetBkColor(hdc);
+ old_text = GreGetTextColor(hdc);
co_IntSendMessage(UserHMGetHandle(WndOwner), WM_DRAWITEM, 0, (LPARAM) &dis);
+ IntGdiSetBkColor(hdc, old_bk);
+ IntGdiSetTextColor(hdc, old_text);
/* Draw the popup-menu arrow */
- if (lpitem->spSubMenu)
+ if (!menuBar && lpitem->spSubMenu)
{
RECT rectTemp;
RtlCopyMemory(&rectTemp, &rect, sizeof(RECT));
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);
HFONT hfontOld = 0;
PMENU lppop = UserGetMenuObject(UlongToHandle(pWnd->IDMenu));
- if (lppop == NULL || lprect == NULL)
+ if (lppop == NULL)
+ {
+ // 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);
if (!(MenuItem = MENU_FindItem( &Menu, &Item, (ByPosition ? MF_BYPOSITION : MF_BYCOMMAND) )))
{
+ /* workaround for Word 95: pretend that SC_TASKLIST item exists. */
+ if ( SetOrGet && Item == SC_TASKLIST && !ByPosition )
+ return TRUE;
+
EngSetLastError(ERROR_MENU_ITEM_NOT_FOUND);
return( FALSE);
}
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
*/
/* lpszCaption may be NULL, check for it and call RtlInitUnicodeString()
if bInsert == TRUE call UserInsertMenuItem() else UserSetMenuItemInfo() */
+ RtlInitEmptyUnicodeString(&lstrCaption, NULL, 0);
+
if (!(Menu = UserGetMenuObject(hMenu)))
{
RETURN(FALSE);
}
- RtlInitUnicodeString(&lstrCaption, 0);
-
/* Check if we got a Caption */
if (lpszCaption && lpszCaption->Buffer)
{
RETURN( UserMenuItemInfo(Menu, uItem, fByPosition, (PROSMENUITEMINFO)lpmii, TRUE, &lstrCaption));
CLEANUP:
+ if (lstrCaption.Buffer)
+ {
+ ReleaseCapturedUnicodeString(&lstrCaption, UserMode);
+ }
+
TRACE("Leave NtUserThunkedMenuItemInfo, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;