All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
IIS,6,的,PHP,最佳配置方法_php资料_编程技术
ASP.NET程序中常用的三十三种代码1_[Asp.Net教程]
ASP.NET,2.0编程小技巧两则_[Asp.Net教程]
“ConnectionString,属性尚未初始化”的另类解决办法_[Asp.Net教程]
通过ADO.NET存取文件_[Asp.Net教程]
SQL,Server,全局变量_mssql学习_编程技术
微软.NET平台中类型使用的基本原理_.net资料_编程技术
PHP实例:PHP批量生成缩略图_[PHP教程]
C#教程:操作注册表
WEB开发源代码:PHP生成静态页面的类_[PHP教程]
Reading number is top 10 pictures
Summer is most suitable for young people to travel in China1
这才是真正的人体艺术3
南昌铁路局攸县车站125户铁路职工微利房终成骗局
我国房地产真相
Tie a large font of mouse
关于提肛的健身效果
Sora aoi possession photo2
China's first snake village1
Breasts woman big set 1
西方气质的东方美女3
Download software ranking
卡丁车单机版
Sora aoi - one of more PK
超级战舰
Tram sex maniac 2 (H) rar bag19
双旗镇刀客A
Ashlynn Video3
Desire a peach blossom
都市狐狸姑娘传
Eclipse 4.2.2 For Win64
小黑猫大战两米大花蛇
qq published in(发表于) 2014/7/9 22:39:35 Edit(编辑)
visual c++中弹出式菜单

visual c++中弹出式菜单

visual c++中弹出式菜单

visual c++中弹出式菜单

菜单一般分两类,除了前面介绍的依附于框架窗口的一般菜单,另一类是浮动的弹出式菜单,也称为快捷菜单或上下文菜单。

在Visual C++中,弹出式菜单主要是通过CMenu类实现的。

请看下面的实例,为程序增加一个帮助、关于快捷菜单。


void CMyDlg::OnContextMenu(CWnd* pWnd, CPoint point)

{

CMenu mnu;

if(mnu.CreatePopupMenu())

{

mnu.AppendMenu(MF_STRING,ID_MYHELP,"帮助(&H)");

mnu.AppendMenu(MF_STRING,ID_MYABOUT,"关于(&A)…");

mnu.TrackPopupMenu(TPM_CENTERALIGN,point.x,point.y ,this);

}

}

运行结果如图1所示。


图1 快捷菜单实例运行结果

除了上面的方法,Visual C++还提供了更简便的方法。

(1)单击系统主菜单“Project”/“Add to Project”/“Components and Controls”,在弹出的“Components and Controls Gallery”对话框中选择“Visual C++ Components”文件夹,然后选择“Pop-up Menu”,如图2所示。


图2 “Components and Contrals Gallery”对话框

(2)单击“Insert”按钮,系统会要求用户确认,单击“确定”按钮,弹出“Pop-up Menu”对话框。

(3)在此对话框中,将“Add Pop-up Menu to”组合框的内容改为“CMyView”。单击“OK”按钮,将此快捷菜单添加到项目中。

(4)此时,在“Workspace”工作区中,“ResourceView”选项卡里会添加一个菜单资源,按照上面讲述的编辑普通菜单的方法编辑此快捷菜单。

(5)实际上,这种方法只是让系统自动为程序添加显示快捷菜单的代码,其OnContextMenu成员函数中会自动添加如下代码:


void CAboutDlg::OnContextMenu(CWnd*, CPoint point)

{

{

if (point.x == -1 && point.y == -1){

//keystroke invocation

CRect rect;

GetClientRect(rect);

ClientToScreen(rect);

point = rect.TopLeft();

point.Offset(5, 5);

}

CMenu menu;

VERIFY(menu.LoadMenu(CG_IDR_POPUP_ABOUT_DLG));

CMenu* pPopup = menu.GetSubMenu(0);

ASSERT(pPopup != NULL);

CWnd* pWndPopupOwner = this;

while (pWndPopupOwner->GetStyle() & WS_CHILD)

pWndPopupOwner = pWndPopupOwner->GetParent();

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,

pWndPopupOwner);

}

}


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.