开发者

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开发者_如何学Python 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜