- 4
- 0
- 约 15页
- 2016-11-27 发布于河南
- 举报
05菜单编程_静态添加
菜单编程_静态添加
1.新建工程
新建一个MFC单文档应用程序,取名Menu
在IDM_NAINFRAME中添加一个菜单test -右键- ClassWizard… 分别在CMainFrame、CMenuDoc、CMenuApp、CMenuView中添加对Test菜单项的COMMAND消息。
MessageBox(ManinFrame clicked);
AfxMessageBox(Doc clicked);
AfxMessageBox(App clicked);
MessageBox(clicked);
命令消息传递顺序:view类-doc类-frame类-app类
2. 消息的分类(如下图)
创建标记菜单:
在新建菜单上创建一个标记菜单,在CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)函数中添加:
// GetMenu()-GetSubMenu(0)-CheckMenuItem(0,MF_BYPOSITION|MF_CHECKED);//添加标记
GetMenu()-GetSubMenu(0)-CheckMenuItem(ID_FILE_NEW,MF_BYCOMMAND|MF_CHECKED);//添加标记第二种方法
注释:
UINT CheckMenuItem( UINT nIDCheckItem, UINT nCheck );
Return Value
The previous state of the item: MF_CHECKED or MF_UNCHECKED, or 0xFFFFFFFF if the menu item did not exist.
Parameters
nIDCheckItem
Specifies the menu item to be checked, as determined by nCheck.
nCheck
Specifies how to check the menu item and how to determine the item’s position in the menu. The nCheck parameter can be a combination of MF_CHECKED or MF_UNCHECKED with MF_BYPOSITION or MF_BYCOMMAND flags. These flags can be combined by using the bitwise OR operator. They have the following meanings:
MF_BYCOMMAND???Specifies that the parameter gives the command ID of the existing menu item. This is the default.
MF_BYPOSITION???Specifies that the parameter gives the position of the existing menu item. The first item is at position 0.
MF_CHECKED???Acts as a toggle with MF_UNCHECKED to place the default check mark next to the item.
MF_UNCHECKED???Acts as a toggle with MF_CHECKED to remove a check mark next to the item.
Remarks
Adds check marks to or removes check marks from menu items in the pop-up menu. The nIDCheckItem parameter specifies the item to be modified.
The nIDCheckItem parameter may identify a pop-up menu item as well as a menu item. No special steps are required to check a pop-up menu item. Top-level menu items cannot be checked. A pop-up menu item must be checked by position since it does not have a menu-item identifier associated with i
您可能关注的文档
最近下载
- (高清版)DB31∕T 1487-2024 国际医疗服务规范.docx VIP
- 精益管理措施在医院手术室医用耗材管理中的应用.pdf VIP
- 2026及未来5年中国商务男装市场运行态势及战略咨询报告.docx
- 泸州市高2023级(2026届)高三(一诊)数学试题(含标准答案).pdf
- 新城地产商开目标成本主要科目价格测算标准-定稿.pptx VIP
- 12月1日艾滋病宣传日活动方案模板(集锦5篇).docx VIP
- 2024年湖南铁道职业技术学院单招计算机测试模拟题库必考题.docx VIP
- 遗产分割起诉状.docx VIP
- 2021年重庆市中考物理真题(a卷).pdf VIP
- 2025年度民主生活会对照检查材料8篇五个带头合集.docx VIP
原创力文档

文档评论(0)