AdjustWindowRectEx problems

Started by
4 comments, last by T-Mic 16 years, 6 months ago
I'm having problems with the AdjustWindowRectEx function. It seems to be resizing my window to a larger height than it should. I'm attempting to create a 900x600 window, but later when I call GetClientRect, it returns 900x620. Please see the relevant code below.

#define MAIN_WIDTH	800
#define MAIN_HEIGHT	600
#define PANEL_WIDTH     100

mainWinStyle = WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU;

RECT clientRes = {0, 0, MAIN_WIDTH + PANEL_WIDTH, MAIN_HEIGHT};
LPRECT winRes = &clientRes;
AdjustWindowRectEx(winRes, mainWinStyle, true, NULL);

hWnd = CreateWindowEx(NULL, MAIN_CLASS, MAIN_TITLE, mainWinStyle, CW_USEDEFAULT,
CW_USEDEFAULT, winRes->right - winRes->left, winRes->bottom - winRes->top, NULL,
NULL, hInstance, NULL);

I checked the MSDN site and it said not to use WS_OVERLAPPED, which I'm not. Maybe a combination of my styles is equivalent to WS_OVERLAPPED? Any ideas?
Advertisement
Where does the MSDN say not to use WS_OVERLAPPED? I suspect AdjustWindowRect will work if you just use WS_OVERLAPPEDWINDOW.
Quote:
Where does the MSDN say not to use WS_OVERLAPPED?


It says it here, under the blurb about parameter dwstyle.
Ah, I see. That's because WS_OVERLAPPED just means "not popup". WS_OVERLAPPEDWINDOW should work fine though (And that's what I use in my code).
As Evil Steve stated, WS_OVERLAPPEDWINDOW should work. I'm taking a guess that's what your style is, because there is a border also associated with WS_OVERLAPPEDWINDOW. When I just created a WS_OVERLAPPED window with WS_CAPTION as the style, the numbers came out correctly.
I've figured it out. The problem had nothing to do with styles, it has to do with the third paramater in the AdjustWindowRectEx function. The parameter should be true if the window has a menu, however that doesn't include the system menu. I changed the input to false and everything's working great.

Thanks for the replies.

This topic is closed to new replies.

Advertisement