why can not delete the Menu? RRS feed

  • Question

  • Hi,

    i use  the following Code to dynamic delete sub item:

    CMenu *pMenu;

    pMenu->DeleteMenu(ID_FUNC, MF_BYCOMMAND);


    it work well on EVC4 + PPC 2003/SE

    and the EXE also work well on WM 5.0 for PPC

    but i migrate to vs2005 + WM5.0 for PPC

    the above code can not work, and it return FALSE,







    Monday, April 23, 2007 11:12 AM


All replies

  • Hi,


    I had the same problem, try this:


    Code Snippet

    HWND hMenuMB = (HWND)SHFindMenuBar(AfxGetMainWnd()->GetSafeHwnd());

    HMENU hMenu  = (HMENU)::SendMessage(hMenuMB, SHCMBM_GETSUBMENU, 0, IDM_MENU);


    CMenu *mnuPrincipal = CMenu::FromHandle(hMenu);

    mnuPrincipal->DeleteMenu(6, MF_BYPOSITION);





    Monday, April 23, 2007 2:35 PM
  • Thank you very much,  Thiago Leite .

    but the code can not work either.


    Tuesday, April 24, 2007 12:59 AM
  • Dear Myime,


    Don't forget to call CWnd:: DrawMenuBar() after the delete operation on an menu.


    Zero Dai - MSFT

    Tuesday, April 24, 2007 9:31 AM
  • Thanks, i use the function from the MSDN, so i do call the CWnd:: DrawMenuBar() , but it can not work either.

    and in my first note: says the DeleteMenu return 0.

    Tuesday, April 24, 2007 10:27 AM
  • Dear Myime,


    In John Kennedy's Blog, he discribed the new menu features in Windows Mobile 5.0 in details.

    Windows Mobile 5.0 and Pocket PC menus

    At the end of the article,  you will find what you want.



    Zero Dai - MSFT

    Wednesday, April 25, 2007 8:35 AM
  • Thanks,

    but the code just is Thiago Leite mentioned.

    Thursday, April 26, 2007 12:48 AM