I wrote an application that uses a user control generating and displaying enhanced metafiles on pictureboxes. This works fine when displaying the application's forms on the PC where the application is running on. It is indispensable to remotely log into this PC using Windows remote login. In this case the display resolution and the magnification factor (can be set to 100%, 125%, 150% …) may change for the application while it is running. I found that changing the display resolution does not result in viewing the graphics in wrong size. But changing the magnification factor results in viewing graphics in the wrong size accordingly to the magnification factor.
I am searching for a solution to determine the "magnification factor". This would help to fix the problem sustainable.
I already searched for hours to find something that helps, but did not succeed:
Reading the resolution does not help:
Dim test As Graphics = MyControl.CreateGraphics Dim Resolution As Single = test.DpiX ' Returns 96 under all conditions
I also tried some API- calls with the same result (always 96 DPI).Enabling / disabling DPI- awareness did not help.
Reading the screen resolution can help to find a factor, but this is also not sufficient, because it is not possible to distinguish between changes in resolution and changes of the magnification.
System.Windows.SystemParameters.PrimaryScreenWidth ' Value is updated only when starting the app Screen.PrimaryScreen.Bounds.Width ' Value updated, but depends on resolution setting and magnification setting System.Windows.SystemParameters.PrimaryScreenWidth / Screen.PrimaryScreen.Bounds.Width ' Factor useless