How to add a shortcut menu for vc ++ and a shortcut menu for vc

Source: Internet
Author: User

How to add a shortcut menu for vc ++ and a shortcut menu for vc

1. Create a new project

Ii. Edit menu Resources

1. Press Ctrl + R to add a Menu. Double-click the Menu icon. 2. Edit the Menu in the Menu editor.



4. Add code (red part)

Void CCMenuView: OnUpdateShow (CCmdUI * pCmdUI) {// TODO: Add your command update UI handler code hereMessageBox ("right-click the pop-up menu to test! ");} Void CCMenuView: OnRButtonDown (UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultCMenu menu; menu. loadMenu (IDR_MENU1); CMenu * pPopup = menu. getSubMenu (0); ClientToScreen (& point); pPopup-> TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, point. x, point. y, this); CView: OnRButtonDown (nFlags, point );}

V. Compilation

VII. Function Description

CMenu: TrackPopupMenu function declaration
BOOL TrackPopupMenu (UINT nFlags, int x, int y, CWnd * pWnd, LPCRECT LPrECT = 0) nFlags: Position of the pop-up menu x: horizontal position of the pop-up menu y: vertical Position pWnd: The owner lpRect of the pop-up menu: a rect struct pointer containing rectangular coordinates. Function: displays a pop-up menu. If the function is successfully called, a non-zero value is returned; otherwise, zero is returned.

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.