Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue restoring a maximized window using OverlappedPresenter.Restore(true) #9822

Open
AmelBawa-msft opened this issue Jul 15, 2024 · 2 comments
Labels
area-AppWindow bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team

Comments

@AmelBawa-msft
Copy link

Describe the bug

This is related to this issue in Dev Home, where attempting to restore a maximized window when it's in iconic mode does not get maximized again.

Code where this behavior occurs:

var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
if (PInvoke.IsIconic(new HWND(hWnd)) && MainWindow.AppWindow.Presenter is OverlappedPresenter overlappedPresenter)
{
    overlappedPresenter.Restore(true);
}
else
{
    PInvoke.SetForegroundWindow(new HWND(hWnd));
}

Workaround:

var hWnd = new HWND(WinRT.Interop.WindowNative.GetWindowHandle(MainWindow));
if (PInvoke.IsIconic(hWnd) && MainWindow.AppWindow.Presenter is OverlappedPresenter overlappedPresenter)
{
    overlappedPresenter.Restore();
    // OR overlappedPresenter.Restore(false);
    // OR PInvoke.ShowWindow(hWnd, SHOW_WINDOW_CMD.SW_RESTORE);
}

PInvoke.SetForegroundWindow(hWnd);

Steps to reproduce the bug

Section copied from the original issue:

  • Open DevHome
  • Maximize the window
  • Minimize on taskbar
  • Open another DevHome instance

Expected behavior

Section copied from the original issue:

DevHome should be restored preserving the maximized state

Screenshots

No response

NuGet package version

Windows App SDK 1.5.5: 1.5.240627000

Packaging type

No response

Windows version

No response

IDE

No response

Additional context

No response

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 15, 2024
@codendone codendone transferred this issue from microsoft/WindowsAppSDK Jul 16, 2024
@codendone codendone added bug Something isn't working area-AppWindow team-CompInput Issue for IXP (Composition, Input) team and removed needs-triage Issue needs to be triaged by the area owners labels Jul 16, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 16, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Jul 18, 2024
@Balkoth
Copy link

Balkoth commented Jul 23, 2024

SetForegroundWindow seems to be a problem for the team 7595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-AppWindow bug Something isn't working team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

3 participants