ignore requested height for non-menubar ownerdraw popups

Rein Klazes wijn at wanadoo.nl
Sun May 8 05:25:18 CDT 2005


On Sun, 8 May 2005 11:14:52 +0200, you wrote:

> This fixes bug 2764 (the scrolling issue seems to be resolved  
> already?). Verified this behaviour on WinXP and changed the comment to  
> reflect that.
> 
> ChangeLog:
> Ignore requested height for non-menubar ownerdraw popups too.
> 
> Index: menu.c
> ===================================================================
> RCS file: /home/wine/wine/dlls/user/menu.c,v
> retrieving revision 1.26
> diff -u -r1.26 menu.c
> --- menu.c	19 Apr 2005 09:47:02 -0000	1.26
> +++ menu.c	8 May 2005 09:09:06 -0000
> @@ -887,17 +887,14 @@
>          SendMessageW( hwndOwner, WM_MEASUREITEM, 0, (LPARAM)&mis );
>          lpitem->rect.right  += mis.itemWidth;
>  
> - 	if (menuBar)
> -	{
> -	     lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
> +	/* under windows you are given a standard height for the
> +	   menu and the height value is ignored. delphi 7 depends
> +	   on this behaviour. */
>  
> +	lpitem->rect.bottom += GetSystemMetrics(SM_CYMENU)-1;
>  


That does not seem correct on the Win2k system that I am using for
testing.

Attached is the test that I am working on. It creates a non-menubar
popup menu, fills it with a couple of items and traces the resulting
item rectangles. It is all work in progress of course, not meant for
submitting yet.

Without your patch the rectangles get the height that is returned by the
WM_MEASUREITEM handler both Win2k and Wine. With your patch the Wine
behavior is broken. I have a real world application too, that is
affected by this brokenness.

Can you see if that is different on WinXP. If it is not, can you look
what is different with your test and mine?

Rein.
-------------- next part --------------
--- wine/dlls/user/tests/menu.c	2005-04-14 15:57:27.000000000 +0200
+++ mywine/dlls/user/tests/menu.c	2005-05-08 12:04:08.000000000 +0200
@@ -41,7 +41,30 @@ static LRESULT WINAPI menu_check_wnd_pro
         /* mark window as having entered menu loop */
         SetWindowLongPtr(hwnd, GWLP_USERDATA, TRUE);
         /* exit menu modal loop */
-        return SendMessage(hwnd, WM_CANCELMODE, 0, 0);
+        //return SendMessage(hwnd, WM_CANCELMODE, 0, 0);
+		return DefWindowProc(hwnd, msg, wparam, lparam);
+
+    case WM_MEASUREITEM:
+        trace("WM_MEASUREITEM received\n");
+        ((MEASUREITEMSTRUCT*)lparam)->itemWidth = 10;
+        ((MEASUREITEMSTRUCT*)lparam)->itemHeight = 30;
+        return TRUE;
+    case WM_DRAWITEM:
+        {
+        DRAWITEMSTRUCT * pdis;
+		RECT rc;
+        pdis = (DRAWITEMSTRUCT *) lparam;
+        trace("WM_DRAWITEM received item %d rc %ld,%ld-%ld,%ld \n",
+                pdis->itemID,
+                pdis->rcItem.left,pdis->rcItem.top,pdis->rcItem.right,pdis->rcItem.bottom );
+		GetMenuItemRect( NULL, (HMENU)pdis->hwndItem, 1, &rc);
+		trace("it 1 rc %ld,%ld-%ld,%ld\n",rc.left, rc.top,rc.right,rc.bottom);
+		GetMenuItemRect( NULL, (HMENU)pdis->hwndItem, 3, &rc);
+		trace("it 3 rc %ld,%ld-%ld,%ld\n",rc.left, rc.top,rc.right,rc.bottom);
+
+
+        }
+
     }
     return DefWindowProc(hwnd, msg, wparam, lparam);
 }
@@ -101,9 +124,37 @@ static void test_menu_locked_by_window()
     DestroyWindow(hwnd);
 }
 
+static void test_menu_ownerdrawn()
+{
+    int i,j,k;
+    BOOL ret;
+    HMENU hmenu;
+    HWND hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL,
+        WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+        NULL, NULL, NULL, NULL);
+    ok(hwnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError());
+    if( !hwnd) return;
+    hmenu = CreatePopupMenu();
+    ok(hmenu != NULL, "CreateMenu failed with error %ld\n", GetLastError());
+    if( !hmenu) { DestroyWindow(hwnd);return;}
+    k=1;
+    for( j=0;j<1;j++)
+        for(i=0;i<2;i++) {
+            ret = AppendMenu( hmenu, MF_OWNERDRAW | 
+				(i==0 ? MF_MENUBREAK : 0), k++, 0);
+			ok( ret, "AppendMenu failed for %d\n", k-1);
+		}
+    ret = TrackPopupMenu( hmenu, 0x100, 100,100, 0, hwnd, NULL);
+	ok( ret, "TrackPopupMenu failed gle %ld\n", GetLastError());
+	trace("done\n");
+
+    DestroyWindow(hwnd);
+}
+
 START_TEST(menu)
 {
     register_menu_check_class();
 
-    test_menu_locked_by_window();
+//    test_menu_locked_by_window();
+    test_menu_ownerdrawn();
 }


More information about the wine-devel mailing list