如何从函数CreateWindowEx()窗口的宽度和高度? C ++ [英] How to get width and height from CreateWindowEx() window? C++
问题描述
我与函数CreateWindowEx窗口()函数,现在我怎么从那个窗口我创建的宽度和高度?这听起来做的很基本的东西,但我无法找到任何答案; _;
I have made a window with CreateWindowEx() function, now how do i get the width and height from that window i created? This sounds very basic thing to do, but i just couldnt find any answer ;_;
这是必要的,因为取决于Windows的希望如何创建它自动创建窗口的高度。
This is needed because the window height is created automatically depending on how the Windows wants to create it.
C语言或C ++
推荐答案
使用 GetWindowRect 。从左侧减去权从顶部得到的宽度和底部,以获得高度
Use GetWindowRect. Subtract the right from the left to get the width and the bottom from the top to get the height.
RECT rect;
if(GetWindowRect(hwnd, &rect))
{
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
}
作为一个方面说明,如果你想在客户端区域,而不是整个窗口。您可以使用 GetClientRect 。有关您可以使用 GetWindowInfo 窗口等信息。
As a side note, if you'd like the client area instead of the entire window. You can use GetClientRect. For other information about the window you can use GetWindowInfo.
这篇关于如何从函数CreateWindowEx()窗口的宽度和高度? C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!