Compare commits

...

1 Commits

Author SHA1 Message Date
qhy040404
9d631b54b4 fix #1571 2024-04-25 22:03:04 +08:00
2 changed files with 31 additions and 3 deletions

View File

@@ -48,6 +48,7 @@ internal sealed class WindowSubclass : IDisposable
{
windowProc = OnSubclassProcedure;
bool windowHooked = SetWindowSubclass(options.Hwnd, windowProc, WindowSubclassId, 0);
bool propHooked = SetPropW(options.Hwnd, "NonRudeHWND", BOOL.TRUE);
hotKeyController.RegisterAll();
bool titleBarHooked = true;
@@ -55,7 +56,7 @@ internal sealed class WindowSubclass : IDisposable
// only hook up drag bar proc when use legacy Window.ExtendsContentIntoTitleBar
if (!options.UseLegacyDragBarImplementation)
{
return windowHooked && titleBarHooked;
return windowHooked && propHooked && titleBarHooked;
}
titleBarHooked = false;
@@ -63,13 +64,13 @@ internal sealed class WindowSubclass : IDisposable
if (hwndDragBar.IsNull)
{
return windowHooked && titleBarHooked;
return windowHooked && propHooked && titleBarHooked;
}
legacyDragBarProc = OnLegacyDragBarProcedure;
titleBarHooked = SetWindowSubclass(hwndDragBar, legacyDragBarProc, DragBarSubclassId, 0);
return windowHooked && titleBarHooked;
return windowHooked && propHooked && titleBarHooked;
}
/// <inheritdoc/>
@@ -78,6 +79,7 @@ internal sealed class WindowSubclass : IDisposable
hotKeyController.UnregisterAll();
RemoveWindowSubclass(options.Hwnd, windowProc, WindowSubclassId);
RemovePropW(options.Hwnd, "NonRudeHWND");
windowProc = default!;
if (options.UseLegacyDragBarImplementation)

View File

@@ -85,6 +85,19 @@ internal static class User32
[SupportedOSPlatform("windows5.0")]
public static extern int ReleaseDC([AllowNull] HWND hWnd, HDC hDC);
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern HANDLE RemovePropW(HWND hWnd, PCWSTR lpString);
[DebuggerStepThrough]
public static unsafe HANDLE RemovePropW(HWND hWnd, string str)
{
fixed (char* lpString = str)
{
return RemovePropW(hWnd, lpString);
}
}
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern uint SendInput(uint cInputs, INPUT* pInputs, int cbSize);
@@ -102,6 +115,19 @@ internal static class User32
[SupportedOSPlatform("windows5.0")]
public static extern BOOL SetForegroundWindow(HWND hWnd);
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern BOOL SetPropW(HWND hWnd, PCWSTR lpString, [AllowNull] nint hData);
[DebuggerStepThrough]
public static unsafe BOOL SetPropW(HWND hWnd, string str, [AllowNull] nint hData)
{
fixed (char* lpString = str)
{
return SetPropW(hWnd, lpString, hData);
}
}
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern nint SetWindowLongPtrW(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong);