Is there a way to specify an icon to appear next to a menu item via the resource template?


The MENU­ITEM­INFO structure lets you specify a bitmap to appear next to the menu item. Is there a way to do this from a menu resource template?

No.

If you look at the format of menu templates, you’ll see that there is nowhere to specify a bitmap.

Which kind of makes sense, because it is the responsibility of the application to destroy the bitmap referenced by the hbmpItem member when the menu is destroyed, but if you created the menu from a template, you don’t know what that handle is, so you can’t destroy it either!

Comments (4)
  1. Joshua says:

    [Which kind of makes sense, because it is the responsibility of the application to destroy the bitmap referenced by the hbmpItem member when the menu is destroyed, but if you created the menu from a template, you don't know what that handle is, so you can't destroy it either!]

    I'm sure there are cases where resource-created menus are destroyed, but I've not seen one yet.

    [I discussed this nearly a decade ago. -Raymond]
  2. Joshua says:

    [I discussed this nearly a decade ago. -Raymond]

    That explains it. I've only ever used resource menus for RegisterWindowClass. When I create a popup menu, it's always dynamic from the current context so the only resource is the string resource (translation table [My translation tables aren't actually in the .rc but the concept is almost exactly the same]).

  3. GregM says:

    "I discussed this nearly a decade ago."

    Ow, that hurt.  I haven't been reading TONT since the beginning, but pretty close.  Hard to believe it's been nearly a decade.

  4. . says:

    What hurts is using this byggy blogging software for decades.

Comments are closed.