[CMAKE]
[reactos.git] / dll / win32 / user32 / windows / menu.c
index c9e87de..32b0031 100644 (file)
@@ -3182,7 +3182,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y,
     SetCapture(mt.OwnerWnd);
     (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, mt.OwnerWnd);
 
-    ERR("MenuTrackMenu 1\n");
+    FIXME("MenuTrackMenu 1\n");
     while (! fEndMenu)
     {
         PVOID menu = ValidateHandle(mt.CurrentMenu, VALIDATE_TYPE_MENU);
@@ -3210,6 +3210,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y,
                 }
                 WaitMessage();
             }
+            //FIXME("MenuTrackMenu loop 1\n");
         }
 
         /* check if EndMenu() tried to cancel us, by posting this message */
@@ -3417,6 +3418,7 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y,
         {
             PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
             DispatchMessageW( &msg );
+            //FIXME("MenuTrackMenu loop 2\n");
             continue;
         }
 
@@ -3427,8 +3429,9 @@ static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y,
         if (fRemove && !(mt.TrackFlags & TF_SKIPREMOVE) )
             PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
         else mt.TrackFlags &= ~TF_SKIPREMOVE;
+        //FIXME("MenuTrackMenu loop 3\n");
     }
-    ERR("MenuTrackMenu 2\n");
+    FIXME("MenuTrackMenu 2\n");
 
     (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, NULL);
     SetCapture(NULL);  /* release the capture */
@@ -3487,14 +3490,23 @@ static BOOL FASTCALL MenuInitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT
 
     HideCaret(0);
 
+    MenuGetRosMenuInfo(&MenuInfo, hMenu);
+    /* This makes the menus of applications built with Delphi work.
+     * It also enables menus to be displayed in more than one window,
+     * but there are some bugs left that need to be fixed in this case.
+     */
+    if(MenuInfo.Self == hMenu)
+    {
+        MenuInfo.Wnd = hWnd;
+        MenuSetRosMenuInfo(&MenuInfo);
+    }
+
     /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */
     if (!(wFlags & TPM_NONOTIFY))
        SendMessageW( hWnd, WM_ENTERMENULOOP, bPopup, 0 );
 
     SendMessageW( hWnd, WM_SETCURSOR, (WPARAM)hWnd, HTCAPTION );
 
-    MenuGetRosMenuInfo(&MenuInfo, hMenu);
-
     if (!(wFlags & TPM_NONOTIFY))
     {
        SendMessageW( hWnd, WM_INITMENU, (WPARAM)hMenu, 0 );
@@ -3512,16 +3524,6 @@ static BOOL FASTCALL MenuInitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT
        }
     }
 
-    /* This makes the menus of applications built with Delphi work.
-     * It also enables menus to be displayed in more than one window,
-     * but there are some bugs left that need to be fixed in this case.
-     */
-    if(MenuInfo.Self == hMenu)
-    {
-        MenuInfo.Wnd = hWnd;
-        MenuSetRosMenuInfo(&MenuInfo);
-    }
-
     IntNotifyWinEvent( EVENT_SYSTEM_MENUSTART,
                        hWnd,
                        MenuInfo.Flags & MF_SYSMENU ? OBJID_SYSMENU : OBJID_MENU,
@@ -3652,6 +3654,7 @@ BOOL WINAPI TrackPopupMenuEx( HMENU Menu, UINT Flags, int x, int y,
                               HWND Wnd, LPTPMPARAMS Tpm)
 {
     BOOL ret = FALSE;
+    ROSMENUINFO MenuInfo;
 
     if (!IsMenu(Menu))    
     {
@@ -3659,6 +3662,13 @@ BOOL WINAPI TrackPopupMenuEx( HMENU Menu, UINT Flags, int x, int y,
       return FALSE;
     }
 
+    MenuGetRosMenuInfo(&MenuInfo, Menu);
+    if (IsWindow(MenuInfo.Wnd))
+    {
+        SetLastError( ERROR_POPUP_ALREADY_ACTIVE );
+        return FALSE;
+    }
+
     MenuInitTracking(Wnd, Menu, TRUE, Flags);
 
     /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */