"Bob" <borla...@pless.net> wrote in message
news:3ed6...@newsgroups.borland.com...
> How do I get the pixel height/width from a font size? As I change the font
> size of a control I also want to increase the size of the control
> proportionally?
>
> Thanks, -Bob
> Delphi 6
>
>
You don't need the controls canvas, you can use the forms canvas:
// in a method of the form
canvas.font := edit1.font;
h:= canvas.textHeight('Äy');
// h has the height of a string in the edits font.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
>Only problem is the control may be empty.
You can still ask for the TextWidth and TextHeight - pass your own
text.
>For example, if I have a TEdit
>object 15x50, font changed from 8 to 12 point, how do I grow the control to
>accomadate the same amount of text it would have held at 8p now at 12p?
Set the Size property of the font to the point size and that should
change the Height property to pixels. But the sign will be inverted.
You'll need to add some padding for the border depending on
BorderWidth, BorderStyle, Ctl3D, etc.
>Also, not sure how to access the control's canvas property and TextWidth
>method.
Not all controls have a Canvas property. But you can use any control
(that does) with the same font.
Good luck.
Kurt
Going from 8pnt to 12pnt has increased the size of the text by 50% (1.5 times)
so you should be able to increase the control size by 50%.
1 pnt = 1/72 inch. 8 pnt = 1/9th inch 12pnt = 1/6th inch and so on.
Note of course that if you leave AutoSize on for labels they will automatically
increase in size, both vertical and horizontal. Edit boxes will increase in
height only. So if you want to change them programmatically then you will need
to switch this feature off.
Geoff