Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ask Windows for the size of system tray icons?

I noticed that my app sends icons to the Windows tray with a size of 16x16 pixels--and my Vista PC I've got a doublewide taskbar that appears to show icons at 18x18. The resizing artifacts on my app's icon look awful. How can I ask Windows what size the icons should be?

Edit

I'm generating the icon dynamically, with a pixel font text overlay. It seems wasteful to generate a bunch of icon sizes dynamically, so it would be nice to avoid building an icon with all the "possible" sizes (not that I'm even sure what those are).

  • GetSystemMetrics(SM_CXSMICON) returns 16--the incorrect value.
  • GetThemeBackgroundContentRect didn't help, either.
like image 532
keelo Avatar asked May 04 '26 21:05

keelo


1 Answers

Create your icons in multiple formats, and let Windows select the one it wants.

Here's the Wikipedia article on the .ico format.

If you really need to know, GetSystemMetrics with a parameter of SM_CXICON or SM_CYICON will tell you the width and height that Windows wants to load.

like image 70
Mark Ransom Avatar answered May 06 '26 12:05

Mark Ransom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!