TIP: Click on subject to list as thread! ANSI
echo: delphi
to: BART BROERSMA
from: GARY WEINFURTHER
date: 1997-04-22 11:07:00
subject: Width of a string in pixels.

Bart Broersma mentioned this to All:
 BB> However, this will give a wrong result, if SomeObject has not actually
 BB> been drawn yet with the applied Font. So, the first time I do
 BB> SomeObject.Show, the results are different from subsequent times. 
However,
 BB> I need to know get the right numbers before I do the actual drawing in 
the
 BB> applied Font, so I can calculate the size that SomeObject will have to 
e
 BB> ... (get my drift ??).
Why not calculate them when you actually do the drawing?  The reason the 
results are different is that a canvas doesn't actually get a display context 
assigned to it until it needs to.  And it only needs to when it's about to 
start painting.
If you really have to know in advance, you could post (with PostMessage) a 
custom message to your form from the FormShow event.  By the time the form 
gets around to handling your custom message, the form would be painted, thus 
allowing you to refer to the canvas correctly.
                                ...Gary
--- GoldED 2.41
---------------
* Origin: The Flying Circus BBS, Farmington Hills, MI. (1:2410/905)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.