Archived

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

Window size problems...

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

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 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.

Enjoy!

.travois.

Share on other sites
Ooooh.. Thanks alot. Will do.

defster

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;GetWindowRect(&rcWindow);GetClientRect(&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 on other sites
SetRect( 0, 0, 640, 480 );

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

-bf

Share on other sites
Thanks alot guys. I got it working now

• 39
• 15
• 9
• 23
• 10