Re: ignore requested height for non-menubar ownerdraw popups

2005-05-08 Thread Rein Klazes
On Sun, 8 May 2005 21:00:28 +0200, you wrote:

> On 05/08/2005 04:21:46 PM, Rein Klazes wrote:
> > About the magic number: I looked at the value on Win2k and WinME with  
> > different resolutions ( desktop->properties->settings, click on  
> > advanced tab and change what windows calls "font size" but is really
> > changing the DPI, dots-per-inch, which is also reported).
> > 
> > DPI  Win2k  WinME
> > ==
> > 9616  13
> > 120   20  16
> 
> Looks like a font-height in pixels for me then - maybe some system font  
> has a different size on your Win2k and WinME box? (I'm reinstalling  
> Windows ATM - can't test it)

Everything else that I can think of is the same on those boxes. Changing
menu font size is also irrelevant. I tested also a box with WinXP: same
results as the Win2k column.

Rein. 



Re: ignore requested height for non-menubar ownerdraw popups

2005-05-08 Thread Felix Nawothnig
On 05/08/2005 04:21:46 PM, Rein Klazes wrote:
About the magic number: I looked at the value on Win2k and WinME with  
different resolutions ( desktop->properties->settings, click on  
advanced tab and change what windows calls "font size" but is really
changing the DPI, dots-per-inch, which is also reported).

DPI  Win2k  WinME
==
9616  13
120   20  16
Looks like a font-height in pixels for me then - maybe some system font  
has a different size on your Win2k and WinME box? (I'm reinstalling  
Windows ATM - can't test it)

-flx


Re: ignore requested height for non-menubar ownerdraw popups

2005-05-08 Thread Rein Klazes
On Sun, 8 May 2005 13:30:30 +0200, you wrote:

> On 05/08/2005 12:25:18 PM, Rein Klazes wrote:
> > That does not seem correct on the Win2k system that I am using for
> > testing.
> 
> Right. Windows sets itemHeight before and not after WM_MEASUREITEM.  
> Sorry for that.
> 
> And it also seems not to be GetSystemMetrics(SM_CYMENU)-1 but a rather  
> strange magic value of 16. (with my test it looked 100% the same ...  
> sigh. I'll go to bed soon. ;)
> 
> How about this patch?

Much better.  About the magic number: I looked at the value on Win2k and
WinME with different resolutions ( desktop->properties->settings, click
on advanced tab and change what windows calls "font size" but is really
changing the DPI, dots-per-inch, which is also reported).

DPI  Win2k  WinME
==
9616  13
120   20  16

I assume that you are using a DPI of 96, and XP and 2k behave the same
way. The DPI you can retrieve with GetDeviceCaps( hdc, LOGPIXELSY). I
would recommend using the Win2k values computed by: DPI/6.

Rein.



Re: ignore requested height for non-menubar ownerdraw popups

2005-05-08 Thread Felix Nawothnig
On 05/08/2005 12:25:18 PM, Rein Klazes wrote:
That does not seem correct on the Win2k system that I am using for
testing.
Right. Windows sets itemHeight before and not after WM_MEASUREITEM.  
Sorry for that.

And it also seems not to be GetSystemMetrics(SM_CYMENU)-1 but a rather  
strange magic value of 16. (with my test it looked 100% the same ...  
sigh. I'll go to bed soon. ;)

How about this patch?
-flxIndex: 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 -  1.26
+++ menu.c  8 May 2005 11:23:59 -
@@ -882,7 +882,8 @@
 mis.CtlID  = 0;
 mis.itemID = lpitem->wID;
 mis.itemData   = (DWORD)lpitem->dwItemData;
-mis.itemHeight = 0;
+mis.itemHeight = 16; /* XXX: WinXP sets this - but where does
+this come from? */
 mis.itemWidth  = 0;
 SendMessageW( hwndOwner, WM_MEASUREITEM, 0, (LPARAM)&mis );
 lpitem->rect.right  += mis.itemWidth;


Re: ignore requested height for non-menubar ownerdraw popups

2005-05-08 Thread Rein Klazes
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.c19 Apr 2005 09:47:02 -  1.26
> +++ menu.c8 May 2005 09:09:06 -
> @@ -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.
--- wine/dlls/user/tests/menu.c 2005-04-14 15:57:27.0 +0200
+++ mywine/dlls/user/tests/menu.c   2005-05-08 12:04:08.0 +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();
 }