Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a IDR_MENU, and I want to add event handler for button on menu..but if I click on a text on menu I can't add event handler, I can add it only for submenu and not for menu

What I have tried:

I tried to add it for menu but I can't
Posted
Updated 30-Dec-22 8:01am
Comments
Richard MacCutchan 26-Sep-22 10:33am    
You need to provide more detailed information.
Member 14594285 26-Sep-22 10:45am    
I have a CMenu with horizontal written, if I press on a horizontal written, submenu compares and I can add event handler..but if I want to add event handler directly on horizontal written?
Richard MacCutchan 26-Sep-22 11:29am    
Most likely because the topmost item is not an actual MenuItem but a title for the collection in the submenu.
Member 14594285 26-Sep-22 11:45am    
aaa ok, thanks..so if I want this effect I must use buttons..a question..Can I make a derived class of CMenu? Because when I press add mfc class on my application and search CMenu in baseClass I don't find it

1 solution

You need more than just the resource ID. There is more to do.
Define a member function
CMenu m_mnYourMenu;

As part of initilizing your dialog, you need to load this menu.
// load menu
m_mnYourMenu.LoadMenuW(IDR_MENU_YOURMENU);

Then you add an event and a callback for that event. If you share more details and more code, we can help more.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900