The MSDN Library documents the dwStyle argument of AdjustWindowRect as:
The window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.
I haven't found any explanation for this. What do they mean by "cannot" and why can't I do it?
The WS_OVERLAPPED
style is defined as zero:
#define WS_OVERLAPPED 0x00000000L
AdjustWindowRect()
is checking the style flags supplied and modifies the RECT accordingly:
// ...
if( dwStyle & WS_BORDER ) {
const int cx = GetSystemMetrics(SM_CXBORDER);
const int cy = GetSystemMetrics(SM_CYBORDER);
lpRect->top -= cy;
lpRect->left -= cx;
lpRect->right += cx;
lpRect->bottom += cy;
}
// ...
Therefore AdjustWindowRect()
with the dwStyle parameter set to 0
does not alter the lpRect, hence WS_OVERLAPPED
cannot be used.
If you wish to calculate the size for a top-level frame, you can use WS_OVERLAPPEDWINDOW
or WS_CAPTION|WS_THICKFRAME
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With