[OOBE]Fix msgMonitor to prevent window maximizing (#31136)

This commit is contained in:
Stefan Markovic
2024-01-26 14:29:18 +01:00
committed by GitHub
parent 6da7e3ae39
commit ddeb856372

View File

@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class OobeWindow : WindowEx
public sealed partial class OobeWindow : WindowEx, IDisposable
{
private PowerToysModules initialModule;
@@ -31,6 +31,8 @@ namespace Microsoft.PowerToys.Settings.UI
private WindowId _windowId;
private IntPtr _hWnd;
private AppWindow _appWindow;
private WindowMessageMonitor _msgMonitor;
private bool disposedValue;
public OobeWindow(PowerToysModules initialModule)
{
@@ -59,8 +61,8 @@ namespace Microsoft.PowerToys.Settings.UI
this.initialModule = initialModule;
var msgMonitor = new WindowMessageMonitor(this);
msgMonitor.WindowMessageReceived += (_, e) =>
_msgMonitor = new WindowMessageMonitor(this);
_msgMonitor.WindowMessageReceived += (_, e) =>
{
const int WM_NCLBUTTONDBLCLK = 0x00A3;
if (e.Message.MessageId == WM_NCLBUTTONDBLCLK)
@@ -132,5 +134,22 @@ namespace Microsoft.PowerToys.Settings.UI
mainWindow.CloseHiddenWindow();
}
}
private void Dispose(bool disposing)
{
if (!disposedValue)
{
_msgMonitor?.Dispose();
disposedValue = true;
}
}
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}