Hallo Bart
BB> How do I get the width and heigth of a given string using a given
BB> font ? Currently I'm using:
BB> with SomeObject do {SomeObject currently is of type
BB> TLabel} begin
BB> font.name := "Arial";
BB> font.size := 10;
BB> font.style := [fsBold];
BB> Caption := S;
BB> StringHeight := Canvas.TextHeight(S);
BB> StringWidth := Canvas.TextWidth(S);
BB> Width := StringWidth + 5;
BB> Height := StringHeight + 5;
BB> ....
BB> end;
BB> {All this in the Form's OnShow event}
BB> However, this will give a wrong result, if SomeObject has not
BB> actually been drawn yet with the applied Font. So, the first time
BB> I do SomeObject.Show, the results are different from subsequent
BB> times.
Well, it seems to me you'd be better of setting the lable's AutoSize property
to true. The problem however will be that you're changing SomeObject.Font
instead of SomeObject.Canvas.Font. Without TLable's source code there's no
way telling when SomeObject.Canvas.Font is really changed. It might be no
sooner then the moment just before the next time the caption is drawn, which
seems to be the case here.
BB> Anyone got some ideas ??
I'm full of 'em.
Groeten, Martin.
--- FMail/386 1.02
---------------
* Origin: -=[ E-mail: m_maat@knoware.nl .......... ]=- (2:286/420.1)
|