VC + + How to add right-click popup menu

Source: Internet
Author: User

First, create a new project

Second, Edit menu Resources

   1、添加菜单        按“Ctrl+R”,双击“Menu”图标   2、于菜单编辑器内编辑菜单



Iv. Add code (red part)

voidCcmenuview::onupdateshow (ccmdui*pCmdUI) {//todo:add Your command update UI handler code hereMessageBox ("Right-click popup menu Test! ");}voidCcmenuview::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 );pP Opup->trackpopupmenu (Tpm_leftalign |Tpm_rightbutton, Point.x, Point.y, This); Cview::onrbuttondown (nflags, point);}

Five, compile

Seven, function description

   CMenu::TrackPopupMenu函数声明
BOOL TrackPopupMenu(UINT nFlags,int x,int y,CWnd*pWnd,LPCRECT LPrECT=0)    nFlags:弹出菜单的位置     x:弹出菜单的水平位置    y:弹出菜单的垂直位置   pWnd:弹出菜单的所有者      lpRect:一包含矩形坐标的RECT结构体指针。    功能:显示一弹出菜单。函数调用成功,返回非零值;否则返回零。

VC + + How to add right-click popup menu

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.