You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When changing the dpi size, it is necessary to restart the app. also mentioned here #418 (comment))
we once had in code that it restarts automatically (we removed here #223). This is not the right solution at all. For example when you start certain games, a dpi changed event comes up with 150%. If you switch back to the desktop you get a 100% again. We don't want to burden the system with loading during this time.
So it would need live adjustment of size like windows explorer do.
But then we have another problem. The STM is able to pop up in front of full screen games. This should not appear in 150%, since 100% is normally set on the desktop. For the correct solution we would have to accept this problem.
But there are other problems with a live adjustment. Another problem are the icons, we would have to reload them depending on the dpi which in turn is again not acceptable since we are putting a strain on the system.
we will put the topic on hold for the time being, as there is no solution that meets all requirements.
here is some information about the code for the topic.
-When i create a new project .net6 windows forms, then it automatically changes size when move app between two displays with different dpi size. The app looks blurry and doesn't solve our problems described above. We have explicitly prevented this in the STM in the menu. This works with the STM options menu.
-In the STM menu, we only set a flag to adjust location via SystemEvents_DisplaySettingsChanged at next menu open
-We calculate the dpi size at startup trough
-There are many described solution to detect the dpi size at runtime, this is the only thing that worked for us. But we can not use it in principle because to recognizing the dpi size and reacting to a difference does not help us as described above
// <copyright file="GetDpiRatio.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace SystemTrayMenu.DllImports
{
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SystemTrayMenu.Utilities;
/// <summary>
/// wraps the methodcalls to native windows dll's.
/// </summary>
public static partial class NativeMethods
{
private enum DpiType
{
Effective = 0,
Angular = 1,
Raw = 2,
}
public static float GetDpiRatio(IntPtr hwnd)
{
var dpi = GetDpi(hwnd, DpiType.Effective);
return dpi / 96f;
}
private static uint GetDpi(IntPtr hwnd, DpiType dpiType)
{
var screen = Screen.FromHandle(hwnd);
var pnt = new Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
var mon = MonitorFromPoint(pnt, 2 /*MONITOR_DEFAULTTONEAREST*/);
try
{
GetDpiForMonitor(mon, dpiType, out uint dpiX, out uint dpiY);
return dpiX;
}
catch (Exception ex)
{
Log.Warn($"Failed to {nameof(GetDpi)}", ex);
return 96;
}
}
[DllImport("User32.dll")]
private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags);
[DllImport("Shcore.dll")]
private static extern IntPtr GetDpiForMonitor([In] IntPtr hmonitor, [In] DpiType dpiType, [Out] out uint dpiX, [Out] out uint dpiY);
}
}
maybe we'll tackle the problem again in the future, maybe also in a new GUI framework like MAUI, currently i don't see a solution and we'll leave everything as it is for now.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When changing the dpi size, it is necessary to restart the app. also mentioned here #418 (comment))
we once had in code that it restarts automatically (we removed here #223). This is not the right solution at all. For example when you start certain games, a dpi changed event comes up with 150%. If you switch back to the desktop you get a 100% again. We don't want to burden the system with loading during this time.
So it would need live adjustment of size like windows explorer do.
But then we have another problem. The STM is able to pop up in front of full screen games. This should not appear in 150%, since 100% is normally set on the desktop. For the correct solution we would have to accept this problem.
But there are other problems with a live adjustment. Another problem are the icons, we would have to reload them depending on the dpi which in turn is again not acceptable since we are putting a strain on the system.
we will put the topic on hold for the time being, as there is no solution that meets all requirements.
here is some information about the code for the topic.
-When i create a new project .net6 windows forms, then it automatically changes size when move app between two displays with different dpi size. The app looks blurry and doesn't solve our problems described above. We have explicitly prevented this in the STM in the menu. This works with the STM options menu.
-In the STM menu, we only set a flag to adjust location via SystemEvents_DisplaySettingsChanged at next menu open
-We calculate the dpi size at startup trough
-There are many described solution to detect the dpi size at runtime, this is the only thing that worked for us. But we can not use it in principle because to recognizing the dpi size and reacting to a difference does not help us as described above
maybe we'll tackle the problem again in the future, maybe also in a new GUI framework like MAUI, currently i don't see a solution and we'll leave everything as it is for now.
Beta Was this translation helpful? Give feedback.
All reactions