* Fixed co-ordinate translation for windows that have been moved, adjusting the co-ordinates to take into account the window captions.

NOTE: Menu item tracking is still broken for windows that have been moved. Eg, if you move a window, click on a menu, then move the mouse pointer over another item, the new menu will NOT open unless you click.

svn path=/trunk/; revision=8580
This commit is contained in:
Andrew Greenwood 2004-03-07 22:13:51 +00:00
parent c0b4d77eb9
commit 0e200b6f99

View file

@ -21,7 +21,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.51 2004/02/23 20:10:01 gvg Exp $
/* $Id: menu.c,v 1.52 2004/03/07 22:13:51 silverblade Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/menu.c
@ -48,6 +48,7 @@
#include "../controls/controls.h"
#define NDEBUG
//#define DBG
#include <debug.h>
/* internal popup menu window messages */
@ -435,7 +436,7 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
dis.hDC = Dc;
dis.rcItem = Item->Rect;
DPRINT("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, "
"hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", hwndOwner,
"hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", WndOwner,
dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
dis.rcItem.bottom);
@ -443,8 +444,8 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
/* Fall through to draw popup-menu arrow */
}
DPRINT("rect={%ld,%ld,%ld,%ld}\n", Item->rect.left, Item->rect.top,
Item->rect.right, Item->rect.bottom);
// DPRINT("rect={%ld,%ld,%ld,%ld}\n", Item->rect.left, Item->rect.top,
// Item->rect.right, Item->rect.bottom);
if (MenuBar && 0 != (Item->fType & MF_SEPARATOR))
{
@ -1887,7 +1888,7 @@ MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset)
INT i;
ROSMENUITEMINFO ItemInfo;
DPRINT("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, offset);
DPRINT("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset);
MenuInitRosMenuItemInfo(&ItemInfo);
if (NO_SELECTED_ITEM != MenuInfo->FocusedItem)
@ -2339,12 +2340,16 @@ MenuPtMenu(HMENU Menu, POINT Pt)
ROSMENUITEMINFO ItemInfo;
HMENU Ret = NULL;
INT Ht;
if (! MenuGetRosMenuInfo(&MenuInfo, Menu))
{
return NULL;
}
// ScreenToClient(MenuInfo.Wnd, &Pt);
DPRINT("MenuPtMenu X %d Y %d\n", Pt.x, Pt.y);
/* try subpopup first (if any) */
if (NO_SELECTED_ITEM != MenuInfo.FocusedItem)
{
@ -2365,6 +2370,9 @@ MenuPtMenu(HMENU Menu, POINT Pt)
/* check the current window (avoiding WM_HITTEST) */
Ht = DefWndNCHitTest(MenuInfo.Wnd, Pt);
DPRINT("Hit test == %d\n", Ht);
if (0 != (MenuInfo.Flags & MF_POPUP ))
{
if (HTNOWHERE != Ht && HTERROR != Ht)
@ -2996,6 +3004,7 @@ MenuTrackMenu(HMENU Menu, UINT Flags, INT x, INT y,
Mt.CurrentMenu = Menu;
Mt.TopMenu = Menu;
Mt.OwnerWnd = Wnd;
Mt.Pt.x = x;
Mt.Pt.y = y;
@ -3345,7 +3354,7 @@ MenuTrackMenu(HMENU Menu, UINT Flags, INT x, INT y,
static BOOL FASTCALL
MenuExitTracking(HWND Wnd)
{
DPRINT("hwnd=%p\n", hWnd);
DPRINT("hwnd=%p\n", Wnd);
SendMessageW(Wnd, WM_EXITMENULOOP, 0, 0);
ShowCaret(0);
@ -3359,21 +3368,27 @@ MenuTrackMouseMenuBar(HWND Wnd, ULONG Ht, POINT Pt)
HMENU Menu = (HTSYSMENU == Ht) ? NtUserGetSystemMenu(Wnd, FALSE) : GetMenu(Wnd);
UINT Flags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON;
DPRINT("wnd=%p ht=0x%04x (%ld,%ld)\n", Wnd, Ht, pt.x, pt.y);
DPRINT("wnd=%p ht=0x%04x (%ld,%ld)\n", Wnd, Ht, Pt.x, Pt.y);
if (IsMenu(Menu))
{
DPRINT("Is a menu\n");
/* map point to parent client coordinates */
HWND Parent = GetAncestor(Wnd, GA_PARENT );
if (Parent != GetDesktopWindow())
{
ScreenToClient(Parent, &Pt);
}
// if (Parent != GetDesktopWindow()) // this doesn't work?
// {
MapWindowPoints(Parent, Wnd, &Pt, 1);
Pt.y += (GetSystemMetrics(SM_CYCAPTION)-1) * 2; // is this ok?
// ScreenToClient(Wnd, &Pt); // wnd = parent
DPRINT("MapWindowPoints == %d %d\n", Pt.x, Pt.y);
// }
// else DPRINT("Is desktop window\n");
MenuInitTracking(Wnd, Menu, FALSE, Flags);
MenuTrackMenu(Menu, Flags, Pt.x, Pt.y, Wnd, NULL);
MenuExitTracking(Wnd);
}
else DPRINT("Is NOT a menu\n");
}