简体   繁体   中英

context menu does not show up

In my application i want to have two context menus, which appear on mouse right click dependent on the area where the click was made.

first one was generated by the compiler (visual studio 2010) IDR_POPUP_EDIT. i just added there two additional buttons and it just worked. second one i wanted to create from scratch, so i prepared the IDR_PGRC menu resource, which has identical properties and has 2 buttons. In case when there was click on the right side of the frame the idr_popup_edit should appear and the idr_pgrc otherwise.

I'm positive, that the OnRButtonUp and OnCOntextMenu functions are called each time there was a right click on the frame, however, the IDR_PGRC never show up.

this is how i handle the context menu showing up:

#ifndef SHARED_HANDLERS
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);    
DEB("ending\n");
#endif

and accordingly:

#ifndef SHARED_HANDLERS
theApp.GetContextMenuManager()->ShowPopupMenu(IDR_PGRC, point.x, point.y, this, TRUE);
#endif

Can anyone provide me any hint want i may be doing wrong?

If you created it yourself you most likely should be passing it the HMENU hmenuPopup rather than a resource ID.

(If that's not it then please post your code for creating the menu.)

So if you create your menu with CreatePopupMenu , add your items to it then call the overloaded ShowPopupMenu where you can pass the menu handle ( CMenu::GetSafeHMenu ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM