[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

How to check a selected menu-item and its upper popup??

Hi,

I have a MFC application (single document). I've created a menu in the resource editor.
The menu has one pop-up menu 'test'.
In this popup-menu there's another pop-up menu 'test2'. This menu  consists of one item 'test3'.
Problem : if I select 'test3' by clicking on it, I want to check menu-item 'test3' AND popup 'test2'.
I don't succeed in checking popup 'test2'.
How should I do this in MFC ?

IDR_MENU1 MENU DISCARDABLE
BEGIN
    POPUP "test"
    BEGIN
        POPUP "test2"
        BEGIN
            MENUITEM "test3",                       ID_TEST_TEST2_TEST3
        END
    END
END

thx
jlsjls

0
jlsjls
Asked:
jlsjls
  • 2
1 Solution
 
AndyAinscowCommented:
Add a handler for the updating of the menu in the main frame (or wherever you have the command handler).  Class wizard, select the menu ID and UPDATE_COMMAND_UI.

void CMainFrame::OnUpdateMenuHauptbuch(CCmdUI* pCmdUI)
{
      pCmdUI->Enable(true);//or false to enable/disable
      pCmdUI->SetCheck(true);//or false to display check
}

I don't think you can put a check next to the menu item that launches a sub menu (does it make sense? as a sub menu can have a number of items).
0
 
jlsjlsAuthor Commented:
My problem is like you said 'How to check a menu item that launches a sub menu'.
I want this feature since it gives to the user a clear indication to what has been selected before in a menu consisting out of different menu-levels.
0
 
AndyAinscowCommented:
I understand but if the sub menu has two items does it mean both are checked or just one?  If it has only one sub item then why have a popup menu.

My first thoughts are this isn't going to be very clear to the end user.  If you really require this then you may have to resort to owner draw menus.  A posssible alternative is to ignore the SetCheck support and display bitmaps with your menus.  (A blank rectangle and a tick mark) and modify the menu dynamically.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now