By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

How do I find the font size of the Title Bar?

P: n/a
I am developing an application in VB.NET using Visual Studio 2003. I have a
dialog box where the title may be somewhat long, so I want to resize the
window to fit the entire title. I already know to use CreateGraphics to
measure the length of the string, so my code is something like this (from
the Load event):

objGraphics = CreateGraphics()
objFont = System.Windows.Forms.SystemInformation ??????
intTextLength = cint(objGraphics.MeasureString(Text, objFont).Width)
if intTextLength > Width Then
Width = intTextLength
end if

The problem is, I can't find a simple way to get the Font size of the title
bar of the window. I already Googled for "active title bar" and found a
reference to "System.Windows.Forms.SystemInformation", but none of the
properties there seem to apply. I would think this is a straightforward
thing, to get the current user's settings for Title Bar font size, but it
eludes me. Any help would be appreciated.

--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I suspect that you would have to look it up in the registry. I do not
remember the exact key, but I suspect that it is HKEY_CURRENT_USER\Control
Panel\Desktop\WindowMetrics or one of the associated ones.

HTH

David

"Christopher W. Douglas" <ch********************@SPAM.srs.com> wrote in
message news:OF**************@TK2MSFTNGP09.phx.gbl...
I am developing an application in VB.NET using Visual Studio 2003. I have a dialog box where the title may be somewhat long, so I want to resize the
window to fit the entire title. I already know to use CreateGraphics to
measure the length of the string, so my code is something like this (from
the Load event):

objGraphics = CreateGraphics()
objFont = System.Windows.Forms.SystemInformation ??????
intTextLength = cint(objGraphics.MeasureString(Text, objFont).Width)
if intTextLength > Width Then
Width = intTextLength
end if

The problem is, I can't find a simple way to get the Font size of the title bar of the window. I already Googled for "active title bar" and found a
reference to "System.Windows.Forms.SystemInformation", but none of the
properties there seem to apply. I would think this is a straightforward
thing, to get the current user's settings for Title Bar font size, but it
eludes me. Any help would be appreciated.

--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com

Nov 20 '05 #2

P: n/a
Thanks for your reply, and I will try it. However, does this make sense
that you HAVE to look in the registry to find this information? I mean, I
can get the font of a control with just txtBox.Font, or the font of the form
(labels as such) as me.Font. Why isn't there a SIMPLE means of getting the
title bar font for a form?

--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com

"David Williams" <dw*******@strohlsystems.com> wrote in message
news:#c**************@TK2MSFTNGP09.phx.gbl...
I suspect that you would have to look it up in the registry. I do not
remember the exact key, but I suspect that it is HKEY_CURRENT_USER\Control
Panel\Desktop\WindowMetrics or one of the associated ones.

HTH

David

"Christopher W. Douglas" <ch********************@SPAM.srs.com> wrote in
message news:OF**************@TK2MSFTNGP09.phx.gbl...
I am developing an application in VB.NET using Visual Studio 2003. I have
a
dialog box where the title may be somewhat long, so I want to resize the
window to fit the entire title. I already know to use CreateGraphics to
measure the length of the string, so my code is something like this

(from the Load event):

objGraphics = CreateGraphics()
objFont = System.Windows.Forms.SystemInformation ??????
intTextLength = cint(objGraphics.MeasureString(Text, objFont).Width)
if intTextLength > Width Then
Width = intTextLength
end if

The problem is, I can't find a simple way to get the Font size of the

title
bar of the window. I already Googled for "active title bar" and found a
reference to "System.Windows.Forms.SystemInformation", but none of the
properties there seem to apply. I would think this is a straightforward
thing, to get the current user's settings for Title Bar font size, but it eludes me. Any help would be appreciated.

--
Christopher W. Douglas
SRS Technologies, Inc.
christopher (dot) douglas (at) srs (dot) com


Nov 20 '05 #3

P: n/a
* "Christopher W. Douglas" <ch********************@SPAM.srs.com> scripsit:
I am developing an application in VB.NET using Visual Studio 2003. I have a
dialog box where the title may be somewhat long, so I want to resize the
window to fit the entire title. I already know to use CreateGraphics to
measure the length of the string, so my code is something like this (from
the Load event):


Maybe p/invoke, a VB6 sample can be found here:

<http://vbaccelerator.nuwebhost.com/tips/vba0034.htm>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.