user1404173
user1404173

Reputation: 247

AdjustWindowRect documentation

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?

Upvotes: 8

Views: 4127

Answers (1)

Anonymous Coward
Anonymous Coward

Reputation: 6226

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.

Upvotes: 13

Related Questions