How to add icon for MF_POPUP menu item

Ivan.Zhang
2011-11-01
2013-05-28
  • Ivan.Zhang

    Ivan.Zhang - 2011-11-01

    Hi, David,
    I know how to add icon for nomal menu item using:
    AddMenuIcon(int nID_MenuItem, HICON hIcon, int cx /*= 16*/, int cy /*= 16*/)
    but for MP_POPUP menu item, it has no menu ID, then how can I add an icon for such menu item?
    Thank you.

     
  • David

    David - 2011-11-02

    Hi,

    I don't mean to evade your question, but I'm not sure what you're referring to here. I assume "MP_POPUP" is a miss-type, but MF_POPUP isn't a type of menu item either.

    MF_POPUP is a flag used by several functions which work with menus, but these function also have a HMENU parameter. It is the HMENU parameter that defines the menu items along with their associated menu IDs.

    Best regards,
    David

     
  • Ivan.Zhang

    Ivan.Zhang - 2011-11-08

    Hi, David,
    thank you for your response.
    But, I didn't figure out how to get the itemID of a menu item with MF_POPUP style…

     
  • David

    David - 2011-11-09

    Hi,

    Generally speaking, menu items with the MF_POPUP style don't have an itemID.  When the menu is defined in a resource script it is impossible to assign an ID to the menu item, as far as I'm aware.

    The function used to retrieve any menu item's information is GetMenuItemInfo. It might be possible to assign an ID to a menu item with the MF_POPUP with the SetMenuItemInfo function, in which case GetMenuItemInfo could be used to retrieve it.

    I haven't seen an application display an icon for a menu item with MF_POPUP style, so I suspect that this is a rather unusual thing to do. Still, you can display anything you like for a popup menu if you're prepared to do your own owner-drawing of menus.

    Best regards,
    David

     
  • Ivan.Zhang

    Ivan.Zhang - 2011-11-09

    David, thank you, I'll have a try.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks