Sign in to follow this  

AdjustWindowRectEx problems

This topic is 3726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this