Hallo!
Can you say what's wrong with my code?
My menu bitmap has a dimension of 18x43 pixel. I respond to the WM_MEASUREITEM message
.elseif uMsg==WM_MEASUREITEM
mov ebx,lParam
mov ,18
mov ,43
mov eax,TRUE
ret
but the result is

Sorry I don't have the solution for you but I suffer from the same problem. The problem is that every menu item has this space behind the actual item (just look at a menu somewhere, you'll see the text is never close to the right edge).
You can set the itemwidth smaller like you did, it will solve the problem but I don't think this is the proper way..
Anyone knows how to get rid of the standard extra space in the menu items?
Thomas
The space on the left of the menu is for "check" marks.
All menus by default are check box-esque items, but for the most part we don't use this facility (see the API remarks for CheckMenuItem on using it).
Basically its easier to have the space there, so a mix of checked and unchecked items still looks neat.
For an example of what I mean check "Word Wrap" in notepad.
As for offering any advice, I haven't a clue :D
But at least you know why the space is there :P
Mirno
I found a great article at microsoft, which explains a lot
of the wired gaps and spacings in menus.
MSDN January 98
Mirno: No it's not that space. With owner-drawn menus you can even use that space (normally used for check marks). The space that is the problem here is the space on the right of a menu item, not the left. The vertical red thing in TL's example (first image) is actually a menu item, with the rest of the menu items on a new column. The vertical seperator is the column-seperator. The space on the left of that seperator belongs to the menu item with the red bar. The problem is that windows always adds this space.
By making windows think the image is 7 pixels, it still has that space, but it's then covered with the image you draw on it. But this is not actually allowed by windows.
Thomas
beaster: Thanks I'll take a look at it.
(I saw your post too late, I was already replying :))
Thomas
Thanks for your answers. Seems to be a nice article!
As i understand i must only subtract the width of the checkmark from the width of my bitmap...
No, it's not the checkmark space that's after the bitmap. Owner-drawn controls don't have space reserved for a checkmark as you should draw that your own. It's some extra space on the right of the menu item, and I just figured out what it is for. I think it's for the black arrow that indicates a menu has a submenu. For menus that don't have a sub menu, this space is still reserved. But this is not the checkmark space. Although I think it has the same size as the checkmark space..
Thomas
I was wrong, I just read this in the article:
(this is about calculating the total size of the item)
Once you've added up all the pixels, you're still not ready
to return from OnMeasureItem because this is where you run
into Windows kludge #1: whatever value you return in
MEASUREITEMSTRUCT as the itemWidth, Windows will add the
width of a checkmark. Oh, of course. Why didn't you think
of that? Actually, experience shows that Windows adds one
less than this value, so to make your menu item come out
exact, you must subvert the Windows logic by subtracting
from your final desired value:
lpms->itemWidth -= GetSystemMetrics(SM_CXMENUCHECK)-1;
That explains the problem. Thanks beaster for the article!
Thomas
This message was edited by Thomas, on 6/4/2001 12:18:11 PMOK, problem solved. Thanks beaster for the article.
But the next one is: how to handle different window font sizes (small, large, user defined)?
How can i check the complete height of the popup to draw the left logo bitmap?
Please let me know if anybody has a better solution like this:
invoke GetMenuItemCount,Menu
dec eax
mov MenuItemCounter,eax
mov LogoHeight,0
.repeat
invoke GetMenuItemRect,hwndDlg,Menu,MenuItemCounter,addr Rect
mov eax,Rect.bottom
sub eax,Rect.top
add LogoHeight,eax
dec MenuItemCounter
.until MenuItemCounter==0
Thanx!
You can multiply the returnvalue of invoke GetSystemMetrics, SM_CYMENUSIZE with the number of items. The problem is the seperator, I don't know how to get the size of that.
Thomas