|文件|编辑|设置|帮助|以上是我的在资源中窗创建的Menu,现在要在程序运行界面时,修改成如下:|文件|编辑|设置|帮助|
          |设置方向|
          |设置速度|
          |设置形状|
并实现各个选择项对应程序的执行;比如|设置方向|----> setDirection.exe
|设置速度|----> setSpeed.exe
.........

解决方案 »

  1.   

    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
    pSysMenu->AppendMenu(MF_SEPARATOR);
    pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
    }
      

  2.   

    同意楼上的说法,你修改菜单可以手动,可以通过代码,
    然后添加消息,实现运行其他程序,比如
    winexec
    shellExecute
    等即可实现
      

  3.   

    // CMainFrame::OnChangeFileMenu() is a menu command handler for 
    // CMainFrame class, which in turn is a CFrameWnd-derived class. 
    // It modifies the File menu by inserting, removing and renaming 
    // some menu items. Other operations include associating a context 
    // help id and setting default menu item to the File menu. 
    // CMainFrame is a CFrameWnd-derived class.
    void CMainFrame::OnChangeFileMenu() 
    {
       // Get the menu from the application window.
       CMenu* mmenu = GetMenu();   // Look for "File" menu.
       int pos = FindMenuItem(mmenu, "&File");
       if (pos == -1)
          return;   // Remove "New" menu item from the File menu.
       CMenu* submenu = mmenu->GetSubMenu(pos);
       pos = FindMenuItem(submenu, "&New\tCtrl+N");
       if (pos > -1)
          submenu->RemoveMenu(pos, MF_BYPOSITION);   // Look for "Open" menu item from the File menu. Insert a new
       // menu item called "Close" right after the "Open" menu item.
       // ID_CLOSEFILE is the command id for the "Close" menu item.
       pos = FindMenuItem(submenu, "&Open...\tCtrl+O");
       if (pos > -1)
          submenu->InsertMenu(pos + 1, MF_BYPOSITION, ID_CLOSEFILE, "&Close");   // Rename menu item "Save" to "Save Selection".
       pos = FindMenuItem(submenu, "&Save\tCtrl+S");
       if (pos > -1)
       {
          UINT id = submenu->GetMenuItemID(pos);
          submenu->ModifyMenu(id, MF_BYCOMMAND, id, "&Save Selection");
       }   // Associate a context help ID with File menu, if one is not found.
       // ID_FILE_CONTEXT_HELPID is the context help ID for the File menu
       // that is defined in resource file. 
       if (submenu->GetMenuContextHelpId() == 0)
          submenu->SetMenuContextHelpId(ID_FILE_CONTEXT_HELPID);   // Set "Open" menu item as the default menu item for the File menu, 
       // if one is not found. So, when a user double-clicks the File
       // menu, the system sends a command message to the menu's owner 
       // window and closes the menu as if the File\Open command item had 
       // been chosen. 
       if (submenu->GetDefaultItem(GMDI_GOINTOPOPUPS, TRUE) == -1)
       {
          pos = FindMenuItem(submenu, "&Open...\tCtrl+O");
          submenu->SetDefaultItem(pos, TRUE);
       }
    }// FindMenuItem() will find a menu item string from the specified
    // popup menu and returns its position (0-based) in the specified 
    // popup menu. It returns -1 if no such menu item string is found.
    int FindMenuItem(CMenu* Menu, LPCTSTR MenuString)
    {
       ASSERT(Menu);
       ASSERT(::IsMenu(Menu->GetSafeHmenu()));   int count = Menu->GetMenuItemCount();
       for (int i = 0; i < count; i++)
       {
          CString str;
          if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
             (strcmp(str, MenuString) == 0))
             return i;
       }   return -1;
    }
      

  4.   

    >>可是单击该选择项时要执行的命令,
    如何写?写在哪儿来实现呢?给菜单的item加消息映射啊
      

  5.   

    xiaohyy(醉大饿极)要用代码实现,item ?
    代码如何实现加入item的消息映射啊?
      

  6.   

    你先做个例子,看MFC是怎么加的,然后你找抄就可以了。
      

  7.   

    http://www.csdn.net/develop/read_article.asp?id=9413Command what is yours
    Conquer what is not