append一个menu
为什么是灰的呢?enable以后还是不行
如果想动态创建一个popup菜单和子菜单(资源里面没有)
怎么向popup菜单里面添加子菜单呢?

解决方案 »

  1.   

    菜单项没有相应的处理函数
    BOOL InsertMenu( UINT nPosition, UINT nFlags, UINT nIDNewItem = 0, LPCTSTR lpszNewItem = NULL );
      

  2.   

    建议你看<<MFC Windows 程序设计>>{第2版本) 作者 Jeff Prosise
    北京博彦科技发展有限责任公司译
    可以解决你的很多问题
      

  3.   

    给对话框窗口的WM_CONTEXTMENU事件消息加如一个函数
    oid CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point) 
    {
    // TODO: Add your message handler code here
    //my code starts here
    //declare  local variable
    CMenu *m_lMenu;//a pointer to the menu
    CPoint m_pPoint;//a copy of the mouse position
    //copy the mouse Position to a local variable
    m_pPoint=point;
    // covert the position to a screen position
    ClientToScreen(&m_pPoint);
    //get a pointer to window menu
    m_lMenu=GetMenu();
    //get a pointer to the first submenu
    m_lMenu=m_lMenu->GetSubMenu(0);
    //show the popup menu
    m_lMenu->TrackPopupMenu(TPM_CENTERALIGN+TPM_LEFTBUTTON,
    m_pPoint.x,m_pPoint.y,this,NULL); //MY CODE ENDS HERE
    }
      

  4.   

    因为VC会自动把没有做消息映射的菜单项禁用,如果想取消这个功能,可以将FrameWnd OnCreate的时候把成员变量m_bAutoMenuEnable = FALSE;这样VC就不会多此一举禁用你的菜单了.