Jump to content
  • Advertisement
Sign in to follow this  
T-Mic

AdjustWindowRectEx problems

This topic is 4090 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
Advertisement
Where does the MSDN say not to use WS_OVERLAPPED? I suspect AdjustWindowRect will work if you just use WS_OVERLAPPEDWINDOW.

Share this post


Link to post
Share on other sites
Quote:

Where does the MSDN say not to use WS_OVERLAPPED?


It says it here, under the blurb about parameter dwstyle.

Share this post


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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!