1

I am trying to figure out why my application's icons display differently when the program is running from the Program Files (x86) directory.

When running the Release version of the code from the Release folder, the ToolStripMenuItem icon displays correctly inside of the right-click menu of the NotifyIcon. However, when I move the executable to the Program Files (x86) folder, the icons are suddenly smaller:

Release Folder Program Files (x86) Folder
icons display correctly icons display incorrectly

I have reviewed the following options and they have not solved the issue:

  1. notifyicon image looks terrible once image ends up in system tray
  2. Change size of ToolStripMenuItem

More information:

  • dpi scaling is already enabled in the app.manifest file
  • The icons are stored in an ImageList, then copied to the menu items as needed
  • The icon is loaded using Icon.ExtractAssociatedIcon(tp.path).ToBitmap()

I am going to continue attempting things, and hopefully find a fix. Any and all suggestions welcome.

Update #1

I created the following project locally (https://www.codeproject.com/Tips/627796/Doing-a-NotifyIcon-Program-the-Right-Way) and noticed that seems to be a problem with adding DPI awareness. By adding the code to make the app DPI aware (see link 1 above), the menu icons look as follows:

Before DPI Aware After DPI Aware
enter image description here enter image description here
SamuelSVD
  • 112
  • 2
  • 9
  • 1
    Care to show us your code? Or point out any differences to this: https://www.codeproject.com/Tips/627796/Doing-a-NotifyIcon-Program-the-Right-Way – Jeremy Thompson Mar 30 '22 at 05:58
  • Okay this got me closer to the problem. I found that it might be a result of making the app DPI aware. See update. It's a bit difficult to narrow down only the code for the notify icon but I'll try to mock something similar up. – SamuelSVD Mar 30 '22 at 06:28

1 Answers1

0

Looks like this is an issue with how Windows interprets 32-bit and 64-bit applications.

An application built for a 32-bit machine placed inside of Program Files (x86) on a 64-bit machine with scaling not set to 100% will encounter issues in scaling the WinForms application. When the application is built for a 64-bit machine and placed in the Program Files folder this issue goes away.

The fix for this is to create a 64-bit build of the application and place it under Program Files.

SamuelSVD
  • 112
  • 2
  • 9