是否有确定窗口的小条和窗口边框大小的功能? [英] Are there a functions for determining the size of a window's tittle bar and a windows border?

查看:94
本文介绍了是否有确定窗口的小条和窗口边框大小的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有用于确定窗口的小条和窗口边框大小的功能?



有充分理由我正在创建某种模态对话框拆分两个窗格,但是我很难计算每个窗格的坐标。



我使用了GetClientRect和GetWindowRect,但由于标题栏更宽比边界。



那么,这些函数是否存在?

解决方案

这是的一部分系统指标。应用程序不会决定它们是什么,它们是系统范围的。请参阅: http://msdn.microsoft.com /en-us/library/system.windows.systemparameters%28v=vs.110%29.aspx [ ^ ]。



如果你想为一个应用程序改变它,解决方案可能是:定义一个没有任何非客户区域的windows类,并在客户区模拟这些区域,或者只使用函数<设置单个窗口的样式 SetWindowLong

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600% 28v = vs.85%29.aspx [ ^ ]。



你需要使用索引 GWL_STYLE 并设置没有标题栏的样式( WS_CAPTION )且没有任何边框或框架(请参阅样式值的其他位)。



-SA


下面的代码可行。请自己解释一下。



 RECT rc1,rc2; 
int barWidth,titlebarHeight;
wchar_t a [ 10 ];
GetClientRect(hWnd,& rc1);
GetWindowRect(hWnd,& rc2);
barWidth =((rc2.right-rc2.left) - (rc1.right-rc1.left))/ 2;
titlebarHeight =(rc2.bottom-rc2.top) - (rc1.bottom-rc1.top)-bar_width-GetSystemMetrics(SM_CYMENU);
wsprintf(a,L %d,titlebarHeight);
MessageBox(hWnd,a,L 无论,MB_OK);


Are there a functions for determining the size of a window's tittle bar and a windows border?

For good reasons I am creating some kind of Modal dialogue boxes with split two panes, however I am facing difficulty calculation the coordinates of each pane.

I used GetClientRect and GetWindowRect but there is a slight shift because the title bar is much wider than the border.

So, does such functions exist?

解决方案

This is a part of "system metrics". The application does not decide what are they, they are system-wide. Please see: http://msdn.microsoft.com/en-us/library/system.windows.systemparameters%28v=vs.110%29.aspx[^].

If you want to change it for a single application, the solution could be: define a windows class without any non-client areas at all, and simulate these areas in a client area, or just set the style for a single window using the function SetWindowLong:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx[^].

You would need to use the index GWL_STYLE and set style without a title bar (WS_CAPTION) and without any borders or frames (see other bits of the style value).

—SA


The code below would work. And please explain yourself.

RECT rc1, rc2;
int barWidth, titlebarHeight;
wchar_t a[10];
GetClientRect(hWnd, &rc1);
GetWindowRect(hWnd, &rc2);
barWidth=((rc2.right-rc2.left)-(rc1.right-rc1.left))/2;
titlebarHeight=(rc2.bottom-rc2.top)-(rc1.bottom-rc1.top)-bar_width-GetSystemMetrics(SM_CYMENU);
wsprintf(a, L"%d",  titlebarHeight);
MessageBox(hWnd, a, L"Whatever", MB_OK);


这篇关于是否有确定窗口的小条和窗口边框大小的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆