mosi
asked on
read Windows Font Size
In a Delphi program I display text from a textfile, with
a specifiable font size on a window.
The problem off course is, that when someone on the network
has changed his
Start->Settings->Control Panel->Display->Setting->F ont Size
setting to Large fonts, he can't read all of the text.
My question is:
How can I determiner this setting in delphi (remember
a Windows APi call, but I can get the use of parameters
right, so please give a example procedure).
How can I map these large fonts to small fonts
,calculate the font size to use (
I mean I want the person with the large fonts settings
to see the same size of the text in my programwindow,
he would see if you used the small fonts settings).
Can I just divide a certain font size by half?
Is this a constant?
a specifiable font size on a window.
The problem off course is, that when someone on the network
has changed his
Start->Settings->Control Panel->Display->Setting->F
setting to Large fonts, he can't read all of the text.
My question is:
How can I determiner this setting in delphi (remember
a Windows APi call, but I can get the use of parameters
right, so please give a example procedure).
How can I map these large fonts to small fonts
,calculate the font size to use (
I mean I want the person with the large fonts settings
to see the same size of the text in my programwindow,
he would see if you used the small fonts settings).
Can I just divide a certain font size by half?
Is this a constant?
You want the text metrics for the font.
VAR
DC: HDC;
SaveFont: HFont;
Metrics: TTextMetric;
DC := GetDC(0);
SaveFont := SelectObject( DC, Font.Handle);
GetTextMetrics(DC, Metrics );
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
Now, you have use of the metrics, like:
MyHeight := Metrics.tmHeight + 3;
Hope this helps.
Ian C.
VAR
DC: HDC;
SaveFont: HFont;
Metrics: TTextMetric;
DC := GetDC(0);
SaveFont := SelectObject( DC, Font.Handle);
GetTextMetrics(DC, Metrics );
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
Now, you have use of the metrics, like:
MyHeight := Metrics.tmHeight + 3;
Hope this helps.
Ian C.
ASKER
Thanx ICAMPBEL, but I rejected your answer, althrough it probably contains part of the answer, but it is not so complete that I can use it. Please clarify!
I tried your code, and when Windows 95 on this PC is using The large font setting, I get a Metrics.tmHeight value of 16. When it is using
The small font setting, I get a Metrics.tmHeight value of 13.
Will this always be the case, on all PC's, not depending on other
settings such as resolution e.g. 1024*768 in stead of 800 * 600, or other videodrivers?
I explain again what I what to do (simplified):
I display a window on the screen which always has a width of 600 pixels.
In this window is a label. The program reads the text to display on this
label and it fontsize from the commandline.
Suppose, I have a text to display which exactly fits into that window,
when I'm using the Use small fonts setting in Windows 95, only
a part will be visible when I'm using the Use large fonts settings.
(I do not want use scrolling),
Therefore I need a function like this;
FontSizeFromCommandline (integer) is known, e.g. 14
FontSizeToUse:= CalculateFontSizeToUse(Fon
CalculatieFontSizeToUse must do 2 things.
1) Detect whether the Windows 95/NT setting of the fonts to use
is Use Large Fonts or Use Small Fonts
2a) When the setting is Use Small Fonts: return FontSizeFromCommandline
(in fact: do nothing, this value is already known).
2b) When the setting is Use Large Fonts: calculate a fontsize,
depending on FontSizeFromCommandline, such that exactly the
same text will fit onto (the same line on) the window, as if the
setting would be Use Small Fonts.
ASKER
Adjusted points to 110
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx.
I accept your answer, although I guess I still have to
work out some things.
I accept your answer, although I guess I still have to
work out some things.
When text is (in example) in TMemo then user can use ScrollBars so tell more what happened and what you need because i can't understand.