none
SetMenu() not supporting in wince ??? RRS feed

  • General discussion

  • Hi all,

    I am trying to implement menu's and sub menu's using the following code snippet 

    /*******************************************************************/

    cs = (LPCREATESTRUCT)lParam;
          hMenu = CreateMenu();
          SetMenu(hwnd, hMenu);

          hSubMenu = CreatePopupMenu();
          AppendMenu(hSubMenu, MF_STRING, ID_OPEN, "&Open");
          AppendMenu(hSubMenu, MF_STRING, ID_CLOSE, "&Close");
          AppendMenu(hSubMenu, MF_STRING, ID_EXIT, "E&xit");
          AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL);
          InsertMenu(hMenu, 0, MF_POPUP|MF_BYPOSITION, (UINT_PTR)hSubMenu, "File");

          hSubMenu2 = CreatePopupMenu();
          AppendMenu(hSubMenu2, MF_STRING, ID_1, "File 1");
          AppendMenu(hSubMenu2, MF_STRING, ID_2, "File 2");
          AppendMenu(hSubMenu2, MF_STRING, ID_3, "File 3");
          InsertMenu(hSubMenu, 5, MF_POPUP|MF_BYPOSITION, (UINT_PTR)hSubMenu2, "Recent &Files");
          DestroyMenu(hSubMenu2);
          DestroyMenu(hSubMenu);

          hSubMenu = CreatePopupMenu();
          AppendMenu(hSubMenu, MF_STRING, ID_CUT, "Cut");
          AppendMenu(hSubMenu, MF_STRING, ID_COPY, "Copy");
          AppendMenu(hSubMenu, MF_STRING, ID_PASTE, "Paste");
          InsertMenu(hMenu, 1, MF_POPUP|MF_BYPOSITION, (UINT_PTR)hSubMenu, "Edit");
          DestroyMenu(hSubMenu);
          DestroyMenu(hMenu);

          DrawMenuBar(hwnd);

    /*****************************************************************************/

    I am not able to compile SetMenu() function in wince 6.

     

    where in i am able to compile the same in windows and execute.

     

    Please let me know that why i am not able to compile SetMenu() fn and let me know any other substitute

     

     

    Thanks

    Misbah

     

    Friday, July 30, 2010 7:58 AM

All replies

  • SetMenu is not supported in WinCE.
     
    You can use SHCreateMenuBar() to load the menu into specified window.In the nToolBarId member you can assign your hMenu created using CreateMenu().
     
    Friday, July 30, 2010 2:06 PM
  • hMainMenu = CreateMenu();
    
    ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
    mbi.cbSize  = sizeof(SHMENUBARINFO);
    mbi.hwndParent = hWnd;
    mbi.nToolBarId = (UINT)hMainMenu;
    mbi.hInstRes = hInstance;
    mbi.dwFlags= SHCMBF_HMENU;
    
    SHCreateMenuBar(&mbi);

    ^^^^^^^^^^^^^^^^


    It returns zero, humans. What can i do?
    • Edited by baraboom Tuesday, August 24, 2010 9:32 PM
    Friday, August 20, 2010 9:40 PM
  •  
    Check whether both hWnd and hInstance are valid handles.
    Try to get the exact error code using GetLastError() after failure and give us the error code.
    --
    Regards,
    Prabu
    http://prabukumar.wordpress.com/
    www.e-consystems.com
    Monday, August 23, 2010 12:27 PM
  • hMainMenu = CreateMenu();
    
    ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
    mbi.cbSize = sizeof(SHMENUBARINFO);
    mbi.hwndParent = hWnd;
    mbi.nToolBarId = (UINT_PTR)hMainMenu;//hMainMenu even without submenus. I thought CreatePopupMenu() might work - it didn't, played with hiword nulification - nothing
    mbi.hInstRes = hInstance; //i use this application instance, not other resource instance. Tried zero - didn't work. Don't want to create resource file.
    mbi.dwFlags= SHCMBF_HMENU;
    mbi.nBmpId = 0; 
    mbi.cBmpImages = 0; 
    mbi.clrBk=RGB(178,70,178);
    
    SHCreateMenuBar(&mbi);
    
    GetLastError returns 120;

    i even made initcommoncontrolex call before this - nothing helps

    http://wmdevelopers.blogspot.com/2008/05/create-menu-bar-programmatically-wm5.html
    ^^^^^^^^^^^^^^^
    this guy managed to do it using atl

    (there are similar issues with other functions - e.g. CommandBar_InsertMenubarEx - which tentd to work statically while been documented to work dynamically)

    P.S. cegcc/ubuntu windows mobile 2003 se
    • Edited by baraboom Tuesday, August 24, 2010 9:32 PM
    Monday, August 23, 2010 2:55 PM
  • Looking up 120 in winerror.h will tell you that the function isn't implememted on your device.  That does seem odd though, if it is in fact running PocketPC 2003 SE.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, August 23, 2010 4:26 PM
    Moderator