Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining width of last line in an editbox
Message
De
10/02/2010 00:41:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01447267
Message ID:
01448499
Vues:
42
>>Bottom line: When it comes to measuring string lengths, is yours
>>more likely to provide a more accurate result than
>>GdipMeasureString?
>
>GDI+'s GdipMeasureString is the most precise, device independent way of accuratly measuring a string's width and height...
>
>...UNLESS you need to know exactly, to the pixel, how wide and tall a string was rendered using the older GDI graphics engine. Only the older GDI engine can tell you that.
>
>Think of it like an odometer in 2 different cars and measuring distance between 2 points...
>
>Car (A) has no 1/10th indicator on its odometer. Everytime it stops at a stop sign or traffic light it writes down it's milage (to +/-1.0 acurracy) and resets the odomter. When it finishes it's trip it adds all the numbers together to get the total distance traveled.
>
>Car (B) has a 1/10th indicator on its odometer and it doesn't reset its odomoter. It just keeps it running from the beginning of the trip to the end.
>
>Both of these cars could measure close to the same distance. But the more stops you have, the farther off the measurment will be.
>
>Car (A) is like GDI. It uses integers and calculates the character width of each letter and rounds it to the nearest pixel then adds the integers up sequentially. Car (B) is like GDI+, it uses floating point numbers and doesn't round off the character width. It is a more accurate way of measuring, but will never be exactly the same as GDI.
>
>I hope this helps.

Thanks for the feedback, Bo. I've found that GdipMeasureString can be off
by several percent in some scenarios, even when taking care to
minimize round-off errors. I guess I'll just have to continue to
fudge-factor it.

-m.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform