Skip to content

Winui3 window cannot correctly fullscreen using win32 apis #10839

@HO-COOH

Description

@HO-COOH

Describe the bug

I was using Raymond Chen's method 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

2025-10-18.02-50-25.mp4

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions