melak47/BorderlessWindow

5px overflow in borderless mode when window is maximized.

shenzhigang opened this issue · 2 comments

Tested in win7 and win10.
maximized
normal

This is normal - part of the window frame spills beyond the screen when maximized.
Since we are expanding the client area to the whole window, it spills as well.
You can calculate the precise amount by getting the RECT for the current/closest HMONITOR of the window and the window's RECT, and taking the difference between monitor.top and window.top.

Then you could compensate manually for this effect.
It might also be possible to adjust the client rect's top in WM_NCCALCSIZE by that amount, which should resolve it without any manual offsetting. I'll try to see if that works later.

Adjusting the client rectangle to the monitor work rectangle (excludes the task bar) when maximized fixes the problem, and doesn't require the user to be aware of it.

Compare before:
before

And After:
after

Under some circumstances you could even see the window spilling onto other screens and under the task bar, though I can't always reproduce it. This fixes that, too.