用代码添加菜单运行时出错
用mfc创建了一个sdi程序,写添加菜单的代码,运行时一点击“POP UP”就出错,不知为
什么。代码如下:
CMyApp::::InitInstance()
{
// ........................
// ........................
CMenu NewMenu;
NewMenu.CreatePopupMenu();
NewMenu.AppendMenu(MF_STRING, 200, "HAHA");
// and add the new menu to main menu
CMenu *pMainMenu = AfxGetMainWnd()->GetMenu();
pMainMenu->AppendMenu(MF_STRING | MF_POPUP, (UINT)(NewMenu.m_hMenu), "pop up");
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
谢啦:)