How to create a window based on only the size of the screen not including the windows border with C++/Windows?

When creating a window using CreateWindow(...), which requires the window width and height, I have to enter the values 656 and 516, instead of 640 and 480, so as to account for the windows border.

I'm wondering if there is a way to create a window based only on the portion of the window not including the border, especially considering that if different versions of windows have different size borders, than the program might be displayed differently when I run it on said different versions

(ie: using 640 - object.width will place the object not quite on the edge of the screen if the user's version of windows has different sized borders).

So is there a way to create a window based only on the portion of the screen relevant to the program, or at the vary least a function along the lines of GetVericalBorder()/GetHorizontalBorder() so that I use these in CreateWindow()'s parameters instead of arbitrary and vague values like 656 and 516?


Have a look at AdjustWindowRectEx. You pass this function a rectangle containing the desired size of your windows' client area, and the window style flags, and it calculates how big to make the overall window so that the client area is the desired size.

You can use the SystemParametersInfo() API to get this kind of window information. See the SPI_GETBORDER and/or SPI_GETNONCLIENTMETRICS parameters refer Microsoft Library

SystemParametersInfo should allow you to account for borders, menus, etc.

int WINAPI GetSystemMetrics(
  __in  int nIndex

Refer Microsoft Library

Need Your Help

working with list of list using python

python list

I am working on list using python

How to create a method parameter object with ReSharper in a few seconds?

.net design-patterns refactoring resharper

Is it possible to select all the parameters of a method and ask ReSharper to create a class from those parameters as a "method parameter object?"

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.