locked
The Icons For Menu Items RRS feed

  • Question

  • Hi

    Which way is better to set icons for the menu items:

    1- Make owner draw menu

    2- Using hbmpItem member of MENUITEMINFO structure

    I think in prior Windows Vista, the system does not show correctly 32  bit icons for menus if we use way #2

    Also if we use way #2 we need to destroy the bitmap handle or system do it?

    Saturday, November 19, 2016 3:37 PM

All replies

  • 1 - Owner draw requires more work than #2.

    2 - The application is responsible for destroying the bitmap.  See SetMenuItemBitmaps function where it says "When the menu is destroyed, these bitmaps are not destroyed; it is up to the application to destroy them. "

    • Proposed as answer by Eddie Lotter Saturday, November 19, 2016 3:57 PM
    Saturday, November 19, 2016 3:52 PM
  • I test the way #2, but the result is not good! for the first time menu opened icon is displayed as screenshot 1 and after redrawing it by moving pointer on it, shows like screenshot 2 even in the screenshot 2 the icon is not anti-alised and alpha channel is not correctly composited.

    I use a pre-multiplied alpha channel image and load the bitmap using LoadImage()+LR_CREATEDIBSECTION.

    The best way is still owner draw menu.


    • Edited by drjackool Saturday, November 19, 2016 7:29 PM
    Saturday, November 19, 2016 7:28 PM
  • Hi drjackool,

    thanks for posting here.

    >>Which way is better to set icons for the menu items:

    1- Make owner draw menu

    2- Using hbmpItem member of MENUITEMINFO structure

    I think in prior Windows Vista, the system does not show correctly 32  bit icons for menus if we use way #2

    In my opinion, there has no best ways. Either of these two ways could help you implement drawing Menu-Item Bitmaps.

    For new applications, you can use the SetMenuItemInfo or InsertMenuItem function to set the MIIM_BITMAP type flag. To change a menu item from a text item to a bitmap item, use SetMenuItemInfo. To add a new bitmap item to a menu, use the InsertMenuItem function.

    Applications written for earlier versions of the system can continue to use the ModifyMenu, InsertMenu, or AppendMenu functions to set the MF_BITMAP flag. To change a menu item from a text string item to a bitmap item, use ModifyMenu. To add a new bitmap item to a menu, use the MF_BITMAP flag with the InsertMenu or AppendMenu function.

    If you need complete control over the appearance of a menu item, you can use an owner-drawn menu item in your application. This section describes the steps involved in creating and using an owner-drawn menu item.

    For more information and sample codes, please refer to this document.

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms647558(v=vs.85).aspx#_win32_Example_of_Menu_Item_Bitmaps

    Hope this could be help of you.

    Best Regards,
    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Baron Bi Monday, November 28, 2016 7:04 AM
    Tuesday, November 22, 2016 9:34 AM
  • Thanks.How to prevent the system from drawing sybmenu arrow in the owner draw menu?
    Tuesday, November 22, 2016 1:00 PM
  • Hi drjackool,

    >>Thanks.How to prevent the system from drawing sybmenu arrow in the owner draw menu?

    You could use MENUITEMINFO without setting MIIM_SUBMENU to disable the submenu.

    Hope this could be help you.

    Best Regards,

    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Baron Bi Monday, November 28, 2016 7:04 AM
    Thursday, November 24, 2016 6:20 AM