Skip to content

Commit fb226a7

Browse files
authored
Specify SetWindowLong for x86 configuration
1 parent 829b2a4 commit fb226a7

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

src/Files.App.CsWin32/Files.App.CsWin32.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
66
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
77
<IsTrimmable>true</IsTrimmable>
8+
<DefineConstants Condition="'$(Platform)' == 'x86'">X86</DefineConstants>
89
</PropertyGroup>
910

1011
<ItemGroup>

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ SendMessage
9999
IsWindowVisible
100100
COPYDATASTRUCT
101101
SetWindowLongPtr
102+
SetWindowLong
102103
GetDpiForWindow
103104
CallWindowProc
104105
MINMAXINFO

src/Files.App.CsWin32/Windows.Win32.Extras.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ namespace UI.WindowsAndMessaging
1717
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
1818
public delegate LRESULT WNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam);
1919
}
20+
21+
public static partial class PInvoke
22+
{
23+
public static nint SetWindowLongPlat(HWND hWnd, UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)
24+
{
25+
#if X86
26+
return SetWindowLong(hWnd, nIndex, (int)dwNewLong);
27+
#else
28+
return SetWindowLongPtr(hWnd, nIndex, dwNewLong);
29+
#endif
30+
}
31+
}
2032
}

src/Files.App/Data/Items/WindowEx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public unsafe WindowEx(int minWidth = 400, int minHeight = 300)
102102

103103
_newWndProc = new(NewWindowProc);
104104
var pNewWndProc = Marshal.GetFunctionPointerForDelegate(_newWndProc);
105-
var pOldWndProc = PInvoke.SetWindowLongPtr(new(WindowHandle), WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, pNewWndProc);
105+
var pOldWndProc = PInvoke.SetWindowLongPlat(new(WindowHandle), WINDOW_LONG_PTR_INDEX.GWL_WNDPROC, pNewWndProc);
106106
_oldWndProc = Marshal.GetDelegateForFunctionPointer<WNDPROC>(pOldWndProc);
107107

108108
Closed += WindowEx_Closed;

src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ public unsafe void PointerEntered(bool onPreview)
249249
(uint)Marshal.SizeOf(dwAttrib));
250250

251251
if (isOfficePreview)
252-
PInvoke.SetWindowLongPtr(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, 0);
252+
PInvoke.SetWindowLongPlat(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, 0);
253253
}
254254
else
255255
{
256-
PInvoke.SetWindowLongPtr(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (nint)(WINDOW_EX_STYLE.WS_EX_LAYERED | WINDOW_EX_STYLE.WS_EX_COMPOSITED));
256+
PInvoke.SetWindowLongPlat(new((nint)hwnd), WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (nint)(WINDOW_EX_STYLE.WS_EX_LAYERED | WINDOW_EX_STYLE.WS_EX_COMPOSITED));
257257

258258
var dwAttrib = Convert.ToUInt32(true);
259259

0 commit comments

Comments
 (0)