I want a window which behaves identically to normal Overlapped window, except it does not have capton bar when maximized (to make more room for the client area).
I can remove WS_CAPTION|WS_SYSMENU
from the window style.
However, I cannot find way to get window position and size right:
A normal window is maximized by expanding work area rectangle with border width. This makes border to "hang" outside. When I remove WS_CAPTION
, the border is different (3 vs 4 pixels in my case) so I have to reposition the window somehow.
What I have tried:
First change style, then maximize: this does not maximize to work area, but to full screen instead. Looks like this is a feature of window manager that relies on
WS_CAPTION
style. Other than that, the border is "hanging" correctly.First maximize, then change style, position and size:
- I can't find API to get the maximized size and position. However, work area of closest monitor looks good to me.
- I can't find API to expand window rect with appropriate "hanging border".
AdjustWindowRectEx
is almost there, however non-client area is not the same as border (obviously it also includes caption and menu). I also tried to do the math myself usingGetSystemMetrics
values, but it seems too unpredictable. The border could beSM_CXSIZEFRAME
, orSM_CXSIZEFRAME
+SM_CXPADDEDBORDER
, orSM_CXFIXEDFRAME
, and maybe this depends on OS version, theme and whatever.
Is it possible to do this in a robust, "official" way?
I put my own answer below but it is too hacked.