locked
How to copy all items of a HMENU to another HMENU RRS feed

  • Question

  • I want to write a function as follows:

    void CopyMenu(HMENU hMenuDestination, HMENU hMenuSource);

    In this function, I want to remove all menu items of hMenuDestination, and copy all items of hMenuSource to hMenuDestinatin, how to implement this fucntion?

    If you have some idea, please give the implementation.

    Tuesday, April 26, 2011 1:20 PM

All replies

  • Use the ModifyMenu API, or CMenu::ModifyMenu
    Tuesday, April 26, 2011 2:10 PM
  • On 4/26/2011 9:20 AM, MFC_Michael wrote:

    I want to write a function as follows:

    void CopyMenu(HMENU hMenuDestination, HMENU hMenuSource);

    In this function, I want to remove all menu items of hMenuDestination, and copy all items of hMenuSource to hMenuDestinatin, how to implement this fucntion?

    See GetMenuItemCount, GetMenuItemInfo, InsertMenuItem, DeleteMenu. There is no "move this menu item over there" API. You'll have to enumerate all items in one menu, create identical items in the other, then delete the originals.


    Igor Tandetnik

    Tuesday, April 26, 2011 3:39 PM
  • Don't understand why you need to do this operation.

    Just use handle to menu in other place where you want to display this menu.


    Nikita Leontiev
    • Proposed as answer by D.Sreedhar Wednesday, April 27, 2011 6:22 AM
    Tuesday, April 26, 2011 3:39 PM