动态创建菜单时出错 afxwin1.inl 1023
来源:互联网 发布:arm7的寄存器数据宽度 编辑:程序博客网 时间:2024/05/29 12:27
代码很简单,如下,写在 view 层的 OnChar 事件中
CMenu cmu;
cmu.CreateMenu();
GetMenu()->AppendMenu(MF_POPUP,(UINT)cmu.m_hMenu,_T("电话本"));
cmu.Detach();
以前按书上写是可以的,结果这里报错 提示 assert 失败 afxwin1.inl 1023
报错时,点击重试,进入报错的地点,发现是这么一句:
_AFXWIN_INLINE BOOL CMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem)
{ ASSERT(::IsMenu(m_hMenu)); return ::AppendMenu(m_hMenu, nFlags, nIDNewItem, lpszNewItem); }
看来是ASSERT(::IsMenu(m_hMenu)) 失败,那么就是 菜单无效
综合以前的代码发现,以前是写在frame层的,这个是view层的,一想,菜单属于frame层,不属于view层,所以GetMenu() 获取不到东西。明白了错误所在,改下代码就ok了,如下,添加 GetParent():
GetParent()->GetMenu()->AppendMenu(MF_POPUP,(UINT)cmu.m_hMenu,_T("电话本"));
0 0
- 动态创建菜单时出错 afxwin1.inl 1023
- vs2010 debug afxwin1.inl错误
- smartphone创建菜单时出错
- Debug Assertion Failed! File:afxwin1.inl Line:22的解决
- Debug Assertion Failed! File:afxwin1.inl Line:22
- Run time error assertion failed afxwin1.inl Line24
- Debug Assertion Failed! File:afxwin1.inl Line:22
- afxwin1.inl(1014) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- 【原创】VC实现文件选择对话框并且排除afxwin1.inl line22错误
- Debug Assertion Failed!——File:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl
- 关于Cwnd::Create()函数出现afxwin1.inl line:21错误的解决方法
- CFileDialog File:f:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl Line24
- 如何动态创建菜单
- 动态菜单的创建
- Delphi动态创建菜单
- 动态创建菜单
- 动态创建菜单
- C#动态创建菜单
- AWD Format: About
- hibernate 的Configuration类
- Ruby on Rails学习笔记1
- 使用VS2012 的15个技巧
- FormatUtils java格式化 随笔
- 动态创建菜单时出错 afxwin1.inl 1023
- linux下创建oracle表空间(
- Asp.NET随记---NO1---Page类。
- 5.10.4 静态代码块
- 织梦高级搜索的一些小问题
- 【转载】winForm窗体关闭按钮 实现提示选择,托盘后台运行或退出(类似QQ托盘区运行)
- 编年体纪事
- ArcEngine发布WebService服务
- windows7客户端加入域后系统会出现临时桌面的解决办法