Commit 57226607 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

user32: Simplify some code.

parent f288ed99
...@@ -703,18 +703,17 @@ static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu, ...@@ -703,18 +703,17 @@ static MENUITEM *MENU_FindItemByCoords( const POPUPMENU *menu,
{ {
MENUITEM *item; MENUITEM *item;
UINT i; UINT i;
RECT wrect;
RECT rect; RECT rect;
if (!GetWindowRect(menu->hWnd,&wrect)) return NULL; if (!GetWindowRect(menu->hWnd, &rect)) return NULL;
pt.x -= wrect.left;pt.y -= wrect.top; pt.x -= rect.left;
pt.y -= rect.top;
item = menu->items; item = menu->items;
for (i = 0; i < menu->nItems; i++, item++) for (i = 0; i < menu->nItems; i++, item++)
{ {
rect = item->rect; rect = item->rect;
MENU_AdjustMenuItemRect(menu, &rect); MENU_AdjustMenuItemRect(menu, &rect);
if ((pt.x >= rect.left) && (pt.x < rect.right) && if (PtInRect(&rect, pt))
(pt.y >= rect.top) && (pt.y < rect.bottom))
{ {
if (pos) *pos = i; if (pos) *pos = i;
return item; return item;
...@@ -1109,7 +1108,7 @@ MENU_GetMaxPopupHeight(LPPOPUPMENU lppop) ...@@ -1109,7 +1108,7 @@ MENU_GetMaxPopupHeight(LPPOPUPMENU lppop)
* *
* Calculate the size of a popup menu. * Calculate the size of a popup menu.
*/ */
static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner ) static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
{ {
MENUITEM *lpitem; MENUITEM *lpitem;
HDC hdc; HDC hdc;
...@@ -1143,7 +1142,7 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner ) ...@@ -1143,7 +1142,7 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner )
if ((i != start) && if ((i != start) &&
(lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break; (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE, lppop ); MENU_CalcItemSize( hdc, lpitem, lppop->hwndOwner, orgX, orgY, FALSE, lppop );
maxX = max( maxX, lpitem->rect.right ); maxX = max( maxX, lpitem->rect.right );
orgY = lpitem->rect.bottom; orgY = lpitem->rect.bottom;
if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab) if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
...@@ -1792,7 +1791,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, ...@@ -1792,7 +1791,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id,
menu->hwndOwner = hwndOwner; menu->hwndOwner = hwndOwner;
menu->nScrollPos = 0; menu->nScrollPos = 0;
MENU_PopupMenuCalcSize( menu, hwndOwner ); MENU_PopupMenuCalcSize( menu );
/* adjust popup menu pos so that it fits within the desktop */ /* adjust popup menu pos so that it fits within the desktop */
...@@ -3657,7 +3656,7 @@ INT WINAPI GetMenuStringA( ...@@ -3657,7 +3656,7 @@ INT WINAPI GetMenuStringA(
if (!str || !nMaxSiz) return strlenW(item->text); if (!str || !nMaxSiz) return strlenW(item->text);
if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL )) if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL ))
str[nMaxSiz-1] = 0; str[nMaxSiz-1] = 0;
TRACE("returning '%s'\n", str ); TRACE("returning %s\n", debugstr_a(str));
return strlen(str); return strlen(str);
} }
...@@ -3682,6 +3681,7 @@ INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID, ...@@ -3682,6 +3681,7 @@ INT WINAPI GetMenuStringW( HMENU hMenu, UINT wItemID,
return 0; return 0;
} }
lstrcpynW( str, item->text, nMaxSiz ); lstrcpynW( str, item->text, nMaxSiz );
TRACE("returning %s\n", debugstr_w(str));
return strlenW(str); return strlenW(str);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment