[ros-kernel] Fixing menus when window moved
Andrew "Silver Blade" Greenwood
lists at silverblade.co.uk
Sun Mar 7 21:20:54 CET 2004
I was browsing the issue tracker on reactos.com recently and found a bug
that looked relatively simple to fix.
Basically, if you move a window and then try using its menus, they don't
respond. This is due to some co-ordinate translation being done incorrectly.
After much tweaking, I've come up with this: (from user32\windows\menu.c) :
VOID
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);
if (IsMenu(Menu))
{
DPRINT("Is a menu\n");
/* map point to parent client coordinates */
HWND Parent = GetAncestor(Wnd, GA_PARENT );
// if (Parent != GetDesktopWindow()) // this doesn't work?
// {
MapWindowPoints(Parent, Wnd, &Pt, 1);
Pt.y += 40; // FIXME: This is a temporary fix
// 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");
}
The commented out stuff doesn't appear to work.
Note the Pt.y += 40 bit - this is necessary as the Y co-ordinate will be in
the minuses. Not sure why. Maybe someone can take a look at this and attempt
to improve it?
Also, tracking is still broken (ie, if you click on a menu and move the
mouse pointer across) as I haven't looked at that yet.
I would've made a patch, but figured it's such a small chunk of code, there
isn't much point. Just compare it to the existing menu.c :)
If someone can suggest the RIGHT way to get Pt.y back to being a positive
number without the Pt.y += 40, please let me know and I'll get onto fixing
it.
-Andrew
More information about the Ros-kernel
mailing list