Skip to content

Commit 704c187

Browse files
authored
Code Quality: Replaced DllImport calls with CsWin32 generations for DPI calculation operations (#17118)
1 parent dcc5875 commit 704c187

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

src/Files.App.CsWin32/NativeMethods.txt

-1
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

+3-2
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,9 +129,8 @@ 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+
private float _AppWindowDPI = PInvoke.GetDpiForWindow((HWND)MainWindow.Instance.WindowHandle) / 96f;
133134
public float AppWindowDPI
134135
{
135136
get => _AppWindowDPI;

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

-5
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)