diff --git a/src/Files.App.CsWin32/Files.App.CsWin32.csproj b/src/Files.App.CsWin32/Files.App.CsWin32.csproj
index 2a1d7733b97e..1f60d2e9e4fc 100644
--- a/src/Files.App.CsWin32/Files.App.CsWin32.csproj
+++ b/src/Files.App.CsWin32/Files.App.CsWin32.csproj
@@ -11,6 +11,7 @@
win-x86;win-x64;win-arm64
TRACE;DEBUG;NETFX_CORE
TRACE;RELEASE;NETFX_CORE
+ $(DefineConstants);$(Platform)
true
diff --git a/src/Files.App.CsWin32/NativeMethods.txt b/src/Files.App.CsWin32/NativeMethods.txt
index c521ed9b183b..86837b295466 100644
--- a/src/Files.App.CsWin32/NativeMethods.txt
+++ b/src/Files.App.CsWin32/NativeMethods.txt
@@ -99,6 +99,7 @@ SendMessage
IsWindowVisible
COPYDATASTRUCT
SetWindowLongPtr
+SetWindowLong
GetDpiForWindow
CallWindowProc
MINMAXINFO
diff --git a/src/Files.App.CsWin32/Windows.Win32.Extras.cs b/src/Files.App.CsWin32/Windows.Win32.Extras.cs
index 048d8d1f7681..fdb0fa60345b 100644
--- a/src/Files.App.CsWin32/Windows.Win32.Extras.cs
+++ b/src/Files.App.CsWin32/Windows.Win32.Extras.cs
@@ -17,4 +17,16 @@ namespace UI.WindowsAndMessaging
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate LRESULT WNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam);
}
+
+ public static partial class PInvoke
+ {
+ public static nint SetWindowLongPlat(HWND hWnd, UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)
+ {
+#if x86
+ return SetWindowLong(hWnd, nIndex, (int)dwNewLong);
+#else
+ return SetWindowLongPtr(hWnd, nIndex, dwNewLong);
+#endif
+ }
+ }
}
diff --git a/src/Files.App/Data/Items/WindowEx.cs b/src/Files.App/Data/Items/WindowEx.cs
index 782788918989..b1cf044cb990 100644
--- a/src/Files.App/Data/Items/WindowEx.cs
+++ b/src/Files.App/Data/Items/WindowEx.cs
@@ -102,7 +102,7 @@ public unsafe WindowEx(int minWidth = 400, int minHeight = 300)
_newWndProc = new(NewWindowProc);
var pNewWndProc = Marshal.GetFunctionPointerForDelegate(_newWndProc);
- var pOldWndProc = PInvoke.SetWindowLongPtr(new(WindowHandle), WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, pNewWndProc);
+ var pOldWndProc = PInvoke.SetWindowLongPlat(new(WindowHandle), WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, pNewWndProc);
_oldWndProc = Marshal.GetDelegateForFunctionPointer(pOldWndProc);
Closed += WindowEx_Closed;
diff --git a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs
index c001531701fa..1c866363dc4b 100644
--- a/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs
+++ b/src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs
@@ -249,11 +249,11 @@ public unsafe void PointerEntered(bool onPreview)
(uint)Marshal.SizeOf(dwAttrib));
if (isOfficePreview)
- PInvoke.SetWindowLongPtr(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, 0);
+ PInvoke.SetWindowLongPlat(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, 0);
}
else
{
- PInvoke.SetWindowLongPtr(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (nint)(WINDOW_EX_STYLE.WS_EX_LAYERED | WINDOW_EX_STYLE.WS_EX_COMPOSITED));
+ PInvoke.SetWindowLongPlat(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (nint)(WINDOW_EX_STYLE.WS_EX_LAYERED | WINDOW_EX_STYLE.WS_EX_COMPOSITED));
var dwAttrib = Convert.ToUInt32(true);