How to fullscreen a 3rd-party application by its hwnd?

I’m looking to fullscreen 3rd-party windows in a (hopefully) reliable and consistent way for a window manager project. The goal is to have the fullscreen window cover the taskbar completely.

My current approach is to set the window’s position and dimensions to match the current monitor. This works well for some windows, but for others, the taskbar ends up covering the bottom part of the window (see vid). Implementation:

use windows::Win32::{
  Foundation::HWND,
  Graphics::Gdi::{
    GetMonitorInfoW, MonitorFromWindow, MONITORINFOEXW,
    MONITOR_DEFAULTTONEAREST,
  },
  UI::WindowsAndMessaging::{
    SetWindowPos, HWND_NOTOPMOST, SWP_FRAMECHANGED, SWP_NOACTIVATE,
    SWP_NOCOPYBITS, SWP_NOSENDCHANGING,
  },
};

pub fn set_fullscreen(window_handle: isize) -> anyhow::Result<()> {
  let monitor_handle = unsafe {
    MonitorFromWindow(HWND(window_handle), MONITOR_DEFAULTTONEAREST)
  };

  let mut monitor = MONITORINFOEXW::default();
  monitor.monitorInfo.cbSize =
    std::mem::size_of::<MONITORINFOEXW>() as u32;

  unsafe {
    GetMonitorInfoW(monitor_handle, &mut monitor as *mut _ as _)
  }
  .ok()?;

  let monitor_rect = monitor.monitorInfo.rcMonitor;

  unsafe {
    SetWindowPos(
      HWND(window_handle),
      HWND_NOTOPMOST,
      monitor_rect.left,
      monitor_rect.top,
      monitor_rect.right - monitor_rect.left,
      monitor_rect.top - monitor_rect.bottom,
      SWP_FRAMECHANGED
        | SWP_NOACTIVATE
        | SWP_NOCOPYBITS
        | SWP_NOSENDCHANGING,
    )
  }?;

  Ok(())
}

I’ve tried a couple other approaches based on Raymond Chen’s post on implementing fullscreen:

  1. Removing the WS_OVERLAPPEDWINDOW style: This does make the windows cover the taskbar, but it’s an intrusive change and sometimes causes the window to bug out.
  2. Setting the z-order to HWND_TOPMOST: This also works to cover the taskbar, but forcing the window to be always on top isn’t ideal.

Interestingly, some windows (like Spotify and Visual Studio) can successfully overlap the taskbar despite having the WS_OVERLAPPEDWINDOW style. Here’s a comparison of window styles for various apps in normal and fullscreen modes:

VSCode (normal) - Fullscreen with above implementation covers taskbar ✅
styles: MaximizeBox | Group | SizeBox | Caption | ClipSiblings | Visible
styles ex: WindowEdge

VSCode (built-in f11 fullscreen)
styles: MaximizeBox | Group | ClipSiblings | Visible
styles ex: Left

Chrome (normal) - Fullscreen with above implementation does not cover taskbar ❌
styles: OverlappedWindow | ClipChildren | ClipSiblings | Visible
styles ex: WindowEdge

Chrome (built-in f11 fullscreen)
styles: MaximizeBox | Group | SysMenu | ClipChildren | ClipSiblings | Visible
styles ex: Left

Obsidian (normal) - Fullscreen with above implementation covers taskbar ✅
styles: MaximizeBox | Group | SizeBox | Caption | ClipSiblings | Visible
styles ex: WindowEdge

Obsidian (built-in f11 fullscreen)
styles: MaximizeBox | Group | ClipSiblings | Visible
styles ex: Left

Spotify (normal) - Fullscreen with above implementation covers taskbar ✅
styles: OverlappedWindow | ClipChildren | ClipSiblings | Visible
styles ex: WindowEdge

File explorer (normal) - Fullscreen with above implementation does not cover taskbar ❌
styles: OverlappedWindow | ClipSiblings | Visible
styles ex: WindowEdge

File explorer (built-in f11 fullscreen)
styles: Group | SysMenu | ClipSiblings | Visible
styles ex: Left

Visual studio (normal) - Fullscreen with above implementation covers taskbar ✅
styles: OverlappedWindow | ClipChildren | ClipSiblings | Visible
styles ex: WindowEdge | AppWindow

Visual studio (built-in f11 fullscreen) - interestingly, no change
styles: OverlappedWindow | ClipChildren | ClipSiblings | Visible
styles ex: WindowEdge | AppWindow

Since some apps can properly fullscreen with WS_OVERLAPPEDWINDOW, I’m wondering if there’s a way to achieve this behavior consistently across all windows.

What is the most reliable and consistent way to fullscreen a window so that it covers the taskbar completely?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật