Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Feb 5, 2025
1 parent d079525 commit f3c9abe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/Files.App.CsWin32/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ FindWindow
SendMessage
IsWindowVisible
COPYDATASTRUCT
SetWindowLongPtr
GetDpiForWindow
CallWindowProc
MINMAXINFO
Expand Down
19 changes: 19 additions & 0 deletions src/Files.App.CsWin32/Windows.Win32.Extras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,23 @@ namespace UI.WindowsAndMessaging
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate LRESULT WNDPROC(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam);
}

public static partial class PInvoke
{
[DllImport("User32", EntryPoint = "SetWindowLongW", ExactSpelling = true)]
static extern int _SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);

[DllImport("User32", EntryPoint = "SetWindowLongPtrW", ExactSpelling = true)]
static extern nint _SetWindowLongPtr(HWND hWnd, int nIndex, nint dwNewLong);

// NOTE:
// CsWin32 doesn't generate SetWindowLong on other than x86 and vice versa.
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
public static unsafe nint SetWindowLongPtr(HWND hWnd, UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)

Check failure on line 32 in src/Files.App.CsWin32/Windows.Win32.Extras.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

The type or namespace name 'WINDOW_LONG_PTR_INDEX' does not exist in the namespace 'Windows.Win32.UI.WindowsAndMessaging' (are you missing an assembly reference?)

Check failure on line 32 in src/Files.App.CsWin32/Windows.Win32.Extras.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

The type or namespace name 'WINDOW_LONG_PTR_INDEX' does not exist in the namespace 'Windows.Win32.UI.WindowsAndMessaging' (are you missing an assembly reference?)

Check failure on line 32 in src/Files.App.CsWin32/Windows.Win32.Extras.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

The type or namespace name 'WINDOW_LONG_PTR_INDEX' does not exist in the namespace 'Windows.Win32.UI.WindowsAndMessaging' (are you missing an assembly reference?)

Check failure on line 32 in src/Files.App.CsWin32/Windows.Win32.Extras.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

The type or namespace name 'WINDOW_LONG_PTR_INDEX' does not exist in the namespace 'Windows.Win32.UI.WindowsAndMessaging' (are you missing an assembly reference?)
{
return sizeof(nint) is 4
? (nint)_SetWindowLong(hWnd, (int)nIndex, (int)dwNewLong)
: _SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
}
}
}

0 comments on commit f3c9abe

Please sign in to comment.