Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Window size problems...

This topic is 6486 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 new here, so please dont flame me for being to lazy to scan 55000 msgs to see if my question has been asked already I''m wondering about window-sizes. When i create a window with a size of, say, 640 x 480, by using WS_POPUP and WS_VISIBLE, all is good. But when i add WS_OVERLAPPED or similar tags, i get a titlebar and thin borders, just as i want to. The problem is that the total size of the window is still 640 x 480, meaning my graphics are scaled slightly down. With a 8pt titlebar font, the height of my actual surface is now "only" about 470. Using a tileengine, you can see some nasty artifacts since it skips a few scanlines. So... Anyone know how to calculate the height of the titlebar, and the borders so i can resize my window slightly after i''ve created it? Any help would be welcome. Thank you defster

Share this post

Link to post
Share on other sites
Check out: GetSystemMetrics()

GetSystemMetrics(SM_CYCAPTION) for title bar height.
GetSystemMetrics(SM_CYBORDER) for border height.
GetSystemMetrics(SM_CXBORDER) for border width.



Share this post

Link to post
Share on other sites
I don''t think that accounts for the type of border (thin, thick, dialog, etc.). Just create the window _without_ WS_VISIBLE but with all the other flags you want. Then get the size of the window, and the size of the client (where you draw):

RECT rcWindow, rcClient;

Just increase the size of the window by the difference between the client size you desire (i.e., 640x480) and the current size (i.e., 619x408). That should work for any window style, even WS_POPUP.

Don''t forget to call ShowWindow to make the window visible.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
SetRect( 0, 0, 640, 480 );

AdjustWindowRect( &rect, WS_OVERLAPPED|etc..., menu ? true : false );

rect will then be adjusted to have a 640x480 client area..


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!