# How do you compinsate for a window toolbar/boarders

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

## Recommended Posts

I am trying to figure out how to compinsate for the toolbar a window generates. For example lets say a window is 500 x 500. When I blit a sprite (via directX) that is also 500x 500 the image is not fully displayed because the toolbar seems to be part of the 500 x 500 makeup of the window. Regards Chad

##### Share on other sites
There are a number of different ways to retrieve the size of a window's client area. GetClientRect() is probably the most straight-forward, but you can also use GetWindowInfo(), which will also tell you things like the size of the window borders if you also need that information.

##### Share on other sites
One approach is to create your window slightly larger than the desired client area size. You do this by filling a RECT structure with your desired size (for example, size 500 x 500, origin at 0, 0), then pass this structure into the Win32 function AdjustWindowRectEx. When calling this function, you can specify the window properties such as borders or menus. The RECT structure returns with a new size, you then create your window using this RECT and the same window properties, and the client area will be the right size.

##### Share on other sites
Thanks guys. This is what I came up with...

bool E_Application::Resize(long Width, long Height){		RECT WndRect, ClientRect;	long WndWidth, WndHeight;	GetWindowRect(m_hWnd, &WndRect);	GetClientRect(m_hWnd, &ClientRect);	WndWidth  = (WndRect.right  - (ClientRect.right  - Width))  - WndRect.left;	WndHeight = (WndRect.bottom - (ClientRect.bottom - Height)) - WndRect.top;	MoveWindow(m_hWnd, WndRect.left, WndRect.top, WndWidth, WndHeight, TRUE);	return true;}
It is ran once through every loop. Seems to work perfect.

Regards