-
February 1st, 2022, 04:55 AM
#1
[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.
-
February 1st, 2022, 07:47 AM
#2
Re: CMenu own draw - set submenu height
Victor Nijegorodov
-
February 1st, 2022, 09:14 AM
#3
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.
-
February 1st, 2022, 09:26 AM
#4
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
Victor Nijegorodov
-
February 1st, 2022, 09:41 AM
#5
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);
-
February 1st, 2022, 09:43 AM
#6
Re: CMenu own draw - set submenu height
Glad you could solve it! 
Victor Nijegorodov
-
February 1st, 2022, 09:46 AM
#7
Re: CMenu own draw - set submenu height
Thanks again for your time. Have a nice day.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|