Sign in to follow this  

How do you compinsate for a window toolbar/boarders

This topic is 3597 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 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Chad

Share this post


Link to post
Share on other sites

This topic is 3597 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