2

I want to load an appropriate icon size myself before displaying it on the Windows system tray . If I let Windows do this (as suggested on many pages on the net), it uses the wrong icon size and the resulting system tray icon looks bad. I can do a much better job in Photoshop if I find a way to specify which icon size to load.

The task of loading a specific icon size is easy with LoadIconWithScaleDown or even LoadImage, the question is how do I find out the current size of icons displayed in the system tray?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • This has been discussed here: [How do I ask Windows for the size of system tray icons?](http://stackoverflow.com/questions/568199/how-do-i-ask-windows-for-the-size-of-system-tray-icons) I'm not sure if it's helpful though – Mataniko Dec 03 '12 at 05:02
  • @Mataniko: As I said, everyone says, "Let Windows pick" which does not work in my case. – c00000fd Dec 03 '12 at 05:03
  • @chris: Wouldn't small icon size change if a user alters the size of the window's title bar without increasing the DPI for the screen? In this case the system tray size will stay the same. – c00000fd Dec 03 '12 at 05:04
  • @user843732, Yeah, I saw from the other question that it wasn't right. It was just a guess. – chris Dec 03 '12 at 05:06
  • I added the code that I was able to come up with. My best guess was to use the size of context menu checks icons. They seem to be the most consistent with the changing DPI setting. So what do you think? – c00000fd Dec 03 '12 at 06:06

1 Answers1

3

Notification area icons are square icons, of size equal to GetSystemMetrics(SM_CXSMICON). In other words, they are small icons.

The sample code towards the end of the NOTIFYICONDATA documentation gives tacit confirmation of this.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • You mean LoadIconMetric right? Well, I guess that's the only way of doing it. Although again, when OS does the scaling it doesn't always look good... – c00000fd Dec 03 '12 at 20:04
  • No I don't mean that. The question asked for the icon size. That function loads icons. – David Heffernan Dec 03 '12 at 20:06
  • The OS only scales icons if you don't give it the size it needs. Give it icons of the right size and there will be no aliasing. – David Heffernan Dec 03 '12 at 20:08
  • Although the doc I link to uses LoadIconMetric, that's not the only way to do it. That's just an illustration of one way to get an icon that's the right size. I included the link because it's the closest I've seen to official confirmation of what is known in the lore, that notification icons are small icons. You can get your small icons any way you please. – David Heffernan Dec 03 '12 at 20:16
  • I know, if I knew the size of the icon that will be displayed, I'd specify it in one of those API that loads it. Again, finding the correct size that will be displayed seems to be the issue... – c00000fd Dec 03 '12 at 22:10
  • OK, I did the tests and SM_CXSMICON/SM_CYSMICON seems to coincide with the actual system tray icon size (although there's no official documentation that states that.) Thanks. – c00000fd Dec 04 '12 at 05:56