Right-click to create a menu and create a key to bring up a menu.

Source: Internet
Author: User

Right-click to create a menu and create a key to bring up a menu.

① Add a menu resource with the ID IDM_RIGHTMENU. The top-level menu is not displayed when you right-click the menu, so you can set any text for it.

② Add a WM_RBUTTONDOWN message to the video class. Right-click the message and choose the context menu. Because the class window always overwrites the Framework Window and the Framework Window cannot receive the mouse message, the class captures the WM_RBUTTONDOWN message.

Void CMenuView: OnRButtonDown (UINT nFlags, CPoint point) {// TODO: add the message processing program code and/or call the default CMenu menu; menu. loadMenuW (IDM_RIGHTMENU); // load the menu resource CMenu * pPopup = menu. getSubMenu (0); ClientToScreen (& point); // convert the client region to screen coordinates. // right-click the displayed menu, which is owned by the video window. PPopup-> TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, point. x, point. y, this); // The last parameter of TrackPopupMenu. You can right-click the frame window in the parent window for GetParent, in this way, the // framework class window obtains the command response to the menu item in the right-click menu, CView: OnRButtonDown (nFlags, point );}

 

③ Add the Command Message response function for the right-click menu item.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.