Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 905
user1404173 Avatar asked Dec 09 '12 23:12

user1404173


1 Answers

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.

like image 162
Anonymous Coward Avatar answered Sep 24 '22 12:09

Anonymous Coward