mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Settings]Remember maximized state (#31424)
* restore settings in maximized state * fix using
This commit is contained in:
committed by
GitHub
parent
0afec7293b
commit
e607b26df6
@@ -7,7 +7,6 @@ using ManagedCommon;
|
||||
using Microsoft.PowerLauncher.Telemetry;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
|
||||
using Microsoft.PowerToys.Settings.UI.Views;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using Microsoft.UI;
|
||||
@@ -41,6 +40,9 @@ namespace Microsoft.PowerToys.Settings.UI
|
||||
if (createHidden)
|
||||
{
|
||||
placement.ShowCmd = NativeMethods.SW_HIDE;
|
||||
|
||||
// Restore the last known placement on the first activation
|
||||
this.Activated += Window_Activated;
|
||||
}
|
||||
|
||||
NativeMethods.SetWindowPlacement(hWnd, ref placement);
|
||||
@@ -213,6 +215,17 @@ namespace Microsoft.PowerToys.Settings.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Activated(object sender, WindowActivatedEventArgs args)
|
||||
{
|
||||
if (args.WindowActivationState != WindowActivationState.Deactivated)
|
||||
{
|
||||
this.Activated -= Window_Activated;
|
||||
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
||||
var placement = Utils.DeserializePlacementOrDefault(hWnd);
|
||||
NativeMethods.SetWindowPlacement(hWnd, ref placement);
|
||||
}
|
||||
}
|
||||
|
||||
internal void EnsurePageIsSelected()
|
||||
{
|
||||
ShellPage.EnsurePageIsSelected();
|
||||
|
||||
Reference in New Issue
Block a user