Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining width of last line in an editbox
Message
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:
01447614
Vues:
50
Hi m@,

>Bo, that's unbelievable!!! I really thought it might not be possible, but this works beautifully.
>
>Thank you!!

Your welcome.

>Nothing to do with the code that you provided, but I have noticed that GDI's MeasureString() isn't always 100% accurate when I use it to redraw the editbox based on the text value. It's WAY better than using the fontmetric, but are you aware of any tricks to making it closer to perfect?

When you say "GDI's", I assume you are talking about GDIPlus. GDI is the old graphics engine and GDIPlus is the new, with the MeasureString function.

The problem is that the EditBox (as well as most screen drawing of text and controls) are using "GDI", which is integer based, whereas "GDIPlus" is float based. So the differences you are seing are basically rounding errors. The more text you have and the more lines it wraps, the more of a difference you will see between the two.

Like I hinted in my last post, if you want it dead on accurate, you have to use the same graphics engine to do the calcultations.

BTW, FoxPro's TXTWIDTH function uses GDI. You just have to translate the font information to make it work right. It is still very difficult to predict line wrap though, that is what makes the function I sent you more accurate for what you are trying to accomplish.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform