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.