1. implemented MenuItemFromPoint()
authorThomas Bluemel <thomas@reactsoft.com>
Mon, 26 Jan 2004 12:46:16 +0000 (12:46 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Mon, 26 Jan 2004 12:46:16 +0000 (12:46 +0000)
2. fixed hittest-code so it returns HTMENU properly

svn path=/trunk/; revision=7881

reactos/iface/addsys/w32ksvc.db
reactos/include/win32k/ntuser.h
reactos/lib/user32/include/user32.h
reactos/lib/user32/windows/menu.c
reactos/lib/user32/windows/nonclient.c
reactos/subsys/win32k/include/menu.h
reactos/subsys/win32k/ntuser/menu.c
reactos/subsys/win32k/ntuser/misc.c

index ff6d064..b72bddf 100644 (file)
@@ -316,7 +316,7 @@ NtUserCreateCaret                       4
 NtUserCreateCursorIconHandle            2
 NtUserCreateDesktop                     5
 NtUserCreateLocalMemHandle              4
-NtUserCreateMenu                       0
+NtUserCreateMenu                       1
 NtUserCreateWindowEx                    14
 NtUserCreateWindowStation               6
 NtUserDdeGetQualityOfService            3
index 57e4a92..11dbcb7 100644 (file)
@@ -186,6 +186,7 @@ NtUserCallOneParam(
   DWORD Param,
   DWORD Routine);
 
+#define TWOPARAM_ROUTINE_SETMENUBARHEIGHT   0x50
 #define TWOPARAM_ROUTINE_SETMENUITEMRECT    0x51
 #define TWOPARAM_ROUTINE_SETGUITHRDHANDLE   0x52
   #define TPR_SGTH_ACTIVE         0x01
@@ -312,7 +313,7 @@ NtUserCreateLocalMemHandle(
 
 HMENU
 STDCALL
-NtUserCreateMenu(VOID);
+NtUserCreateMenu(BOOL PopupMenu);
 
 HWND
 STDCALL
index f6a0fa4..1b32e4e 100644 (file)
@@ -52,6 +52,9 @@ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
 #define NtUserSetMenuItemRect(menu, mir) \
   (BOOL)NtUserCallTwoParam((DWORD)menu, (DWORD)mir, TWOPARAM_ROUTINE_SETMENUITEMRECT)
 
+#define NtUserSetMenuBarHeight(menu, height) \
+  (BOOL)NtUserCallTwoParam((DWORD)menu, (DWORD)height, TWOPARAM_ROUTINE_SETMENUBARHEIGHT)
+
 #define NtUserSetCaretBlinkTime(uMSeconds) \
   (BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
 
index 6254363..6b1f7b1 100644 (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.43 2004/01/26 10:09:04 weiden Exp $
+/* $Id: menu.c,v 1.44 2004/01/26 12:46:16 weiden Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/menu.c
@@ -470,7 +470,13 @@ MenuDrawMenuBar(HDC hDC, LPRECT Rect, HWND hWnd, BOOL Draw)
 
 VOID
 MenuTrackMouseMenuBar(HWND hWnd, ULONG Ht, POINT Pt)
-{
+{DbgPrint("MenuTrackMouseMenuBar at %i, %i\n", Pt.x, Pt.y);
+  int Item = NtUserMenuItemFromPoint(hWnd, GetMenu(hWnd), Pt.x, Pt.y);
+  
+  if(Item > -1)
+  {
+  
+  }
 }
 
 
@@ -549,7 +555,7 @@ CheckMenuRadioItem(HMENU hmenu,
 HMENU STDCALL
 CreateMenu(VOID)
 {
-  return NtUserCreateMenu();
+  return NtUserCreateMenu(FALSE);
 }
 
 
@@ -559,8 +565,7 @@ CreateMenu(VOID)
 HMENU STDCALL
 CreatePopupMenu(VOID)
 {
-  /* FIXME - add MF_POPUP style? */
-  return NtUserCreateMenu();
+  return NtUserCreateMenu(TRUE);
 }
 
 
@@ -636,7 +641,7 @@ GetMenu(HWND hWnd)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL STDCALL
 GetMenuBarInfo(HWND hwnd,
@@ -644,8 +649,7 @@ GetMenuBarInfo(HWND hwnd,
               LONG idItem,
               PMENUBARINFO pmbi)
 {
-  UNIMPLEMENTED;
-  return FALSE;
+  return (BOOL)NtUserGetMenuBarInfo(hwnd, idObject, idItem, pmbi);
 }
 
 
@@ -1158,7 +1162,7 @@ LoadMenuW(HINSTANCE hInstance,
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 int
 STDCALL
@@ -1167,8 +1171,7 @@ MenuItemFromPoint(
   HMENU hMenu,
   POINT ptScreen)
 {
-  UNIMPLEMENTED;
-  return 0;
+  return NtUserMenuItemFromPoint(hWnd, hMenu, ptScreen.x, ptScreen.y);
 }
 
 
index 4beb3f3..ad2ffe1 100644 (file)
@@ -44,6 +44,7 @@ Already defined in makefile now.
 #include <menu.h>
 #include <winpos.h>
 #include <user32/wininternal.h>
+#include <user32.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -686,6 +687,8 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
    
    if(!(Style & WS_MINIMIZE))
    {
+     HMENU menu;
+     
      ClientPoint = Point;
      ScreenToClient(hWnd, &ClientPoint);
      GetClientRect(hWnd, &ClientRect);
@@ -695,9 +698,9 @@ DefWndNCHitTest(HWND hWnd, POINT Point)
         return HTCLIENT;
      }
      
-     if (UserHasMenu(hWnd, Style))
+     if ((menu = GetMenu(hWnd)) && !(Style & WS_CHILD))
      {
-        if (Point.y < 0 && Point.x >= 0 && Point.x <= WindowRect.right)
+        if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
            return HTMENU;
      }
 
index ebdcd5d..70ec63c 100644 (file)
@@ -40,6 +40,8 @@ typedef struct _MENU_OBJECT
   MENUINFO MenuInfo;
   BOOL RtoL;
   BOOL IsSystemMenu;
+  BOOL IsMenuBar;
+  int Height;
 } MENU_OBJECT, *PMENU_OBJECT;
 
 PMENU_OBJECT FASTCALL
@@ -63,7 +65,7 @@ BOOL FASTCALL
 IntDestroyMenuObject(PMENU_OBJECT MenuObject, BOOL bRecurse, BOOL RemoveFromProcess);
 
 PMENU_OBJECT FASTCALL
-IntCreateMenu(PHANDLE Handle);
+IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar);
 
 PMENU_OBJECT FASTCALL
 IntCloneMenu(PMENU_OBJECT Source);
@@ -120,176 +122,4 @@ InitMenuImpl(VOID);
 NTSTATUS FASTCALL
 CleanupMenuImpl(VOID);
 
-DWORD
-STDCALL
-NtUserBuildMenuItemList(
- HMENU hMenu,
- PVOID Buffer,
- ULONG nBufSize,
- DWORD Reserved);
-
-DWORD
-STDCALL
-NtUserCheckMenuItem(
-  HMENU hmenu,
-  UINT uIDCheckItem,
-  UINT uCheck);
-  
-HMENU
-STDCALL
-NtUserCreateMenu(VOID);
-
-BOOL
-STDCALL
-NtUserDeleteMenu(
-HMENU hMenu,
-  UINT uPosition,
-  UINT uFlags);
-  
-BOOL
-STDCALL
-NtUserDestroyMenu(
-  HMENU hMenu);
-  
-DWORD
-STDCALL
-NtUserDrawMenuBarTemp(
-  HWND hWnd,
-  HDC hDC,
-  PRECT hRect,
-  HMENU hMenu,
-  HFONT hFont);
-  
-UINT
-STDCALL
-NtUserEnableMenuItem(
-  HMENU hMenu,
-  UINT uIDEnableItem,
-  UINT uEnable);
-  
-DWORD
-STDCALL
-NtUserInsertMenuItem(
-  HMENU hMenu,
-  UINT uItem,
-  BOOL fByPosition,
-  LPCMENUITEMINFOW lpmii);
-
-  
-BOOL
-STDCALL
-NtUserEndMenu(VOID);
-
-UINT
-STDCALL
-NtUserGetMenuDefaultItem(
-  HMENU hMenu,
-  UINT fByPos,
-  UINT gmdiFlags);
-
-BOOL
-STDCALL
-NtUserGetMenuBarInfo(
-  HWND hwnd,
-  LONG idObject,
-  LONG idItem,
-  PMENUBARINFO pmbi);
-  
-UINT
-STDCALL
-NtUserGetMenuIndex(
-  HMENU hMenu,
-  UINT wID);
-  
-BOOL
-STDCALL
-NtUserGetMenuItemRect(
-  HWND hWnd,
-  HMENU hMenu,
-  UINT uItem,
-  LPRECT lprcItem);
-  
-BOOL
-STDCALL
-NtUserHiliteMenuItem(
-  HWND hwnd,
-  HMENU hmenu,
-  UINT uItemHilite,
-  UINT uHilite);
-
-BOOL
-STDCALL
-NtUserMenuInfo(
- HMENU hmenu,
- LPMENUINFO lpmi,
- BOOL fsog);
-  
-int
-STDCALL
-NtUserMenuItemFromPoint(
-  HWND hWnd,
-  HMENU hMenu,
-  DWORD X,
-  DWORD Y);
-
-BOOL
-STDCALL
-NtUserMenuItemInfo(
- HMENU hMenu,
- UINT uItem,
- BOOL fByPosition,
- LPMENUITEMINFOW lpmii,
- BOOL fsog);
-  
-BOOL
-STDCALL
-NtUserRemoveMenu(
-  HMENU hMenu,
-  UINT uPosition,
-  UINT uFlags);
-  
-BOOL
-STDCALL
-NtUserSetMenuContextHelpId(
-  HMENU hmenu,
-  DWORD dwContextHelpId);
-  
-BOOL
-STDCALL
-NtUserSetMenuDefaultItem(
-  HMENU hMenu,
-  UINT uItem,
-  UINT fByPos);
-  
-BOOL
-STDCALL
-NtUserSetMenuFlagRtoL(
-  HMENU hMenu);
-  
-DWORD
-STDCALL
-NtUserThunkedMenuInfo(
-  HMENU hMenu,
-  LPCMENUINFO lpcmi);
-  
-DWORD
-STDCALL
-NtUserThunkedMenuItemInfo(
-  HMENU hMenu,
-  UINT uItem,
-  BOOL fByPosition,
-  BOOL bInsert,
-  LPMENUITEMINFOW lpmii,
-  PUNICODE_STRING lpszCaption);
-  
-BOOL
-STDCALL
-NtUserTrackPopupMenuEx(
-  HMENU hmenu,
-  UINT fuFlags,
-  int x,
-  int y,
-  HWND hwnd,
-  LPTPMPARAMS lptpm);
-
 #endif /* _WIN32K_MENU_H */
index 3403a4d..8d0cbdb 100644 (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.41 2004/01/26 10:09:04 weiden Exp $
+/* $Id: menu.c,v 1.42 2004/01/26 12:46:16 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
   } \
 }
 
+#define InRect(r, x, y) \
+      ( ( ((r).right >=  x)) && \
+        ( ((r).left <= x)) && \
+        ( ((r).bottom >=  y)) && \
+        ( ((r).top <= y)) )
+
 NTSTATUS FASTCALL
 InitMenuImpl(VOID)
 {
@@ -250,7 +256,7 @@ IntDestroyMenuObject(PMENU_OBJECT MenuObject,
 }
 
 PMENU_OBJECT FASTCALL
-IntCreateMenu(PHANDLE Handle)
+IntCreateMenu(PHANDLE Handle, BOOL IsMenuBar)
 {
   PMENU_OBJECT MenuObject;
   PW32PROCESS Win32Process = PsGetWin32Process();
@@ -266,6 +272,7 @@ IntCreateMenu(PHANDLE Handle)
   }
   
   MenuObject->Self = *Handle;
+  MenuObject->IsMenuBar = IsMenuBar;
   MenuObject->W32Process = Win32Process;
   MenuObject->RtoL = FALSE; /* default */
   MenuObject->MenuInfo.cbSize = sizeof(MENUINFO); /* not used */
@@ -1165,7 +1172,7 @@ NtUserCheckMenuItem(
  * @unimplemented
  */
 HMENU STDCALL
-NtUserCreateMenu(VOID)
+NtUserCreateMenu(BOOL PopupMenu)
 {
   PWINSTATION_OBJECT WinStaObject;
   HANDLE Handle;
@@ -1183,7 +1190,7 @@ NtUserCreateMenu(VOID)
     return (HMENU)0;
   }
 
-  IntCreateMenu(&Handle);
+  IntCreateMenu(&Handle, !PopupMenu);
 
   ObDereferenceObject(WinStaObject);
   return (HMENU)Handle;
@@ -1456,7 +1463,7 @@ NtUserMenuInfo(
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 int STDCALL
 NtUserMenuItemFromPoint(
@@ -1465,9 +1472,45 @@ NtUserMenuItemFromPoint(
   DWORD X,
   DWORD Y)
 {
-  UNIMPLEMENTED
-
-  return 0;
+  PMENU_OBJECT MenuObject;
+  PWINDOW_OBJECT WindowObject;
+  PMENU_ITEM mi;
+  int i;
+  
+  MenuObject = IntGetMenuObject(hMenu);
+  if(!MenuObject)
+  {
+    SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
+    return -1;
+  }
+  if(hWnd)
+  {
+    WindowObject = IntGetWindowObject(hWnd);
+    if(!WindowObject)
+    {
+      SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
+      return -1;
+    }
+  }
+  
+  ExAcquireFastMutexUnsafe(&MenuObject->MenuItemsLock);
+  mi = MenuObject->MenuItemList;
+  for(i = 0; mi; i++)
+  {
+    if(InRect(mi->Rect, X, Y))
+    {
+      break;
+    }
+    mi = mi->Next;
+  }
+  ExReleaseFastMutexUnsafe(&MenuObject->MenuItemsLock);
+  
+  IntReleaseMenuObject(MenuObject);
+  
+  if(hWnd)
+    IntReleaseWindowObject(WindowObject);
+  
+  return (mi ? i : -1);
 }
 
 
index 84bdf9e..d8a4a1b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.44 2004/01/26 10:09:04 weiden Exp $
+/* $Id: misc.c,v 1.45 2004/01/26 12:46:16 weiden Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -196,6 +196,18 @@ NtUserCallTwoParam(
   
   switch(Routine)
   {
+    case TWOPARAM_ROUTINE_SETMENUBARHEIGHT:
+    {
+      DWORD Ret;
+      PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1);
+      if(!MenuObject)
+        return 0;
+      if(Param2 > 0)
+        MenuObject->Height = (int)Param2;
+      Ret = (DWORD)MenuObject->Height;
+      IntReleaseMenuObject(MenuObject);
+      return Ret;
+    }
     case TWOPARAM_ROUTINE_SETMENUITEMRECT:
     {
       BOOL Ret;