Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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?
Posted

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
 
Share this answer
 
The code below would work. And please explain yourself.

C++
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);
 
Share this answer
 
Comments
Gbenbam 29-Dec-14 18:33pm    
Just what I needed.Thanks.
Mohibur Rashid 29-Dec-14 23:46pm    
Welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900