checkmark/icon in submenu[owner draw menu]
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: checkmark/icon in submenu[owner draw menu]

  1. #1
    Join Date
    Dec 2008
    Posts
    28

    checkmark/icon in submenu[owner draw menu]

    Hi, Is there any ways for me to add a check marks or icon into the submenu?

    I'm currently creating owner draw menu.
    So far, I only able to print out the text into the submenu... I failed to put the check mark/icon into it.. Any help will be appreciated

    Currently all my drawing are done at:

    DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
    {

    }

    Regards,
    KH
    Last edited by karhong; December 17th, 2008 at 04:34 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    178

    Re: checkmark/icon in submenu[owner draw menu]

    See MSDN owner-drawn menu samples

  3. #3

    Re: checkmark/icon in submenu[owner draw menu]

    Check out the
    ON_UPDATE_COMMAND_UI() macro. This allows you to update menu items dynamically, and enable/disable menu items as well as set the checkflag.

    Here's a sample for a 'large view' menu item.

    In your message map, add this line...

    Code:
     
    ON_UPDATE_COMMAND_UI(ID_EDIT_SHOWLARGE, OnUpdateCommand)
    And here's a sample function...

    Code:
     
    void CMainFrame::OnUpdateCommand(CCmdUI* pCmdUI)
    {
        switch(pCmdUI->m_nID) {
        case ID_EDIT_SHOWLARGE:
            pCmdUI->SetCheck(m_large_view);
            break;
        }
    }
    The pCmdUI pointer passed in allows many different menu items to share the same OnUpdateCommand function, or you can use different functions for different menu items.

    This OnUpdateCommand() function is called each time the menu is displayed, so it's a handy way to make sure your menu items are updated each time they are needed.

    As for the icons, you might want to start using the new MFC classes in VS2008 - these support icons and everything else you need for nice menus. You just create a toolbar icon with the same ID as the menu item, and it picks up the toolbar icon and puts it in the menu bar. I'm using the old BCG classes from before Microsoft bought them, so I haven't used the Microsoft versions yet, but they are essentially the same functionality.

  4. #4
    Join Date
    Dec 2008
    Posts
    28

    Re: checkmark/icon in submenu[owner draw menu]

    oh thanks !!
    it worked out now ! ^^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center