Re: Caption Height
- From: "David Youngblood" <dwy@xxxxxxxxx>
- Date: Wed, 14 Jan 2009 19:20:14 -0600
"expvb" <nobody@xxxxxxx> wrote in message
news:%23$22bqqdJHA.5904@xxxxxxxxxxxxxxxxxxxxxxx
"David Youngblood" <dwy@xxxxxxxxx> wrote in message
news:OpS2rLqdJHA.4684@xxxxxxxxxxxxxxxxxxxxxxx
26, and yes I have considered that. But that assumes a border at the top
and bottom of the form (width - scalewidth = 2 times frame thickness).
That doesn't appear to be the case for a themed window. The caption has
rounded corners so drawing a top border will not work. Also, looking at
the themed window part ID's there are parts for left frame, right frame
and bottom frame, but no top frame part.
That might be what I end up doing, adding caption height + 1 frame width.
For the not themed window, I am already subtracting border width (1
pixel) from the value returned by GetSystemMetrics. I'm just trying to
find "correct" formula, if one exists.
This code asks Windows what is the top left (0,0) corner positions in
pixels relative to the screen, then subtract the result from the upper
left corner of the window, including the title bar. This gets the actual
border size. In my case with XP default theme, your code printed the
following(With BoderStyle of Form1 set to the default "2 - Sizable"):
Using GetThemePartSize, caption height = 29
Using GetSystemMetrics, caption height = 26
Larry's code printed the following:
Border: 60 (Twips) = 4 (Pixels)
TitleBar: 390 (Twips) = 26 (Pixels)
Strangely I expected Larry's method to work and it does when I converted
everything to pixels first as shown here:
Larry's example subtracted two border widths which is why it returned 26
rather than 30.
Your posted code returns the correct value. But (isn't there always a but),
I need (want) to draw a caption on a caption-less window. In this case the
code returns 0. I might could query an external form, but would rather avoid
that. The system should be able to tell me the correct height.
David
.
- References:
- Caption Height
- From: David Youngblood
- Re: Caption Height
- From: Larry Serflaten
- Re: Caption Height
- From: David Youngblood
- Re: Caption Height
- From: expvb
- Caption Height
- Prev by Date: Re: Caption Height
- Next by Date: Re: Caption Height
- Previous by thread: Re: Caption Height
- Next by thread: Re: Caption Height
- Index(es):
Relevant Pages
|