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

Date:February 28, 2013 / year-entry #57
Tags:code
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20130228-00/?p=5113
Comments:    4
Summary: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 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.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index