1 Attachment(s)
[RESOLVED] CMenu own draw - set submenu height
Hi gurus,
I have my custom context menu created. Everything is working well, except for one thing. I can set up menu-item height in the MeasureItem function, but my context menu contains a submenu how can I the submenu height?
Thx in advance.
Screenshot: Notice the first item is a submenu and it's narrow against the rest of the items.
Attachment 36019
Re: CMenu own draw - set submenu height
Re: CMenu own draw - set submenu height
I got your point but this is not my case. The itemIDs in my OnMeasureItem func are indeed itemIDs. The problem is simply that I enter this function only 6 times and I have 7 menu items including the submenu. So the submenu is not treated as a menuitem.
Re: CMenu own draw - set submenu height
Have you implemented the OnMeasureItem method in the window class that owns the menu?
Example: https://forums.codeguru.com/showthre...76#post1066776
Re: CMenu own draw - set submenu height
Thank you for your help. I found the problem. I followed owner menu article from here: https://www.codeguru.com/cplusplus/c...-step-by-step/.
The problem was in the ChangeToOwnerDraw function, which set the MF_OWNERDRAW flag to every menuitem or submenu.
For submenus they set 0 as a NewItemID which should be a handle to submenu instead. Now I get into the OnMeasureItem function 7 times and the itemID is a submenu handle as you mentioned. This is no problem for me because I set the same height for every item.
pMyMenu->ModifyMenu(i, MF_BYPOSITION | MF_OWNERDRAW, 0, (LPCTSTR)pMenuData);
The altered piece of code is :
pMyMenu->ModifyMenu(i, MF_BYPOSITION | MF_OWNERDRAW , (UINT) pMyMenu->GetSubMenu(i)->GetSafeHmenu(), (LPCTSTR)pMenuData);
Re: CMenu own draw - set submenu height
Glad you could solve it! :thumb::)
Re: CMenu own draw - set submenu height
Thanks again for your time. Have a nice day.