[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how do i find out how thick the title bar of a window

Posted on 2006-03-22
10
Medium Priority
?
305 Views
Last Modified: 2010-04-04
For my form I can find the thick of my title bar Height-ClientHeight.
My question is: How do I determine the thick of title bar for a window having the handle of the window?
0
Comment
Question by:diandr
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 9

Expert Comment

by:bernani
ID: 16263400
0
 

Author Comment

by:diandr
ID: 16263520
Thanks for the answer. But I already answered that for the form I know: Height-ClientHeight. I need for a window that I know only the handle.
0
 
LVL 2

Accepted Solution

by:
heretoread earned 1400 total points
ID: 16263924
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Assisted Solution

by:quilley
quilley earned 300 total points
ID: 16264273
To be precise: Height - ClientHeight = height of title bar + height of menu bar (if any)

You can get the dimensions of various windows elements using the Windows API function GetSystemMetrics. You don't need a window object or handle because the dimensions are the same for all windows to which the element applies. For example:

GetSystemMetrics(SM_CYCAPTION) = Height, in pixels, of normal caption area

[On my system this gives 26 but Height - ClientHeight gives 34. Why that is I don't know - presumably the SM_CYCAPTION doesn't include the border around the client area.]

Below are results of calling GetSystemMetrics with various parameters on a standard XP installation:

SM_CXBORDER=1
SM_CYBORDER=1
SM_CXCURSOR=32
SM_CYCURSOR=32
SM_CXDLGFRAME=3
SM_CYDLGFRAME=3
SM_CXDOUBLECLK=4
SM_CYDOUBLECLK=4
SM_CXDRAG=4
SM_CYDRAG=4
SM_CXEDGE=2
SM_CYEDGE=2
SM_CXFIXEDFRAME=3
SM_CYFIXEDFRAME=3
SM_CXFRAME=4
SM_CYFRAME=4
SM_CXFULLSCREEN=1024
SM_CYFULLSCREEN=712
SM_CXHSCROLL=17
SM_CYHSCROLL=17
SM_CXHTHUMB=17
SM_CXICON=32
SM_CYICON=32
SM_CXICONSPACING=75
SM_CYICONSPACING=75
SM_CXMAXIMIZED=1032
SM_CYMAXIMIZED=746
SM_CXMAXTRACK=1036
SM_CYMAXTRACK=780
SM_CXMENUCHECK=13
SM_CYMENUCHECK=13
SM_CXMENUSIZE=18
SM_CYMENUSIZE=19
SM_CXMIN=123
SM_CYMIN=34
SM_CXMINIMIZED=160
SM_CYMINIMIZED=31
SM_CXMINSPACING=160
SM_CYMINSPACING=31
SM_CXMINTRACK=123
SM_CYMINTRACK=34
SM_CXSCREEN=1024
SM_CYSCREEN=768
SM_CXSIZE=25
SM_CYSIZE=25
SM_CXSIZEFRAME=4
SM_CYSIZEFRAME=4
SM_CXSMICON=16
SM_CYSMICON=16
SM_CXSMSIZE=17
SM_CYSMSIZE=17
SM_CXVSCROLL=17
SM_CYVSCROLL=17
SM_CYCAPTION=26
SM_CYMENU=20
SM_CYSMCAPTION=18
SM_CYVTHUMB=17
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16267473
Marking for myself to read too :o)
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16269526
Height - ClientHeight = height of title bar + height of menu + height of borders (top and bottom)
0
 
LVL 11

Assisted Solution

by:ZhaawZ
ZhaawZ earned 300 total points
ID: 16269558
var
  wnd : cardinal; // handle of window
  captHeight : integer;
...
begin
// if window is tool-window (i.e., with small caption)
if GetWindowLong(wnd, gwl_exstyle) and ws_ex_toolwindow = ws_ex_toolwindow
// then get height of tool-window caption
then captHeight := GetSystemMetrics(sm_cysmcaption)
// else get height of "standard" window caption
else captHeight := GetSystemMetrics(sm_cycaption);
end;
0
 

Author Comment

by:diandr
ID: 16269936
Acutally for my program I needed including the menus, so heretoread answered to what I need. Anyway to the entered question answered all.

Thanks everyone.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16269969
Don't forget that his sollution has also height of borders included in result
0
 
LVL 1

Expert Comment

by:quilley
ID: 16270099
@Zhaw
>Height - ClientHeight = height of title bar + height of menu + height of borders (top and bottom)
Thanks for correction.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question