simplify dpi-aware coding using default argument

This commit is contained in:
Kang Yu 2023-08-02 15:52:58 -07:00
parent ed49813531
commit 3840a9108a
6 changed files with 7 additions and 7 deletions

View file

@ -12,7 +12,7 @@ namespace PersistentWindows.Common
public DbKeySelect() public DbKeySelect()
{ {
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
InitializeComponent(); InitializeComponent();
} }

View file

@ -12,7 +12,7 @@ namespace PersistentWindows.Common
public LaunchProcess(string process, string title) public LaunchProcess(string process, string title)
{ {
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
InitializeComponent(); InitializeComponent();

View file

@ -11,7 +11,7 @@ namespace PersistentWindows.Common
public LayoutProfile() public LayoutProfile()
{ {
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
InitializeComponent(); InitializeComponent();
} }

View file

@ -10,7 +10,7 @@ namespace PersistentWindows.Common
public string db_entry_name = null; public string db_entry_name = null;
public NameDbEntry() public NameDbEntry()
{ {
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
InitializeComponent(); InitializeComponent();
} }

View file

@ -204,7 +204,7 @@ namespace PersistentWindows.Common
} }
catch (Exception) catch (Exception)
{ {
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
System.Windows.Forms.MessageBox.Show("Another instance is already running.", productName, System.Windows.Forms.MessageBox.Show("Another instance is already running.", productName,
System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxButtons.OK,
@ -719,7 +719,7 @@ namespace PersistentWindows.Common
sessionActive = false; // no new capture sessionActive = false; // no new capture
pauseAutoRestore = true; pauseAutoRestore = true;
User32.SetThreadDpiAwarenessContextSafe(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); User32.SetThreadDpiAwarenessContextSafe();
System.Windows.Forms.MessageBox.Show("Proceed to restore windows", System.Windows.Forms.MessageBox.Show("Proceed to restore windows",
System.Windows.Forms.Application.ProductName, System.Windows.Forms.Application.ProductName,

View file

@ -454,7 +454,7 @@ namespace PersistentWindows.Common.WinApiBridge
public const int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = -3; public const int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = -3;
public const int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = -4; public const int DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = -4;
public const int DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = -5; public const int DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = -5;
public static int SetThreadDpiAwarenessContextSafe(int dpi_awareness_cxt) public static int SetThreadDpiAwarenessContextSafe(int dpi_awareness_cxt = DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)
{ {
var os_version = Environment.OSVersion; var os_version = Environment.OSVersion;
if (os_version.Version.Major < 10) if (os_version.Version.Major < 10)