Results 1 to 18 of 18

Thread: How to place an icon next to a menu item

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Question How to place an icon next to a menu item

    Hello. I'm sorry for asking this but for the last hour I've been looking for a simple answer to my question and can't find one.

    Anyways, I am creating a menu on a VB6 form using the menu editor. (I know there's other controls out there that look way better - but I'm a little leary about using an .ocx I didn't create in my program - and I actually don't think the VB6 menu looks that bad).

    How do I place an icon next to my menu item? I am aware of the "SetMenuItemBitmaps" API but this apparently only places a bitmap next to the menu item - whereas I would like to place the .ico file next to it. This is relatively easy to do right??

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to place an icon next to a menu item

    IIRC you can only put bitmaps next to menu items.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: How to place an icon next to a menu item

    y don't you use toolbars or coolbar instead?

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    I'd love to use a coolbar or toolbar for the menu - but it appears to be a lot of work to create a menu that way (or is it?) It's just frustrating because I'm happy with the look of the VB6 menu - which is very easy to create - and all I want to do now is place a little 'ol icon next to the menu item - it must be possible right? I tried using the bitmap but the result looked very poor.

    Does anyone know how to do this??

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How to place an icon next to a menu item

    I hope this helps you....
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    Thanks for the link dee-u. However, as great as that program looks, I'm really just looking for a quick answer. Apparently this must be harder to do than I thought Oh well, I guess I'll just have to live without it (sigh).

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How to place an icon next to a menu item

    It maybe a good investment to learn how did they do it, why dont you try?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to place an icon next to a menu item

    For a basic image to be added to a menu you can use the SetMenuItemBitmaps API. To get the handle
    of the menus you will need to use GetMenu and GetSubMenu APIs also. If you dont have the API Viewer and
    API Guide then you will find more info on them in there.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    I already tried using those APIs - the problem was the bitmap looked terrible - perhaps I was using an incorrect size for the bitmap file? Can you enlighten me on what size the bitmap file needs to be? Thanks...

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to place an icon next to a menu item


  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to place an icon next to a menu item

    It needs to be 16 x 16. The issue with this API method is that the selection covers the image causing it to
    invert and look terrible. You could subclass the menu and do some owner drawing for the cleanest and trickest
    look but its allot of work
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to place an icon next to a menu item

    Nice link Hack but it contains the same highlighting issue
    The only real solution is Owner Drawn menus. The GDI API calls are the ones that you would be interested in.

    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    Yeah that is exactly what I want! - is it that hard to do? I'd be willing to try if I had some code to review. I know how to get the handle of the menu item, so I wouldn't think it be would too difficult beyond that ??

    Also, using this approach can you use the icon file instead of a bitmap??

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to place an icon next to a menu item

    Here are a number of potential examples.

  15. #15

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    Thanks a lot - I'll try it out and let you know whether or not I get it to work...

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to place an icon next to a menu item

    It requires subclassing the menu and measuring and drawing everything on themenu. Text, the selection,
    the 3d box, inverting the color of the text when its selected, etc. So no its not hard at all.

    If I get some time I can whip up a demo for you, but I nned to finish something first.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17

    Thread Starter
    Member
    Join Date
    Aug 2004
    Posts
    56

    Re: How to place an icon next to a menu item

    Thanks to Hack's link I found some code which I believe already does all that - so don't trouble yourself with putting together a demo for now. I'll try it out later today and if it doesn't work then I may take you up on your offer (as the menus in your screenshot are exactly what I'm trying to achieve...)

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to place an icon next to a menu item

    Ok, those menus are duplicating the Office 2000 style menus
    Just let me know if you need any more help
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width