Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding icon to Menu and MenuItem #291

Open
eugenesvk opened this issue Apr 24, 2024 · 5 comments
Open

Allow adding icon to Menu and MenuItem #291

eugenesvk opened this issue Apr 24, 2024 · 5 comments

Comments

@eugenesvk
Copy link

eugenesvk commented Apr 24, 2024

So you could have menu items like this

men_icon

Also, is it possible to just add text to that empty area? As emoji icon could serve the purpose of a real image

@nickbeth
Copy link

nickbeth commented May 1, 2024

Hey, I wrote some extension methods for native-windows-gui for my app, and that includes a function to set a bitmap to a menu item. Here you can find the implementation, you're free to use it in your project as long as you respect the MIT license ;)

You might need to modify it a little as I'm using the windows-sys crate for the Windows calls and you might want to use winapi instead, but it should take very little effort to adjust it.

@eugenesvk
Copy link
Author

Thanks! Will take a look (and MIT is one of the most respected licenses ;))

@eugenesvk
Copy link
Author

Do you know how to add an icon to the whole menu group, not just its items (for which your extension works fine, thanks!). I've tried a similar thing for the Menu, but there are no bitmap fields/arguments for the MenuInfo equivalent to menuitems?

@nickbeth
Copy link

nickbeth commented May 2, 2024

I have no idea myself, you'll have to dive deep into the Win32 API and see if what you want can be done. If there is a way, it can be done as an extension to native-windows-gui objects.

@eugenesvk eugenesvk changed the title Allow adding icon to menu items Allow adding icon to Menu and MenuItem May 3, 2024
@eugenesvk
Copy link
Author

Another look revealed that Menu is constructed the same way as MenuItem, so I can tweak you impl to apply an icon to it as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants