set menuitem rects after measuring the size

svn path=/trunk/; revision=7880
This commit is contained in:
Thomas Bluemel 2004-01-26 10:09:04 +00:00
parent 9d9f3772f6
commit e6249843b8
4 changed files with 44 additions and 5 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: menu.c,v 1.42 2004/01/26 08:44:51 weiden Exp $
/* $Id: menu.c,v 1.43 2004/01/26 10:09:04 weiden Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/menu.c
@ -378,6 +378,7 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
PVOID Buf, hBuf;
DWORD BufSize, Items, Items2;
MENUITEMINFOW *mii;
SETMENUITEMRECT smir;
RECT *omir, *mir = NULL;
LPWSTR str;
@ -400,6 +401,8 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
/* copy menu items into buffer */
Items = Items2 = NtUserBuildMenuItemList(mnu, Buf, BufSize, 0);
smir.fByPosition = TRUE;
smir.uItem = 0;
/* calculate menu item rectangles */
while(Items > 0)
{
@ -428,10 +431,13 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
mir->top = Rect->top;
}
MeasureMenuItem(hWnd, mnu, hDC, mii, mir, str);
smir.rcRect = *mir;
NtUserSetMenuItemRect(mnu, &smir);
height = max(height, mir->top + mir->bottom);
/* DbgPrint("Measure menu item %ws: (%d, %d, %d, %d)\n", str, mir->left, mir->top, mir->right, mir->bottom); */
Items--;
smir.uItem++;
}
height = max(height, GetSystemMetrics(SM_CYMENU));

View file

@ -106,6 +106,9 @@ IntCheckMenuItem(PMENU_OBJECT MenuObject, UINT uIDCheckItem, UINT uCheck);
BOOL FASTCALL
IntSetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT uItem, UINT fByPos);
BOOL FASTCALL
IntSetMenuItemRect(PMENU_OBJECT MenuObject, UINT Item, BOOL fByPos, RECT *rcRect);
BOOL FASTCALL
IntCleanupMenus(struct _EPROCESS *Process, PW32PROCESS Win32Process);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: menu.c,v 1.40 2004/01/24 08:26:25 ekohl Exp $
/* $Id: menu.c,v 1.41 2004/01/26 10:09:04 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -1048,6 +1048,19 @@ SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL FASTCALL
IntSetMenuItemRect(PMENU_OBJECT MenuObject, UINT Item, BOOL fByPos, RECT *rcRect)
{
PMENU_ITEM mi;
if(IntGetMenuItemByFlag(MenuObject, Item, (fByPos ? MF_BYPOSITION : MF_BYCOMMAND),
&mi, NULL) > -1)
{
mi->Rect = *rcRect;
return TRUE;
}
return FALSE;
}
/*!
* Internal function. Called when the process is destroyed to free the remaining menu handles.

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.43 2004/01/26 08:44:51 weiden Exp $
/* $Id: misc.c,v 1.44 2004/01/26 10:09:04 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -15,6 +15,7 @@
#include <internal/safe.h>
#include <include/error.h>
#include <include/window.h>
#include <include/menu.h>
#include <include/painting.h>
#include <include/dce.h>
#include <include/mouse.h>
@ -196,8 +197,24 @@ NtUserCallTwoParam(
switch(Routine)
{
case TWOPARAM_ROUTINE_SETMENUITEMRECT:
UNIMPLEMENTED
return 0;
{
BOOL Ret;
SETMENUITEMRECT smir;
PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
if(!MenuObject)
return 0;
if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT))))
{
IntReleaseMenuObject(MenuObject);
return 0;
}
Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect);
IntReleaseMenuObject(MenuObject);
return (DWORD)Ret;
}
case TWOPARAM_ROUTINE_SETGUITHRDHANDLE:
{