Skip to content

Commit 8542c54

Browse files
committed
Clean up code for GetDpiForWindow
1 parent cb0b47b commit 8542c54

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ SendMessage
9797
IsWindowVisible
9898
COPYDATASTRUCT
9999
WINDOW_LONG_PTR_INDEX
100-
GetDpiForWindow
101100
CallWindowProc
102101
MINMAXINFO
103102
SUBCLASSPROC

src/Files.App/Data/Models/AppModel.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Microsoft.UI.Xaml.Controls;
55
using System.Runtime.InteropServices;
66
using Windows.ApplicationModel.DataTransfer;
7+
using Windows.Win32;
8+
using Windows.Win32.Foundation;
79

810
namespace Files.App.Data.Models
911
{
@@ -127,12 +129,11 @@ public string PCloudDrivePath
127129

128130
/// <summary>
129131
/// Gets or sets a value indicating the AppWindow DPI.
130-
/// TODO update value if the DPI changes
131132
/// </summary>
132-
private float _AppWindowDPI = Win32PInvoke.GetDpiForWindow(MainWindow.Instance.WindowHandle) / 96f;
133-
public float AppWindowDPI
133+
private float _AppWindowDPI = PInvoke.GetDpiForWindow((HWND)MainWindow.Instance.WindowHandle) / 96f;
134+
public float AppWindowDPI // TODO: Update value if the DPI changes
134135
{
135-
get => _AppWindowDPI;
136+
get => _AppWindowDPI;
136137
set => SetProperty(ref _AppWindowDPI, value);
137138
}
138139
}

src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ public static extern bool SetEvent(
7676
IntPtr hEvent
7777
);
7878

79-
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
80-
public static extern int GetDpiForWindow(
81-
IntPtr hwnd
82-
);
83-
8479
[DllImport("ole32.dll")]
8580
public static extern uint CoWaitForMultipleObjects(
8681
uint dwFlags,

0 commit comments

Comments
 (0)