borderless-window
borderless-window copied to clipboard
Possibly better way of calculating maximized client rectangle
Hello! Thank you for this example, it helped me a lot.
After experimenting a bit, I think I found a better way of calculating the bounding rectangle of the non-client area in WM_NCCALCSIZE. Firstly, add the WS_MAXIMIZEBOX style flag to the window. This enables it to maximize when dragging it towards an edge of the monitor (size snapping), but it also makes the bottom of the window not get obscured by the taskbar. This makes the hacky solution with has_autohide_appbar unnecessary (the shell won't make it full-screen).
In my WM_NCCALCSIZE message, I then just do this:
auto const parameters = reinterpret_cast<NCCALCSIZE_PARAMS*>(p_data_b);
if (IsMaximized(m_windowHandle)) {
auto info = MONITORINFO{};
info.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromRect(parameters->rgrc, MONITOR_DEFAULTTONEAREST), &info);
parameters->rgrc[0] = info.rcWork;
}
return 0;
to properly fit the client area.
Hope this could help anyone.
Do you add the WS_MAXIMIZEBOX style on WM_NCCALCSIZE handler or on the call to CreateWindowEx?
Just on the call to CreateWindowEx.