Disable DPI Awareness

Symptom

Very rarely, but it does happen, that developers are faced with a very strange behaviour where their winForm application automatically changes it size on start up when DicomObjects.NET version 8 is loaded. Using earlier versions will not give the same behaviour.

Root Cause

This scaling issue is caused by PresentationCore.dll (which is referneced by DicomObjects.NET v8 for 3D related data structures) which makes a call to SetProcessDPIAware when it is loaded. This changes the application’s DPIAwareness after a form’s initialization is started.

Solution

There are several ways to disable the application’s DPI Awareness. But the easiest would be to add the following line in your application’s AssemblyInfo file

  
 [assembly: System.Windows.Media.DisableDpiAwareness] 

Note, reference to WindowsBase is required in your project to make this work.


We use cookies to give you the best possible experience on our website. By continuing to use this website, you agree with our use of cookies. for more information please click HERE