Can't Check Submenu Item

So basically, I am trying to check a menu item that belongs in a cascading submenu. I have a sample diagram to show you want I mean. I am sure I am getting the handle because I get get the string, but I just can't put a check mark there. I want to check mar Item2 and Item1.

(Submenu Bar ) Item1 Item2
^
|
(Submenu Bar ) Add Subtract Mutiply Divide Opts
^
|
(Main Menu Bar )Close Edit Tools

////////////////////////////MY CODE////////////////////////////

CMenu* mmenu = GetDialogMenu();

CMenu* submenu = mmenu->GetSubMenu(1);

CMenu* sub_submenu= submenu->GetSubMenu(0);

sub_submenu->GetMenuString(1,str_temp,MF_BYPOSITION );

sub_submenu->CheckMenuItem( 1, MF_CHECKED | MF_POSITION);



Answer this question

Can't Check Submenu Item

  • genius15

    Thanks for the tip, but I think we may disagree.

    I can't say I entirely agree with you comments. In regards to the wrapper function. If I bring item1 and item 2 down to the firt submenu, I can add the check box. Meaning, item1 and item2 is on the same level at "Add Subtract Mutiply Divide Opts."

    If GetDialogMenu was just a wrapper function, then when I bring down item1 and item2 to a lower submenu, it would still mean I couldn't add the check. But in my case, I can.

    Had anyone else got cascading submenus to work correctly yet


  • Ahmed Abd-ElHaffiez

    Still trying to figure this bloody thing out. Do I need to call some kind of menu bar update Its almost as if it recieves the call to put a check mark, but nobody tells it to update the appearance.
  • NormanL

    Well, I didn't really solve this problem. So I just moved the item1 and item2 to the first level submenu.
  • ReneeB

    The actually submenu of the submenu is this section of code,

    ......

    POPUP "Tools"

    BEGIN

    POPUP "Options"

    BEGIN

    MENUITEM "Check for Overlapping Points", ID_OPTS_CHECKFORPTOVERLAP

    MENUITEM "Input 3D Measurements", ID_OPTS_INPUT3DMEASUREMENTS

    END

    ......


  • M Roy

    bool CDialogCEShared::AddCustomToolbarButtons( CToolBarCtrl* pToolBarCtrl, int& iRightIndex )

    {

    UINT dwDlgMenuID = GetDlgMenuID();

    if ( dwDlgMenuID != 0 )

    {

    m_wndCommandBar.InsertMenuBar( dwDlgMenuID );

    m_hDlgMenu = m_wndCommandBar.GetMenu();

    }


  • Jag711

    can I assume then this a is a bug Putting a check in a cascading submenu
  • jy_lam

    // menu functionality

    HMENU m_hDlgMenu;

    CMenu* GetDialogMenu() { return ( m_hDlgMenu != NULL ) CMenu::FromHandle( m_hDlgMenu ) : NULL; }


  • gpetrosh

    Hi,

    This worked for me; I was able to place a check mark before the 2nd entry in the options menu.

    TBBUTTON tbb;
    ::SendMessageW(m_wndCommandBar.m_hCommandBar, TB_GETBUTTON,1,(LONG) (LPARAM)&tbb);

    TBBUTTONINFO tbbi = {0};
    tbbi.cbSize = sizeof(tbbi);
    tbbi.dwMask = TBIF_LPARAM | TBIF_COMMAND;

    ::SendMessageW(m_wndCommandBar.m_hCommandBar,TB_GETBUTTONINFO,
    tbb.idCommand, (LPARAM)&tbbi);

    HMENU hMenu = (HMENU)tbbi.lParam;

    CMenu* mmenu = CMenu::FromHandle(hMenu);
    CMenu* sub_submenu= mmenu->GetSubMenu(0);

    CString str_temp;
    sub_submenu->GetMenuString(1,str_temp,MF_BYPOSITION );
    sub_submenu->CheckMenuItem( 1, MF_CHECKED | MF_BYPOSITION);

    For resons why we need to do it like this, refer to these threads.

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=338409&SiteID=1
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=226853&SiteID=1

    Thanks


  • Hilarion

    GetDialogMenu is a method I created myself. It essential is like GetMenu(), it returns the handle to the main menu bar. I am quite certain that I am getting the correct handle to the submenut of the submenu. I can even use GetMenuString and get the string of the menu item. So I am sure its not some null pointer.

    Any thoughts Has anyone even have such menu system in their system


  • shantanu_gadgil

    Sorry for the delay. I was away from work for some time. Can you post the main steps in the implementation of GetDialogMenu I shall try to create a repro and then get back to you, ASAP.

    Thanks



  • metamata

    Hi,
    How do you assign the value to
    m_hDlgMenu GetDialogMenu is just a wrapper function and shouldn't effect the functionality.

    Thanks

    Avinash


  • Fredriko

    Hi,

    How are you creating this menubar  Can you post the menu resources, including the SHMENUBAR resource from the RC2 file, if you are using it

    One more thing which class has GetDialogMenu as a method

    Thanks



  • Larry Bynum

    IDR_ENTERLINEDLGMENU MENU DISCARDABLE

    BEGIN

    POPUP "Edit"

    BEGIN

    MENUITEM "&Redo", ID_EDIT_REDO

    MENUITEM SEPARATOR

    MENUITEM "&Change...", ID_EDIT_CHANGE

    MENUITEM "&Insert...", ID_EDIT_INSERT

    POPUP "&Delete"

    BEGIN

    MENUITEM "Delete Points...", ID_DELETE_POINTS

    MENUITEM "Delete Line...", ID_DELETE_LINES

    MENUITEM "Delete Arc...", ID_DELETE_ARCS

    MENUITEM "Del. Offset Points...", ID_DELETE_OFFSETPOINTS

    MENUITEM "Del. Pts. Pattern...", ID_DELETE_POINTSPATTERN

    END

    MENUITEM SEPARATOR

    MENUITEM "Check &Lines", ID_EDIT_ENTEREDLINES

    END

    POPUP "Tools"

    BEGIN

    POPUP "Options"

    BEGIN

    MENUITEM "Check for Overlapping Points", ID_OPTS_CHECKFORPTOVERLAP

    MENUITEM "Input 3D Measurements", ID_OPTS_INPUT3DMEASUREMENTS

    END

    MENUITEM "&Perform Closure Check...", ID_TOOLS_CLOSURECHECK

    MENUITEM "&Insert Point Pattern...", ID_TOOLS_POINTPATTERN_INSERT

    MENUITEM SEPARATOR

    POPUP "Change &Elevation"

    BEGIN

    MENUITEM "&Find && Replace...", ID_TOOLS_CHANGE_ELEV_FINDREPLACE

    MENUITEM "Individual Points...", ID_TOOLS_CHANGE_ELEV_INDIVIDUALPT

    END

    MENUITEM "&Enter an Arc...", ID_TOOLS_ENTERANARC

    MENUITEM "Create &Line Intersection...", ID_TOOLS_LINEINTERSECTION

    MENUITEM "Create Line &Mid-point...", ID_TOOLS_MIDPOINTOFLINE

    POPUP "&Offset Points..."

    BEGIN

    MENUITEM "Offset From a Line...", ID_TOOLS_MULT_OFFSETPOINTS

    MENUITEM "Offset from a Polyline...", ID_TOOLS_OFFSETPOINTS_FROM_ANALIGNMENT

    MENUITEM "Line Down And Out...", IDC_TOOLS_DOWN_AND_OUT_PT

    MENUITEM "Arc Down and Out...", ID_TOOLS_OFFSETPOINTS_ARC_DOWNANDOUT

    MENUITEM "Two Tapes Intersection...", ID_TOOLS_TWO_TAPES_INTERSECT

    END

    MENUITEM "Co&nnect Points...", ID_TOOLS_CONNECTPOINTS

    MENUITEM SEPARATOR

    MENUITEM "&Calculator...", ID_TOOLS_CALCULATOR

    END

    END


  • Seaman Jiang

    I am assuming that the platfrom is WM 5.0 or 2003 PPC/SP
    Thanks


  • Can't Check Submenu Item