Windows Develop Bookmark and Share   
 index > Windows Forms General > How to get correct window caption height?
 

How to get correct window caption height?

It seems that both SystemInformation and VisualStyleRenderer provide wrong window caption height. For the default XP theme, the correct caption height is 30 (I captured a window and measured the caption height.). However, the caption height taken from SystemInformation.CaptionHeight is 26 while VisualStyleRenderer returns 29 . Below are my code snippets.

int captionHeight = SystemInformation.CaptionHeight;

and

using ( Graphics g = CreateGraphics() )
{
VisualStyleRenderer renderer =
new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
int captionHeight = renderer.GetPartSize(g, ThemeSizeType.True).Height;
}

I have to display unicode on the window caption bar regardless the system caption font and keep other elements unchanged. My question is: What is the secret place where Microsoft placed the correct caption height?

Thank you for viewing and/or answering!
Redsome  Thursday, January 18, 2007 8:48 AM

The border of the window is 4pixels then. Try get the border height somehow. I can't remember how ;)

EDIT : It's BorderSize. I love reflector.

AndrewVos  Thursday, January 18, 2007 9:20 AM

The border of the window is 4pixels then. Try get the border height somehow. I can't remember how ;)

EDIT : It's BorderSize. I love reflector.

AndrewVos  Thursday, January 18, 2007 9:20 AM

You can use google to search for other answers

Custom Search

More Threads

• IE failing where visual Studio Succeeds?
• SQL help
• UICues and Windows Messages.
• Create An Event To Handle Many Events
• Windows XP
• keep listview item selection
• Need Help with my project
• Wanted: Ad-Hoc Query Tool
• mouse movement and position -SK
• Simple search engine (newbie)