microsoft / microsoft/microsoft-ui-xaml

Winui3 window cannot correctly fullscreen using win32 apis

Open
#10,839 2 comments 1 reaction 0 assignees View on GitHub
area-AppWindow bug team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

I was using [Raymond Chen's method](https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353) to fullscreen a winui3 window, and found out it does not work correctly.

- If you open a winui3 window, then click the taskbar once, then make the window fullscreen, the taskbar does not disappear.
- If you make a winui3 window fullscreen, then click `win` key to show the taskbar and the start menu, the taskbar does not disappear either.

However, using the exact same code on a normal win32 window (created by using `RegisterClass` and `CreateWindow`) works as expected.

Using `Microsoft.UI.Windowing` apis on a winui3 window DO work as expected. I wonder what magic does it do and what additional win32 code requires to make it work.

### Why is this important?

I need my win32 apis to work.

### Steps to reproduce the bug

https://github.com/user-attachments/assets/0da2589a-abe4-4e7b-9bc9-bc4cc0da88f8

As in the video, I have a win32 window and a winui3 window opened. And on clicking the buttons, it will make a window fullscreen and then restore after 3 seconds.

You can see how the taskbar does not dismiss with the winui3 window.

My code:
```cpp
class SupportFullScreen
{
HWND m_hwnd;
WINDOWPLACEMENT m_placement;
bool m_isFullScreen = false;

void SetFullscreen();
void ExitFullscreen();
public:
void SetHwnd(HWND hwnd);

void Toggle();
};

void SupportFullScreen::SetHwnd(HWND hwnd)
{
m_hwnd = hwnd;
}

void SupportFullScreen::SetFullscreen()
{
DWORD dwStyle = GetWindowLong(m_hwnd, GWL_STYLE);
MONITORINFO mi = { .cbSize = sizeof(mi) };
if (GetWindowPlacement(m_hwnd, &m_placement) &&
GetMonitorInfo(MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTOPRIMARY), &mi)
)
{
SetWindowLong(m_hwnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
SetWindowPos(m_hwnd,
HWND_TOP,
mi.rcMonitor.left, mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED
);
}
}

void SupportFullScreen::ExitFullscreen()
{
DWORD dwStyle = GetWindowLong(m_hwnd, GWL_STYLE);
SetWindowLong(m_hwnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
SetWindowPlacement(m_hwnd, &m_placement);
SetWindowPos(
m_hwnd,
NULL,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}

void SupportFullScreen::Toggle()
{
m_isFullScreen ? ExitFullscreen() : SetFullscreen();
m_isFullScreen = !m_isFullScreen;
}
```

### Actual behavior

_No response_

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.8.2: 1.8.251003001

### Windows version

Windows 11 (24H2): Build 26100

### Additional context
[Full repro here](https://github.com/HO-COOH/WinUI-Bug/tree/main/32-Win32FullScreen)

Contributor guide

Open the contributing guide

Research direction

Start with the full repro in the 32-Win32FullScreen project and run the scenario comparing its Win32 and WinUI 3 windows. Trace the SupportFullScreen methods and compare their behavior with the Microsoft.UI.Windowing APIs; done means the WinUI 3 window dismisses and restores the taskbar correctly in both reported sequences.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.