A problem about the menus in Smartphone 2003

I created a new MFC Smart Device Application Project for Smartphone 2003 using VS2005.  And then I found the menu didn't work right.  So I searched the solution here and found the article: http://blogs.msdn.com/johnkenn/archive/2005/08/22/454858.aspx

I followed the all instructions in the artcile but I still have a little trouble.

Here is a part of the Test03sp.rc:

IDR_MAINFRAME MENU
BEGIN
    MENUITEM "OK",                          IDOK
    POPUP "Option"
    BEGIN
        MENUITEM "Opt1",                          ID_OPT1
    END
END

Here is a part of the Test03sp.rc2:

IDR_MAINFRAME RCDATA
BEGIN
 IDR_MAINFRAME,
 2,


  I_IMAGENONE, IDOK, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,
 IDS_OK, 0, NOMENU,
 
 I_IMAGENONE, ID_OPTION, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
 IDS_OPTION, 0, 0,
END

But when I press the right soft key in the software,  the menu "Option" can't popup the submenu "Opt1".  In my opinion, there may be some problems in the sentence:  "I_IMAGENONE, ID_OPTION, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
 IDS_OPTION, 0, 0,". But I don't know what are they and how to fix them.

Do some one knows the solution Any suggestion will be appreciated.

Sorry for my poor English.

Thanks.



Answer this question

A problem about the menus in Smartphone 2003

  • NewToC#47259

    How do you add soft key bar to an MFC Smart Device Windows Mobile 5.0 Pocket PC Dialog based application using VS2005

    I have not found any information on this. Kindly help!


  • nav13

    There's also a simpler way to specify your softkey bar which is to just use a single HMENU resource and not use an RCDATA structure at all.

    Just Specify your entire softkey bar as a single menu resource

    IDM_MENU_TEST MENU DISCARDABLE
    BEGIN
        MENUITEM "OK"     101
        POPUP "Menu"
            BEGIN
                MENUITEM "Menu Item 1"   102
                MENUITEM "Menu Item 2"    103
                MENUITEM "Menu Item 3"    104
            END
    END

    Then when you call SHCreateMenuBar, pass in this ID and set the SHCMBF_HMENU flag:

    SHMENUBARINFO mbi = {0};
    mbi.cbSize = sizeof(SHMENUBARINFO);
    mbi.hwndParent = hWnd;
    mbi.nToolBarId = IDM_MENU_TEST;
    mbi.hInstRes = g_hInstance;
    mbi.dwFlags |= SHCMBF_HMENU;
    SHCreateMenuBar(&mbi);
    g_hwndMb = mbi.hwndMB;

    This will give you a softkey bar with "OK" on the left softkey and a menu on the right softkey with three menu items. I find this a lot easier than using RCDATA and it saves a few bytes too.



  • RobertJe

    The last number is the index of the submenu, in the menu item identified by the first element of the RCDATA/SHMENUBAR resource.

    Have a look at the following link
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/win_ce/html/pwc_CreatingaSmartphoneMenuBarControl.asp

    Hope this helps.
    Thanks


  • Tammy*

    I know where is the key now.

    It is at the sentence which I pointed out last time: "I_IMAGENONE, ID_OPTION, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_OPTION, 0, 0,".

    The key is the last number, it should be "1" instead of "0". So the correct sentence should be: "I_IMAGENONE, ID_OPTION, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_OPTION, 0, 1,".

    But I still want to know why.


  • A problem about the menus in Smartphone 2003