Window size (WINAPI) includes blue bar

Started by
6 comments, last by Ra 15 years, 9 months ago
Hey there! Apparently the width and height you give up when creating a window (CreateWindowEx) include that titlebar on top of your window. I find this very annoying, because it gives pixelcalculationproblems in my games. Is there a way around? Lots of thanks, -Stijn
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Advertisement
AdjustWindowRect
-Mike
Or you could use the GetSystemMetrics function in order to find the width and height of window titlebars and borders, then take those values into consideration when creating your window.
I find that AdjustWindowRect is more exact. With GetSystemMetrics I always seem to be 2 pixels too long both on height and width.
Aah, thanks mates! Those should do the trick :) I think I'll go with AdjustWindowRect.

[EDIT]
Which style should I put in if my window's created with WS_OVERLAPPEDWINDOW? If I use WS_OVERLAPPEDWINDOW, the return height is too big (displaying a 640*480 pic in the background and there's room left at the bottom).

[Edited by - stenny on July 13, 2008 5:31:16 PM]
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Hi, make sure that the style parameter in AdjustWindowRect matchs the one in CreateWindowEx, i use the function and no problem so far.

though personally i use CreateWindow
Quote:Original post by Noplace
though personally i use CreateWindow

CreateWindow() merely calls CreateWindowEx() with the first parameter set to 0, so it's all the same really.
Quote:Original post by RandomPixel
I find that AdjustWindowRect is more exact. With GetSystemMetrics I always seem to be 2 pixels too long both on height and width.

You may be forgetting to take into account the width of the window border, which can also be queried with GetSystemMetrics().
Ra

This topic is closed to new replies.

Advertisement