# windowed pixel resolution

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

## Recommended Posts

##### Share on other sites
That should do exactly what I want, but it doesn't? I may be wrong here but I tell it to do a 1024x768 window and I get 1021x746? Without it I get 1018x743, so the AdjustRect changes it 3x3 pixels.

Here's the code:
	LPRECT rect = new RECT;	rect->left = rect->top = 40;	rect->right = 1024;	rect->bottom = 768;	int flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);	AdjustWindowRect(rect, flags, FALSE);	hWnd = CreateWindow(APP_TITLE, APP_TITLE, flags, rect->left, rect->top, rect->right, rect->bottom, GetDesktopWindow(), NULL, windowClass.hInstance, NULL);	GetClientRect(hWnd, rect);	char s[1000];	sprintf(s, "width: %i && height: %i", rect->right, rect->bottom);	logger.Log(s);

As you see, I call GetClientRect right after to check it. What am I missing?

##### Share on other sites
Your initial Rect that you pass to AdjustRect has a top and left of 40, instead of 0. Is there some reason behind that, as I'd expect you to use 0.

##### Share on other sites
left = top = 0 does not alter the result. Still the same. I just used 40 because of some reason the top title / caption field was above the screen when I used 0. So the direct3d rendering area started at 0,0. Instead of the top left corner of the title / caption field.

##### Share on other sites
Quote:
 Original post by Kijaleft = top = 0 does not alter the result. Still the same. I just used 40 because of some reason the top title / caption field was above the screen when I used 0. So the direct3d rendering area started at 0,0. Instead of the top left corner of the title / caption field.

That would happen because it is making the client part of the window the same size as the screen, which means the caption would go offscreen.

##### Share on other sites
RECT::right and RECT::bottom are not the width and height. They are the right and bottom. I can't see how the result's the same when using 0 for top and left (in which case right and bottom will be the width and height).

Sure you tried this?
RECT rect;rect.left = 0;rect.top = 0;rect.bottom = 768;rect.right = 1024;DWORD flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);AdjustWindowRect(&rect, flags, FALSE);

##### Share on other sites
In your first post you say you're using WS_OVERLAPPED and WS_CAPTION for your flags, but when you call AdjustRect you don't specify them?

int flags = (WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);

You forgot to say WS_OVERLAPPED, which would include WS_BORDER, which is probably where you're losing your three pixels (left, right and bottom borders).

##### Share on other sites
Parameters

lpRect
[in, out] Pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.
dwstyle
[in] Specifies the window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.
[in] Specifies whether the window has a menu.

##### Share on other sites
GroZZleR, I removed WS_OVERLAPPED since the MSDN tells me so:
Quote:
 MSDN: AdjustWindowRect Functiondwstyle [in] Specifies the window style of the window whose required size is to be calculated. Note that you cannot specify the WS_OVERLAPPED style.

Coder, yep, the result would be the same even if left and top were set to 0, however... Your post and especially njpauls post gave me the answer. AdjustWindowRect changes top and left too :)

I send this to it:
left: 0 top: 0 right: 1024 bottom: 768
and I get this:
left: -3 top: -22 right: 1027 bottom: 771

So if I use right - left as width and bottom - top as height, it all goes well. I should've realised this when the window went above the screen... Well well, as I said: I'm new to this :)

Thanks for the quick replies everyone

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 14
• 46
• 22
• ### Forum Statistics

• Total Topics
634054
• Total Posts
3015274
×