From 56d1785ca5cedb25f79b69f2646f706fc94cb6fd Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 17 Jul 2005 12:26:24 +0000 Subject: [PATCH] Implemented NtUser-GetMenuItemRect. svn path=/trunk/; revision=16612 --- reactos/lib/user32/windows/menu.c | 5 ++- reactos/subsys/win32k/ntuser/menu.c | 47 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/reactos/lib/user32/windows/menu.c b/reactos/lib/user32/windows/menu.c index fa1e0d0de80..56ad7a0b43b 100644 --- a/reactos/lib/user32/windows/menu.c +++ b/reactos/lib/user32/windows/menu.c @@ -3792,7 +3792,7 @@ GetMenuItemInfoW( /* - * @unimplemented + * @implemented */ BOOL STDCALL GetMenuItemRect(HWND hWnd, @@ -3800,8 +3800,7 @@ GetMenuItemRect(HWND hWnd, UINT uItem, LPRECT lprcItem) { - UNIMPLEMENTED; - return(FALSE); + return NtUserGetMenuItemRect( hWnd, hMenu, uItem, lprcItem); } diff --git a/reactos/subsys/win32k/ntuser/menu.c b/reactos/subsys/win32k/ntuser/menu.c index 462d994aefd..f17021b7899 100644 --- a/reactos/subsys/win32k/ntuser/menu.c +++ b/reactos/subsys/win32k/ntuser/menu.c @@ -1558,7 +1558,7 @@ NtUserGetMenuIndex( /* - * @unimplemented + * @implemented */ BOOL STDCALL NtUserGetMenuItemRect( @@ -1567,9 +1567,50 @@ NtUserGetMenuItemRect( UINT uItem, LPRECT lprcItem) { - UNIMPLEMENTED + ROSMENUINFO mi; + ROSMENUITEMINFO mii; + HWND referenceHwnd; + LPPOINT lpPoints; + LPRECT lpRect; + POINT FromOffset; + LONG XMove, YMove; + ULONG i; + NTSTATUS Status; + + if(!NtUserMenuItemInfo(hMenu, uItem, MF_BYPOSITION, &mii, FALSE)) + return FALSE; + + referenceHwnd = hWnd; - return 0; + if(!hWnd) + { + if(!NtUserMenuInfo(hMenu, &mi, FALSE)) return FALSE; + if(mi.Wnd == 0) return FALSE; + referenceHwnd = mi.Wnd; + } + + if (lprcItem == NULL) return FALSE; + *lpRect = mii.Rect; + lpPoints = (LPPOINT)lpRect; + + if(!NtUserGetClientOrigin(referenceHwnd, &FromOffset)) return FALSE; + + XMove = FromOffset.x; + YMove = FromOffset.y; + + for (i = 0; i < 2; i++) + { + lpPoints[i].x += XMove; + lpPoints[i].y += YMove; + } + + Status = MmCopyToCaller(lprcItem, lpPoints, sizeof(POINT)); + if (! NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return FALSE; + } + return TRUE; }