积极答复者
关于vs2010中MFC添加菜单出现的问题

问题
-
我建立了一个MFC单文档应用程序,unicode字符集前面的√被我取消的。
我在Cmainframe类中增加了对象CMenu menu.
我在mainfrm.cpp的oncreate()函数中然后添加代码
menu.CreatePopupMenu();
GetMenu()->AppendMenu(MF_POPUP,(UINT)menu.m_hMenu,"TEST");
编译没有问题,运行到上面最后一句时出现如下错误,求大神解答
menu2.exe 中的 0x538afd6c (mfc100d.dll) 处有未经处理的异常: 0xC0000005: 读取位
置 0x00000004 时发生访问冲突- 已移动 Sheng Jiang 蒋晟Moderator 2011年12月22日 16:14 (发件人:一般性问题讨论区)
答案
-
用默认的选项创建应用的话,GetMenu()应该返回null,因为换了BCG的menu bar。要替换掉menu bar的菜单的话,记得是要自己手动加载文档模板对应的菜单,修改之后更新 menu bar
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 Rob Pan 2011年12月28日 6:36
全部回复
-
用默认的选项创建应用的话,GetMenu()应该返回null,因为换了BCG的menu bar。要替换掉menu bar的菜单的话,记得是要自己手动加载文档模板对应的菜单,修改之后更新 menu bar
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP- 已标记为答案 Rob Pan 2011年12月28日 6:36