Window size problems...

Started by
4 comments, last by deffie 23 years, 2 months ago
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
Advertisement
Check out: GetSystemMetrics()

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

Enjoy!

.travois.
Ooooh.. Thanks alot. Will do.

defster
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.
SetRect( 0, 0, 640, 480 );

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

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

-bf
Thanks alot guys. I got it working now

This topic is closed to new replies.

Advertisement